Chromium Code Reviews| 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 #include "content/browser/frame_host/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "content/browser/frame_host/frame_tree.h" | 8 #include "content/browser/frame_host/frame_tree.h" |
| 9 #include "content/browser/frame_host/frame_tree_node.h" | 9 #include "content/browser/frame_host/frame_tree_node.h" |
| 10 #include "content/browser/frame_host/navigation_controller_impl.h" | 10 #include "content/browser/frame_host/navigation_controller_impl.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 delegate_(delegate) { | 137 delegate_(delegate) { |
| 138 } | 138 } |
| 139 | 139 |
| 140 NavigationController* NavigatorImpl::GetController() { | 140 NavigationController* NavigatorImpl::GetController() { |
| 141 return controller_; | 141 return controller_; |
| 142 } | 142 } |
| 143 | 143 |
| 144 void NavigatorImpl::DidStartProvisionalLoad( | 144 void NavigatorImpl::DidStartProvisionalLoad( |
| 145 RenderFrameHostImpl* render_frame_host, | 145 RenderFrameHostImpl* render_frame_host, |
| 146 int parent_routing_id, | 146 int parent_routing_id, |
| 147 const GURL& url) { | 147 const GURL& url, |
| 148 bool is_transition_navigation) { | |
| 148 bool is_error_page = (url.spec() == kUnreachableWebDataURL); | 149 bool is_error_page = (url.spec() == kUnreachableWebDataURL); |
| 149 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); | 150 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); |
| 150 GURL validated_url(url); | 151 GURL validated_url(url); |
| 151 RenderProcessHost* render_process_host = render_frame_host->GetProcess(); | 152 RenderProcessHost* render_process_host = render_frame_host->GetProcess(); |
| 152 render_process_host->FilterURL(false, &validated_url); | 153 render_process_host->FilterURL(false, &validated_url); |
| 153 | 154 |
| 154 bool is_main_frame = render_frame_host->frame_tree_node()->IsMainFrame(); | 155 bool is_main_frame = render_frame_host->frame_tree_node()->IsMainFrame(); |
| 155 NavigationEntryImpl* pending_entry = | 156 NavigationEntryImpl* pending_entry = |
| 156 NavigationEntryImpl::FromNavigationEntry(controller_->GetPendingEntry()); | 157 NavigationEntryImpl::FromNavigationEntry(controller_->GetPendingEntry()); |
| 158 | |
| 159 is_transition_navigation |= (pending_entry && | |
| 160 pending_entry->is_transition_navigation()); | |
| 161 | |
| 157 if (is_main_frame) { | 162 if (is_main_frame) { |
| 158 // If there is no browser-initiated pending entry for this navigation and it | 163 // If there is no browser-initiated pending entry for this navigation and it |
| 159 // is not for the error URL, create a pending entry using the current | 164 // is not for the error URL, create a pending entry using the current |
| 160 // SiteInstance, and ensure the address bar updates accordingly. We don't | 165 // SiteInstance, and ensure the address bar updates accordingly. We don't |
| 161 // know the referrer or extra headers at this point, but the referrer will | 166 // know the referrer or extra headers at this point, but the referrer will |
| 162 // be set properly upon commit. | 167 // be set properly upon commit. |
| 163 bool has_browser_initiated_pending_entry = pending_entry && | 168 bool has_browser_initiated_pending_entry = pending_entry && |
| 164 !pending_entry->is_renderer_initiated(); | 169 !pending_entry->is_renderer_initiated(); |
| 165 if (!has_browser_initiated_pending_entry && !is_error_page) { | 170 if (!has_browser_initiated_pending_entry && !is_error_page) { |
| 166 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( | 171 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 178 if (pending_entry) { | 183 if (pending_entry) { |
| 179 entry->set_transferred_global_request_id( | 184 entry->set_transferred_global_request_id( |
| 180 pending_entry->transferred_global_request_id()); | 185 pending_entry->transferred_global_request_id()); |
| 181 entry->set_should_replace_entry(pending_entry->should_replace_entry()); | 186 entry->set_should_replace_entry(pending_entry->should_replace_entry()); |
| 182 entry->SetRedirectChain(pending_entry->GetRedirectChain()); | 187 entry->SetRedirectChain(pending_entry->GetRedirectChain()); |
| 183 } | 188 } |
| 184 controller_->SetPendingEntry(entry); | 189 controller_->SetPendingEntry(entry); |
| 185 if (delegate_) | 190 if (delegate_) |
| 186 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 191 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
| 187 } | 192 } |
| 193 | |
| 194 if (delegate_ && is_transition_navigation) | |
| 195 delegate_->DidStartNavigationTransition(render_frame_host); | |
|
nasko
2014/07/03 09:39:30
Why add a full new delegate method when you are pa
oystein (OOO til 10th of July)
2014/07/22 00:02:43
I could pass it along to WebContentsObserver::DidS
| |
| 188 } | 196 } |
| 189 | 197 |
| 190 if (delegate_) { | 198 if (delegate_) { |
| 191 // Notify the observer about the start of the provisional load. | 199 // Notify the observer about the start of the provisional load. |
| 192 delegate_->DidStartProvisionalLoad( | 200 delegate_->DidStartProvisionalLoad( |
| 193 render_frame_host, parent_routing_id, | 201 render_frame_host, parent_routing_id, |
| 194 validated_url, is_error_page, is_iframe_srcdoc); | 202 validated_url, is_error_page, is_iframe_srcdoc); |
| 195 } | 203 } |
| 196 } | 204 } |
| 197 | 205 |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 552 // should "use up" the SiteInstance. | 560 // should "use up" the SiteInstance. |
| 553 return GetContentClient()->browser()->ShouldAssignSiteForURL(url); | 561 return GetContentClient()->browser()->ShouldAssignSiteForURL(url); |
| 554 } | 562 } |
| 555 | 563 |
| 556 void NavigatorImpl::RequestOpenURL( | 564 void NavigatorImpl::RequestOpenURL( |
| 557 RenderFrameHostImpl* render_frame_host, | 565 RenderFrameHostImpl* render_frame_host, |
| 558 const GURL& url, | 566 const GURL& url, |
| 559 const Referrer& referrer, | 567 const Referrer& referrer, |
| 560 WindowOpenDisposition disposition, | 568 WindowOpenDisposition disposition, |
| 561 bool should_replace_current_entry, | 569 bool should_replace_current_entry, |
| 562 bool user_gesture) { | 570 bool user_gesture, |
| 571 bool is_transition_navigation) { | |
| 563 SiteInstance* current_site_instance = | 572 SiteInstance* current_site_instance = |
| 564 GetRenderManager(render_frame_host)->current_frame_host()-> | 573 GetRenderManager(render_frame_host)->current_frame_host()-> |
| 565 GetSiteInstance(); | 574 GetSiteInstance(); |
| 566 // If this came from a swapped out RenderViewHost, we only allow the request | 575 // If this came from a swapped out RenderViewHost, we only allow the request |
| 567 // if we are still in the same BrowsingInstance. | 576 // if we are still in the same BrowsingInstance. |
| 568 if (render_frame_host->render_view_host()->IsSwappedOut() && | 577 if (render_frame_host->render_view_host()->IsSwappedOut() && |
| 569 !render_frame_host->GetSiteInstance()->IsRelatedSiteInstance( | 578 !render_frame_host->GetSiteInstance()->IsRelatedSiteInstance( |
| 570 current_site_instance)) { | 579 current_site_instance)) { |
| 571 return; | 580 return; |
| 572 } | 581 } |
| 573 | 582 |
| 574 // Delegate to RequestTransferURL because this is just the generic | 583 // Delegate to RequestTransferURL because this is just the generic |
| 575 // case where |old_request_id| is empty. | 584 // case where |old_request_id| is empty. |
| 576 // TODO(creis): Pass the redirect_chain into this method to support client | 585 // TODO(creis): Pass the redirect_chain into this method to support client |
| 577 // redirects. http://crbug.com/311721. | 586 // redirects. http://crbug.com/311721. |
| 578 std::vector<GURL> redirect_chain; | 587 std::vector<GURL> redirect_chain; |
| 579 RequestTransferURL( | 588 RequestTransferURL( |
| 580 render_frame_host, url, redirect_chain, referrer, PAGE_TRANSITION_LINK, | 589 render_frame_host, url, redirect_chain, referrer, PAGE_TRANSITION_LINK, |
| 581 disposition, GlobalRequestID(), | 590 disposition, GlobalRequestID(), |
| 582 should_replace_current_entry, user_gesture); | 591 should_replace_current_entry, user_gesture, is_transition_navigation); |
| 583 } | 592 } |
| 584 | 593 |
| 585 void NavigatorImpl::RequestTransferURL( | 594 void NavigatorImpl::RequestTransferURL( |
| 586 RenderFrameHostImpl* render_frame_host, | 595 RenderFrameHostImpl* render_frame_host, |
| 587 const GURL& url, | 596 const GURL& url, |
| 588 const std::vector<GURL>& redirect_chain, | 597 const std::vector<GURL>& redirect_chain, |
| 589 const Referrer& referrer, | 598 const Referrer& referrer, |
| 590 PageTransition page_transition, | 599 PageTransition page_transition, |
| 591 WindowOpenDisposition disposition, | 600 WindowOpenDisposition disposition, |
| 592 const GlobalRequestID& transferred_global_request_id, | 601 const GlobalRequestID& transferred_global_request_id, |
| 593 bool should_replace_current_entry, | 602 bool should_replace_current_entry, |
| 594 bool user_gesture) { | 603 bool user_gesture, |
| 604 bool is_transition_navigation) { | |
| 595 GURL dest_url(url); | 605 GURL dest_url(url); |
| 596 SiteInstance* current_site_instance = | 606 SiteInstance* current_site_instance = |
| 597 GetRenderManager(render_frame_host)->current_frame_host()-> | 607 GetRenderManager(render_frame_host)->current_frame_host()-> |
| 598 GetSiteInstance(); | 608 GetSiteInstance(); |
| 599 if (!GetContentClient()->browser()->ShouldAllowOpenURL( | 609 if (!GetContentClient()->browser()->ShouldAllowOpenURL( |
| 600 current_site_instance, url)) { | 610 current_site_instance, url)) { |
| 601 dest_url = GURL(url::kAboutBlankURL); | 611 dest_url = GURL(url::kAboutBlankURL); |
| 602 } | 612 } |
| 603 | 613 |
| 604 int64 frame_tree_node_id = -1; | 614 int64 frame_tree_node_id = -1; |
| 605 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 615 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { |
| 606 frame_tree_node_id = | 616 frame_tree_node_id = |
| 607 render_frame_host->frame_tree_node()->frame_tree_node_id(); | 617 render_frame_host->frame_tree_node()->frame_tree_node_id(); |
| 608 } | 618 } |
| 609 OpenURLParams params( | 619 OpenURLParams params( |
| 610 dest_url, referrer, frame_tree_node_id, disposition, page_transition, | 620 dest_url, referrer, frame_tree_node_id, disposition, page_transition, |
| 611 true /* is_renderer_initiated */); | 621 true /* is_renderer_initiated */); |
| 612 if (redirect_chain.size() > 0) | 622 if (redirect_chain.size() > 0) |
| 613 params.redirect_chain = redirect_chain; | 623 params.redirect_chain = redirect_chain; |
| 614 params.transferred_global_request_id = transferred_global_request_id; | 624 params.transferred_global_request_id = transferred_global_request_id; |
| 615 params.should_replace_current_entry = should_replace_current_entry; | 625 params.should_replace_current_entry = should_replace_current_entry; |
| 616 params.user_gesture = user_gesture; | 626 params.user_gesture = user_gesture; |
| 627 params.is_transition_navigation = is_transition_navigation; | |
| 617 | 628 |
| 618 if (GetRenderManager(render_frame_host)->web_ui()) { | 629 if (GetRenderManager(render_frame_host)->web_ui()) { |
| 619 // Web UI pages sometimes want to override the page transition type for | 630 // Web UI pages sometimes want to override the page transition type for |
| 620 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for | 631 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for |
| 621 // automatically generated suggestions). We don't override other types | 632 // automatically generated suggestions). We don't override other types |
| 622 // like TYPED because they have different implications (e.g., autocomplete). | 633 // like TYPED because they have different implications (e.g., autocomplete). |
| 623 if (PageTransitionCoreTypeIs(params.transition, PAGE_TRANSITION_LINK)) | 634 if (PageTransitionCoreTypeIs(params.transition, PAGE_TRANSITION_LINK)) |
| 624 params.transition = | 635 params.transition = |
| 625 GetRenderManager(render_frame_host)->web_ui()-> | 636 GetRenderManager(render_frame_host)->web_ui()-> |
| 626 GetLinkTransitionType(); | 637 GetLinkTransitionType(); |
| 627 | 638 |
| 628 // Note also that we hide the referrer for Web UI pages. We don't really | 639 // Note also that we hide the referrer for Web UI pages. We don't really |
| 629 // want web sites to see a referrer of "chrome://blah" (and some | 640 // want web sites to see a referrer of "chrome://blah" (and some |
| 630 // chrome: URLs might have search terms or other stuff we don't want to | 641 // chrome: URLs might have search terms or other stuff we don't want to |
| 631 // send to the site), so we send no referrer. | 642 // send to the site), so we send no referrer. |
| 632 params.referrer = Referrer(); | 643 params.referrer = Referrer(); |
| 633 | 644 |
| 634 // Navigations in Web UI pages count as browser-initiated navigations. | 645 // Navigations in Web UI pages count as browser-initiated navigations. |
| 635 params.is_renderer_initiated = false; | 646 params.is_renderer_initiated = false; |
| 636 } | 647 } |
| 637 | 648 |
| 638 if (delegate_) | 649 if (delegate_) |
| 639 delegate_->RequestOpenURL(render_frame_host, params); | 650 delegate_->RequestOpenURL(render_frame_host, params); |
| 640 } | 651 } |
| 641 | 652 |
| 642 } // namespace content | 653 } // namespace content |
| OLD | NEW |