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 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/timer/elapsed_timer.h" | 13 #include "base/timer/elapsed_timer.h" |
14 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 14 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
15 #include "content/public/browser/javascript_dialog_manager.h" | 15 #include "content/public/browser/javascript_dialog_manager.h" |
16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
18 #include "content/public/browser/web_contents_delegate.h" | 18 #include "content/public/browser/web_contents_delegate.h" |
19 #include "content/public/browser/web_contents_observer.h" | 19 #include "content/public/browser/web_contents_observer.h" |
20 #include "extensions/common/stack_frame.h" | 20 #include "extensions/common/stack_frame.h" |
21 #include "extensions/common/view_type.h" | 21 #include "extensions/common/view_type.h" |
22 | 22 |
23 #if !defined(OS_ANDROID) | |
24 #include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h" | |
25 #include "components/web_modal/web_contents_modal_dialog_host.h" | |
26 #endif | |
27 | |
28 class PrefsTabHelper; | 23 class PrefsTabHelper; |
29 | 24 |
30 namespace content { | 25 namespace content { |
31 class BrowserContext; | 26 class BrowserContext; |
32 class RenderProcessHost; | 27 class RenderProcessHost; |
33 class RenderWidgetHostView; | 28 class RenderWidgetHostView; |
34 class SiteInstance; | 29 class SiteInstance; |
35 } | 30 } |
36 | 31 |
37 namespace extensions { | 32 namespace extensions { |
38 class Extension; | 33 class Extension; |
39 class WindowController; | 34 class WindowController; |
40 | 35 |
41 // This class is the browser component of an extension component's RenderView. | 36 // This class is the browser component of an extension component's RenderView. |
42 // It handles setting up the renderer process, if needed, with special | 37 // It handles setting up the renderer process, if needed, with special |
43 // privileges available to extensions. It may have a view to be shown in the | 38 // privileges available to extensions. It may have a view to be shown in the |
44 // browser UI, or it may be hidden. | 39 // browser UI, or it may be hidden. |
45 // TODO(jamescook): Move the ChromeWebModalDialogManagerDelegate interface to | |
46 // ExtensionViewHost. | |
47 class ExtensionHost : public content::WebContentsDelegate, | 40 class ExtensionHost : public content::WebContentsDelegate, |
48 #if !defined(OS_ANDROID) | |
49 public ChromeWebModalDialogManagerDelegate, | |
50 public web_modal::WebContentsModalDialogHost, | |
51 #endif | |
52 public content::WebContentsObserver, | 41 public content::WebContentsObserver, |
53 public ExtensionFunctionDispatcher::Delegate, | 42 public ExtensionFunctionDispatcher::Delegate, |
54 public content::NotificationObserver { | 43 public content::NotificationObserver { |
55 public: | 44 public: |
56 class ProcessCreationQueue; | 45 class ProcessCreationQueue; |
57 | 46 |
58 ExtensionHost(const Extension* extension, | 47 ExtensionHost(const Extension* extension, |
59 content::SiteInstance* site_instance, | 48 content::SiteInstance* site_instance, |
60 const GURL& url, ViewType host_type); | 49 const GURL& url, ViewType host_type); |
61 virtual ~ExtensionHost(); | 50 virtual ~ExtensionHost(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 content::WebContents* web_contents, | 110 content::WebContents* web_contents, |
122 const content::MediaStreamRequest& request, | 111 const content::MediaStreamRequest& request, |
123 const content::MediaResponseCallback& callback) OVERRIDE; | 112 const content::MediaResponseCallback& callback) OVERRIDE; |
124 | 113 |
125 // content::NotificationObserver | 114 // content::NotificationObserver |
126 virtual void Observe(int type, | 115 virtual void Observe(int type, |
127 const content::NotificationSource& source, | 116 const content::NotificationSource& source, |
128 const content::NotificationDetails& details) OVERRIDE; | 117 const content::NotificationDetails& details) OVERRIDE; |
129 | 118 |
130 protected: | 119 protected: |
| 120 content::NotificationRegistrar* registrar() { return ®istrar_; } |
| 121 |
131 // Called after the extension page finishes loading but before the | 122 // Called after the extension page finishes loading but before the |
132 // EXTENSION_HOST_DID_STOP_LOADING notification is sent. | 123 // EXTENSION_HOST_DID_STOP_LOADING notification is sent. |
133 virtual void OnDidStopLoading(); | 124 virtual void OnDidStopLoading(); |
134 | 125 |
135 // Called once when the document first becomes available. | 126 // Called once when the document first becomes available. |
136 virtual void OnDocumentAvailable(); | 127 virtual void OnDocumentAvailable(); |
137 | 128 |
| 129 // Navigates to the initial page. |
| 130 virtual void LoadInitialURL(); |
| 131 |
138 // Returns true if we're hosting a background page. | 132 // Returns true if we're hosting a background page. |
139 virtual bool IsBackgroundPage() const; | 133 virtual bool IsBackgroundPage() const; |
140 | 134 |
141 // Closes this host (results in deletion). | 135 // Closes this host (results in deletion). |
142 void Close(); | 136 void Close(); |
143 | 137 |
144 private: | 138 private: |
145 friend class ProcessCreationQueue; | 139 friend class ProcessCreationQueue; |
146 | 140 |
147 // Actually create the RenderView for this host. See CreateRenderViewSoon. | 141 // Actually create the RenderView for this host. See CreateRenderViewSoon. |
148 void CreateRenderViewNow(); | 142 void CreateRenderViewNow(); |
149 | 143 |
150 // Navigates to the initial page. | |
151 void LoadInitialURL(); | |
152 | |
153 #if !defined(OS_ANDROID) | |
154 // TODO(jamescook): Move this to ExtensionViewHost. | |
155 // ChromeWebModalDialogManagerDelegate | |
156 virtual web_modal::WebContentsModalDialogHost* | |
157 GetWebContentsModalDialogHost() OVERRIDE; | |
158 | |
159 // web_modal::WebContentsModalDialogHost | |
160 virtual gfx::NativeView GetHostView() const OVERRIDE; | |
161 virtual gfx::Point GetDialogPosition(const gfx::Size& size) OVERRIDE; | |
162 virtual gfx::Size GetMaximumDialogSize() OVERRIDE; | |
163 virtual void AddObserver( | |
164 web_modal::ModalDialogHostObserver* observer) OVERRIDE; | |
165 virtual void RemoveObserver( | |
166 web_modal::ModalDialogHostObserver* observer) OVERRIDE; | |
167 #endif | |
168 | |
169 // Message handlers. | 144 // Message handlers. |
170 void OnRequest(const ExtensionHostMsg_Request_Params& params); | 145 void OnRequest(const ExtensionHostMsg_Request_Params& params); |
171 void OnEventAck(); | 146 void OnEventAck(); |
172 void OnIncrementLazyKeepaliveCount(); | 147 void OnIncrementLazyKeepaliveCount(); |
173 void OnDecrementLazyKeepaliveCount(); | 148 void OnDecrementLazyKeepaliveCount(); |
174 void OnDetailedConsoleMessageAdded( | 149 void OnDetailedConsoleMessageAdded( |
175 const base::string16& message, | 150 const base::string16& message, |
176 const base::string16& source, | 151 const base::string16& source, |
177 const StackTrace& stack_trace, | 152 const StackTrace& stack_trace, |
178 int32 severity_level); | 153 int32 severity_level); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 192 |
218 // Used to measure how long it's been since the host was created. | 193 // Used to measure how long it's been since the host was created. |
219 base::ElapsedTimer since_created_; | 194 base::ElapsedTimer since_created_; |
220 | 195 |
221 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); | 196 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); |
222 }; | 197 }; |
223 | 198 |
224 } // namespace extensions | 199 } // namespace extensions |
225 | 200 |
226 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ | 201 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |
OLD | NEW |