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_VIEW_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |
7 | 7 |
8 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 8 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
9 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" | 9 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" |
10 | 10 |
11 // TODO(port): Port these files. | |
12 #if defined(OS_WIN) | |
13 #include "chrome/browser/views/hwnd_html_view.h" | |
14 #else | |
15 #include "chrome/common/temp_scaffolding_stubs.h" | |
16 #endif | |
17 | |
18 class Browser; | 11 class Browser; |
19 class Extension; | 12 class Extension; |
| 13 class ExtensionView; |
20 class RenderWidgetHost; | 14 class RenderWidgetHost; |
21 class RenderWidgetHostView; | 15 class RenderWidgetHostView; |
22 class WebContents; | 16 class WebContents; |
23 struct WebPreferences; | 17 struct WebPreferences; |
24 | 18 |
25 // This class is the browser component of an extension component's RenderView. | 19 // This class is the browser component of an extension component's RenderView. |
26 // It handles setting up the renderer process, if needed, with special | 20 // It handles setting up the renderer process, if needed, with special |
27 // priviliges available to extensions. The view may be drawn to the screen or | 21 // privileges available to extensions. It may have a view to be shown in the |
28 // hidden. | 22 // in the browser UI, or it may be hidden. |
29 class ExtensionView : public HWNDHtmlView, | 23 class ExtensionHost : public RenderViewHostDelegate, |
30 public RenderViewHostDelegate, | |
31 public RenderViewHostDelegate::View { | 24 public RenderViewHostDelegate::View { |
32 public: | 25 public: |
33 ExtensionView(Extension* extension, | 26 ExtensionHost(Extension* extension, SiteInstance* site_instance); |
34 const GURL& url, | 27 ~ExtensionHost(); |
35 SiteInstance* instance, | |
36 Browser* browser); | |
37 | 28 |
38 // HWNDHtmlView | 29 void set_view(ExtensionView* view) { view_ = view; } |
39 virtual void CreatingRenderer(); | 30 ExtensionView* view() const { return view_; } |
| 31 Extension* extension() { return extension_; } |
| 32 RenderViewHost* render_view_host() const { return render_view_host_; } |
| 33 SiteInstance* site_instance() const; |
| 34 bool did_stop_loading() const { return did_stop_loading_; } |
| 35 |
| 36 // Initializes our RenderViewHost by creating its RenderView and navigating |
| 37 // to the given URL. Uses host_view for the RenderViewHost's view (can be |
| 38 // NULL). |
| 39 void CreateRenderView(const GURL& url, RenderWidgetHostView* host_view); |
40 | 40 |
41 // RenderViewHostDelegate | 41 // RenderViewHostDelegate |
42 // TODO(mpcomplete): GetProfile is unused. | 42 // TODO(mpcomplete): GetProfile is unused. |
43 virtual Profile* GetProfile() const { return NULL; } | 43 virtual Profile* GetProfile() const { return NULL; } |
44 virtual void RenderViewCreated(RenderViewHost* render_view_host); | 44 virtual void RenderViewCreated(RenderViewHost* render_view_host); |
45 virtual void DidContentsPreferredWidthChange(const int pref_width); | 45 virtual void DidContentsPreferredWidthChange(const int pref_width); |
46 virtual void DidStopLoading(RenderViewHost* render_view_host, | |
47 int32 page_id); | |
48 virtual WebPreferences GetWebkitPrefs(); | 46 virtual WebPreferences GetWebkitPrefs(); |
49 virtual void RunJavaScriptMessage( | 47 virtual void RunJavaScriptMessage( |
50 const std::wstring& message, | 48 const std::wstring& message, |
51 const std::wstring& default_prompt, | 49 const std::wstring& default_prompt, |
52 const GURL& frame_url, | 50 const GURL& frame_url, |
53 const int flags, | 51 const int flags, |
54 IPC::Message* reply_msg, | 52 IPC::Message* reply_msg, |
55 bool* did_suppress_message); | 53 bool* did_suppress_message); |
56 virtual void DidStartLoading(RenderViewHost* render_view_host, | 54 virtual void DidStartLoading(RenderViewHost* render_view_host); |
57 int32 page_id); | 55 virtual void DidStopLoading(RenderViewHost* render_view_host); |
58 virtual RenderViewHostDelegate::View* GetViewDelegate() const; | 56 virtual RenderViewHostDelegate::View* GetViewDelegate() const; |
| 57 virtual ExtensionFunctionDispatcher* CreateExtensionFunctionDispatcher( |
| 58 RenderViewHost *render_view_host, const std::string& extension_id); |
59 | 59 |
60 // RenderViewHostDelegate::View | 60 // RenderViewHostDelegate::View |
61 virtual void CreateNewWindow(int route_id, | 61 virtual void CreateNewWindow(int route_id, |
62 base::WaitableEvent* modal_dialog_event); | 62 base::WaitableEvent* modal_dialog_event); |
63 virtual void CreateNewWidget(int route_id, bool activatable); | 63 virtual void CreateNewWidget(int route_id, bool activatable); |
64 virtual void ShowCreatedWindow(int route_id, | 64 virtual void ShowCreatedWindow(int route_id, |
65 WindowOpenDisposition disposition, | 65 WindowOpenDisposition disposition, |
66 const gfx::Rect& initial_pos, | 66 const gfx::Rect& initial_pos, |
67 bool user_gesture); | 67 bool user_gesture); |
68 virtual void ShowCreatedWidget(int route_id, | 68 virtual void ShowCreatedWidget(int route_id, |
69 const gfx::Rect& initial_pos); | 69 const gfx::Rect& initial_pos); |
70 virtual void ShowContextMenu(const ContextMenuParams& params); | 70 virtual void ShowContextMenu(const ContextMenuParams& params); |
71 virtual void StartDragging(const WebDropData& drop_data); | 71 virtual void StartDragging(const WebDropData& drop_data); |
72 virtual void UpdateDragCursor(bool is_drop_target); | 72 virtual void UpdateDragCursor(bool is_drop_target); |
73 virtual void TakeFocus(bool reverse); | 73 virtual void TakeFocus(bool reverse); |
74 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); | 74 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); |
75 | 75 |
76 Extension* extension() { return extension_; } | |
77 private: | 76 private: |
| 77 // If this ExtensionHost has a view, this returns the Browser that view is a |
| 78 // part of. If this is a global background page, we use the active Browser |
| 79 // instead. |
| 80 Browser* GetBrowser(); |
| 81 |
78 // The extension that we're hosting in this view. | 82 // The extension that we're hosting in this view. |
79 Extension* extension_; | 83 Extension* extension_; |
80 | 84 |
81 // The browser window that this view is in. | 85 // Optional view that shows the rendered content in the UI. |
82 Browser* browser_; | 86 ExtensionView* view_; |
| 87 |
| 88 // The host for our HTML content. |
| 89 RenderViewHost* render_view_host_; |
83 | 90 |
84 // Common implementations of some RenderViewHostDelegate::View methods. | 91 // Common implementations of some RenderViewHostDelegate::View methods. |
85 RenderViewHostDelegateViewHelper delegate_view_helper_; | 92 RenderViewHostDelegateViewHelper delegate_view_helper_; |
86 | 93 |
87 DISALLOW_COPY_AND_ASSIGN(ExtensionView); | 94 // Whether the RenderWidget has reported that it has stopped loading. |
| 95 bool did_stop_loading_; |
| 96 |
| 97 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); |
88 }; | 98 }; |
89 | 99 |
90 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_ | 100 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ |
OLD | NEW |