OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/renderer_host/navigator.h" |
| 6 |
| 7 #include "content/browser/renderer_host/navigator_observer.h" |
| 8 #include "content/browser/renderer_host/render_frame_host_impl.h" |
| 9 #include "content/browser/site_instance_impl.h" |
| 10 #include "content/browser/web_contents/navigation_controller_impl.h" |
| 11 #include "content/browser/web_contents/navigation_entry_impl.h" |
| 12 #include "content/public/browser/browser_context.h" |
| 13 #include "content/public/browser/invalidate_type.h" |
| 14 #include "content/public/browser/navigation_controller.h" |
| 15 #include "content/public/browser/render_view_host.h" |
| 16 #include "content/public/common/url_constants.h" |
| 17 |
| 18 namespace content { |
| 19 |
| 20 void Navigator::DidStartProvisionalLoad( |
| 21 RenderFrameHost* render_frame_host, |
| 22 int64 frame_id, |
| 23 int64 parent_frame_id, |
| 24 bool is_main_frame, |
| 25 const GURL& url) { |
| 26 bool is_error_page = (url.spec() == kUnreachableWebDataURL); |
| 27 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); |
| 28 GURL validated_url(url); |
| 29 RenderProcessHost* render_process_host = |
| 30 render_frame_host->GetProcess(); |
| 31 RenderViewHost::FilterURL(render_process_host, false, &validated_url); |
| 32 |
| 33 if (is_main_frame) { |
| 34 // If there is no browser-initiated pending entry for this navigation and it |
| 35 // is not for the error URL, create a pending entry using the current |
| 36 // SiteInstance, and ensure the address bar updates accordingly. We don't |
| 37 // know the referrer or extra headers at this point, but the referrer will |
| 38 // be set properly upon commit. |
| 39 NavigationEntry* pending_entry = controller_->GetPendingEntry(); |
| 40 bool has_browser_initiated_pending_entry = pending_entry && |
| 41 !NavigationEntryImpl::FromNavigationEntry(pending_entry)-> |
| 42 is_renderer_initiated(); |
| 43 if (!has_browser_initiated_pending_entry && !is_error_page) { |
| 44 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( |
| 45 controller_->CreateNavigationEntry(validated_url, |
| 46 content::Referrer(), |
| 47 content::PAGE_TRANSITION_LINK, |
| 48 true /* is_renderer_initiated */, |
| 49 std::string(), |
| 50 controller_->GetBrowserContext())); |
| 51 render_frame_host->GetSiteInstance(); |
| 52 controller_->SetPendingEntry(entry); |
| 53 observer_->NavigationStateChanged(content::INVALIDATE_TYPE_URL); |
| 54 } |
| 55 } |
| 56 |
| 57 // Notify the observer about the start of the provisional load. |
| 58 observer_->DidStartProvisionalLoad( |
| 59 frame_id, parent_frame_id, is_main_frame, validated_url, is_error_page, |
| 60 is_iframe_srcdoc, render_frame_host); |
| 61 |
| 62 if (is_main_frame) { |
| 63 // Notify the observer about the provisional change in the main frame URL. |
| 64 observer_->ProvisionalChangeToMainFrameUrl( |
| 65 validated_url, render_frame_host); |
| 66 } |
| 67 } |
| 68 |
| 69 } // namespace content |
OLD | NEW |