OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_TAB_CONTENTS_BACKGROUND_CONTENTS_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_BACKGROUND_CONTENTS_H_ |
6 #define CHROME_BROWSER_TAB_CONTENTS_BACKGROUND_CONTENTS_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_BACKGROUND_CONTENTS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" | 13 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" |
14 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" | 14 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" |
15 #include "chrome/common/view_types.h" | 15 #include "chrome/common/view_types.h" |
16 #include "content/browser/renderer_host/render_view_host_delegate.h" | 16 #include "content/browser/renderer_host/render_view_host_delegate.h" |
17 #include "content/common/notification_registrar.h" | 17 #include "content/common/notification_registrar.h" |
18 #include "content/common/window_container_type.h" | 18 #include "content/common/window_container_type.h" |
19 #include "webkit/glue/window_open_disposition.h" | 19 #include "webkit/glue/window_open_disposition.h" |
20 | 20 |
21 class TabContents; | 21 class TabContents; |
| 22 class DesktopNotificationHandler; |
| 23 class ExtensionMessageHandler; |
22 struct WebPreferences; | 24 struct WebPreferences; |
23 class DesktopNotificationHandler; | |
24 | 25 |
25 namespace gfx { | 26 namespace gfx { |
26 class Rect; | 27 class Rect; |
27 } | 28 } |
28 | 29 |
29 // This class is a peer of TabContents. It can host a renderer, but does not | 30 // This class is a peer of TabContents. It can host a renderer, but does not |
30 // have any visible display. Its navigation is not managed by a | 31 // have any visible display. Its navigation is not managed by a |
31 // NavigationController because is has no facility for navigating (other than | 32 // NavigationController because is has no facility for navigating (other than |
32 // programatically view window.location.href) or RenderViewHostManager because | 33 // programatically view window.location.href) or RenderViewHostManager because |
33 // it is never allowed to navigate across a SiteInstance boundary. | 34 // it is never allowed to navigate across a SiteInstance boundary. |
(...skipping 27 matching lines...) Expand all Loading... |
61 | 62 |
62 // RenderViewHostDelegate implementation. | 63 // RenderViewHostDelegate implementation. |
63 virtual BackgroundContents* GetAsBackgroundContents(); | 64 virtual BackgroundContents* GetAsBackgroundContents(); |
64 virtual RenderViewHostDelegate::View* GetViewDelegate(); | 65 virtual RenderViewHostDelegate::View* GetViewDelegate(); |
65 virtual const GURL& GetURL() const; | 66 virtual const GURL& GetURL() const; |
66 virtual ViewType::Type GetRenderViewType() const; | 67 virtual ViewType::Type GetRenderViewType() const; |
67 virtual int GetBrowserWindowID() const; | 68 virtual int GetBrowserWindowID() const; |
68 virtual void DidNavigate(RenderViewHost* render_view_host, | 69 virtual void DidNavigate(RenderViewHost* render_view_host, |
69 const ViewHostMsg_FrameNavigate_Params& params); | 70 const ViewHostMsg_FrameNavigate_Params& params); |
70 virtual WebPreferences GetWebkitPrefs(); | 71 virtual WebPreferences GetWebkitPrefs(); |
71 virtual void ProcessWebUIMessage( | |
72 const ExtensionHostMsg_DomMessage_Params& params); | |
73 virtual void RunJavaScriptMessage(const std::wstring& message, | 72 virtual void RunJavaScriptMessage(const std::wstring& message, |
74 const std::wstring& default_prompt, | 73 const std::wstring& default_prompt, |
75 const GURL& frame_url, | 74 const GURL& frame_url, |
76 const int flags, | 75 const int flags, |
77 IPC::Message* reply_msg, | 76 IPC::Message* reply_msg, |
78 bool* did_suppress_message); | 77 bool* did_suppress_message); |
79 virtual void Close(RenderViewHost* render_view_host); | 78 virtual void Close(RenderViewHost* render_view_host); |
80 virtual RendererPreferences GetRendererPrefs(Profile* profile) const; | 79 virtual RendererPreferences GetRendererPrefs(Profile* profile) const; |
81 virtual void RenderViewGone(RenderViewHost* rvh, | 80 virtual void RenderViewGone(RenderViewHost* rvh, |
82 base::TerminationStatus status, | 81 base::TerminationStatus status, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // Should only be called from the UI thread, since it accesses | 145 // Should only be called from the UI thread, since it accesses |
147 // BackgroundContents. | 146 // BackgroundContents. |
148 static BackgroundContents* GetBackgroundContentsByID(int render_process_id, | 147 static BackgroundContents* GetBackgroundContentsByID(int render_process_id, |
149 int render_view_id); | 148 int render_view_id); |
150 | 149 |
151 protected: | 150 protected: |
152 // Exposed for testing. | 151 // Exposed for testing. |
153 BackgroundContents(); | 152 BackgroundContents(); |
154 | 153 |
155 private: | 154 private: |
156 // Message handlers. | |
157 void OnPostMessage(int port_id, const std::string& message); | |
158 | |
159 // The delegate for this BackgroundContents. | 155 // The delegate for this BackgroundContents. |
160 Delegate* delegate_; | 156 Delegate* delegate_; |
161 | 157 |
162 // The host for our HTML content. | 158 // The host for our HTML content. |
163 RenderViewHost* render_view_host_; | 159 RenderViewHost* render_view_host_; |
164 | 160 |
165 // Common implementations of some RenderViewHostDelegate::View methods. | 161 // Common implementations of some RenderViewHostDelegate::View methods. |
166 RenderViewHostDelegateViewHelper delegate_view_helper_; | 162 RenderViewHostDelegateViewHelper delegate_view_helper_; |
167 | 163 |
168 // The URL being hosted. | 164 // The URL being hosted. |
169 GURL url_; | 165 GURL url_; |
170 | 166 |
171 NotificationRegistrar registrar_; | 167 NotificationRegistrar registrar_; |
172 | 168 |
173 // Handles desktop notification IPCs. | 169 // Handles desktop notification IPCs. |
174 scoped_ptr<DesktopNotificationHandler> desktop_notification_handler_; | 170 scoped_ptr<DesktopNotificationHandler> desktop_notification_handler_; |
175 | 171 |
| 172 // Handles extension IPCs. |
| 173 scoped_ptr<ExtensionMessageHandler> extension_message_handler_; |
| 174 |
176 DISALLOW_COPY_AND_ASSIGN(BackgroundContents); | 175 DISALLOW_COPY_AND_ASSIGN(BackgroundContents); |
177 }; | 176 }; |
178 | 177 |
179 // This is the data sent out as the details with BACKGROUND_CONTENTS_OPENED. | 178 // This is the data sent out as the details with BACKGROUND_CONTENTS_OPENED. |
180 struct BackgroundContentsOpenedDetails { | 179 struct BackgroundContentsOpenedDetails { |
181 // The BackgroundContents object that has just been opened. | 180 // The BackgroundContents object that has just been opened. |
182 BackgroundContents* contents; | 181 BackgroundContents* contents; |
183 | 182 |
184 // The name of the parent frame for these contents. | 183 // The name of the parent frame for these contents. |
185 const string16& frame_name; | 184 const string16& frame_name; |
186 | 185 |
187 // The ID of the parent application (if any). | 186 // The ID of the parent application (if any). |
188 const string16& application_id; | 187 const string16& application_id; |
189 }; | 188 }; |
190 | 189 |
191 #endif // CHROME_BROWSER_TAB_CONTENTS_BACKGROUND_CONTENTS_H_ | 190 #endif // CHROME_BROWSER_TAB_CONTENTS_BACKGROUND_CONTENTS_H_ |
OLD | NEW |