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/devtools/render_frame_devtools_agent_host.h" | 12 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
11 #include "content/browser/frame_host/frame_tree_node.h" | 13 #include "content/browser/frame_host/frame_tree_node.h" |
12 #include "content/browser/frame_host/navigator.h" | 14 #include "content/browser/frame_host/navigator.h" |
13 #include "content/browser/frame_host/navigator_delegate.h" | 15 #include "content/browser/frame_host/navigator_delegate.h" |
14 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 16 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
15 #include "content/common/frame_messages.h" | 17 #include "content/common/frame_messages.h" |
16 #include "content/common/resource_request_body_impl.h" | 18 #include "content/common/resource_request_body_impl.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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
518 complete_callback_.Reset(); | 526 complete_callback_.Reset(); |
519 | 527 |
520 if (!callback.is_null()) | 528 if (!callback.is_null()) |
521 callback.Run(result); | 529 callback.Run(result); |
522 | 530 |
523 // No code after running the callback, as it might have resulted in our | 531 // No code after running the callback, as it might have resulted in our |
524 // destruction. | 532 // destruction. |
525 } | 533 } |
526 | 534 |
527 void NavigationHandleImpl::RegisterNavigationThrottles() { | 535 void NavigationHandleImpl::RegisterNavigationThrottles() { |
528 // Register the navigation throttles. The ScopedVector returned by | 536 // Register the platform's navigation throttles. |
537 if (AreExperimentalFeaturesEnabled()) { | |
538 std::unique_ptr<content::NavigationThrottle> clear_site_data_throttle = | |
539 content::ClearSiteDataThrottle::CreateThrottleFor(this); | |
540 throttles_.push_back(std::move(clear_site_data_throttle)); | |
clamy
2016/07/18 14:47:49
If the throttle is put there, it means it will exe
msramek
2016/07/18 17:03:20
Done.
Good point - moved it to the end.
We haven
| |
541 } | |
542 | |
543 // Register the embedder's navigation throttles. The ScopedVector returned by | |
529 // GetNavigationThrottles is not assigned to throttles_ directly because it | 544 // GetNavigationThrottles is not assigned to throttles_ directly because it |
530 // would overwrite any throttle previously added with | 545 // would overwrite any throttle previously added with |
531 // RegisterThrottleForTesting. | 546 // RegisterThrottleForTesting. |
532 ScopedVector<NavigationThrottle> throttles_to_register = | 547 ScopedVector<NavigationThrottle> throttles_to_register = |
533 GetContentClient()->browser()->CreateThrottlesForNavigation(this); | 548 GetContentClient()->browser()->CreateThrottlesForNavigation(this); |
534 if (throttles_to_register.size() > 0) { | 549 if (throttles_to_register.size() > 0) { |
535 throttles_.insert(throttles_.end(), throttles_to_register.begin(), | 550 throttles_.insert(throttles_.end(), throttles_to_register.begin(), |
536 throttles_to_register.end()); | 551 throttles_to_register.end()); |
537 throttles_to_register.weak_clear(); | 552 throttles_to_register.weak_clear(); |
538 } | 553 } |
539 std::unique_ptr<NavigationThrottle> devtools_throttle = | 554 std::unique_ptr<NavigationThrottle> devtools_throttle = |
540 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this); | 555 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this); |
541 if (devtools_throttle) | 556 if (devtools_throttle) |
542 throttles_.push_back(devtools_throttle.release()); | 557 throttles_.push_back(devtools_throttle.release()); |
543 } | 558 } |
544 | 559 |
545 } // namespace content | 560 } // namespace content |
OLD | NEW |