OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_HOST_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 namespace content { | 35 namespace content { |
36 class RenderProcessHost; | 36 class RenderProcessHost; |
37 class RenderWidgetHostView; | 37 class RenderWidgetHostView; |
38 class SiteInstance; | 38 class SiteInstance; |
39 } | 39 } |
40 | 40 |
41 namespace extensions { | 41 namespace extensions { |
42 class Extension; | 42 class Extension; |
43 class WindowController; | 43 class WindowController; |
44 } | |
45 | 44 |
46 // This class is the browser component of an extension component's RenderView. | 45 // This class is the browser component of an extension component's RenderView. |
47 // It handles setting up the renderer process, if needed, with special | 46 // It handles setting up the renderer process, if needed, with special |
48 // privileges available to extensions. It may have a view to be shown in the | 47 // privileges available to extensions. It may have a view to be shown in the |
49 // browser UI, or it may be hidden. | 48 // browser UI, or it may be hidden. |
50 class ExtensionHost : public content::WebContentsDelegate, | 49 class ExtensionHost : public content::WebContentsDelegate, |
51 public content::WebContentsObserver, | 50 public content::WebContentsObserver, |
52 public ExtensionFunctionDispatcher::Delegate, | 51 public ExtensionFunctionDispatcher::Delegate, |
53 public content::NotificationObserver { | 52 public content::NotificationObserver { |
54 public: | 53 public: |
55 class ProcessCreationQueue; | 54 class ProcessCreationQueue; |
56 | 55 |
57 #if defined(TOOLKIT_VIEWS) | 56 #if defined(TOOLKIT_VIEWS) |
58 typedef ExtensionView PlatformExtensionView; | 57 typedef ExtensionView PlatformExtensionView; |
59 #elif defined(OS_MACOSX) | 58 #elif defined(OS_MACOSX) |
60 typedef ExtensionViewMac PlatformExtensionView; | 59 typedef ExtensionViewMac PlatformExtensionView; |
61 #elif defined(TOOLKIT_GTK) | 60 #elif defined(TOOLKIT_GTK) |
62 typedef ExtensionViewGtk PlatformExtensionView; | 61 typedef ExtensionViewGtk PlatformExtensionView; |
63 #elif defined(OS_ANDROID) | 62 #elif defined(OS_ANDROID) |
64 // Android does not support extensions. | 63 // Android does not support extensions. |
65 typedef ExtensionViewAndroid PlatformExtensionView; | 64 typedef ExtensionViewAndroid PlatformExtensionView; |
66 #endif | 65 #endif |
67 | 66 |
68 ExtensionHost(const extensions::Extension* extension, | 67 ExtensionHost(const Extension* extension, |
69 content::SiteInstance* site_instance, | 68 content::SiteInstance* site_instance, |
70 const GURL& url, chrome::ViewType host_type); | 69 const GURL& url, chrome::ViewType host_type); |
71 virtual ~ExtensionHost(); | 70 virtual ~ExtensionHost(); |
72 | 71 |
73 #if defined(TOOLKIT_VIEWS) | 72 #if defined(TOOLKIT_VIEWS) |
74 void set_view(PlatformExtensionView* view) { view_.reset(view); } | 73 void set_view(PlatformExtensionView* view) { view_.reset(view); } |
75 #endif | 74 #endif |
76 | 75 |
77 const PlatformExtensionView* view() const { | 76 const PlatformExtensionView* view() const { |
78 #if defined(OS_ANDROID) | 77 #if defined(OS_ANDROID) |
79 NOTREACHED(); | 78 NOTREACHED(); |
80 #endif | 79 #endif |
81 return view_.get(); | 80 return view_.get(); |
82 } | 81 } |
83 | 82 |
84 PlatformExtensionView* view() { | 83 PlatformExtensionView* view() { |
85 #if defined(OS_ANDROID) | 84 #if defined(OS_ANDROID) |
86 NOTREACHED(); | 85 NOTREACHED(); |
87 #endif | 86 #endif |
88 return view_.get(); | 87 return view_.get(); |
89 } | 88 } |
90 | 89 |
91 // Create an ExtensionView and tie it to this host and |browser|. Note NULL | 90 // Create an ExtensionView and tie it to this host and |browser|. Note NULL |
92 // is a valid argument for |browser|. Extension views may be bound to | 91 // is a valid argument for |browser|. Extension views may be bound to |
93 // tab-contents hosted in ExternalTabContainer objects, which do not | 92 // tab-contents hosted in ExternalTabContainer objects, which do not |
94 // instantiate Browser objects. | 93 // instantiate Browser objects. |
95 void CreateView(Browser* browser); | 94 void CreateView(Browser* browser); |
96 | 95 |
97 const extensions::Extension* extension() const { return extension_; } | 96 const Extension* extension() const { return extension_; } |
98 const std::string& extension_id() const { return extension_id_; } | 97 const std::string& extension_id() const { return extension_id_; } |
99 content::WebContents* host_contents() const { return host_contents_.get(); } | 98 content::WebContents* host_contents() const { return host_contents_.get(); } |
100 content::RenderViewHost* render_view_host() const; | 99 content::RenderViewHost* render_view_host() const; |
101 content::RenderProcessHost* render_process_host() const; | 100 content::RenderProcessHost* render_process_host() const; |
102 bool did_stop_loading() const { return did_stop_loading_; } | 101 bool did_stop_loading() const { return did_stop_loading_; } |
103 bool document_element_available() const { | 102 bool document_element_available() const { |
104 return document_element_available_; | 103 return document_element_available_; |
105 } | 104 } |
106 | 105 |
107 Profile* profile() const { return profile_; } | 106 Profile* profile() const { return profile_; } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // Platform specific implementation may override this method to handle the | 196 // Platform specific implementation may override this method to handle the |
198 // event in platform specific way. | 197 // event in platform specific way. |
199 virtual void UnhandledKeyboardEvent( | 198 virtual void UnhandledKeyboardEvent( |
200 const content::NativeWebKeyboardEvent& event); | 199 const content::NativeWebKeyboardEvent& event); |
201 | 200 |
202 // Returns true if we're hosting a background page. | 201 // Returns true if we're hosting a background page. |
203 // This isn't valid until CreateRenderView is called. | 202 // This isn't valid until CreateRenderView is called. |
204 bool is_background_page() const { return !view(); } | 203 bool is_background_page() const { return !view(); } |
205 | 204 |
206 // The extension that we're hosting in this view. | 205 // The extension that we're hosting in this view. |
207 const extensions::Extension* extension_; | 206 const Extension* extension_; |
208 | 207 |
209 // Id of extension that we're hosting in this view. | 208 // Id of extension that we're hosting in this view. |
210 const std::string extension_id_; | 209 const std::string extension_id_; |
211 | 210 |
212 // The profile that this host is tied to. | 211 // The profile that this host is tied to. |
213 Profile* profile_; | 212 Profile* profile_; |
214 | 213 |
215 // Optional view that shows the rendered content in the UI. | 214 // Optional view that shows the rendered content in the UI. |
216 scoped_ptr<PlatformExtensionView> view_; | 215 scoped_ptr<PlatformExtensionView> view_; |
217 | 216 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 248 |
250 // The relevant WebContents associated with this ExtensionHost, if any. | 249 // The relevant WebContents associated with this ExtensionHost, if any. |
251 content::WebContents* associated_web_contents_; | 250 content::WebContents* associated_web_contents_; |
252 | 251 |
253 // Used to measure how long it's been since the host was created. | 252 // Used to measure how long it's been since the host was created. |
254 PerfTimer since_created_; | 253 PerfTimer since_created_; |
255 | 254 |
256 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); | 255 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); |
257 }; | 256 }; |
258 | 257 |
| 258 } // namespace extensions |
| 259 |
259 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ | 260 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |
OLD | NEW |