OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_RENDER_VIEW_HOST_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
6 #define CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/scoped_ptr.h" |
9 #include "chrome/browser/renderer_host/render_view_host.h" | 10 #include "chrome/browser/renderer_host/render_view_host.h" |
10 #include "chrome/common/notification_registrar.h" | 11 #include "chrome/common/notification_registrar.h" |
11 #include "chrome/common/notification_observer.h" | 12 #include "chrome/common/notification_observer.h" |
12 | 13 |
| 14 class DOMUI; |
13 class InterstitialPage; | 15 class InterstitialPage; |
14 class NavigationController; | 16 class NavigationController; |
15 class NavigationEntry; | 17 class NavigationEntry; |
16 class Profile; | 18 class Profile; |
17 class RenderViewHostDelegate; | 19 class RenderViewHostDelegate; |
18 class RenderViewHostFactory; | 20 class RenderViewHostFactory; |
19 class RenderWidgetHostView; | 21 class RenderWidgetHostView; |
20 class SiteInstance; | 22 class SiteInstance; |
21 | 23 |
22 // Manages RenderViewHosts for a WebContents. Normally there is only one and | 24 // Manages RenderViewHosts for a WebContents. Normally there is only one and |
(...skipping 18 matching lines...) Expand all Loading... |
41 virtual void BeforeUnloadFiredFromRenderManager( | 43 virtual void BeforeUnloadFiredFromRenderManager( |
42 bool proceed, bool* proceed_to_fire_unload) = 0; | 44 bool proceed, bool* proceed_to_fire_unload) = 0; |
43 virtual void DidStartLoadingFromRenderManager( | 45 virtual void DidStartLoadingFromRenderManager( |
44 RenderViewHost* render_view_host, int32 page_id) = 0; | 46 RenderViewHost* render_view_host, int32 page_id) = 0; |
45 virtual void RenderViewGoneFromRenderManager( | 47 virtual void RenderViewGoneFromRenderManager( |
46 RenderViewHost* render_view_host) = 0; | 48 RenderViewHost* render_view_host) = 0; |
47 virtual void UpdateRenderViewSizeForRenderManager() = 0; | 49 virtual void UpdateRenderViewSizeForRenderManager() = 0; |
48 virtual void NotifySwappedFromRenderManager() = 0; | 50 virtual void NotifySwappedFromRenderManager() = 0; |
49 virtual NavigationController* GetControllerForRenderManager() = 0; | 51 virtual NavigationController* GetControllerForRenderManager() = 0; |
50 | 52 |
| 53 // Creates a DOMUI object for the given URL if one applies. Ownership of the |
| 54 // returned pointer will be passed to the caller. If no DOMUI applies, |
| 55 // returns NULL. |
| 56 virtual DOMUI* CreateDOMUIForRenderManager(const GURL& url) = 0; |
| 57 |
51 // Returns the navigation entry of the current navigation, or NULL if there | 58 // Returns the navigation entry of the current navigation, or NULL if there |
52 // is none. | 59 // is none. |
53 virtual NavigationEntry* | 60 virtual NavigationEntry* |
54 GetLastCommittedNavigationEntryForRenderManager() = 0; | 61 GetLastCommittedNavigationEntryForRenderManager() = 0; |
55 }; | 62 }; |
56 | 63 |
57 // The factory is optional. It is used by unit tests to supply custom render | 64 // The factory is optional. It is used by unit tests to supply custom render |
58 // view hosts. When NULL, the regular RenderViewHost will be created. | 65 // view hosts. When NULL, the regular RenderViewHost will be created. |
59 // | 66 // |
60 // Both delegate pointers must be non-NULL and are not owned by this class. | 67 // Both delegate pointers must be non-NULL and are not owned by this class. |
(...skipping 26 matching lines...) Expand all Loading... |
87 } | 94 } |
88 | 95 |
89 // Returns the view associated with the current RenderViewHost, or NULL if | 96 // Returns the view associated with the current RenderViewHost, or NULL if |
90 // there is no current one. | 97 // there is no current one. |
91 RenderWidgetHostView* current_view() const { | 98 RenderWidgetHostView* current_view() const { |
92 if (!render_view_host_) | 99 if (!render_view_host_) |
93 return NULL; | 100 return NULL; |
94 return render_view_host_->view(); | 101 return render_view_host_->view(); |
95 } | 102 } |
96 | 103 |
| 104 // Returns the pending render view host, or NULL if there is no pending one. |
| 105 RenderViewHost* pending_render_view_host() const { |
| 106 return pending_render_view_host_; |
| 107 } |
| 108 |
| 109 // Returns the current committed DOM UI or NULL if none applies. |
| 110 DOMUI* dom_ui() const { return dom_ui_.get(); } |
| 111 |
| 112 // Returns the DOM UI for the pending navigation, or NULL of none applies. |
| 113 DOMUI* pending_dom_ui() const { return pending_dom_ui_.get(); } |
| 114 |
97 // Called when we want to instruct the renderer to navigate to the given | 115 // Called when we want to instruct the renderer to navigate to the given |
98 // navigation entry. It may create a new RenderViewHost or re-use an existing | 116 // navigation entry. It may create a new RenderViewHost or re-use an existing |
99 // one. The RenderViewHost to navigate will be returned. Returns NULL if one | 117 // one. The RenderViewHost to navigate will be returned. Returns NULL if one |
100 // could not be created. | 118 // could not be created. |
101 RenderViewHost* Navigate(const NavigationEntry& entry); | 119 RenderViewHost* Navigate(const NavigationEntry& entry); |
102 | 120 |
103 // Instructs the various live views to stop. Called when the user directed the | 121 // Instructs the various live views to stop. Called when the user directed the |
104 // page to stop loading. | 122 // page to stop loading. |
105 void Stop(); | 123 void Stop(); |
106 | 124 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // Helper method to create a pending RenderViewHost for a cross-site | 206 // Helper method to create a pending RenderViewHost for a cross-site |
189 // navigation. | 207 // navigation. |
190 bool CreatePendingRenderView(SiteInstance* instance); | 208 bool CreatePendingRenderView(SiteInstance* instance); |
191 | 209 |
192 // Creates a RenderViewHost using render_view_factory_ (or directly, if the | 210 // Creates a RenderViewHost using render_view_factory_ (or directly, if the |
193 // factory is NULL). | 211 // factory is NULL). |
194 RenderViewHost* CreateRenderViewHost(SiteInstance* instance, | 212 RenderViewHost* CreateRenderViewHost(SiteInstance* instance, |
195 int routing_id, | 213 int routing_id, |
196 base::WaitableEvent* modal_dialog_event); | 214 base::WaitableEvent* modal_dialog_event); |
197 | 215 |
198 // Replaces the currently shown render_view_host_ with the RenderViewHost in | 216 // Sets the pending RenderViewHost/DOMUI to be the active one. Note that this |
199 // the field pointed to by |new_render_view_host|, and then NULLs the field. | 217 // doesn't require the pending render_view_host_ pointer to be non-NULL, since |
200 // Callers should only pass pointers to the pending_render_view_host_, | 218 // there could be DOM UI switching as well. Call this for every commit. |
201 // interstitial_render_view_host_, or original_render_view_host_ fields of | 219 void CommitPending(); |
202 // this object. If |destroy_after|, this method will call | |
203 // ScheduleDeferredDestroy on the previous render_view_host_. | |
204 void SwapToRenderView(RenderViewHost** new_render_view_host, | |
205 bool destroy_after); | |
206 | 220 |
207 // Helper method to terminate the pending RenderViewHost. | 221 // Helper method to terminate the pending RenderViewHost. |
208 void CancelPendingRenderView(); | 222 void CancelPending(); |
209 | 223 |
210 RenderViewHost* UpdateRendererStateNavigate(const NavigationEntry& entry); | 224 RenderViewHost* UpdateRendererStateForNavigate(const NavigationEntry& entry); |
211 | 225 |
212 // Our delegate, not owned by us. Guaranteed non-NULL. | 226 // Our delegate, not owned by us. Guaranteed non-NULL. |
213 Delegate* delegate_; | 227 Delegate* delegate_; |
214 | 228 |
215 // Whether a navigation requiring different RenderView's is pending. This is | 229 // Whether a navigation requiring different RenderView's is pending. This is |
216 // either cross-site request is (in the new process model), or when required | 230 // either cross-site request is (in the new process model), or when required |
217 // for the view type (like view source versus not). | 231 // for the view type (like view source versus not). |
218 bool cross_navigation_pending_; | 232 bool cross_navigation_pending_; |
219 | 233 |
220 // Allows tests to create their own render view host types. | 234 // Allows tests to create their own render view host types. |
221 RenderViewHostFactory* render_view_factory_; | 235 RenderViewHostFactory* render_view_factory_; |
222 | 236 |
223 // Implemented by the owner of this class, this delegate is installed into all | 237 // Implemented by the owner of this class, this delegate is installed into all |
224 // the RenderViewHosts that we create. | 238 // the RenderViewHosts that we create. |
225 RenderViewHostDelegate* render_view_delegate_; | 239 RenderViewHostDelegate* render_view_delegate_; |
226 | 240 |
227 // Our RenderView host. This object is responsible for all communication with | 241 // Our RenderView host and its associated DOM UI (if any, will be NULL for |
| 242 // non-DOM-UI pages). This object is responsible for all communication with |
228 // a child RenderView instance. | 243 // a child RenderView instance. |
229 RenderViewHost* render_view_host_; | 244 RenderViewHost* render_view_host_; |
| 245 scoped_ptr<DOMUI> dom_ui_; |
230 | 246 |
231 // A RenderViewHost used to load a cross-site page. This remains hidden | 247 // A RenderViewHost used to load a cross-site page. This remains hidden |
232 // while a cross-site request is pending until it calls DidNavigate. | 248 // while a cross-site request is pending until it calls DidNavigate. It may |
| 249 // have an associated DOM UI, in which case the DOM UI pointer will be non- |
| 250 // NULL. |
| 251 // |
| 252 // The pending_dom_ui may be non-NULL even when the pending_render_view_host_ |
| 253 // is. This will happen when we're transitioning between two DOM UI pages: |
| 254 // the RVH won't be swapped, so the pending pointer will be unused, but there |
| 255 // will be a pending DOM UI associated with the navigation. |
233 RenderViewHost* pending_render_view_host_; | 256 RenderViewHost* pending_render_view_host_; |
| 257 scoped_ptr<DOMUI> pending_dom_ui_; |
234 | 258 |
235 // The intersitial page currently shown if any, not own by this class | 259 // The intersitial page currently shown if any, not own by this class |
236 // (the InterstitialPage is self-owned, it deletes itself when hidden). | 260 // (the InterstitialPage is self-owned, it deletes itself when hidden). |
237 InterstitialPage* interstitial_page_; | 261 InterstitialPage* interstitial_page_; |
238 | 262 |
239 NotificationRegistrar registrar_; | 263 NotificationRegistrar registrar_; |
240 | 264 |
241 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); | 265 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); |
242 }; | 266 }; |
243 | 267 |
244 // The "details" for a NOTIFY_RENDER_VIEW_HOST_CHANGED notification. The old | 268 // The "details" for a NOTIFY_RENDER_VIEW_HOST_CHANGED notification. The old |
245 // host can be NULL when the first RenderViewHost is set. | 269 // host can be NULL when the first RenderViewHost is set. |
246 struct RenderViewHostSwitchedDetails { | 270 struct RenderViewHostSwitchedDetails { |
247 RenderViewHost* old_host; | 271 RenderViewHost* old_host; |
248 RenderViewHost* new_host; | 272 RenderViewHost* new_host; |
249 }; | 273 }; |
250 | 274 |
251 #endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 275 #endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
OLD | NEW |