OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_handle_impl.h" | 5 #include "content/browser/frame_host/navigation_handle_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "content/browser/browsing_data/clear_site_data_throttle.h" | |
10 #include "content/browser/frame_host/frame_tree_node.h" | 12 #include "content/browser/frame_host/frame_tree_node.h" |
11 #include "content/browser/frame_host/navigator.h" | 13 #include "content/browser/frame_host/navigator.h" |
12 #include "content/browser/frame_host/navigator_delegate.h" | 14 #include "content/browser/frame_host/navigator_delegate.h" |
13 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 15 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
14 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 16 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
15 #include "content/common/frame_messages.h" | 17 #include "content/common/frame_messages.h" |
16 #include "content/common/resource_request_body.h" | 18 #include "content/common/resource_request_body.h" |
17 #include "content/public/browser/content_browser_client.h" | 19 #include "content/public/browser/content_browser_client.h" |
18 #include "content/public/common/browser_side_navigation_policy.h" | 20 #include "content/public/common/browser_side_navigation_policy.h" |
19 #include "content/public/common/content_client.h" | 21 #include "content/public/common/content_client.h" |
22 #include "content/public/common/content_switches.h" | |
20 #include "net/url_request/redirect_info.h" | 23 #include "net/url_request/redirect_info.h" |
21 #include "url/gurl.h" | 24 #include "url/gurl.h" |
22 #include "url/url_constants.h" | 25 #include "url/url_constants.h" |
23 | 26 |
24 namespace content { | 27 namespace content { |
25 | 28 |
26 namespace { | 29 namespace { |
27 | 30 |
28 void UpdateThrottleCheckResult( | 31 void UpdateThrottleCheckResult( |
29 NavigationThrottle::ThrottleCheckResult* to_update, | 32 NavigationThrottle::ThrottleCheckResult* to_update, |
30 NavigationThrottle::ThrottleCheckResult result) { | 33 NavigationThrottle::ThrottleCheckResult result) { |
31 *to_update = result; | 34 *to_update = result; |
32 } | 35 } |
33 | 36 |
37 bool AreExperimentalFeaturesEnabled() { | |
38 return base::CommandLine::ForCurrentProcess()->HasSwitch( | |
39 switches::kEnableExperimentalWebPlatformFeatures); | |
40 } | |
41 | |
34 } // namespace | 42 } // namespace |
35 | 43 |
36 // static | 44 // static |
37 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( | 45 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( |
38 const GURL& url, | 46 const GURL& url, |
39 FrameTreeNode* frame_tree_node, | 47 FrameTreeNode* frame_tree_node, |
40 bool is_renderer_initiated, | 48 bool is_renderer_initiated, |
41 bool is_synchronous, | 49 bool is_synchronous, |
42 bool is_srcdoc, | 50 bool is_srcdoc, |
43 const base::TimeTicks& navigation_start, | 51 const base::TimeTicks& navigation_start, |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 CHECK_NE(INITIAL, state_) | 184 CHECK_NE(INITIAL, state_) |
177 << "This accessor should not be called before the request is started."; | 185 << "This accessor should not be called before the request is started."; |
178 return is_external_protocol_; | 186 return is_external_protocol_; |
179 } | 187 } |
180 | 188 |
181 net::Error NavigationHandleImpl::GetNetErrorCode() { | 189 net::Error NavigationHandleImpl::GetNetErrorCode() { |
182 return net_error_code_; | 190 return net_error_code_; |
183 } | 191 } |
184 | 192 |
185 RenderFrameHostImpl* NavigationHandleImpl::GetRenderFrameHost() { | 193 RenderFrameHostImpl* NavigationHandleImpl::GetRenderFrameHost() { |
186 CHECK(state_ >= READY_TO_COMMIT) | 194 CHECK(state_ >= WILL_PROCESS_RESPONSE) |
melandory
2016/06/15 08:12:34
also fix comment in navigation_handle.h (see here
msramek
2016/06/15 18:00:40
Done. I have updated the comment, but I didn't exa
| |
187 << "This accessor should only be called " | 195 << "This accessor should only be called " |
188 "after the navigation is ready to commit."; | 196 "after a response has been received."; |
189 return render_frame_host_; | 197 return render_frame_host_; |
190 } | 198 } |
191 | 199 |
192 bool NavigationHandleImpl::IsSamePage() { | 200 bool NavigationHandleImpl::IsSamePage() { |
193 DCHECK(state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE) | 201 DCHECK(state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE) |
194 << "This accessor should not be called before the navigation has " | 202 << "This accessor should not be called before the navigation has " |
195 "committed."; | 203 "committed."; |
196 return is_same_page_; | 204 return is_same_page_; |
197 } | 205 } |
198 | 206 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 if (method_ == "POST") | 329 if (method_ == "POST") |
322 resource_request_body_ = resource_request_body; | 330 resource_request_body_ = resource_request_body; |
323 sanitized_referrer_ = sanitized_referrer; | 331 sanitized_referrer_ = sanitized_referrer; |
324 has_user_gesture_ = has_user_gesture; | 332 has_user_gesture_ = has_user_gesture; |
325 transition_ = transition; | 333 transition_ = transition; |
326 is_external_protocol_ = is_external_protocol; | 334 is_external_protocol_ = is_external_protocol; |
327 | 335 |
328 state_ = WILL_SEND_REQUEST; | 336 state_ = WILL_SEND_REQUEST; |
329 complete_callback_ = callback; | 337 complete_callback_ = callback; |
330 | 338 |
331 // Register the navigation throttles. The ScopedVector returned by | 339 // Register the platform's navigation throttles. |
340 if (AreExperimentalFeaturesEnabled()) { | |
341 std::unique_ptr<content::NavigationThrottle> clear_site_data_throttle = | |
342 content::ClearSiteDataThrottle::CreateThrottleFor(this); | |
343 throttles_.push_back(std::move(clear_site_data_throttle)); | |
344 } | |
345 | |
346 // Register the embedder's navigation throttles. The ScopedVector returned by | |
332 // GetNavigationThrottles is not assigned to throttles_ directly because it | 347 // GetNavigationThrottles is not assigned to throttles_ directly because it |
333 // would overwrite any throttle previously added with | 348 // would overwrite any throttle previously added with |
334 // RegisterThrottleForTesting. | 349 // RegisterThrottleForTesting. |
335 ScopedVector<NavigationThrottle> throttles_to_register = | 350 ScopedVector<NavigationThrottle> throttles_to_register = |
336 GetContentClient()->browser()->CreateThrottlesForNavigation(this); | 351 GetContentClient()->browser()->CreateThrottlesForNavigation(this); |
337 if (throttles_to_register.size() > 0) { | 352 if (throttles_to_register.size() > 0) { |
338 throttles_.insert(throttles_.end(), throttles_to_register.begin(), | 353 throttles_.insert(throttles_.end(), throttles_to_register.begin(), |
339 throttles_to_register.end()); | 354 throttles_to_register.end()); |
340 throttles_to_register.weak_clear(); | 355 throttles_to_register.weak_clear(); |
341 } | 356 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
532 complete_callback_.Reset(); | 547 complete_callback_.Reset(); |
533 | 548 |
534 if (!callback.is_null()) | 549 if (!callback.is_null()) |
535 callback.Run(result); | 550 callback.Run(result); |
536 | 551 |
537 // No code after running the callback, as it might have resulted in our | 552 // No code after running the callback, as it might have resulted in our |
538 // destruction. | 553 // destruction. |
539 } | 554 } |
540 | 555 |
541 } // namespace content | 556 } // namespace content |
OLD | NEW |