Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/perftimer.h" | 13 #include "base/perftimer.h" |
| 14 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 14 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 15 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" | 15 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" |
| 16 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" | 16 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" |
| 17 #include "chrome/common/extensions/extension.h" | |
| 17 #include "content/browser/renderer_host/render_view_host_delegate.h" | 18 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 18 #include "content/common/notification_registrar.h" | 19 #include "content/common/notification_registrar.h" |
| 19 | 20 |
| 20 #if defined(TOOLKIT_VIEWS) | 21 #if defined(TOOLKIT_VIEWS) |
| 21 #include "chrome/browser/ui/views/extensions/extension_view.h" | 22 #include "chrome/browser/ui/views/extensions/extension_view.h" |
| 22 #elif defined(OS_MACOSX) | 23 #elif defined(OS_MACOSX) |
| 23 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" | 24 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" |
| 24 #elif defined(TOOLKIT_GTK) | 25 #elif defined(TOOLKIT_GTK) |
| 25 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" | 26 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" |
| 26 #endif | 27 #endif |
| 27 | 28 |
| 28 class Browser; | 29 class Browser; |
| 29 class Extension; | |
| 30 class FileSelectHelper; | 30 class FileSelectHelper; |
| 31 class RenderProcessHost; | 31 class RenderProcessHost; |
| 32 class RenderWidgetHostView; | 32 class RenderWidgetHostView; |
| 33 class TabContents; | 33 class TabContents; |
| 34 struct ViewHostMsg_RunFileChooser_Params; | 34 struct ViewHostMsg_RunFileChooser_Params; |
| 35 struct WebPreferences; | 35 struct WebPreferences; |
| 36 | 36 |
| 37 // This class is the browser component of an extension component's RenderView. | 37 // This class is the browser component of an extension component's RenderView. |
| 38 // It handles setting up the renderer process, if needed, with special | 38 // It handles setting up the renderer process, if needed, with special |
| 39 // privileges available to extensions. It may have a view to be shown in the | 39 // privileges available to extensions. It may have a view to be shown in the |
| 40 // in the browser UI, or it may be hidden. | 40 // browser UI, or it may be hidden. |
| 41 class ExtensionHost : public RenderViewHostDelegate, | 41 class ExtensionHost : public RenderViewHostDelegate, |
| 42 public RenderViewHostDelegate::View, | 42 public RenderViewHostDelegate::View, |
| 43 public ExtensionFunctionDispatcher::Delegate, | 43 public ExtensionFunctionDispatcher::Delegate, |
| 44 public NotificationObserver, | 44 public NotificationObserver, |
| 45 public JavaScriptAppModalDialogDelegate { | 45 public JavaScriptAppModalDialogDelegate { |
| 46 public: | 46 public: |
| 47 class ProcessCreationQueue; | 47 class ProcessCreationQueue; |
| 48 | 48 |
| 49 // Enable DOM automation in created render view hosts. | 49 // Enable DOM automation in created render view hosts. |
| 50 static void EnableDOMAutomation() { enable_dom_automation_ = true; } | 50 static void EnableDOMAutomation() { enable_dom_automation_ = true; } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 65 ExtensionViewGtk* view() { return view_.get(); } | 65 ExtensionViewGtk* view() { return view_.get(); } |
| 66 #endif | 66 #endif |
| 67 | 67 |
| 68 // Create an ExtensionView and tie it to this host and |browser|. Note NULL | 68 // Create an ExtensionView and tie it to this host and |browser|. Note NULL |
| 69 // is a valid argument for |browser|. Extension views may be bound to | 69 // is a valid argument for |browser|. Extension views may be bound to |
| 70 // tab-contents hosted in ExternalTabContainer objects, which do not | 70 // tab-contents hosted in ExternalTabContainer objects, which do not |
| 71 // instantiate Browser objects. | 71 // instantiate Browser objects. |
| 72 void CreateView(Browser* browser); | 72 void CreateView(Browser* browser); |
| 73 | 73 |
| 74 const Extension* extension() const { return extension_; } | 74 const Extension* extension() const { return extension_; } |
| 75 const std::string& id() const { | |
|
Matt Perry
2011/05/06 18:19:36
I think this should be named extension_id (and the
Denis Lagno
2011/05/06 19:50:33
Done.
| |
| 76 DCHECK(extension_ == NULL || extension_->id() == id_); | |
|
Matt Perry
2011/05/06 18:19:36
nit: this is overkill IMO. I'd leave it out.
Denis Lagno
2011/05/06 19:50:33
Done.
| |
| 77 return id_; | |
| 78 } | |
| 75 RenderViewHost* render_view_host() const { return render_view_host_; } | 79 RenderViewHost* render_view_host() const { return render_view_host_; } |
| 76 RenderProcessHost* render_process_host() const; | 80 RenderProcessHost* render_process_host() const; |
| 77 SiteInstance* site_instance() const; | 81 SiteInstance* site_instance() const; |
| 78 bool did_stop_loading() const { return did_stop_loading_; } | 82 bool did_stop_loading() const { return did_stop_loading_; } |
| 79 bool document_element_available() const { | 83 bool document_element_available() const { |
| 80 return document_element_available_; | 84 return document_element_available_; |
| 81 } | 85 } |
| 82 | 86 |
| 83 Profile* profile() const { return profile_; } | 87 Profile* profile() const { return profile_; } |
| 84 | 88 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 // event in platform specific way. | 238 // event in platform specific way. |
| 235 virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) {} | 239 virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) {} |
| 236 | 240 |
| 237 // Returns true if we're hosting a background page. | 241 // Returns true if we're hosting a background page. |
| 238 // This isn't valid until CreateRenderView is called. | 242 // This isn't valid until CreateRenderView is called. |
| 239 bool is_background_page() const { return !view(); } | 243 bool is_background_page() const { return !view(); } |
| 240 | 244 |
| 241 // The extension that we're hosting in this view. | 245 // The extension that we're hosting in this view. |
| 242 const Extension* extension_; | 246 const Extension* extension_; |
| 243 | 247 |
| 248 // Id of extension that we're hosting in this view. | |
| 249 std::string id_; | |
|
akalin
2011/05/06 18:40:31
may as well make this const
Denis Lagno
2011/05/06 19:50:33
Done.
| |
| 250 | |
| 244 // The profile that this host is tied to. | 251 // The profile that this host is tied to. |
| 245 Profile* profile_; | 252 Profile* profile_; |
| 246 | 253 |
| 247 // Optional view that shows the rendered content in the UI. | 254 // Optional view that shows the rendered content in the UI. |
| 248 #if defined(TOOLKIT_VIEWS) | 255 #if defined(TOOLKIT_VIEWS) |
| 249 scoped_ptr<ExtensionView> view_; | 256 scoped_ptr<ExtensionView> view_; |
| 250 #elif defined(OS_MACOSX) | 257 #elif defined(OS_MACOSX) |
| 251 scoped_ptr<ExtensionViewMac> view_; | 258 scoped_ptr<ExtensionViewMac> view_; |
| 252 #elif defined(TOOLKIT_GTK) | 259 #elif defined(TOOLKIT_GTK) |
| 253 scoped_ptr<ExtensionViewGtk> view_; | 260 scoped_ptr<ExtensionViewGtk> view_; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 // The time that the last javascript message was dismissed. | 295 // The time that the last javascript message was dismissed. |
| 289 base::TimeTicks last_javascript_message_dismissal_; | 296 base::TimeTicks last_javascript_message_dismissal_; |
| 290 | 297 |
| 291 // Whether to suppress all javascript messages. | 298 // Whether to suppress all javascript messages. |
| 292 bool suppress_javascript_messages_; | 299 bool suppress_javascript_messages_; |
| 293 | 300 |
| 294 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); | 301 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); |
| 295 }; | 302 }; |
| 296 | 303 |
| 297 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ | 304 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |
| OLD | NEW |