| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
| 10 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 11 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
| 10 | 12 |
| 11 #if defined(TOOLKIT_VIEWS) | 13 #if defined(TOOLKIT_VIEWS) |
| 12 #include "chrome/browser/ui/views/extensions/extension_view_views.h" | 14 #include "chrome/browser/ui/views/extensions/extension_view_views.h" |
| 13 #elif defined(OS_MACOSX) | 15 #elif defined(OS_MACOSX) |
| 14 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" | 16 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" |
| 15 #elif defined(TOOLKIT_GTK) | 17 #elif defined(TOOLKIT_GTK) |
| 16 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" | 18 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" |
| 17 #elif defined(OS_ANDROID) | 19 #elif defined(OS_ANDROID) |
| 18 #include "chrome/browser/ui/android/extensions/extension_view_android.h" | 20 #include "chrome/browser/ui/android/extensions/extension_view_android.h" |
| 19 #endif | 21 #endif |
| 20 | 22 |
| 21 class Browser; | 23 class Browser; |
| 22 | 24 |
| 23 namespace content { | 25 namespace content { |
| 24 class SiteInstance; | 26 class SiteInstance; |
| 25 class WebContents; | 27 class WebContents; |
| 26 } | 28 } |
| 27 | 29 |
| 28 namespace extensions { | 30 namespace extensions { |
| 29 | 31 |
| 30 // The ExtensionHost for an extension that backs a view in the browser UI. For | 32 // The ExtensionHost for an extension that backs a view in the browser UI. For |
| 31 // example, this could be an extension popup, infobar or dialog, but not a | 33 // example, this could be an extension popup, infobar or dialog, but not a |
| 32 // background page. | 34 // background page. |
| 33 class ExtensionViewHost : public ExtensionHost { | 35 class ExtensionViewHost |
| 36 : public ExtensionHost, |
| 37 public web_modal::WebContentsModalDialogManagerDelegate, |
| 38 public web_modal::WebContentsModalDialogHost { |
| 34 public: | 39 public: |
| 35 ExtensionViewHost(const Extension* extension, | 40 ExtensionViewHost(const Extension* extension, |
| 36 content::SiteInstance* site_instance, | 41 content::SiteInstance* site_instance, |
| 37 const GURL& url, | 42 const GURL& url, |
| 38 ViewType host_type); | 43 ViewType host_type); |
| 39 virtual ~ExtensionViewHost(); | 44 virtual ~ExtensionViewHost(); |
| 40 | 45 |
| 41 // TODO(jamescook): Create platform specific subclasses? | 46 // TODO(jamescook): Create platform specific subclasses? |
| 42 #if defined(TOOLKIT_VIEWS) | 47 #if defined(TOOLKIT_VIEWS) |
| 43 typedef ExtensionViewViews PlatformExtensionView; | 48 typedef ExtensionViewViews PlatformExtensionView; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 63 // Handles keyboard events that were not handled by HandleKeyboardEvent(). | 68 // Handles keyboard events that were not handled by HandleKeyboardEvent(). |
| 64 // Platform specific implementation may override this method to handle the | 69 // Platform specific implementation may override this method to handle the |
| 65 // event in platform specific way. | 70 // event in platform specific way. |
| 66 virtual void UnhandledKeyboardEvent( | 71 virtual void UnhandledKeyboardEvent( |
| 67 content::WebContents* source, | 72 content::WebContents* source, |
| 68 const content::NativeWebKeyboardEvent& event); | 73 const content::NativeWebKeyboardEvent& event); |
| 69 | 74 |
| 70 // ExtensionHost | 75 // ExtensionHost |
| 71 virtual void OnDidStopLoading() OVERRIDE; | 76 virtual void OnDidStopLoading() OVERRIDE; |
| 72 virtual void OnDocumentAvailable() OVERRIDE; | 77 virtual void OnDocumentAvailable() OVERRIDE; |
| 78 virtual void LoadInitialURL() OVERRIDE; |
| 73 virtual bool IsBackgroundPage() const OVERRIDE; | 79 virtual bool IsBackgroundPage() const OVERRIDE; |
| 74 | 80 |
| 75 // content::WebContentsDelegate | 81 // content::WebContentsDelegate |
| 76 virtual content::WebContents* OpenURLFromTab( | 82 virtual content::WebContents* OpenURLFromTab( |
| 77 content::WebContents* source, | 83 content::WebContents* source, |
| 78 const content::OpenURLParams& params) OVERRIDE; | 84 const content::OpenURLParams& params) OVERRIDE; |
| 79 virtual bool PreHandleKeyboardEvent( | 85 virtual bool PreHandleKeyboardEvent( |
| 80 content::WebContents* source, | 86 content::WebContents* source, |
| 81 const content::NativeWebKeyboardEvent& event, | 87 const content::NativeWebKeyboardEvent& event, |
| 82 bool* is_keyboard_shortcut) OVERRIDE; | 88 bool* is_keyboard_shortcut) OVERRIDE; |
| 83 virtual void HandleKeyboardEvent( | 89 virtual void HandleKeyboardEvent( |
| 84 content::WebContents* source, | 90 content::WebContents* source, |
| 85 const content::NativeWebKeyboardEvent& event) OVERRIDE; | 91 const content::NativeWebKeyboardEvent& event) OVERRIDE; |
| 86 virtual void ResizeDueToAutoResize(content::WebContents* source, | 92 virtual void ResizeDueToAutoResize(content::WebContents* source, |
| 87 const gfx::Size& new_size) OVERRIDE; | 93 const gfx::Size& new_size) OVERRIDE; |
| 88 | 94 |
| 89 // content::WebContentsObserver | 95 // content::WebContentsObserver |
| 90 virtual void RenderViewCreated( | 96 virtual void RenderViewCreated( |
| 91 content::RenderViewHost* render_view_host) OVERRIDE; | 97 content::RenderViewHost* render_view_host) OVERRIDE; |
| 92 | 98 |
| 93 #if !defined(OS_ANDROID) | 99 // web_modal::WebContentsModalDialogManagerDelegate |
| 100 virtual web_modal::WebContentsModalDialogHost* |
| 101 GetWebContentsModalDialogHost() OVERRIDE; |
| 102 virtual bool IsWebContentsVisible( |
| 103 content::WebContents* web_contents) OVERRIDE; |
| 104 |
| 94 // web_modal::WebContentsModalDialogHost | 105 // web_modal::WebContentsModalDialogHost |
| 95 virtual gfx::NativeView GetHostView() const OVERRIDE; | 106 virtual gfx::NativeView GetHostView() const OVERRIDE; |
| 96 #endif | 107 virtual gfx::Point GetDialogPosition(const gfx::Size& size) OVERRIDE; |
| 108 virtual gfx::Size GetMaximumDialogSize() OVERRIDE; |
| 109 virtual void AddObserver( |
| 110 web_modal::ModalDialogHostObserver* observer) OVERRIDE; |
| 111 virtual void RemoveObserver( |
| 112 web_modal::ModalDialogHostObserver* observer) OVERRIDE; |
| 97 | 113 |
| 98 // ExtensionFunctionDispatcher::Delegate | 114 // ExtensionFunctionDispatcher::Delegate |
| 99 virtual WindowController* GetExtensionWindowController() const OVERRIDE; | 115 virtual WindowController* GetExtensionWindowController() const OVERRIDE; |
| 100 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; | 116 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; |
| 101 virtual content::WebContents* GetVisibleWebContents() const OVERRIDE; | 117 virtual content::WebContents* GetVisibleWebContents() const OVERRIDE; |
| 102 | 118 |
| 119 // content::NotificationObserver |
| 120 virtual void Observe(int type, |
| 121 const content::NotificationSource& source, |
| 122 const content::NotificationDetails& details) OVERRIDE; |
| 123 |
| 103 private: | 124 private: |
| 104 // Insert a default style sheet for Extension Infobars. | 125 // Insert a default style sheet for Extension Infobars. |
| 105 void InsertInfobarCSS(); | 126 void InsertInfobarCSS(); |
| 106 | 127 |
| 107 // Optional view that shows the rendered content in the UI. | 128 // Optional view that shows the rendered content in the UI. |
| 108 scoped_ptr<PlatformExtensionView> view_; | 129 scoped_ptr<PlatformExtensionView> view_; |
| 109 | 130 |
| 110 // The relevant WebContents associated with this ExtensionViewHost, if any. | 131 // The relevant WebContents associated with this ExtensionViewHost, if any. |
| 111 content::WebContents* associated_web_contents_; | 132 content::WebContents* associated_web_contents_; |
| 112 | 133 |
| 113 // Observer to detect when the associated web contents is destroyed. | 134 // Observer to detect when the associated web contents is destroyed. |
| 114 class AssociatedWebContentsObserver; | 135 class AssociatedWebContentsObserver; |
| 115 scoped_ptr<AssociatedWebContentsObserver> associated_web_contents_observer_; | 136 scoped_ptr<AssociatedWebContentsObserver> associated_web_contents_observer_; |
| 116 | 137 |
| 117 DISALLOW_COPY_AND_ASSIGN(ExtensionViewHost); | 138 DISALLOW_COPY_AND_ASSIGN(ExtensionViewHost); |
| 118 }; | 139 }; |
| 119 | 140 |
| 120 } // namespace extensions | 141 } // namespace extensions |
| 121 | 142 |
| 122 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_ | 143 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_ |
| OLD | NEW |