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_VIEW_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_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 #include "skia/include/SkBitmap.h" |
10 | 11 |
11 // TODO(port): Port these files. | 12 // TODO(port): Port these files. |
12 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
13 #include "chrome/browser/views/hwnd_html_view.h" | 14 #include "chrome/browser/views/hwnd_html_view.h" |
14 #else | 15 #else |
15 #include "chrome/common/temp_scaffolding_stubs.h" | 16 #include "chrome/common/temp_scaffolding_stubs.h" |
16 #endif | 17 #endif |
17 | 18 |
18 class Browser; | 19 class Browser; |
19 class Extension; | 20 class Extension; |
20 class RenderWidgetHost; | 21 class RenderWidgetHost; |
21 class RenderWidgetHostView; | 22 class RenderWidgetHostView; |
22 class WebContents; | 23 class WebContents; |
23 struct WebPreferences; | 24 struct WebPreferences; |
24 | 25 |
25 // This class is the browser component of an extension component's RenderView. | 26 // This class is the browser component of an extension component's RenderView. |
26 // It handles setting up the renderer process, if needed, with special | 27 // 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 | 28 // priviliges available to extensions. The view may be drawn to the screen or |
28 // hidden. | 29 // hidden. |
29 class ExtensionView : public HWNDHtmlView, | 30 class ExtensionView : public HWNDHtmlView, |
30 public RenderViewHostDelegate, | 31 public RenderViewHostDelegate, |
31 public RenderViewHostDelegate::View { | 32 public RenderViewHostDelegate::View { |
32 public: | 33 public: |
| 34 // ExtensionView |
33 ExtensionView(Extension* extension, | 35 ExtensionView(Extension* extension, |
34 const GURL& url, | 36 const GURL& url, |
35 SiteInstance* instance, | 37 SiteInstance* instance, |
36 Browser* browser); | 38 Browser* browser); |
37 | 39 |
| 40 Extension* extension() { return extension_; } |
| 41 |
38 // HWNDHtmlView | 42 // HWNDHtmlView |
39 virtual void CreatingRenderer(); | 43 virtual void CreatingRenderer(); |
40 | 44 |
| 45 virtual void SetBackground(const SkBitmap& background); |
| 46 |
41 // RenderViewHostDelegate | 47 // RenderViewHostDelegate |
42 // TODO(mpcomplete): GetProfile is unused. | 48 // TODO(mpcomplete): GetProfile is unused. |
43 virtual Profile* GetProfile() const { return NULL; } | 49 virtual Profile* GetProfile() const { return NULL; } |
44 virtual void RenderViewCreated(RenderViewHost* render_view_host); | 50 virtual void RenderViewCreated(RenderViewHost* render_view_host); |
45 virtual void DidContentsPreferredWidthChange(const int pref_width); | 51 virtual void DidContentsPreferredWidthChange(const int pref_width); |
46 virtual void DidStopLoading(RenderViewHost* render_view_host, | 52 virtual void DidStopLoading(RenderViewHost* render_view_host, |
47 int32 page_id); | 53 int32 page_id); |
48 virtual WebPreferences GetWebkitPrefs(); | 54 virtual WebPreferences GetWebkitPrefs(); |
49 virtual void RunJavaScriptMessage( | 55 virtual void RunJavaScriptMessage( |
50 const std::wstring& message, | 56 const std::wstring& message, |
(...skipping 15 matching lines...) Expand all Loading... |
66 const gfx::Rect& initial_pos, | 72 const gfx::Rect& initial_pos, |
67 bool user_gesture); | 73 bool user_gesture); |
68 virtual void ShowCreatedWidget(int route_id, | 74 virtual void ShowCreatedWidget(int route_id, |
69 const gfx::Rect& initial_pos); | 75 const gfx::Rect& initial_pos); |
70 virtual void ShowContextMenu(const ContextMenuParams& params); | 76 virtual void ShowContextMenu(const ContextMenuParams& params); |
71 virtual void StartDragging(const WebDropData& drop_data); | 77 virtual void StartDragging(const WebDropData& drop_data); |
72 virtual void UpdateDragCursor(bool is_drop_target); | 78 virtual void UpdateDragCursor(bool is_drop_target); |
73 virtual void TakeFocus(bool reverse); | 79 virtual void TakeFocus(bool reverse); |
74 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); | 80 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); |
75 | 81 |
76 Extension* extension() { return extension_; } | |
77 private: | 82 private: |
| 83 // We wait to show the ExtensionView until several things have loaded. |
| 84 void ShowIfCompletelyLoaded(); |
| 85 |
78 // The extension that we're hosting in this view. | 86 // The extension that we're hosting in this view. |
79 Extension* extension_; | 87 Extension* extension_; |
80 | 88 |
81 // The browser window that this view is in. | 89 // The browser window that this view is in. |
82 Browser* browser_; | 90 Browser* browser_; |
83 | 91 |
84 // Common implementations of some RenderViewHostDelegate::View methods. | 92 // Common implementations of some RenderViewHostDelegate::View methods. |
85 RenderViewHostDelegateViewHelper delegate_view_helper_; | 93 RenderViewHostDelegateViewHelper delegate_view_helper_; |
86 | 94 |
| 95 // Whether the RenderWidget has reported that it has stopped loading. |
| 96 bool did_stop_loading_; |
| 97 |
| 98 // What we should set the preferred width to once the ExtensionView has |
| 99 // loaded. |
| 100 int pending_preferred_width_; |
| 101 |
87 DISALLOW_COPY_AND_ASSIGN(ExtensionView); | 102 DISALLOW_COPY_AND_ASSIGN(ExtensionView); |
88 }; | 103 }; |
89 | 104 |
90 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_ | 105 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_ |
OLD | NEW |