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

Side by Side Diff: chrome/browser/net/chrome_network_delegate.cc

Issue 2655443003: Unify the "get" and "set" cookie access settings. (Closed)
Patch Set: rebase Created 3 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/net/chrome_network_delegate.h" 5 #include "chrome/browser/net/chrome_network_delegate.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 request, auth_info, callback, credentials); 403 request, auth_info, callback, credentials);
404 } 404 }
405 405
406 bool ChromeNetworkDelegate::OnCanGetCookies( 406 bool ChromeNetworkDelegate::OnCanGetCookies(
407 const net::URLRequest& request, 407 const net::URLRequest& request,
408 const net::CookieList& cookie_list) { 408 const net::CookieList& cookie_list) {
409 // nullptr during tests, or when we're running in the system context. 409 // nullptr during tests, or when we're running in the system context.
410 if (!cookie_settings_.get()) 410 if (!cookie_settings_.get())
411 return true; 411 return true;
412 412
413 bool allow = cookie_settings_->IsReadingCookieAllowed( 413 bool allow = cookie_settings_->IsCookieAccessAllowed(
414 request.url(), request.first_party_for_cookies()); 414 request.url(), request.first_party_for_cookies());
415 415
416 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request); 416 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request);
417 if (info) { 417 if (info) {
418 BrowserThread::PostTask( 418 BrowserThread::PostTask(
419 BrowserThread::UI, FROM_HERE, 419 BrowserThread::UI, FROM_HERE,
420 base::Bind(&TabSpecificContentSettings::CookiesRead, 420 base::Bind(&TabSpecificContentSettings::CookiesRead,
421 info->GetWebContentsGetterForRequest(), 421 info->GetWebContentsGetterForRequest(),
422 request.url(), request.first_party_for_cookies(), 422 request.url(), request.first_party_for_cookies(),
423 cookie_list, !allow)); 423 cookie_list, !allow));
424 } 424 }
425 425
426 return allow; 426 return allow;
427 } 427 }
428 428
429 bool ChromeNetworkDelegate::OnCanSetCookie(const net::URLRequest& request, 429 bool ChromeNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
430 const std::string& cookie_line, 430 const std::string& cookie_line,
431 net::CookieOptions* options) { 431 net::CookieOptions* options) {
432 // nullptr during tests, or when we're running in the system context. 432 // nullptr during tests, or when we're running in the system context.
433 if (!cookie_settings_.get()) 433 if (!cookie_settings_.get())
434 return true; 434 return true;
435 435
436 bool allow = cookie_settings_->IsSettingCookieAllowed( 436 bool allow = cookie_settings_->IsCookieAccessAllowed(
437 request.url(), request.first_party_for_cookies()); 437 request.url(), request.first_party_for_cookies());
438 438
439 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request); 439 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request);
440 if (info) { 440 if (info) {
441 BrowserThread::PostTask( 441 BrowserThread::PostTask(
442 BrowserThread::UI, FROM_HERE, 442 BrowserThread::UI, FROM_HERE,
443 base::Bind(&TabSpecificContentSettings::CookieChanged, 443 base::Bind(&TabSpecificContentSettings::CookieChanged,
444 info->GetWebContentsGetterForRequest(), 444 info->GetWebContentsGetterForRequest(),
445 request.url(), request.first_party_for_cookies(), 445 request.url(), request.first_party_for_cookies(),
446 cookie_line, *options, !allow)); 446 cookie_line, *options, !allow));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) 518 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
519 } 519 }
520 520
521 bool ChromeNetworkDelegate::OnCanEnablePrivacyMode( 521 bool ChromeNetworkDelegate::OnCanEnablePrivacyMode(
522 const GURL& url, 522 const GURL& url,
523 const GURL& first_party_for_cookies) const { 523 const GURL& first_party_for_cookies) const {
524 // nullptr during tests, or when we're running in the system context. 524 // nullptr during tests, or when we're running in the system context.
525 if (!cookie_settings_.get()) 525 if (!cookie_settings_.get())
526 return false; 526 return false;
527 527
528 bool reading_cookie_allowed = false; 528 return !cookie_settings_->IsCookieAccessAllowed(url, first_party_for_cookies);
529 bool setting_cookie_allowed = false;
530 cookie_settings_->GetReadingAndSettingCookieAllowed(
531 url, first_party_for_cookies, &reading_cookie_allowed,
532 &setting_cookie_allowed);
533 bool privacy_mode = !(reading_cookie_allowed && setting_cookie_allowed);
534 return privacy_mode;
535 } 529 }
536 530
537 bool ChromeNetworkDelegate::OnAreExperimentalCookieFeaturesEnabled() const { 531 bool ChromeNetworkDelegate::OnAreExperimentalCookieFeaturesEnabled() const {
538 return experimental_web_platform_features_enabled_; 532 return experimental_web_platform_features_enabled_;
539 } 533 }
540 534
541 bool ChromeNetworkDelegate::OnAreStrictSecureCookiesEnabled() const { 535 bool ChromeNetworkDelegate::OnAreStrictSecureCookiesEnabled() const {
542 const std::string enforce_strict_secure_group = 536 const std::string enforce_strict_secure_group =
543 base::FieldTrialList::FindFullName("StrictSecureCookies"); 537 base::FieldTrialList::FindFullName("StrictSecureCookies");
544 return experimental_web_platform_features_enabled_ || 538 return experimental_web_platform_features_enabled_ ||
(...skipping 15 matching lines...) Expand all
560 if (!data_use_aggregator_) 554 if (!data_use_aggregator_)
561 return; 555 return;
562 556
563 if (is_data_usage_off_the_record_) { 557 if (is_data_usage_off_the_record_) {
564 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); 558 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes);
565 return; 559 return;
566 } 560 }
567 561
568 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); 562 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes);
569 } 563 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698