OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "content/browser/renderer_host/render_view_host_delegate.h" | 14 #include "content/browser/renderer_host/render_view_host_delegate.h" |
15 #include "content/browser/site_instance_impl.h" | 15 #include "content/browser/site_instance_impl.h" |
16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
17 #include "content/public/browser/global_request_id.h" | 17 #include "content/public/browser/global_request_id.h" |
18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
20 #include "content/public/common/referrer.h" | 20 #include "content/public/common/referrer.h" |
21 #include "ui/base/page_transition_types.h" | 21 #include "ui/base/page_transition_types.h" |
22 | 22 |
23 struct FrameMsg_Navigate_Params; | 23 struct FrameMsg_Navigate_Params; |
24 | 24 |
25 namespace content { | 25 namespace content { |
26 class BrowserContext; | 26 class BrowserContext; |
27 class CrossProcessFrameConnector; | 27 class CrossProcessFrameConnector; |
28 class CrossSiteTransferringRequest; | 28 class CrossSiteTransferringRequest; |
| 29 class FrameTreeNode; |
29 class InterstitialPageImpl; | 30 class InterstitialPageImpl; |
30 class FrameTreeNode; | |
31 class NavigationControllerImpl; | 31 class NavigationControllerImpl; |
32 class NavigationEntry; | 32 class NavigationEntry; |
33 class NavigationEntryImpl; | 33 class NavigationEntryImpl; |
34 class RenderFrameHost; | 34 class RenderFrameHost; |
35 class RenderFrameHostDelegate; | 35 class RenderFrameHostDelegate; |
36 class RenderFrameHost; | |
37 class RenderFrameHostImpl; | 36 class RenderFrameHostImpl; |
38 class RenderFrameHostManagerTest; | 37 class RenderFrameHostManagerTest; |
39 class RenderFrameProxyHost; | 38 class RenderFrameProxyHost; |
40 class RenderViewHost; | 39 class RenderViewHost; |
41 class RenderViewHostImpl; | 40 class RenderViewHostImpl; |
42 class RenderWidgetHostDelegate; | 41 class RenderWidgetHostDelegate; |
43 class RenderWidgetHostView; | 42 class RenderWidgetHostView; |
44 class TestWebContents; | 43 class TestWebContents; |
45 class WebUIImpl; | 44 class WebUIImpl; |
46 | 45 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // Create swapped out RenderViews in the given SiteInstance for each tab in | 140 // Create swapped out RenderViews in the given SiteInstance for each tab in |
142 // the opener chain of this tab, if any. This allows the current tab to | 141 // the opener chain of this tab, if any. This allows the current tab to |
143 // make cross-process script calls to its opener(s). Returns the route ID | 142 // make cross-process script calls to its opener(s). Returns the route ID |
144 // of the immediate opener, if one exists (otherwise MSG_ROUTING_NONE). | 143 // of the immediate opener, if one exists (otherwise MSG_ROUTING_NONE). |
145 virtual int CreateOpenerRenderViewsForRenderManager( | 144 virtual int CreateOpenerRenderViewsForRenderManager( |
146 SiteInstance* instance) = 0; | 145 SiteInstance* instance) = 0; |
147 | 146 |
148 // Creates a WebUI object for the given URL if one applies. Ownership of the | 147 // Creates a WebUI object for the given URL if one applies. Ownership of the |
149 // returned pointer will be passed to the caller. If no WebUI applies, | 148 // returned pointer will be passed to the caller. If no WebUI applies, |
150 // returns NULL. | 149 // returns NULL. |
151 virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) = 0; | 150 virtual scoped_ptr<WebUIImpl> CreateWebUIForRenderManager( |
| 151 const GURL& url) = 0; |
152 | 152 |
153 // Returns the navigation entry of the current navigation, or NULL if there | 153 // Returns the navigation entry of the current navigation, or NULL if there |
154 // is none. | 154 // is none. |
155 virtual NavigationEntry* | 155 virtual NavigationEntry* |
156 GetLastCommittedNavigationEntryForRenderManager() = 0; | 156 GetLastCommittedNavigationEntryForRenderManager() = 0; |
157 | 157 |
158 // Returns true if the location bar should be focused by default rather than | 158 // Returns true if the location bar should be focused by default rather than |
159 // the page contents. The view calls this function when the tab is focused | 159 // the page contents. The view calls this function when the tab is focused |
160 // to see what it should do. | 160 // to see what it should do. |
161 virtual bool FocusLocationBarByDefault() = 0; | 161 virtual bool FocusLocationBarByDefault() = 0; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 224 |
225 // Returns the current committed Web UI or NULL if none applies. | 225 // Returns the current committed Web UI or NULL if none applies. |
226 WebUIImpl* web_ui() const { return web_ui_.get(); } | 226 WebUIImpl* web_ui() const { return web_ui_.get(); } |
227 | 227 |
228 // Returns the Web UI for the pending navigation, or NULL of none applies. | 228 // Returns the Web UI for the pending navigation, or NULL of none applies. |
229 WebUIImpl* pending_web_ui() const { | 229 WebUIImpl* pending_web_ui() const { |
230 return pending_web_ui_.get() ? pending_web_ui_.get() : | 230 return pending_web_ui_.get() ? pending_web_ui_.get() : |
231 pending_and_current_web_ui_.get(); | 231 pending_and_current_web_ui_.get(); |
232 } | 232 } |
233 | 233 |
234 // Sets the pending Web UI for the pending navigation, ensuring that the | |
235 // bindings are appropriate compared to |bindings|. | |
236 void SetPendingWebUI(const GURL& url, int bindings); | |
237 | |
238 // Called when we want to instruct the renderer to navigate to the given | 234 // Called when we want to instruct the renderer to navigate to the given |
239 // navigation entry. It may create a new RenderFrameHost or re-use an existing | 235 // navigation entry. It may create a new RenderFrameHost or re-use an existing |
240 // one. The RenderFrameHost to navigate will be returned. Returns NULL if one | 236 // one. The RenderFrameHost to navigate will be returned. Returns NULL if one |
241 // could not be created. | 237 // could not be created. |
242 RenderFrameHostImpl* Navigate(const NavigationEntryImpl& entry); | 238 RenderFrameHostImpl* Navigate(const NavigationEntryImpl& entry); |
243 | 239 |
244 // Instructs the various live views to stop. Called when the user directed the | 240 // Instructs the various live views to stop. Called when the user directed the |
245 // page to stop loading. | 241 // page to stop loading. |
246 void Stop(); | 242 void Stop(); |
247 | 243 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 286 |
291 // Clear navigation transition data. | 287 // Clear navigation transition data. |
292 void ClearNavigationTransitionData(); | 288 void ClearNavigationTransitionData(); |
293 | 289 |
294 // Called when a renderer's frame navigates. | 290 // Called when a renderer's frame navigates. |
295 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host); | 291 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host); |
296 | 292 |
297 // Called when a renderer sets its opener to null. | 293 // Called when a renderer sets its opener to null. |
298 void DidDisownOpener(RenderFrameHost* render_frame_host); | 294 void DidDisownOpener(RenderFrameHost* render_frame_host); |
299 | 295 |
300 // Helper method to create and initialize a RenderFrameHost. If |flags| | 296 // Sets the pending Web UI for the pending navigation, ensuring that the |
301 // has the CREATE_RF_SWAPPED_OUT bit set from the CreateRenderFrameFlags | 297 // bindings are appropriate compared to |bindings|. |
302 // enum, it will initially be placed on the swapped out hosts list. | 298 void SetPendingWebUI(const GURL& url, int bindings); |
303 // Returns the routing id of the *view* associated with the frame. | 299 |
304 int CreateRenderFrame(SiteInstance* instance, int opener_route_id, int flags); | 300 // Creates and initializes a RenderFrameHost. The |web_ui| is an optional |
| 301 // input parameter used to double check bindings when swapping back in a |
| 302 // previously existing RenderFrameHost. If |flags| has the |
| 303 // CREATE_RF_SWAPPED_OUT bit set from the CreateRenderFrameFlags enum, it will |
| 304 // initially be placed on the swapped out hosts list. If |view_routing_id_ptr| |
| 305 // is not nullptr it will be set to the routing id of the view associated with |
| 306 // the frame. |
| 307 scoped_ptr<RenderFrameHostImpl> CreateRenderFrame(SiteInstance* instance, |
| 308 WebUIImpl* web_ui, |
| 309 int opener_route_id, |
| 310 int flags, |
| 311 int* view_routing_id_ptr); |
305 | 312 |
306 // Helper method to create and initialize a RenderFrameProxyHost and return | 313 // Helper method to create and initialize a RenderFrameProxyHost and return |
307 // its routing id. | 314 // its routing id. |
308 int CreateRenderFrameProxy(SiteInstance* instance); | 315 int CreateRenderFrameProxy(SiteInstance* instance); |
309 | 316 |
310 // Sets the passed passed interstitial as the currently showing interstitial. | 317 // Sets the passed passed interstitial as the currently showing interstitial. |
311 // |interstitial_page| should be non NULL (use the remove_interstitial_page | 318 // |interstitial_page| should be non NULL (use the remove_interstitial_page |
312 // method to unset the interstitial) and no interstitial page should be set | 319 // method to unset the interstitial) and no interstitial page should be set |
313 // when there is already a non NULL interstitial page set. | 320 // when there is already a non NULL interstitial page set. |
314 void set_interstitial_page(InterstitialPageImpl* interstitial_page) { | 321 void set_interstitial_page(InterstitialPageImpl* interstitial_page) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 // SiteInstance's site and when we later call IsSameWebSite. If there is no | 401 // SiteInstance's site and when we later call IsSameWebSite. If there is no |
395 // current NavigationEntry, check the current SiteInstance's site, which might | 402 // current NavigationEntry, check the current SiteInstance's site, which might |
396 // already be committed to a Web UI URL (such as the NTP). | 403 // already be committed to a Web UI URL (such as the NTP). |
397 bool ShouldSwapBrowsingInstancesForNavigation( | 404 bool ShouldSwapBrowsingInstancesForNavigation( |
398 const GURL& current_effective_url, | 405 const GURL& current_effective_url, |
399 bool current_is_view_source_mode, | 406 bool current_is_view_source_mode, |
400 SiteInstance* new_site_instance, | 407 SiteInstance* new_site_instance, |
401 const GURL& new_effective_url, | 408 const GURL& new_effective_url, |
402 bool new_is_view_source_mode) const; | 409 bool new_is_view_source_mode) const; |
403 | 410 |
| 411 // Creates a new Web UI, ensuring that the bindings are appropriate compared |
| 412 // to |bindings|. |
| 413 scoped_ptr<WebUIImpl> CreateWebUI(const GURL& url, int bindings); |
| 414 |
404 // Returns true if it is safe to reuse the current WebUI when navigating from | 415 // Returns true if it is safe to reuse the current WebUI when navigating from |
405 // |current_entry| to |new_url|. | 416 // |current_entry| to |new_url|. |
406 bool ShouldReuseWebUI( | 417 bool ShouldReuseWebUI( |
407 const NavigationEntry* current_entry, | 418 const NavigationEntry* current_entry, |
408 const GURL& new_url) const; | 419 const GURL& new_url) const; |
409 | 420 |
410 // Returns the SiteInstance to use for the navigation. | 421 // Returns the SiteInstance to use for the navigation. |
411 SiteInstance* GetSiteInstanceForNavigation( | 422 SiteInstance* GetSiteInstanceForNavigation( |
412 const GURL& dest_url, | 423 const GURL& dest_url, |
413 SiteInstance* dest_instance, | 424 SiteInstance* dest_instance, |
(...skipping 14 matching lines...) Expand all Loading... |
428 bool dest_is_view_source_mode, | 439 bool dest_is_view_source_mode, |
429 SiteInstance* current_instance, | 440 SiteInstance* current_instance, |
430 bool force_browsing_instance_swap); | 441 bool force_browsing_instance_swap); |
431 | 442 |
432 // Determines the appropriate url to use as the current url for SiteInstance | 443 // Determines the appropriate url to use as the current url for SiteInstance |
433 // selection. | 444 // selection. |
434 const GURL& GetCurrentURLForSiteInstance( | 445 const GURL& GetCurrentURLForSiteInstance( |
435 SiteInstance* current_instance, | 446 SiteInstance* current_instance, |
436 NavigationEntry* current_entry); | 447 NavigationEntry* current_entry); |
437 | 448 |
438 // Creates a new RenderFrameHostImpl for the |new_instance| while respecting | 449 // Creates a new RenderFrameHostImpl for the |new_instance| and assign it to |
439 // the opener route if needed and stores it in pending_render_frame_host_. | 450 // |pending_render_frame_host_| while respecting the opener route if needed |
440 void CreateRenderFrameHostForNewSiteInstance( | 451 // and stores it in pending_render_frame_host_. |
441 SiteInstance* old_instance, | 452 void CreatePendingRenderFrameHost(SiteInstance* old_instance, |
442 SiteInstance* new_instance, | 453 SiteInstance* new_instance, |
443 bool is_main_frame); | 454 bool is_main_frame); |
| 455 |
| 456 // Ensure that we have created RFHs for the new RFH's opener chain if |
| 457 // we are staying in the same BrowsingInstance. This allows the new RFH |
| 458 // to send cross-process script calls to its opener(s). Returns the opener |
| 459 // route ID to be used for the new RenderView to be created. |
| 460 int CreateOpenerRenderViewsIfNeeded(SiteInstance* old_instance, |
| 461 SiteInstance* new_instance); |
444 | 462 |
445 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. | 463 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. |
446 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, | 464 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, |
447 int view_routing_id, | 465 int view_routing_id, |
448 int frame_routing_id, | 466 int frame_routing_id, |
449 int flags); | 467 int flags); |
450 | 468 |
451 // Sets up the necessary state for a new RenderViewHost with the given opener, | 469 // Sets up the necessary state for a new RenderViewHost with the given opener, |
452 // if necessary. It creates a RenderFrameProxy in the target renderer process | 470 // if necessary. It creates a RenderFrameProxy in the target renderer process |
453 // with the given |proxy_routing_id|, which is used to route IPC messages when | 471 // with the given |proxy_routing_id|, which is used to route IPC messages when |
(...skipping 13 matching lines...) Expand all Loading... |
467 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this | 485 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this |
468 // doesn't require the pending render_frame_host_ pointer to be non-NULL, | 486 // doesn't require the pending render_frame_host_ pointer to be non-NULL, |
469 // since there could be Web UI switching as well. Call this for every commit. | 487 // since there could be Web UI switching as well. Call this for every commit. |
470 void CommitPending(); | 488 void CommitPending(); |
471 | 489 |
472 // Runs the unload handler in the old RenderFrameHost, after the new | 490 // Runs the unload handler in the old RenderFrameHost, after the new |
473 // RenderFrameHost has committed. |old_render_frame_host| will either be | 491 // RenderFrameHost has committed. |old_render_frame_host| will either be |
474 // deleted or put on the pending delete list during this call. | 492 // deleted or put on the pending delete list during this call. |
475 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host); | 493 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host); |
476 | 494 |
| 495 // Discards a RenderFrameHost that was never made active (for active ones |
| 496 // SwapOutOldFrame is used instead). |
| 497 void DiscardUnusedFrame(scoped_ptr<RenderFrameHostImpl> render_frame_host); |
| 498 |
477 // Holds |render_frame_host| until it can be deleted when its swap out ACK | 499 // Holds |render_frame_host| until it can be deleted when its swap out ACK |
478 // arrives. | 500 // arrives. |
479 void MoveToPendingDeleteHosts( | 501 void MoveToPendingDeleteHosts( |
480 scoped_ptr<RenderFrameHostImpl> render_frame_host); | 502 scoped_ptr<RenderFrameHostImpl> render_frame_host); |
481 | 503 |
482 // Shutdown all RenderFrameProxyHosts in a SiteInstance. This is called to | 504 // Shutdown all RenderFrameProxyHosts in a SiteInstance. This is called to |
483 // shutdown frames when all the frames in a SiteInstance are confirmed to be | 505 // shutdown frames when all the frames in a SiteInstance are confirmed to be |
484 // swapped out. | 506 // swapped out. |
485 void ShutdownRenderFrameProxyHostsInSiteInstance(int32 site_instance_id); | 507 void ShutdownRenderFrameProxyHostsInSiteInstance(int32 site_instance_id); |
486 | 508 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 NotificationRegistrar registrar_; | 601 NotificationRegistrar registrar_; |
580 | 602 |
581 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; | 603 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; |
582 | 604 |
583 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); | 605 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); |
584 }; | 606 }; |
585 | 607 |
586 } // namespace content | 608 } // namespace content |
587 | 609 |
588 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 610 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
OLD | NEW |