| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 | 9 |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 11 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 12 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 12 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
| 13 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" | 13 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" |
| 14 #if defined(TOOLKIT_VIEWS) | 14 #if defined(TOOLKIT_VIEWS) |
| 15 #include "chrome/browser/views/extensions/extension_view.h" | 15 #include "chrome/browser/views/extensions/extension_view.h" |
| 16 #elif defined(OS_LINUX) |
| 17 #include "chrome/browser/gtk/extension_view_gtk.h" |
| 16 #endif | 18 #endif |
| 17 | 19 |
| 18 class Browser; | 20 class Browser; |
| 19 class Extension; | 21 class Extension; |
| 20 class ExtensionProcessManager; | 22 class ExtensionProcessManager; |
| 21 class RenderProcessHost; | 23 class RenderProcessHost; |
| 22 class RenderWidgetHost; | 24 class RenderWidgetHost; |
| 23 class RenderWidgetHostView; | 25 class RenderWidgetHostView; |
| 24 class TabContents; | 26 class TabContents; |
| 25 struct WebPreferences; | 27 struct WebPreferences; |
| 26 | 28 |
| 27 // This class is the browser component of an extension component's RenderView. | 29 // This class is the browser component of an extension component's RenderView. |
| 28 // It handles setting up the renderer process, if needed, with special | 30 // It handles setting up the renderer process, if needed, with special |
| 29 // privileges available to extensions. It may have a view to be shown in the | 31 // privileges available to extensions. It may have a view to be shown in the |
| 30 // in the browser UI, or it may be hidden. | 32 // in the browser UI, or it may be hidden. |
| 31 class ExtensionHost : public RenderViewHostDelegate, | 33 class ExtensionHost : public RenderViewHostDelegate, |
| 32 public RenderViewHostDelegate::View, | 34 public RenderViewHostDelegate::View, |
| 33 public ExtensionFunctionDispatcher::Delegate { | 35 public ExtensionFunctionDispatcher::Delegate { |
| 34 public: | 36 public: |
| 35 // Enable DOM automation in created render view hosts. | 37 // Enable DOM automation in created render view hosts. |
| 36 static void EnableDOMAutomation() { enable_dom_automation_ = true; } | 38 static void EnableDOMAutomation() { enable_dom_automation_ = true; } |
| 37 | 39 |
| 38 ExtensionHost(Extension* extension, SiteInstance* site_instance, | 40 ExtensionHost(Extension* extension, SiteInstance* site_instance, |
| 39 const GURL& url); | 41 const GURL& url); |
| 40 ~ExtensionHost(); | 42 ~ExtensionHost(); |
| 41 | 43 |
| 42 #if defined(TOOLKIT_VIEWS) | 44 #if defined(TOOLKIT_VIEWS) |
| 43 void set_view(ExtensionView* view) { view_.reset(view); } | 45 void set_view(ExtensionView* view) { view_.reset(view); } |
| 44 ExtensionView* view() const { return view_.get(); } | 46 ExtensionView* view() const { return view_.get(); } |
| 47 #elif defined(OS_LINUX) |
| 48 ExtensionViewGtk* view() const { return view_.get(); } |
| 45 #endif | 49 #endif |
| 46 | 50 |
| 47 // Create an ExtensionView and tie it to this host and |browser|. | 51 // Create an ExtensionView and tie it to this host and |browser|. |
| 48 void CreateView(Browser* browser); | 52 void CreateView(Browser* browser); |
| 49 | 53 |
| 50 Extension* extension() { return extension_; } | 54 Extension* extension() { return extension_; } |
| 51 RenderViewHost* render_view_host() const { return render_view_host_; } | 55 RenderViewHost* render_view_host() const { return render_view_host_; } |
| 52 RenderProcessHost* render_process_host() const; | 56 RenderProcessHost* render_process_host() const; |
| 53 SiteInstance* site_instance() const; | 57 SiteInstance* site_instance() const; |
| 54 bool did_stop_loading() const { return did_stop_loading_; } | 58 bool did_stop_loading() const { return did_stop_loading_; } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // part of. If this is a global background page, we use the active Browser | 124 // part of. If this is a global background page, we use the active Browser |
| 121 // instead. | 125 // instead. |
| 122 virtual Browser* GetBrowser(); | 126 virtual Browser* GetBrowser(); |
| 123 | 127 |
| 124 // The extension that we're hosting in this view. | 128 // The extension that we're hosting in this view. |
| 125 Extension* extension_; | 129 Extension* extension_; |
| 126 | 130 |
| 127 // The profile that this host is tied to. | 131 // The profile that this host is tied to. |
| 128 Profile* profile_; | 132 Profile* profile_; |
| 129 | 133 |
| 134 // Optional view that shows the rendered content in the UI. |
| 130 #if defined(TOOLKIT_VIEWS) | 135 #if defined(TOOLKIT_VIEWS) |
| 131 // Optional view that shows the rendered content in the UI. | |
| 132 scoped_ptr<ExtensionView> view_; | 136 scoped_ptr<ExtensionView> view_; |
| 137 #elif defined(OS_LINUX) |
| 138 scoped_ptr<ExtensionViewGtk> view_; |
| 133 #endif | 139 #endif |
| 134 | 140 |
| 135 // The host for our HTML content. | 141 // The host for our HTML content. |
| 136 RenderViewHost* render_view_host_; | 142 RenderViewHost* render_view_host_; |
| 137 | 143 |
| 138 // Common implementations of some RenderViewHostDelegate::View methods. | 144 // Common implementations of some RenderViewHostDelegate::View methods. |
| 139 RenderViewHostDelegateViewHelper delegate_view_helper_; | 145 RenderViewHostDelegateViewHelper delegate_view_helper_; |
| 140 | 146 |
| 141 // Whether the RenderWidget has reported that it has stopped loading. | 147 // Whether the RenderWidget has reported that it has stopped loading. |
| 142 bool did_stop_loading_; | 148 bool did_stop_loading_; |
| 143 | 149 |
| 144 // The URL being hosted. | 150 // The URL being hosted. |
| 145 GURL url_; | 151 GURL url_; |
| 146 | 152 |
| 147 scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_; | 153 scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_; |
| 148 | 154 |
| 149 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); | 155 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); |
| 150 }; | 156 }; |
| 151 | 157 |
| 152 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ | 158 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |
| OLD | NEW |