| 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/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/common/view_type.h" | |
| 16 #include "content/public/browser/javascript_dialog_manager.h" | 15 #include "content/public/browser/javascript_dialog_manager.h" |
| 17 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 19 #include "content/public/browser/web_contents_delegate.h" | 18 #include "content/public/browser/web_contents_delegate.h" |
| 20 #include "content/public/browser/web_contents_observer.h" | 19 #include "content/public/browser/web_contents_observer.h" |
| 20 #include "extensions/common/view_type.h" |
| 21 | 21 |
| 22 #if defined(TOOLKIT_VIEWS) | 22 #if defined(TOOLKIT_VIEWS) |
| 23 #include "chrome/browser/ui/views/extensions/extension_view_views.h" | 23 #include "chrome/browser/ui/views/extensions/extension_view_views.h" |
| 24 #elif defined(OS_MACOSX) | 24 #elif defined(OS_MACOSX) |
| 25 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" | 25 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" |
| 26 #elif defined(TOOLKIT_GTK) | 26 #elif defined(TOOLKIT_GTK) |
| 27 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" | 27 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" |
| 28 #elif defined(OS_ANDROID) | 28 #elif defined(OS_ANDROID) |
| 29 #include "chrome/browser/ui/android/extensions/extension_view_android.h" | 29 #include "chrome/browser/ui/android/extensions/extension_view_android.h" |
| 30 #endif | 30 #endif |
| (...skipping 28 matching lines...) Expand all Loading... |
| 59 typedef ExtensionViewMac PlatformExtensionView; | 59 typedef ExtensionViewMac PlatformExtensionView; |
| 60 #elif defined(TOOLKIT_GTK) | 60 #elif defined(TOOLKIT_GTK) |
| 61 typedef ExtensionViewGtk PlatformExtensionView; | 61 typedef ExtensionViewGtk PlatformExtensionView; |
| 62 #elif defined(OS_ANDROID) | 62 #elif defined(OS_ANDROID) |
| 63 // Android does not support extensions. | 63 // Android does not support extensions. |
| 64 typedef ExtensionViewAndroid PlatformExtensionView; | 64 typedef ExtensionViewAndroid PlatformExtensionView; |
| 65 #endif | 65 #endif |
| 66 | 66 |
| 67 ExtensionHost(const Extension* extension, | 67 ExtensionHost(const Extension* extension, |
| 68 content::SiteInstance* site_instance, | 68 content::SiteInstance* site_instance, |
| 69 const GURL& url, chrome::ViewType host_type); | 69 const GURL& url, ViewType host_type); |
| 70 virtual ~ExtensionHost(); | 70 virtual ~ExtensionHost(); |
| 71 | 71 |
| 72 #if defined(TOOLKIT_VIEWS) | 72 #if defined(TOOLKIT_VIEWS) |
| 73 void set_view(PlatformExtensionView* view) { view_.reset(view); } | 73 void set_view(PlatformExtensionView* view) { view_.reset(view); } |
| 74 #endif | 74 #endif |
| 75 | 75 |
| 76 const PlatformExtensionView* view() const { | 76 const PlatformExtensionView* view() const { |
| 77 #if defined(OS_ANDROID) | 77 #if defined(OS_ANDROID) |
| 78 NOTREACHED(); | 78 NOTREACHED(); |
| 79 #endif | 79 #endif |
| (...skipping 18 matching lines...) Expand all Loading... |
| 98 content::WebContents* host_contents() const { return host_contents_.get(); } | 98 content::WebContents* host_contents() const { return host_contents_.get(); } |
| 99 content::RenderViewHost* render_view_host() const; | 99 content::RenderViewHost* render_view_host() const; |
| 100 content::RenderProcessHost* render_process_host() const; | 100 content::RenderProcessHost* render_process_host() const; |
| 101 bool did_stop_loading() const { return did_stop_loading_; } | 101 bool did_stop_loading() const { return did_stop_loading_; } |
| 102 bool document_element_available() const { | 102 bool document_element_available() const { |
| 103 return document_element_available_; | 103 return document_element_available_; |
| 104 } | 104 } |
| 105 | 105 |
| 106 Profile* profile() const { return profile_; } | 106 Profile* profile() const { return profile_; } |
| 107 | 107 |
| 108 chrome::ViewType extension_host_type() const { return extension_host_type_; } | 108 ViewType extension_host_type() const { return extension_host_type_; } |
| 109 const GURL& GetURL() const; | 109 const GURL& GetURL() const; |
| 110 | 110 |
| 111 // ExtensionFunctionDispatcher::Delegate | 111 // ExtensionFunctionDispatcher::Delegate |
| 112 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; | 112 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; |
| 113 void SetAssociatedWebContents(content::WebContents* web_contents); | 113 void SetAssociatedWebContents(content::WebContents* web_contents); |
| 114 | 114 |
| 115 // Returns true if the render view is initialized and didn't crash. | 115 // Returns true if the render view is initialized and didn't crash. |
| 116 bool IsRenderViewLive() const; | 116 bool IsRenderViewLive() const; |
| 117 | 117 |
| 118 // Prepares to initializes our RenderViewHost by creating its RenderView and | 118 // Prepares to initializes our RenderViewHost by creating its RenderView and |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // Actually create the RenderView for this host. See CreateRenderViewSoon. | 181 // Actually create the RenderView for this host. See CreateRenderViewSoon. |
| 182 void CreateRenderViewNow(); | 182 void CreateRenderViewNow(); |
| 183 | 183 |
| 184 // Navigates to the initial page. | 184 // Navigates to the initial page. |
| 185 void LoadInitialURL(); | 185 void LoadInitialURL(); |
| 186 | 186 |
| 187 // Closes this host (results in deletion). | 187 // Closes this host (results in deletion). |
| 188 void Close(); | 188 void Close(); |
| 189 | 189 |
| 190 // ExtensionFunctionDispatcher::Delegate | 190 // ExtensionFunctionDispatcher::Delegate |
| 191 virtual extensions::WindowController* | 191 virtual WindowController* GetExtensionWindowController() const OVERRIDE; |
| 192 GetExtensionWindowController() const OVERRIDE; | |
| 193 | 192 |
| 194 // Message handlers. | 193 // Message handlers. |
| 195 void OnRequest(const ExtensionHostMsg_Request_Params& params); | 194 void OnRequest(const ExtensionHostMsg_Request_Params& params); |
| 196 void OnEventAck(); | 195 void OnEventAck(); |
| 197 void OnIncrementLazyKeepaliveCount(); | 196 void OnIncrementLazyKeepaliveCount(); |
| 198 void OnDecrementLazyKeepaliveCount(); | 197 void OnDecrementLazyKeepaliveCount(); |
| 199 | 198 |
| 200 // Handles keyboard events that were not handled by HandleKeyboardEvent(). | 199 // Handles keyboard events that were not handled by HandleKeyboardEvent(). |
| 201 // Platform specific implementation may override this method to handle the | 200 // Platform specific implementation may override this method to handle the |
| 202 // event in platform specific way. | 201 // event in platform specific way. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 bool document_element_available_; | 239 bool document_element_available_; |
| 241 | 240 |
| 242 // The original URL of the page being hosted. | 241 // The original URL of the page being hosted. |
| 243 GURL initial_url_; | 242 GURL initial_url_; |
| 244 | 243 |
| 245 content::NotificationRegistrar registrar_; | 244 content::NotificationRegistrar registrar_; |
| 246 | 245 |
| 247 ExtensionFunctionDispatcher extension_function_dispatcher_; | 246 ExtensionFunctionDispatcher extension_function_dispatcher_; |
| 248 | 247 |
| 249 // The type of view being hosted. | 248 // The type of view being hosted. |
| 250 chrome::ViewType extension_host_type_; | 249 ViewType extension_host_type_; |
| 251 | 250 |
| 252 // The relevant WebContents associated with this ExtensionHost, if any. | 251 // The relevant WebContents associated with this ExtensionHost, if any. |
| 253 content::WebContents* associated_web_contents_; | 252 content::WebContents* associated_web_contents_; |
| 254 | 253 |
| 255 // Used to measure how long it's been since the host was created. | 254 // Used to measure how long it's been since the host was created. |
| 256 PerfTimer since_created_; | 255 PerfTimer since_created_; |
| 257 | 256 |
| 258 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); | 257 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); |
| 259 }; | 258 }; |
| 260 | 259 |
| 261 } // namespace extensions | 260 } // namespace extensions |
| 262 | 261 |
| 263 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ | 262 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |
| OLD | NEW |