| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "content/browser/renderer_host/render_view_host_delegate.h" | 12 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 13 #include "content/browser/site_instance_impl.h" | 13 #include "content/browser/site_instance_impl.h" |
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 #include "content/public/browser/global_request_id.h" | 15 #include "content/public/browser/global_request_id.h" |
| 16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 18 #include "content/public/common/referrer.h" | 18 #include "content/public/common/referrer.h" |
| 19 #include "ui/base/page_transition_types.h" | 19 #include "ui/base/page_transition_types.h" |
| 20 | 20 |
| 21 struct FrameHostMsg_BeginNavigation_Params; | |
| 22 struct FrameMsg_Navigate_Params; | 21 struct FrameMsg_Navigate_Params; |
| 23 | 22 |
| 24 namespace content { | 23 namespace content { |
| 25 class BrowserContext; | 24 class BrowserContext; |
| 26 class CrossProcessFrameConnector; | 25 class CrossProcessFrameConnector; |
| 27 class CrossSiteTransferringRequest; | 26 class CrossSiteTransferringRequest; |
| 28 class InterstitialPageImpl; | 27 class InterstitialPageImpl; |
| 29 class FrameTreeNode; | 28 class FrameTreeNode; |
| 30 class NavigationControllerImpl; | 29 class NavigationControllerImpl; |
| 31 class NavigationEntry; | 30 class NavigationEntry; |
| 32 class NavigationEntryImpl; | 31 class NavigationEntryImpl; |
| 33 class NavigationRequest; | |
| 34 class RenderFrameHost; | 32 class RenderFrameHost; |
| 35 class RenderFrameHostDelegate; | 33 class RenderFrameHostDelegate; |
| 36 class RenderFrameHost; | 34 class RenderFrameHost; |
| 37 class RenderFrameHostImpl; | 35 class RenderFrameHostImpl; |
| 38 class RenderFrameHostManagerTest; | 36 class RenderFrameHostManagerTest; |
| 39 class RenderFrameProxyHost; | 37 class RenderFrameProxyHost; |
| 40 class RenderViewHost; | 38 class RenderViewHost; |
| 41 class RenderViewHostImpl; | 39 class RenderViewHostImpl; |
| 42 class RenderWidgetHostDelegate; | 40 class RenderWidgetHostDelegate; |
| 43 class RenderWidgetHostView; | 41 class RenderWidgetHostView; |
| 44 class TestWebContents; | 42 class TestWebContents; |
| 45 class WebUIImpl; | 43 class WebUIImpl; |
| 46 struct CommonNavigationParams; | |
| 47 struct NavigationBeforeCommitInfo; | |
| 48 struct RequestNavigationParams; | |
| 49 | 44 |
| 50 // Manages RenderFrameHosts for a FrameTreeNode. This class acts as a state | 45 // Manages RenderFrameHosts for a FrameTreeNode. This class acts as a state |
| 51 // machine to make cross-process navigations in a frame possible. | 46 // machine to make cross-process navigations in a frame possible. |
| 52 class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { | 47 class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { |
| 53 public: | 48 public: |
| 54 // Functions implemented by our owner that we need. | 49 // Functions implemented by our owner that we need. |
| 55 // | 50 // |
| 56 // TODO(brettw) Clean this up! These are all the functions in WebContentsImpl | 51 // TODO(brettw) Clean this up! These are all the functions in WebContentsImpl |
| 57 // that are required to run this class. The design should probably be better | 52 // that are required to run this class. The design should probably be better |
| 58 // such that these are more clear. | 53 // such that these are more clear. |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 304 |
| 310 // Deletes any proxy hosts associated with this node. Used during destruction | 305 // Deletes any proxy hosts associated with this node. Used during destruction |
| 311 // of WebContentsImpl. | 306 // of WebContentsImpl. |
| 312 void ResetProxyHosts(); | 307 void ResetProxyHosts(); |
| 313 | 308 |
| 314 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy | 309 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy |
| 315 // that has the given SiteInstance and is associated with this | 310 // that has the given SiteInstance and is associated with this |
| 316 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. | 311 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. |
| 317 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); | 312 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); |
| 318 | 313 |
| 319 // PlzNavigate: sends a RequestNavigation IPC to the renderer to ask it to | 314 // PlzNavigate: Called when a navigation is ready to commit, to select the |
| 320 // navigate. If no live renderer is present, then the navigation request will | 315 // renderer that will commit it. |
| 321 // be sent directly to the ResourceDispatcherHost. Takes ownership of | 316 RenderFrameHostImpl* GetFrameHostForNavigation(const GURL& url, |
| 322 // |navigation_request|. | 317 ui::PageTransition transition); |
| 323 bool RequestNavigation(scoped_ptr<NavigationRequest> navigation_request, | |
| 324 const RequestNavigationParams& request_params); | |
| 325 | |
| 326 // PlzNavigate: Used to start a navigation. OnBeginNavigation is called | |
| 327 // directly by RequestNavigation when there is no live renderer. Otherwise, it | |
| 328 // is called following a BeginNavigation IPC from the renderer (which in | |
| 329 // browser-initiated navigation also happens after RequestNavigation has been | |
| 330 // called). | |
| 331 void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params, | |
| 332 const CommonNavigationParams& common_params); | |
| 333 | |
| 334 // PlzNavigate: Called when a navigation request has received a response, to | |
| 335 // select a renderer to use for the navigation. | |
| 336 void CommitNavigation(const NavigationBeforeCommitInfo& info); | |
| 337 | 318 |
| 338 private: | 319 private: |
| 339 friend class RenderFrameHostManagerTest; | 320 friend class RenderFrameHostManagerTest; |
| 340 friend class TestWebContents; | 321 friend class TestWebContents; |
| 341 | 322 |
| 342 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, | 323 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, |
| 343 CreateCrossProcessSubframeProxies); | 324 CreateCrossProcessSubframeProxies); |
| 344 | 325 |
| 345 // Returns the current navigation request (used in the PlzNavigate navigation | |
| 346 // logic refactoring project). | |
| 347 NavigationRequest* navigation_request_for_testing() const { | |
| 348 return navigation_request_.get(); } | |
| 349 | |
| 350 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a | 326 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a |
| 351 // FrameTreeNode's RenderFrameHostManager. | 327 // FrameTreeNode's RenderFrameHostManager. |
| 352 static bool ClearProxiesInSiteInstance(int32 site_instance_id, | 328 static bool ClearProxiesInSiteInstance(int32 site_instance_id, |
| 353 FrameTreeNode* node); | 329 FrameTreeNode* node); |
| 354 | 330 |
| 355 // Returns whether this tab should transition to a new renderer for | 331 // Returns whether this tab should transition to a new renderer for |
| 356 // cross-site URLs. Enabled unless we see the --process-per-tab command line | 332 // cross-site URLs. Enabled unless we see the --process-per-tab command line |
| 357 // switch. Can be overridden in unit tests. | 333 // switch. Can be overridden in unit tests. |
| 358 bool ShouldTransitionCrossSite(); | 334 bool ShouldTransitionCrossSite(); |
| 359 | 335 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 typedef base::hash_map<int32, linked_ptr<RenderFrameHostImpl> > | 505 typedef base::hash_map<int32, linked_ptr<RenderFrameHostImpl> > |
| 530 RFHPendingDeleteMap; | 506 RFHPendingDeleteMap; |
| 531 RFHPendingDeleteMap pending_delete_hosts_; | 507 RFHPendingDeleteMap pending_delete_hosts_; |
| 532 | 508 |
| 533 // The intersitial page currently shown if any, not own by this class | 509 // The intersitial page currently shown if any, not own by this class |
| 534 // (the InterstitialPage is self-owned, it deletes itself when hidden). | 510 // (the InterstitialPage is self-owned, it deletes itself when hidden). |
| 535 InterstitialPageImpl* interstitial_page_; | 511 InterstitialPageImpl* interstitial_page_; |
| 536 | 512 |
| 537 NotificationRegistrar registrar_; | 513 NotificationRegistrar registrar_; |
| 538 | 514 |
| 539 // PlzNavigate: Owns a navigation request that originated in that frame until | |
| 540 // it commits. | |
| 541 scoped_ptr<NavigationRequest> navigation_request_; | |
| 542 | |
| 543 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; | 515 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; |
| 544 | 516 |
| 545 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); | 517 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); |
| 546 }; | 518 }; |
| 547 | 519 |
| 548 } // namespace content | 520 } // namespace content |
| 549 | 521 |
| 550 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 522 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
| OLD | NEW |