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

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

Issue 2655443003: Unify the "get" and "set" cookie access settings. (Closed)
Patch Set: fix android 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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 request, auth_info, callback, credentials); 416 request, auth_info, callback, credentials);
417 } 417 }
418 418
419 bool ChromeNetworkDelegate::OnCanGetCookies( 419 bool ChromeNetworkDelegate::OnCanGetCookies(
420 const net::URLRequest& request, 420 const net::URLRequest& request,
421 const net::CookieList& cookie_list) { 421 const net::CookieList& cookie_list) {
422 // nullptr during tests, or when we're running in the system context. 422 // nullptr during tests, or when we're running in the system context.
423 if (!cookie_settings_.get()) 423 if (!cookie_settings_.get())
424 return true; 424 return true;
425 425
426 bool allow = cookie_settings_->IsReadingCookieAllowed( 426 bool allow = cookie_settings_->IsCookieAccessAllowed(
427 request.url(), request.first_party_for_cookies()); 427 request.url(), request.first_party_for_cookies());
428 428
429 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request); 429 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request);
430 if (info) { 430 if (info) {
431 BrowserThread::PostTask( 431 BrowserThread::PostTask(
432 BrowserThread::UI, FROM_HERE, 432 BrowserThread::UI, FROM_HERE,
433 base::Bind(&TabSpecificContentSettings::CookiesRead, 433 base::Bind(&TabSpecificContentSettings::CookiesRead,
434 info->GetWebContentsGetterForRequest(), 434 info->GetWebContentsGetterForRequest(),
435 request.url(), request.first_party_for_cookies(), 435 request.url(), request.first_party_for_cookies(),
436 cookie_list, !allow)); 436 cookie_list, !allow));
437 } 437 }
438 438
439 return allow; 439 return allow;
440 } 440 }
441 441
442 bool ChromeNetworkDelegate::OnCanSetCookie(const net::URLRequest& request, 442 bool ChromeNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
443 const std::string& cookie_line, 443 const std::string& cookie_line,
444 net::CookieOptions* options) { 444 net::CookieOptions* options) {
445 // nullptr during tests, or when we're running in the system context. 445 // nullptr during tests, or when we're running in the system context.
446 if (!cookie_settings_.get()) 446 if (!cookie_settings_.get())
447 return true; 447 return true;
448 448
449 bool allow = cookie_settings_->IsSettingCookieAllowed( 449 bool allow = cookie_settings_->IsCookieAccessAllowed(
450 request.url(), request.first_party_for_cookies()); 450 request.url(), request.first_party_for_cookies());
451 451
452 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request); 452 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request);
453 if (info) { 453 if (info) {
454 BrowserThread::PostTask( 454 BrowserThread::PostTask(
455 BrowserThread::UI, FROM_HERE, 455 BrowserThread::UI, FROM_HERE,
456 base::Bind(&TabSpecificContentSettings::CookieChanged, 456 base::Bind(&TabSpecificContentSettings::CookieChanged,
457 info->GetWebContentsGetterForRequest(), 457 info->GetWebContentsGetterForRequest(),
458 request.url(), request.first_party_for_cookies(), 458 request.url(), request.first_party_for_cookies(),
459 cookie_line, *options, !allow)); 459 cookie_line, *options, !allow));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) 534 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
535 } 535 }
536 536
537 bool ChromeNetworkDelegate::OnCanEnablePrivacyMode( 537 bool ChromeNetworkDelegate::OnCanEnablePrivacyMode(
538 const GURL& url, 538 const GURL& url,
539 const GURL& first_party_for_cookies) const { 539 const GURL& first_party_for_cookies) const {
540 // nullptr during tests, or when we're running in the system context. 540 // nullptr during tests, or when we're running in the system context.
541 if (!cookie_settings_.get()) 541 if (!cookie_settings_.get())
542 return false; 542 return false;
543 543
544 bool reading_cookie_allowed = false; 544 return !cookie_settings_->IsCookieAccessAllowed(url, first_party_for_cookies);
545 bool setting_cookie_allowed = false;
546 cookie_settings_->GetReadingAndSettingCookieAllowed(
547 url, first_party_for_cookies, &reading_cookie_allowed,
548 &setting_cookie_allowed);
549 bool privacy_mode = !(reading_cookie_allowed && setting_cookie_allowed);
550 return privacy_mode;
551 } 545 }
552 546
553 bool ChromeNetworkDelegate::OnAreExperimentalCookieFeaturesEnabled() const { 547 bool ChromeNetworkDelegate::OnAreExperimentalCookieFeaturesEnabled() const {
554 return experimental_web_platform_features_enabled_; 548 return experimental_web_platform_features_enabled_;
555 } 549 }
556 550
557 bool ChromeNetworkDelegate::OnAreStrictSecureCookiesEnabled() const { 551 bool ChromeNetworkDelegate::OnAreStrictSecureCookiesEnabled() const {
558 const std::string enforce_strict_secure_group = 552 const std::string enforce_strict_secure_group =
559 base::FieldTrialList::FindFullName("StrictSecureCookies"); 553 base::FieldTrialList::FindFullName("StrictSecureCookies");
560 return experimental_web_platform_features_enabled_ || 554 return experimental_web_platform_features_enabled_ ||
(...skipping 15 matching lines...) Expand all
576 if (!data_use_aggregator_) 570 if (!data_use_aggregator_)
577 return; 571 return;
578 572
579 if (is_data_usage_off_the_record_) { 573 if (is_data_usage_off_the_record_) {
580 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); 574 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes);
581 return; 575 return;
582 } 576 }
583 577
584 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); 578 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes);
585 } 579 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698