OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/navigation_request.h" | 5 #include "content/browser/frame_host/navigation_request.h" |
6 | 6 |
7 #include "content/browser/frame_host/frame_tree.h" | 7 #include "content/browser/frame_host/frame_tree.h" |
8 #include "content/browser/frame_host/frame_tree_node.h" | 8 #include "content/browser/frame_host/frame_tree_node.h" |
9 #include "content/browser/frame_host/navigation_controller_impl.h" | 9 #include "content/browser/frame_host/navigation_controller_impl.h" |
10 #include "content/browser/frame_host/navigation_request_info.h" | 10 #include "content/browser/frame_host/navigation_request_info.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 case FrameMsg_Navigate_Type::NORMAL: | 44 case FrameMsg_Navigate_Type::NORMAL: |
45 default: | 45 default: |
46 break; | 46 break; |
47 } | 47 } |
48 return load_flags; | 48 return load_flags; |
49 } | 49 } |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 // static | 53 // static |
54 bool NavigationRequest::ShouldMakeNetworkRequest(const GURL& url) { | |
55 // Data and Javascript urls should not make network requests. | |
56 // TODO(clamy): same document navigations should not make network requests. | |
57 return !url.SchemeIs(url::kDataScheme) && url != GURL(url::kAboutBlankURL) && | |
58 !url.SchemeIs(url::kJavaScriptScheme); | |
59 } | |
60 | |
61 // static | |
62 scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( | 54 scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( |
63 FrameTreeNode* frame_tree_node, | 55 FrameTreeNode* frame_tree_node, |
64 const FrameNavigationEntry& frame_entry, | 56 const FrameNavigationEntry& frame_entry, |
65 const NavigationEntryImpl& entry, | 57 const NavigationEntryImpl& entry, |
66 FrameMsg_Navigate_Type::Value navigation_type, | 58 FrameMsg_Navigate_Type::Value navigation_type, |
67 bool is_same_document_history_load, | 59 bool is_same_document_history_load, |
68 base::TimeTicks navigation_start, | 60 base::TimeTicks navigation_start, |
69 NavigationControllerImpl* controller) { | 61 NavigationControllerImpl* controller) { |
70 std::string method = entry.GetHasPostData() ? "POST" : "GET"; | 62 std::string method = entry.GetHasPostData() ? "POST" : "GET"; |
71 | 63 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 } | 167 } |
176 | 168 |
177 NavigationRequest::~NavigationRequest() { | 169 NavigationRequest::~NavigationRequest() { |
178 } | 170 } |
179 | 171 |
180 bool NavigationRequest::BeginNavigation() { | 172 bool NavigationRequest::BeginNavigation() { |
181 DCHECK(!loader_); | 173 DCHECK(!loader_); |
182 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE); | 174 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE); |
183 state_ = STARTED; | 175 state_ = STARTED; |
184 | 176 |
185 if (ShouldMakeNetworkRequest(common_params_.url)) { | 177 if (ShouldMakeNetworkRequestForURL(common_params_.url)) { |
186 loader_ = NavigationURLLoader::Create( | 178 loader_ = NavigationURLLoader::Create( |
187 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), | 179 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), |
188 frame_tree_node_->frame_tree_node_id(), info_.Pass(), this); | 180 frame_tree_node_->frame_tree_node_id(), info_.Pass(), this); |
189 return true; | 181 return true; |
190 } | 182 } |
191 | 183 |
192 // There is no need to make a network request for this navigation, so commit | 184 // There is no need to make a network request for this navigation, so commit |
193 // it immediately. | 185 // it immediately. |
194 state_ = RESPONSE_STARTED; | 186 state_ = RESPONSE_STARTED; |
195 frame_tree_node_->navigator()->CommitNavigation( | 187 frame_tree_node_->navigator()->CommitNavigation( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 frame_tree_node_->navigator()->FailedNavigation( | 220 frame_tree_node_->navigator()->FailedNavigation( |
229 frame_tree_node_, has_stale_copy_in_cache, net_error); | 221 frame_tree_node_, has_stale_copy_in_cache, net_error); |
230 } | 222 } |
231 | 223 |
232 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { | 224 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { |
233 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, | 225 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, |
234 common_params_.url); | 226 common_params_.url); |
235 } | 227 } |
236 | 228 |
237 } // namespace content | 229 } // namespace content |
OLD | NEW |