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 "components/web_modal/popup_manager.h" | 9 #include "components/web_modal/popup_manager.h" |
10 #include "components/web_modal/web_contents_modal_dialog_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" | 11 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
12 #include "extensions/browser/extension_host.h" | 12 #include "extensions/browser/extension_host.h" |
13 | 13 |
14 class Browser; | 14 class Browser; |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 class SiteInstance; | 17 class SiteInstance; |
18 class WebContents; | 18 class WebContents; |
19 } | 19 } |
20 | 20 |
21 namespace extensions { | 21 namespace extensions { |
22 | 22 |
23 class ExtensionView; | 23 class ExtensionView; |
24 | 24 |
25 // The ExtensionHost for an extension that backs a view in the browser UI. For | 25 // The ExtensionHost for an extension that backs a view in the browser UI. For |
26 // example, this could be an extension popup, infobar or dialog, but not a | 26 // example, this could be an extension popup or dialog, but not a background |
27 // background page. | 27 // page. |
28 // TODO(gbillock): See if we can remove WebContentsModalDialogManager here. | 28 // TODO(gbillock): See if we can remove WebContentsModalDialogManager here. |
29 class ExtensionViewHost | 29 class ExtensionViewHost |
30 : public ExtensionHost, | 30 : public ExtensionHost, |
31 public web_modal::WebContentsModalDialogManagerDelegate, | 31 public web_modal::WebContentsModalDialogManagerDelegate, |
32 public web_modal::WebContentsModalDialogHost { | 32 public web_modal::WebContentsModalDialogHost { |
33 public: | 33 public: |
34 ExtensionViewHost(const Extension* extension, | 34 ExtensionViewHost(const Extension* extension, |
35 content::SiteInstance* site_instance, | 35 content::SiteInstance* site_instance, |
36 const GURL& url, | 36 const GURL& url, |
37 ViewType host_type); | 37 ViewType host_type); |
(...skipping 12 matching lines...) Expand all Loading... |
50 | 50 |
51 // Handles keyboard events that were not handled by HandleKeyboardEvent(). | 51 // Handles keyboard events that were not handled by HandleKeyboardEvent(). |
52 // Platform specific implementation may override this method to handle the | 52 // Platform specific implementation may override this method to handle the |
53 // event in platform specific way. | 53 // event in platform specific way. |
54 virtual void UnhandledKeyboardEvent( | 54 virtual void UnhandledKeyboardEvent( |
55 content::WebContents* source, | 55 content::WebContents* source, |
56 const content::NativeWebKeyboardEvent& event); | 56 const content::NativeWebKeyboardEvent& event); |
57 | 57 |
58 // ExtensionHost | 58 // ExtensionHost |
59 void OnDidStopLoading() override; | 59 void OnDidStopLoading() override; |
60 void OnDocumentAvailable() override; | |
61 void LoadInitialURL() override; | 60 void LoadInitialURL() override; |
62 bool IsBackgroundPage() const override; | 61 bool IsBackgroundPage() const override; |
63 | 62 |
64 // content::WebContentsDelegate | 63 // content::WebContentsDelegate |
65 content::WebContents* OpenURLFromTab( | 64 content::WebContents* OpenURLFromTab( |
66 content::WebContents* source, | 65 content::WebContents* source, |
67 const content::OpenURLParams& params) override; | 66 const content::OpenURLParams& params) override; |
68 bool PreHandleKeyboardEvent(content::WebContents* source, | 67 bool PreHandleKeyboardEvent(content::WebContents* source, |
69 const content::NativeWebKeyboardEvent& event, | 68 const content::NativeWebKeyboardEvent& event, |
70 bool* is_keyboard_shortcut) override; | 69 bool* is_keyboard_shortcut) override; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // content::NotificationObserver | 104 // content::NotificationObserver |
106 void Observe(int type, | 105 void Observe(int type, |
107 const content::NotificationSource& source, | 106 const content::NotificationSource& source, |
108 const content::NotificationDetails& details) override; | 107 const content::NotificationDetails& details) override; |
109 | 108 |
110 private: | 109 private: |
111 // Implemented per-platform. Create the platform-specific ExtensionView. | 110 // Implemented per-platform. Create the platform-specific ExtensionView. |
112 static scoped_ptr<ExtensionView> CreateExtensionView(ExtensionViewHost* host, | 111 static scoped_ptr<ExtensionView> CreateExtensionView(ExtensionViewHost* host, |
113 Browser* browser); | 112 Browser* browser); |
114 | 113 |
115 // Insert a default style sheet for Extension Infobars. | |
116 void InsertInfobarCSS(); | |
117 | |
118 // Optional view that shows the rendered content in the UI. | 114 // Optional view that shows the rendered content in the UI. |
119 scoped_ptr<ExtensionView> view_; | 115 scoped_ptr<ExtensionView> view_; |
120 | 116 |
121 // The relevant WebContents associated with this ExtensionViewHost, if any. | 117 // The relevant WebContents associated with this ExtensionViewHost, if any. |
122 content::WebContents* associated_web_contents_; | 118 content::WebContents* associated_web_contents_; |
123 | 119 |
124 // Observer to detect when the associated web contents is destroyed. | 120 // Observer to detect when the associated web contents is destroyed. |
125 class AssociatedWebContentsObserver; | 121 class AssociatedWebContentsObserver; |
126 scoped_ptr<AssociatedWebContentsObserver> associated_web_contents_observer_; | 122 scoped_ptr<AssociatedWebContentsObserver> associated_web_contents_observer_; |
127 | 123 |
128 // Manage popups overlaying the WebContents in this EVH. | 124 // Manage popups overlaying the WebContents in this EVH. |
129 // TODO(gbillock): should usually not be used -- instead use the parent | 125 // TODO(gbillock): should usually not be used -- instead use the parent |
130 // window's popup manager. Should only be used when the EVH is created without | 126 // window's popup manager. Should only be used when the EVH is created without |
131 // a parent window. | 127 // a parent window. |
132 scoped_ptr<web_modal::PopupManager> popup_manager_; | 128 scoped_ptr<web_modal::PopupManager> popup_manager_; |
133 | 129 |
134 DISALLOW_COPY_AND_ASSIGN(ExtensionViewHost); | 130 DISALLOW_COPY_AND_ASSIGN(ExtensionViewHost); |
135 }; | 131 }; |
136 | 132 |
137 } // namespace extensions | 133 } // namespace extensions |
138 | 134 |
139 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_ | 135 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_ |
OLD | NEW |