shell_extensions_api_client.cc 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "extensions/shell/browser/shell_extensions_api_client.h"
  5. #include <utility>
  6. #include "build/build_config.h"
  7. #include "build/chromeos_buildflags.h"
  8. #include "content/public/browser/browser_context.h"
  9. #include "extensions/browser/api/messaging/messaging_delegate.h"
  10. #include "extensions/shell/browser/api/feedback_private/shell_feedback_private_delegate.h"
  11. #include "extensions/shell/browser/delegates/shell_kiosk_delegate.h"
  12. #include "extensions/shell/browser/shell_app_view_guest_delegate.h"
  13. #include "extensions/shell/browser/shell_display_info_provider.h"
  14. #include "extensions/shell/browser/shell_extension_web_contents_observer.h"
  15. #include "extensions/shell/browser/shell_virtual_keyboard_delegate.h"
  16. #include "extensions/shell/browser/shell_web_view_guest_delegate.h"
  17. // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
  18. // of lacros-chrome is complete.
  19. #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
  20. #include "extensions/shell/browser/api/file_system/shell_file_system_delegate.h"
  21. #endif
  22. namespace extensions {
  23. ShellExtensionsAPIClient::ShellExtensionsAPIClient() {}
  24. ShellExtensionsAPIClient::~ShellExtensionsAPIClient() {}
  25. void ShellExtensionsAPIClient::AttachWebContentsHelpers(
  26. content::WebContents* web_contents) const {
  27. ShellExtensionWebContentsObserver::CreateForWebContents(web_contents);
  28. }
  29. AppViewGuestDelegate* ShellExtensionsAPIClient::CreateAppViewGuestDelegate()
  30. const {
  31. return new ShellAppViewGuestDelegate();
  32. }
  33. WebViewGuestDelegate* ShellExtensionsAPIClient::CreateWebViewGuestDelegate(
  34. WebViewGuest* web_view_guest) const {
  35. return new ShellWebViewGuestDelegate();
  36. }
  37. std::unique_ptr<VirtualKeyboardDelegate>
  38. ShellExtensionsAPIClient::CreateVirtualKeyboardDelegate(
  39. content::BrowserContext* browser_context) const {
  40. return std::make_unique<ShellVirtualKeyboardDelegate>();
  41. }
  42. std::unique_ptr<DisplayInfoProvider>
  43. ShellExtensionsAPIClient::CreateDisplayInfoProvider() const {
  44. return std::make_unique<ShellDisplayInfoProvider>();
  45. }
  46. // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
  47. // of lacros-chrome is complete.
  48. #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
  49. FileSystemDelegate* ShellExtensionsAPIClient::GetFileSystemDelegate() {
  50. if (!file_system_delegate_)
  51. file_system_delegate_ = std::make_unique<ShellFileSystemDelegate>();
  52. return file_system_delegate_.get();
  53. }
  54. #endif
  55. MessagingDelegate* ShellExtensionsAPIClient::GetMessagingDelegate() {
  56. // The default implementation does nothing, which is fine.
  57. if (!messaging_delegate_)
  58. messaging_delegate_ = std::make_unique<MessagingDelegate>();
  59. return messaging_delegate_.get();
  60. }
  61. FeedbackPrivateDelegate*
  62. ShellExtensionsAPIClient::GetFeedbackPrivateDelegate() {
  63. if (!feedback_private_delegate_) {
  64. feedback_private_delegate_ =
  65. std::make_unique<ShellFeedbackPrivateDelegate>();
  66. }
  67. return feedback_private_delegate_.get();
  68. }
  69. } // namespace extensions