Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: content/browser/frame_host/navigation_handle_impl.cc

Issue 2025683003: First experimental implementation of the Clear-Site-Data header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/common/frame_messages.h" 16 #include "content/common/frame_messages.h"
15 #include "content/common/resource_request_body_impl.h" 17 #include "content/common/resource_request_body_impl.h"
16 #include "content/public/browser/content_browser_client.h" 18 #include "content/public/browser/content_browser_client.h"
17 #include "content/public/common/browser_side_navigation_policy.h" 19 #include "content/public/common/browser_side_navigation_policy.h"
18 #include "content/public/common/content_client.h" 20 #include "content/public/common/content_client.h"
21 #include "content/public/common/content_switches.h"
19 #include "net/url_request/redirect_info.h" 22 #include "net/url_request/redirect_info.h"
20 #include "url/gurl.h" 23 #include "url/gurl.h"
21 #include "url/url_constants.h" 24 #include "url/url_constants.h"
22 25
23 namespace content { 26 namespace content {
24 27
25 namespace { 28 namespace {
26 29
27 void UpdateThrottleCheckResult( 30 void UpdateThrottleCheckResult(
28 NavigationThrottle::ThrottleCheckResult* to_update, 31 NavigationThrottle::ThrottleCheckResult* to_update,
29 NavigationThrottle::ThrottleCheckResult result) { 32 NavigationThrottle::ThrottleCheckResult result) {
30 *to_update = result; 33 *to_update = result;
31 } 34 }
32 35
36 bool AreExperimentalFeaturesEnabled() {
37 return base::CommandLine::ForCurrentProcess()->HasSwitch(
38 switches::kEnableExperimentalWebPlatformFeatures);
39 }
40
33 } // namespace 41 } // namespace
34 42
35 // static 43 // static
36 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( 44 std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create(
37 const GURL& url, 45 const GURL& url,
38 FrameTreeNode* frame_tree_node, 46 FrameTreeNode* frame_tree_node,
39 bool is_renderer_initiated, 47 bool is_renderer_initiated,
40 bool is_synchronous, 48 bool is_synchronous,
41 bool is_srcdoc, 49 bool is_srcdoc,
42 const base::TimeTicks& navigation_start, 50 const base::TimeTicks& navigation_start,
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 if (method_ == "POST") 324 if (method_ == "POST")
317 resource_request_body_ = resource_request_body; 325 resource_request_body_ = resource_request_body;
318 sanitized_referrer_ = sanitized_referrer; 326 sanitized_referrer_ = sanitized_referrer;
319 has_user_gesture_ = has_user_gesture; 327 has_user_gesture_ = has_user_gesture;
320 transition_ = transition; 328 transition_ = transition;
321 is_external_protocol_ = is_external_protocol; 329 is_external_protocol_ = is_external_protocol;
322 330
323 state_ = WILL_SEND_REQUEST; 331 state_ = WILL_SEND_REQUEST;
324 complete_callback_ = callback; 332 complete_callback_ = callback;
325 333
326 // Register the navigation throttles. The ScopedVector returned by 334 // Register the platform's navigation throttles.
335 if (AreExperimentalFeaturesEnabled()) {
336 std::unique_ptr<content::NavigationThrottle> clear_site_data_throttle =
337 content::ClearSiteDataThrottle::CreateThrottleFor(this);
338 throttles_.push_back(std::move(clear_site_data_throttle));
339 }
340
341 // Register the embedder's navigation throttles. The ScopedVector returned by
327 // GetNavigationThrottles is not assigned to throttles_ directly because it 342 // GetNavigationThrottles is not assigned to throttles_ directly because it
328 // would overwrite any throttle previously added with 343 // would overwrite any throttle previously added with
329 // RegisterThrottleForTesting. 344 // RegisterThrottleForTesting.
330 ScopedVector<NavigationThrottle> throttles_to_register = 345 ScopedVector<NavigationThrottle> throttles_to_register =
331 GetContentClient()->browser()->CreateThrottlesForNavigation(this); 346 GetContentClient()->browser()->CreateThrottlesForNavigation(this);
332 if (throttles_to_register.size() > 0) { 347 if (throttles_to_register.size() > 0) {
333 throttles_.insert(throttles_.end(), throttles_to_register.begin(), 348 throttles_.insert(throttles_.end(), throttles_to_register.begin(),
334 throttles_to_register.end()); 349 throttles_to_register.end());
335 throttles_to_register.weak_clear(); 350 throttles_to_register.weak_clear();
336 } 351 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 complete_callback_.Reset(); 542 complete_callback_.Reset();
528 543
529 if (!callback.is_null()) 544 if (!callback.is_null())
530 callback.Run(result); 545 callback.Run(result);
531 546
532 // No code after running the callback, as it might have resulted in our 547 // No code after running the callback, as it might have resulted in our
533 // destruction. 548 // destruction.
534 } 549 }
535 550
536 } // namespace content 551 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698