| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/perftimer.h" | 10 #include "base/perftimer.h" | 
| 11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" | 
| 12 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 12 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 
| 13 #include "chrome/browser/extensions/extension_popup_host.h" |  | 
| 14 #include "chrome/browser/jsmessage_box_client.h" | 13 #include "chrome/browser/jsmessage_box_client.h" | 
| 15 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 14 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 
| 16 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" | 15 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" | 
| 17 #if defined(TOOLKIT_VIEWS) | 16 #if defined(TOOLKIT_VIEWS) | 
| 18 #include "chrome/browser/views/extensions/extension_view.h" | 17 #include "chrome/browser/views/extensions/extension_view.h" | 
| 19 #elif defined(OS_MACOSX) | 18 #elif defined(OS_MACOSX) | 
| 20 #include "chrome/browser/cocoa/extension_view_mac.h" | 19 #include "chrome/browser/cocoa/extension_view_mac.h" | 
| 21 #elif defined(TOOLKIT_GTK) | 20 #elif defined(TOOLKIT_GTK) | 
| 22 #include "chrome/browser/gtk/extension_view_gtk.h" | 21 #include "chrome/browser/gtk/extension_view_gtk.h" | 
| 23 #endif | 22 #endif | 
| 24 #include "chrome/common/notification_registrar.h" | 23 #include "chrome/common/notification_registrar.h" | 
| 25 | 24 | 
| 26 | 25 | 
| 27 class Browser; | 26 class Browser; | 
| 28 class Extension; | 27 class Extension; | 
| 29 class ExtensionProcessManager; | 28 class ExtensionProcessManager; | 
| 30 class RenderProcessHost; | 29 class RenderProcessHost; | 
| 31 class RenderWidgetHost; | 30 class RenderWidgetHost; | 
| 32 class RenderWidgetHostView; | 31 class RenderWidgetHostView; | 
| 33 class TabContents; | 32 class TabContents; | 
| 34 struct WebPreferences; | 33 struct WebPreferences; | 
| 35 | 34 | 
| 36 // This class is the browser component of an extension component's RenderView. | 35 // This class is the browser component of an extension component's RenderView. | 
| 37 // It handles setting up the renderer process, if needed, with special | 36 // It handles setting up the renderer process, if needed, with special | 
| 38 // privileges available to extensions.  It may have a view to be shown in the | 37 // privileges available to extensions.  It may have a view to be shown in the | 
| 39 // in the browser UI, or it may be hidden. | 38 // in the browser UI, or it may be hidden. | 
| 40 class ExtensionHost : public ExtensionPopupHost::PopupDelegate, | 39 class ExtensionHost : public RenderViewHostDelegate, | 
| 41                       public RenderViewHostDelegate, |  | 
| 42                       public RenderViewHostDelegate::View, | 40                       public RenderViewHostDelegate::View, | 
| 43                       public ExtensionFunctionDispatcher::Delegate, | 41                       public ExtensionFunctionDispatcher::Delegate, | 
| 44                       public NotificationObserver, | 42                       public NotificationObserver, | 
| 45                       public JavaScriptMessageBoxClient { | 43                       public JavaScriptMessageBoxClient { | 
| 46  public: | 44  public: | 
| 47   class ProcessCreationQueue; | 45   class ProcessCreationQueue; | 
| 48 | 46 | 
| 49   // Enable DOM automation in created render view hosts. | 47   // Enable DOM automation in created render view hosts. | 
| 50   static void EnableDOMAutomation() { enable_dom_automation_ = true; } | 48   static void EnableDOMAutomation() { enable_dom_automation_ = true; } | 
| 51 | 49 | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 72   void CreateView(Browser* browser); | 70   void CreateView(Browser* browser); | 
| 73 | 71 | 
| 74   Extension* extension() { return extension_; } | 72   Extension* extension() { return extension_; } | 
| 75   RenderViewHost* render_view_host() const { return render_view_host_; } | 73   RenderViewHost* render_view_host() const { return render_view_host_; } | 
| 76   RenderProcessHost* render_process_host() const; | 74   RenderProcessHost* render_process_host() const; | 
| 77   SiteInstance* site_instance() const; | 75   SiteInstance* site_instance() const; | 
| 78   bool did_stop_loading() const { return did_stop_loading_; } | 76   bool did_stop_loading() const { return did_stop_loading_; } | 
| 79   bool document_element_available() const { | 77   bool document_element_available() const { | 
| 80     return document_element_available_; | 78     return document_element_available_; | 
| 81   } | 79   } | 
|  | 80   gfx::NativeView GetNativeViewOfHost() { | 
|  | 81     return view() ? view()->native_view() : NULL; | 
|  | 82   } | 
|  | 83 | 
| 82   Profile* profile() const { return profile_; } | 84   Profile* profile() const { return profile_; } | 
| 83 | 85 | 
| 84   ViewType::Type extension_host_type() const { return extension_host_type_; } | 86   ViewType::Type extension_host_type() const { return extension_host_type_; } | 
| 85 | 87 | 
| 86   // Sets the the ViewType of this host (e.g. mole, toolstrip). | 88   // Sets the the ViewType of this host (e.g. mole, toolstrip). | 
| 87   void SetRenderViewType(ViewType::Type type); | 89   void SetRenderViewType(ViewType::Type type); | 
| 88 | 90 | 
| 89   // Returns true if the render view is initialized and didn't crash. | 91   // Returns true if the render view is initialized and didn't crash. | 
| 90   bool IsRenderViewLive() const; | 92   bool IsRenderViewLive() const; | 
| 91 | 93 | 
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 197   // Actually create the RenderView for this host. See CreateRenderViewSoon. | 199   // Actually create the RenderView for this host. See CreateRenderViewSoon. | 
| 198   void CreateRenderViewNow(); | 200   void CreateRenderViewNow(); | 
| 199 | 201 | 
| 200   // ExtensionFunctionDispatcher::Delegate | 202   // ExtensionFunctionDispatcher::Delegate | 
| 201   // If this ExtensionHost has a view, this returns the Browser that view is a | 203   // If this ExtensionHost has a view, this returns the Browser that view is a | 
| 202   // part of.  If this is a global background page, we use the active Browser | 204   // part of.  If this is a global background page, we use the active Browser | 
| 203   // instead. | 205   // instead. | 
| 204   virtual Browser* GetBrowser(bool include_incognito) const; | 206   virtual Browser* GetBrowser(bool include_incognito) const; | 
| 205   virtual ExtensionHost* GetExtensionHost() { return this; } | 207   virtual ExtensionHost* GetExtensionHost() { return this; } | 
| 206 | 208 | 
| 207   // ExtensionPopupHost::Delegate |  | 
| 208   virtual Browser* GetBrowser() const { return GetBrowser(true); } | 209   virtual Browser* GetBrowser() const { return GetBrowser(true); } | 
| 209   virtual RenderViewHost* GetRenderViewHost() { return render_view_host(); } | 210   virtual RenderViewHost* GetRenderViewHost() { return render_view_host(); } | 
| 210   virtual gfx::NativeView GetNativeViewOfHost() { |  | 
| 211     return view() ? view()->native_view() : NULL; |  | 
| 212   } |  | 
| 213 | 211 | 
| 214   // Handles keyboard events that were not handled by HandleKeyboardEvent(). | 212   // Handles keyboard events that were not handled by HandleKeyboardEvent(). | 
| 215   // Platform specific implementation may override this method to handle the | 213   // Platform specific implementation may override this method to handle the | 
| 216   // event in platform specific way. | 214   // event in platform specific way. | 
| 217   virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) {} | 215   virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) {} | 
| 218 | 216 | 
| 219   // Returns true if we're hosting a background page. | 217   // Returns true if we're hosting a background page. | 
| 220   // This isn't valid until CreateRenderView is called. | 218   // This isn't valid until CreateRenderView is called. | 
| 221   bool is_background_page() const { return !view(); } | 219   bool is_background_page() const { return !view(); } | 
| 222 | 220 | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 258   // are used here, others are not hosted by ExtensionHost. | 256   // are used here, others are not hosted by ExtensionHost. | 
| 259   ViewType::Type extension_host_type_; | 257   ViewType::Type extension_host_type_; | 
| 260 | 258 | 
| 261   // Used to measure how long it's been since the host was created. | 259   // Used to measure how long it's been since the host was created. | 
| 262   PerfTimer since_created_; | 260   PerfTimer since_created_; | 
| 263 | 261 | 
| 264   DISALLOW_COPY_AND_ASSIGN(ExtensionHost); | 262   DISALLOW_COPY_AND_ASSIGN(ExtensionHost); | 
| 265 }; | 263 }; | 
| 266 | 264 | 
| 267 #endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ | 265 #endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ | 
| OLD | NEW | 
|---|