Index: chrome/browser/extensions/extension_host.h |
=================================================================== |
--- chrome/browser/extensions/extension_host.h (revision 14092) |
+++ chrome/browser/extensions/extension_host.h (working copy) |
@@ -2,21 +2,15 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_ |
-#define CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_ |
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |
#include "chrome/browser/renderer_host/render_view_host_delegate.h" |
#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" |
-// TODO(port): Port these files. |
-#if defined(OS_WIN) |
-#include "chrome/browser/views/hwnd_html_view.h" |
-#else |
-#include "chrome/common/temp_scaffolding_stubs.h" |
-#endif |
- |
class Browser; |
class Extension; |
+class ExtensionView; |
class RenderWidgetHost; |
class RenderWidgetHostView; |
class WebContents; |
@@ -24,27 +18,31 @@ |
// This class is the browser component of an extension component's RenderView. |
// It handles setting up the renderer process, if needed, with special |
-// priviliges available to extensions. The view may be drawn to the screen or |
-// hidden. |
-class ExtensionView : public HWNDHtmlView, |
- public RenderViewHostDelegate, |
+// privileges available to extensions. It may have a view to be shown in the |
+// in the browser UI, or it may be hidden. |
+class ExtensionHost : public RenderViewHostDelegate, |
public RenderViewHostDelegate::View { |
public: |
- ExtensionView(Extension* extension, |
- const GURL& url, |
- SiteInstance* instance, |
- Browser* browser); |
+ ExtensionHost(Extension* extension, SiteInstance* site_instance); |
+ ~ExtensionHost(); |
- // HWNDHtmlView |
- virtual void CreatingRenderer(); |
+ void set_view(ExtensionView* view) { view_ = view; } |
+ ExtensionView* view() const { return view_; } |
+ Extension* extension() { return extension_; } |
+ RenderViewHost* render_view_host() const { return render_view_host_; } |
+ SiteInstance* site_instance() const; |
+ bool did_stop_loading() const { return did_stop_loading_; } |
+ // Initializes our RenderViewHost by creating its RenderView and navigating |
+ // to the given URL. Uses host_view for the RenderViewHost's view (can be |
+ // NULL). |
+ void CreateRenderView(const GURL& url, RenderWidgetHostView* host_view); |
+ |
// RenderViewHostDelegate |
// TODO(mpcomplete): GetProfile is unused. |
virtual Profile* GetProfile() const { return NULL; } |
virtual void RenderViewCreated(RenderViewHost* render_view_host); |
virtual void DidContentsPreferredWidthChange(const int pref_width); |
- virtual void DidStopLoading(RenderViewHost* render_view_host, |
- int32 page_id); |
virtual WebPreferences GetWebkitPrefs(); |
virtual void RunJavaScriptMessage( |
const std::wstring& message, |
@@ -53,9 +51,11 @@ |
const int flags, |
IPC::Message* reply_msg, |
bool* did_suppress_message); |
- virtual void DidStartLoading(RenderViewHost* render_view_host, |
- int32 page_id); |
+ virtual void DidStartLoading(RenderViewHost* render_view_host); |
+ virtual void DidStopLoading(RenderViewHost* render_view_host); |
virtual RenderViewHostDelegate::View* GetViewDelegate() const; |
+ virtual ExtensionFunctionDispatcher* CreateExtensionFunctionDispatcher( |
+ RenderViewHost *render_view_host, const std::string& extension_id); |
// RenderViewHostDelegate::View |
virtual void CreateNewWindow(int route_id, |
@@ -73,18 +73,28 @@ |
virtual void TakeFocus(bool reverse); |
virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); |
- Extension* extension() { return extension_; } |
private: |
+ // If this ExtensionHost has a view, this returns the Browser that view is a |
+ // part of. If this is a global background page, we use the active Browser |
+ // instead. |
+ Browser* GetBrowser(); |
+ |
// The extension that we're hosting in this view. |
Extension* extension_; |
- // The browser window that this view is in. |
- Browser* browser_; |
+ // Optional view that shows the rendered content in the UI. |
+ ExtensionView* view_; |
+ // The host for our HTML content. |
+ RenderViewHost* render_view_host_; |
+ |
// Common implementations of some RenderViewHostDelegate::View methods. |
RenderViewHostDelegateViewHelper delegate_view_helper_; |
- DISALLOW_COPY_AND_ASSIGN(ExtensionView); |
+ // Whether the RenderWidget has reported that it has stopped loading. |
+ bool did_stop_loading_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ExtensionHost); |
}; |
-#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_ |
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |