OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
6 #define CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" |
12 #include "content/browser/site_instance_impl.h" | 13 #include "content/browser/site_instance_impl.h" |
13 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
14 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
15 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
16 #include "content/public/browser/render_view_host_delegate.h" | 17 #include "content/public/browser/render_view_host_delegate.h" |
17 | 18 |
18 class InterstitialPageImpl; | 19 class InterstitialPageImpl; |
19 class NavigationControllerImpl; | 20 class NavigationControllerImpl; |
20 class WebUIImpl; | 21 class WebUIImpl; |
21 | 22 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // there is no current one. | 118 // there is no current one. |
118 content::RenderWidgetHostView* GetRenderWidgetHostView() const; | 119 content::RenderWidgetHostView* GetRenderWidgetHostView() const; |
119 | 120 |
120 // Returns the pending render view host, or NULL if there is no pending one. | 121 // Returns the pending render view host, or NULL if there is no pending one. |
121 content::RenderViewHostImpl* pending_render_view_host() const; | 122 content::RenderViewHostImpl* pending_render_view_host() const; |
122 | 123 |
123 // Returns the current committed Web UI or NULL if none applies. | 124 // Returns the current committed Web UI or NULL if none applies. |
124 WebUIImpl* web_ui() const { return web_ui_.get(); } | 125 WebUIImpl* web_ui() const { return web_ui_.get(); } |
125 | 126 |
126 // Returns the Web UI for the pending navigation, or NULL of none applies. | 127 // Returns the Web UI for the pending navigation, or NULL of none applies. |
127 WebUIImpl* pending_web_ui() const { return pending_web_ui_.get(); } | 128 WebUIImpl* pending_web_ui() const { |
| 129 return pending_web_ui_.get() ? pending_web_ui_.get() : |
| 130 pending_and_current_web_ui_.get(); |
| 131 } |
128 | 132 |
129 // Called when we want to instruct the renderer to navigate to the given | 133 // Called when we want to instruct the renderer to navigate to the given |
130 // navigation entry. It may create a new RenderViewHost or re-use an existing | 134 // navigation entry. It may create a new RenderViewHost or re-use an existing |
131 // one. The RenderViewHost to navigate will be returned. Returns NULL if one | 135 // one. The RenderViewHost to navigate will be returned. Returns NULL if one |
132 // could not be created. | 136 // could not be created. |
133 content::RenderViewHostImpl* Navigate( | 137 content::RenderViewHostImpl* Navigate( |
134 const content::NavigationEntryImpl& entry); | 138 const content::NavigationEntryImpl& entry); |
135 | 139 |
136 // Instructs the various live views to stop. Called when the user directed the | 140 // Instructs the various live views to stop. Called when the user directed the |
137 // page to stop loading. | 141 // page to stop loading. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // switch. Can be overridden in unit tests. | 213 // switch. Can be overridden in unit tests. |
210 bool ShouldTransitionCrossSite(); | 214 bool ShouldTransitionCrossSite(); |
211 | 215 |
212 // Returns true if the two navigation entries are incompatible in some way | 216 // Returns true if the two navigation entries are incompatible in some way |
213 // other than site instances. Cases where this can happen include Web UI | 217 // other than site instances. Cases where this can happen include Web UI |
214 // to regular web pages. It will cause us to swap RenderViewHosts (and hence | 218 // to regular web pages. It will cause us to swap RenderViewHosts (and hence |
215 // RenderProcessHosts) even if the site instance would otherwise be the same. | 219 // RenderProcessHosts) even if the site instance would otherwise be the same. |
216 // As part of this, we'll also force new SiteInstances and BrowsingInstances. | 220 // As part of this, we'll also force new SiteInstances and BrowsingInstances. |
217 // Either of the entries may be NULL. | 221 // Either of the entries may be NULL. |
218 bool ShouldSwapProcessesForNavigation( | 222 bool ShouldSwapProcessesForNavigation( |
219 const content::NavigationEntry* cur_entry, | 223 const content::NavigationEntry* curr_entry, |
| 224 const content::NavigationEntryImpl* new_entry) const; |
| 225 |
| 226 bool ShouldReuseWebUI( |
| 227 const content::NavigationEntry* curr_entry, |
220 const content::NavigationEntryImpl* new_entry) const; | 228 const content::NavigationEntryImpl* new_entry) const; |
221 | 229 |
222 // Returns an appropriate SiteInstance object for the given NavigationEntry, | 230 // Returns an appropriate SiteInstance object for the given NavigationEntry, |
223 // possibly reusing the current SiteInstance. | 231 // possibly reusing the current SiteInstance. |
224 // Never called if --process-per-tab is used. | 232 // Never called if --process-per-tab is used. |
225 content::SiteInstance* GetSiteInstanceForEntry( | 233 content::SiteInstance* GetSiteInstanceForEntry( |
226 const content::NavigationEntryImpl& entry, | 234 const content::NavigationEntryImpl& entry, |
227 content::SiteInstance* curr_instance); | 235 content::SiteInstance* curr_instance); |
228 | 236 |
229 // Helper method to create a pending RenderViewHost for a cross-site | 237 // Helper method to create a pending RenderViewHost for a cross-site |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // non-DOM-UI pages). This object is responsible for all communication with | 275 // non-DOM-UI pages). This object is responsible for all communication with |
268 // a child RenderView instance. | 276 // a child RenderView instance. |
269 content::RenderViewHostImpl* render_view_host_; | 277 content::RenderViewHostImpl* render_view_host_; |
270 scoped_ptr<WebUIImpl> web_ui_; | 278 scoped_ptr<WebUIImpl> web_ui_; |
271 | 279 |
272 // A RenderViewHost used to load a cross-site page. This remains hidden | 280 // A RenderViewHost used to load a cross-site page. This remains hidden |
273 // while a cross-site request is pending until it calls DidNavigate. It may | 281 // while a cross-site request is pending until it calls DidNavigate. It may |
274 // have an associated Web UI, in which case the Web UI pointer will be non- | 282 // have an associated Web UI, in which case the Web UI pointer will be non- |
275 // NULL. | 283 // NULL. |
276 // | 284 // |
277 // The pending_web_ui may be non-NULL even when the pending_render_view_host_ | 285 // The |pending_web_ui_| may be non-NULL even when the |
278 // is. This will happen when we're transitioning between two Web UI pages: | 286 // |pending_render_view_host_| is NULL. This will happen when we're |
279 // the RVH won't be swapped, so the pending pointer will be unused, but there | 287 // transitioning between two Web UI pages: the RVH won't be swapped, so the |
280 // will be a pending Web UI associated with the navigation. | 288 // pending pointer will be unused, but there will be a pending Web UI |
| 289 // associated with the navigation. |
281 content::RenderViewHostImpl* pending_render_view_host_; | 290 content::RenderViewHostImpl* pending_render_view_host_; |
| 291 |
| 292 // If either of these is non-NULL, the pending navigation is to a chrome: |
| 293 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is |
| 294 // used for when they reference the same object. If either is non-NULL, the |
| 295 // other should be NULL. |
282 scoped_ptr<WebUIImpl> pending_web_ui_; | 296 scoped_ptr<WebUIImpl> pending_web_ui_; |
| 297 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_; |
283 | 298 |
284 // A map of site instance ID to swapped out RenderViewHosts. | 299 // A map of site instance ID to swapped out RenderViewHosts. |
285 typedef base::hash_map<int32, content::RenderViewHostImpl*> RenderViewHostMap; | 300 typedef base::hash_map<int32, content::RenderViewHostImpl*> RenderViewHostMap; |
286 RenderViewHostMap swapped_out_hosts_; | 301 RenderViewHostMap swapped_out_hosts_; |
287 | 302 |
288 // The intersitial page currently shown if any, not own by this class | 303 // The intersitial page currently shown if any, not own by this class |
289 // (the InterstitialPage is self-owned, it deletes itself when hidden). | 304 // (the InterstitialPage is self-owned, it deletes itself when hidden). |
290 InterstitialPageImpl* interstitial_page_; | 305 InterstitialPageImpl* interstitial_page_; |
291 | 306 |
292 content::NotificationRegistrar registrar_; | 307 content::NotificationRegistrar registrar_; |
293 | 308 |
294 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); | 309 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); |
295 }; | 310 }; |
296 | 311 |
297 #endif // CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 312 #endif // CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
OLD | NEW |