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.h" | 5 #include "content/browser/frame_host/navigator.h" |
6 | 6 |
7 #include "content/browser/frame_host/frame_tree_node.h" | |
8 #include "content/browser/frame_host/navigation_controller_impl.h" | |
9 #include "content/browser/frame_host/navigation_entry_impl.h" | |
7 #include "content/browser/frame_host/navigator_delegate.h" | 10 #include "content/browser/frame_host/navigator_delegate.h" |
11 #include "content/browser/frame_host/render_frame_host_impl.h" | |
12 #include "content/browser/renderer_host/render_view_host_impl.h" | |
13 #include "content/browser/site_instance_impl.h" | |
14 #include "content/public/browser/browser_context.h" | |
15 #include "content/public/browser/invalidate_type.h" | |
16 #include "content/public/browser/navigation_controller.h" | |
17 #include "content/public/browser/render_view_host.h" | |
18 #include "content/public/common/url_constants.h" | |
8 | 19 |
9 namespace content { | 20 namespace content { |
10 | 21 |
11 Navigator::Navigator( | 22 Navigator::Navigator( |
12 NavigationControllerImpl* nav_controller, | 23 NavigationControllerImpl* nav_controller, |
13 NavigatorDelegate* delegate) | 24 NavigatorDelegate* delegate) |
14 : controller_(nav_controller), | 25 : controller_(nav_controller), |
15 delegate_(delegate) { | 26 delegate_(delegate) { |
16 } | 27 } |
17 | 28 |
29 void Navigator::DidStartProvisionalLoad( | |
30 RenderFrameHostImpl* render_frame_host, | |
31 int64 frame_id, | |
32 int64 parent_frame_id, | |
33 bool is_main_frame, | |
34 const GURL& url) { | |
35 bool is_error_page = (url.spec() == kUnreachableWebDataURL); | |
36 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); | |
37 GURL validated_url(url); | |
38 RenderProcessHost* render_process_host = render_frame_host->GetProcess(); | |
39 RenderViewHost::FilterURL(render_process_host, false, &validated_url); | |
40 | |
41 LOG(ERROR) << "Navigator::DidStartProvisionalLoad: " << url; | |
Charlie Reis
2013/11/21 21:59:32
Don't forget to remove the LOG statements.
nasko
2013/11/22 01:02:34
Yeah, those won't go in : ).
| |
42 | |
43 if (is_main_frame) { | |
44 LOG(ERROR) << "Navigator::DidStartProvisionalLoad: main frame"; | |
45 | |
46 // If there is no browser-initiated pending entry for this navigation and it | |
47 // is not for the error URL, create a pending entry using the current | |
48 // SiteInstance, and ensure the address bar updates accordingly. We don't | |
49 // know the referrer or extra headers at this point, but the referrer will | |
50 // be set properly upon commit. | |
51 NavigationEntryImpl* pending_entry = | |
52 NavigationEntryImpl::FromNavigationEntry( | |
53 controller_->GetPendingEntry()); | |
54 bool has_browser_initiated_pending_entry = pending_entry && | |
55 !pending_entry->is_renderer_initiated(); | |
56 if (!has_browser_initiated_pending_entry && !is_error_page) { | |
57 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( | |
58 controller_->CreateNavigationEntry(validated_url, | |
59 content::Referrer(), | |
60 content::PAGE_TRANSITION_LINK, | |
61 true /* is_renderer_initiated */, | |
62 std::string(), | |
63 controller_->GetBrowserContext())); | |
64 entry->set_site_instance( | |
65 static_cast<SiteInstanceImpl*>( | |
66 render_frame_host->render_view_host()->GetSiteInstance())); | |
67 // TODO(creis): If there's a pending entry already, find a safe way to | |
68 // update it instead of replacing it and copying over things like this. | |
69 if (pending_entry) { | |
70 entry->set_transferred_global_request_id( | |
71 pending_entry->transferred_global_request_id()); | |
72 entry->set_should_replace_entry(pending_entry->should_replace_entry()); | |
73 entry->set_redirect_chain(pending_entry->redirect_chain()); | |
74 } | |
75 controller_->SetPendingEntry(entry); | |
76 if (delegate_) | |
77 delegate_->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL); | |
78 } | |
79 } | |
80 | |
81 if (delegate_) { | |
82 // Notify the observer about the start of the provisional load. | |
83 delegate_->DidStartProvisionalLoad( | |
84 render_frame_host, frame_id, parent_frame_id, is_main_frame, | |
85 validated_url, is_error_page, is_iframe_srcdoc); | |
86 | |
87 if (is_main_frame) { | |
88 // Notify the observer about the provisional change in the main frame URL. | |
89 delegate_->NotifyProvisionalChangeToMainFrameUrl( | |
90 render_frame_host, validated_url); | |
91 } | |
92 } | |
93 } | |
94 | |
18 } // namespace content | 95 } // namespace content |
OLD | NEW |