| 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 embedder's navigation throttles. The ScopedVector returned by |
| 529 // GetNavigationThrottles is not assigned to throttles_ directly because it | 537 // GetNavigationThrottles is not assigned to throttles_ directly because it |
| 530 // would overwrite any throttle previously added with | 538 // would overwrite any throttle previously added with |
| 531 // RegisterThrottleForTesting. | 539 // RegisterThrottleForTesting. |
| 532 ScopedVector<NavigationThrottle> throttles_to_register = | 540 ScopedVector<NavigationThrottle> throttles_to_register = |
| 533 GetContentClient()->browser()->CreateThrottlesForNavigation(this); | 541 GetContentClient()->browser()->CreateThrottlesForNavigation(this); |
| 534 if (throttles_to_register.size() > 0) { | 542 if (throttles_to_register.size() > 0) { |
| 535 throttles_.insert(throttles_.end(), throttles_to_register.begin(), | 543 throttles_.insert(throttles_.end(), throttles_to_register.begin(), |
| 536 throttles_to_register.end()); | 544 throttles_to_register.end()); |
| 537 throttles_to_register.weak_clear(); | 545 throttles_to_register.weak_clear(); |
| 538 } | 546 } |
| 539 std::unique_ptr<NavigationThrottle> devtools_throttle = | 547 std::unique_ptr<NavigationThrottle> devtools_throttle = |
| 540 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this); | 548 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this); |
| 541 if (devtools_throttle) | 549 if (devtools_throttle) |
| 542 throttles_.push_back(devtools_throttle.release()); | 550 throttles_.push_back(devtools_throttle.release()); |
| 551 |
| 552 // Register the platform's navigation throttles. |
| 553 if (AreExperimentalFeaturesEnabled()) { |
| 554 // TODO(msramek): It is currently not clear whether ClearSiteDataThrottle |
| 555 // should defer the navigation until clearing is complete. If we decide |
| 556 // that it shouldn't, and crbug.com/621856 is fixed, it should be instead |
| 557 // implemented as a WebContentsObserver. |
| 558 std::unique_ptr<content::NavigationThrottle> clear_site_data_throttle = |
| 559 content::ClearSiteDataThrottle::CreateThrottleFor(this); |
| 560 throttles_.push_back(std::move(clear_site_data_throttle)); |
| 561 } |
| 543 } | 562 } |
| 544 | 563 |
| 545 } // namespace content | 564 } // namespace content |
| OLD | NEW |