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

Side by Side Diff: chrome/browser/content_settings/host_content_settings_map.cc

Issue 7713034: HostContentSettingsMap refactoring. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Code review comments. Threading fixes. Mac + win fixes. Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/content_settings/host_content_settings_map.h" 5 #include "chrome/browser/content_settings/host_content_settings_map.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/string_util.h"
11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/content_settings/content_settings_details.h" 10 #include "chrome/browser/content_settings/content_settings_details.h"
13 #include "chrome/browser/content_settings/content_settings_extension_provider.h" 11 #include "chrome/browser/content_settings/content_settings_extension_provider.h"
14 #include "chrome/browser/content_settings/content_settings_observable_provider.h " 12 #include "chrome/browser/content_settings/content_settings_observable_provider.h "
15 #include "chrome/browser/content_settings/content_settings_policy_provider.h" 13 #include "chrome/browser/content_settings/content_settings_policy_provider.h"
16 #include "chrome/browser/content_settings/content_settings_pref_provider.h" 14 #include "chrome/browser/content_settings/content_settings_pref_provider.h"
17 #include "chrome/browser/content_settings/content_settings_provider.h" 15 #include "chrome/browser/content_settings/content_settings_provider.h"
18 #include "chrome/browser/content_settings/content_settings_utils.h" 16 #include "chrome/browser/content_settings/content_settings_utils.h"
19 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
21 #include "chrome/browser/prefs/scoped_user_pref_update.h" 19 #include "chrome/browser/prefs/scoped_user_pref_update.h"
22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
24 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
26 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
27 #include "content/browser/browser_thread.h" 24 #include "content/browser/browser_thread.h"
28 #include "content/browser/user_metrics.h" 25 #include "content/browser/user_metrics.h"
29 #include "content/common/notification_service.h" 26 #include "content/common/notification_service.h"
30 #include "content/common/notification_source.h" 27 #include "content/common/notification_source.h"
31 #include "googleurl/src/gurl.h" 28 #include "googleurl/src/gurl.h"
32 #include "net/base/net_errors.h" 29 #include "net/base/net_errors.h"
33 #include "net/base/net_util.h" 30 #include "net/base/net_util.h"
34 #include "net/base/static_cookie_policy.h" 31 #include "net/base/static_cookie_policy.h"
35 32
36 namespace { 33 namespace {
37 34
38 // Returns true if we should allow all content types for this URL. This is
39 // true for various internal objects like chrome:// URLs, so UI and other
40 // things users think of as "not webpages" don't break.
41 static bool ShouldAllowAllContent(const GURL& url,
42 ContentSettingsType content_type) {
43 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
44 return false;
45 return url.SchemeIs(chrome::kChromeDevToolsScheme) ||
46 url.SchemeIs(chrome::kChromeInternalScheme) ||
47 url.SchemeIs(chrome::kChromeUIScheme) ||
48 url.SchemeIs(chrome::kExtensionScheme);
49 }
50
51 typedef linked_ptr<content_settings::DefaultProviderInterface> 35 typedef linked_ptr<content_settings::DefaultProviderInterface>
52 DefaultContentSettingsProviderPtr; 36 DefaultContentSettingsProviderPtr;
53 typedef std::vector<DefaultContentSettingsProviderPtr>::iterator 37 typedef std::vector<DefaultContentSettingsProviderPtr>::iterator
54 DefaultProviderIterator; 38 DefaultProviderIterator;
55 typedef std::vector<DefaultContentSettingsProviderPtr>::const_iterator 39 typedef std::vector<DefaultContentSettingsProviderPtr>::const_iterator
56 ConstDefaultProviderIterator; 40 ConstDefaultProviderIterator;
57 41
58 typedef linked_ptr<content_settings::ProviderInterface> ProviderPtr; 42 typedef linked_ptr<content_settings::ProviderInterface> ProviderPtr;
59 typedef std::vector<ProviderPtr>::iterator ProviderIterator; 43 typedef std::vector<ProviderPtr>::iterator ProviderIterator;
60 typedef std::vector<ProviderPtr>::const_iterator ConstProviderIterator; 44 typedef std::vector<ProviderPtr>::const_iterator ConstProviderIterator;
61 45
62 typedef content_settings::ProviderInterface::Rules Rules; 46 typedef content_settings::ProviderInterface::Rules Rules;
63 47
64 typedef std::pair<std::string, std::string> StringPair; 48 typedef std::pair<std::string, std::string> StringPair;
65 49
66 const char* kProviderNames[] = { 50 const char* kProviderNames[] = {
67 "policy", 51 "policy",
68 "extension", 52 "extension",
69 "preference" 53 "preference"
70 }; 54 };
71 55
72 } // namespace 56 } // namespace
73 57
74 HostContentSettingsMap::HostContentSettingsMap( 58 HostContentSettingsMap::HostContentSettingsMap(
75 PrefService* prefs, 59 PrefService* prefs,
76 ExtensionService* extension_service, 60 ExtensionService* extension_service,
77 bool incognito) 61 bool incognito)
78 : prefs_(prefs), 62 : prefs_(prefs),
79 is_off_the_record_(incognito), 63 is_off_the_record_(incognito) {
80 updating_preferences_(false),
81 block_third_party_cookies_(false),
82 is_block_third_party_cookies_managed_(false) {
83 // The order in which the default content settings providers are created is 64 // The order in which the default content settings providers are created is
84 // critical, as providers that are further down in the list (i.e. added later) 65 // critical, as providers that are further down in the list (i.e. added later)
85 // override providers further up. 66 // override providers further up.
86 content_settings::PrefDefaultProvider* default_provider = 67 content_settings::PrefDefaultProvider* default_provider =
87 new content_settings::PrefDefaultProvider(prefs_, is_off_the_record_); 68 new content_settings::PrefDefaultProvider(prefs_, is_off_the_record_);
88 default_provider->AddObserver(this); 69 default_provider->AddObserver(this);
89 default_content_settings_providers_.push_back( 70 default_content_settings_providers_.push_back(
90 make_linked_ptr(default_provider)); 71 make_linked_ptr(default_provider));
91 72
92 content_settings::PolicyDefaultProvider* policy_default_provider = 73 content_settings::PolicyDefaultProvider* policy_default_provider =
93 new content_settings::PolicyDefaultProvider(prefs_); 74 new content_settings::PolicyDefaultProvider(prefs_);
94 policy_default_provider->AddObserver(this); 75 policy_default_provider->AddObserver(this);
95 default_content_settings_providers_.push_back( 76 default_content_settings_providers_.push_back(
96 make_linked_ptr(policy_default_provider)); 77 make_linked_ptr(policy_default_provider));
97 78
98 // TODO(markusheintz): Discuss whether it is sensible to move migration code
99 // to PrefContentSettingsProvider.
100 MigrateObsoleteCookiePref();
101
102 // Read misc. global settings. 79 // Read misc. global settings.
103 block_third_party_cookies_ =
104 prefs_->GetBoolean(prefs::kBlockThirdPartyCookies);
105 if (block_third_party_cookies_) {
106 UserMetrics::RecordAction(
107 UserMetricsAction("ThirdPartyCookieBlockingEnabled"));
108 } else {
109 UserMetrics::RecordAction(
110 UserMetricsAction("ThirdPartyCookieBlockingDisabled"));
111 }
112 is_block_third_party_cookies_managed_ =
113 prefs_->IsManagedPreference(prefs::kBlockThirdPartyCookies);
114 80
115 // User defined non default content settings are provided by the PrefProvider. 81 // User defined non default content settings are provided by the PrefProvider.
116 // The order in which the content settings providers are created is critical, 82 // The order in which the content settings providers are created is critical,
117 // as providers that are further up in the list (i.e. added earlier) override 83 // as providers that are further up in the list (i.e. added earlier) override
118 // providers further down. 84 // providers further down.
119 content_settings::ObservableProvider* provider = 85 content_settings::ObservableProvider* provider =
120 new content_settings::PolicyProvider(prefs_, policy_default_provider); 86 new content_settings::PolicyProvider(prefs_, policy_default_provider);
121 provider->AddObserver(this); 87 provider->AddObserver(this);
122 content_settings_providers_.push_back(make_linked_ptr(provider)); 88 content_settings_providers_.push_back(make_linked_ptr(provider));
123 89
124 if (extension_service) { 90 if (extension_service) {
125 // |extension_service| can be NULL in unit tests. 91 // |extension_service| can be NULL in unit tests.
126 provider = new content_settings::ExtensionProvider( 92 provider = new content_settings::ExtensionProvider(
127 extension_service->GetExtensionContentSettingsStore(), 93 extension_service->GetExtensionContentSettingsStore(),
128 is_off_the_record_); 94 is_off_the_record_);
129 provider->AddObserver(this); 95 provider->AddObserver(this);
130 content_settings_providers_.push_back(make_linked_ptr(provider)); 96 content_settings_providers_.push_back(make_linked_ptr(provider));
131 } 97 }
132 provider = new content_settings::PrefProvider(prefs_, is_off_the_record_); 98 provider = new content_settings::PrefProvider(prefs_, is_off_the_record_);
133 provider->AddObserver(this); 99 provider->AddObserver(this);
134 content_settings_providers_.push_back(make_linked_ptr(provider)); 100 content_settings_providers_.push_back(make_linked_ptr(provider));
135
136 pref_change_registrar_.Init(prefs_);
137 pref_change_registrar_.Add(prefs::kBlockThirdPartyCookies, this);
138 } 101 }
139 102
140 // static 103 // static
141 void HostContentSettingsMap::RegisterUserPrefs(PrefService* prefs) { 104 void HostContentSettingsMap::RegisterUserPrefs(PrefService* prefs) {
142 prefs->RegisterBooleanPref(prefs::kBlockThirdPartyCookies, 105 prefs->RegisterBooleanPref(prefs::kBlockThirdPartyCookies,
143 false, 106 false,
144 PrefService::SYNCABLE_PREF); 107 PrefService::SYNCABLE_PREF);
145 prefs->RegisterIntegerPref(prefs::kContentSettingsWindowLastTabIndex, 108 prefs->RegisterIntegerPref(prefs::kContentSettingsWindowLastTabIndex,
146 0, 109 0,
147 PrefService::UNSYNCABLE_PREF); 110 PrefService::UNSYNCABLE_PREF);
(...skipping 28 matching lines...) Expand all
176 return setting; 139 return setting;
177 } 140 }
178 141
179 ContentSettings HostContentSettingsMap::GetDefaultContentSettings() const { 142 ContentSettings HostContentSettingsMap::GetDefaultContentSettings() const {
180 ContentSettings output(CONTENT_SETTING_DEFAULT); 143 ContentSettings output(CONTENT_SETTING_DEFAULT);
181 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) 144 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i)
182 output.settings[i] = GetDefaultContentSetting(ContentSettingsType(i)); 145 output.settings[i] = GetDefaultContentSetting(ContentSettingsType(i));
183 return output; 146 return output;
184 } 147 }
185 148
186 ContentSetting HostContentSettingsMap::GetCookieContentSetting(
187 const GURL& url,
188 const GURL& first_party_url,
189 bool setting_cookie) const {
190 if (ShouldAllowAllContent(first_party_url, CONTENT_SETTINGS_TYPE_COOKIES))
191 return CONTENT_SETTING_ALLOW;
192
193 // First get any host-specific settings.
194 ContentSetting setting = GetNonDefaultContentSetting(url,
195 first_party_url, CONTENT_SETTINGS_TYPE_COOKIES, "");
196
197 // If no explicit exception has been made and third-party cookies are blocked
198 // by default, apply that rule.
199 if (setting == CONTENT_SETTING_DEFAULT && BlockThirdPartyCookies()) {
200 bool strict = CommandLine::ForCurrentProcess()->HasSwitch(
201 switches::kBlockReadingThirdPartyCookies);
202 net::StaticCookiePolicy policy(strict ?
203 net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES :
204 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES);
205 int rv;
206 if (setting_cookie)
207 rv = policy.CanSetCookie(url, first_party_url);
208 else
209 rv = policy.CanGetCookies(url, first_party_url);
210 DCHECK_NE(net::ERR_IO_PENDING, rv);
211 if (rv != net::OK)
212 setting = CONTENT_SETTING_BLOCK;
213 }
214
215 // If no other policy has changed the setting, use the default.
216 if (setting == CONTENT_SETTING_DEFAULT)
217 setting = GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES);
218
219 return setting;
220 }
221
222 ContentSetting HostContentSettingsMap::GetContentSetting( 149 ContentSetting HostContentSettingsMap::GetContentSetting(
223 const GURL& primary_url, 150 const GURL& primary_url,
224 const GURL& secondary_url, 151 const GURL& secondary_url,
225 ContentSettingsType content_type, 152 ContentSettingsType content_type,
226 const std::string& resource_identifier) const { 153 const std::string& resource_identifier) const {
227 DCHECK_NE(CONTENT_SETTINGS_TYPE_COOKIES, content_type); 154 DCHECK_NE(CONTENT_SETTINGS_TYPE_COOKIES, content_type);
228 DCHECK_NE(content_settings::RequiresResourceIdentifier(content_type), 155 DCHECK_NE(content_settings::RequiresResourceIdentifier(content_type),
229 resource_identifier.empty()); 156 resource_identifier.empty());
230 return GetContentSettingInternal( 157 return GetContentSettingInternal(
231 primary_url, secondary_url, content_type, resource_identifier); 158 primary_url, secondary_url, content_type, resource_identifier);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 333
407 // static 334 // static
408 bool HostContentSettingsMap::IsSettingAllowedForType( 335 bool HostContentSettingsMap::IsSettingAllowedForType(
409 ContentSetting setting, ContentSettingsType content_type) { 336 ContentSetting setting, ContentSettingsType content_type) {
410 // Intents content settings are hidden behind a switch for now. 337 // Intents content settings are hidden behind a switch for now.
411 if (content_type == CONTENT_SETTINGS_TYPE_INTENTS && 338 if (content_type == CONTENT_SETTINGS_TYPE_INTENTS &&
412 !CommandLine::ForCurrentProcess()->HasSwitch( 339 !CommandLine::ForCurrentProcess()->HasSwitch(
413 switches::kEnableWebIntents)) 340 switches::kEnableWebIntents))
414 return false; 341 return false;
415 342
343 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES_SESSION_ONLY) {
344 return (setting == CONTENT_SETTING_DEFAULT ||
345 setting == CONTENT_SETTING_ALLOW ||
346 setting == CONTENT_SETTING_SESSION_ONLY);
347 }
348
416 // DEFAULT, ALLOW and BLOCK are always allowed. 349 // DEFAULT, ALLOW and BLOCK are always allowed.
417 if (setting == CONTENT_SETTING_DEFAULT || 350 if (setting == CONTENT_SETTING_DEFAULT ||
418 setting == CONTENT_SETTING_ALLOW || 351 setting == CONTENT_SETTING_ALLOW ||
419 setting == CONTENT_SETTING_BLOCK) { 352 setting == CONTENT_SETTING_BLOCK) {
420 return true; 353 return true;
421 } 354 }
422 switch (content_type) { 355 switch (content_type) {
423 case CONTENT_SETTINGS_TYPE_COOKIES:
424 return (setting == CONTENT_SETTING_SESSION_ONLY);
425 case CONTENT_SETTINGS_TYPE_PLUGINS: 356 case CONTENT_SETTINGS_TYPE_PLUGINS:
426 return (setting == CONTENT_SETTING_ASK && 357 return (setting == CONTENT_SETTING_ASK &&
427 CommandLine::ForCurrentProcess()->HasSwitch( 358 CommandLine::ForCurrentProcess()->HasSwitch(
428 switches::kEnableClickToPlay)); 359 switches::kEnableClickToPlay));
429 case CONTENT_SETTINGS_TYPE_GEOLOCATION: 360 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
430 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: 361 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
431 case CONTENT_SETTINGS_TYPE_INTENTS: 362 case CONTENT_SETTINGS_TYPE_INTENTS:
432 return (setting == CONTENT_SETTING_ASK); 363 return (setting == CONTENT_SETTING_ASK);
433 default: 364 default:
434 return false; 365 return false;
435 } 366 }
436 } 367 }
437 368
438 void HostContentSettingsMap::SetBlockThirdPartyCookies(bool block) {
439 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
440 DCHECK(prefs_);
441
442 // This setting may not be directly modified for OTR sessions. Instead, it
443 // is synced to the main profile's setting.
444 if (is_off_the_record_) {
445 NOTREACHED();
446 return;
447 }
448
449 // If the preference block-third-party-cookies is managed then do not allow to
450 // change it.
451 if (prefs_->IsManagedPreference(prefs::kBlockThirdPartyCookies)) {
452 NOTREACHED();
453 return;
454 }
455
456 {
457 base::AutoLock auto_lock(lock_);
458 block_third_party_cookies_ = block;
459 }
460
461 prefs_->SetBoolean(prefs::kBlockThirdPartyCookies, block);
462 }
463
464 void HostContentSettingsMap::OnContentSettingChanged( 369 void HostContentSettingsMap::OnContentSettingChanged(
465 ContentSettingsPattern primary_pattern, 370 ContentSettingsPattern primary_pattern,
466 ContentSettingsPattern secondary_pattern, 371 ContentSettingsPattern secondary_pattern,
467 ContentSettingsType content_type, 372 ContentSettingsType content_type,
468 std::string resource_identifier) { 373 std::string resource_identifier) {
469 const ContentSettingsDetails details(primary_pattern, 374 const ContentSettingsDetails details(primary_pattern,
470 secondary_pattern, 375 secondary_pattern,
471 content_type, 376 content_type,
472 resource_identifier); 377 resource_identifier);
473 NotificationService::current()->Notify( 378 NotificationService::current()->Notify(
474 chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED, 379 chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED,
475 Source<HostContentSettingsMap>(this), 380 Source<HostContentSettingsMap>(this),
476 Details<const ContentSettingsDetails>(&details)); 381 Details<const ContentSettingsDetails>(&details));
477 } 382 }
478 383
479 void HostContentSettingsMap::Observe(int type, 384 // static
480 const NotificationSource& source, 385 // Returns true if we should allow all content types for this URL. This is
481 const NotificationDetails& details) { 386 // true for various internal objects like chrome:// URLs, so UI and other
482 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 387 // things users think of as "not webpages" don't break.
483 388 bool HostContentSettingsMap::ShouldAllowAllContent(
484 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 389 const GURL& url,
485 DCHECK_EQ(prefs_, Source<PrefService>(source).ptr()); 390 ContentSettingsType content_type) {
486 if (updating_preferences_) 391 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
487 return; 392 return false;
488 393 return url.SchemeIs(chrome::kChromeDevToolsScheme) ||
489 std::string* name = Details<std::string>(details).ptr(); 394 url.SchemeIs(chrome::kChromeInternalScheme) ||
490 if (*name == prefs::kBlockThirdPartyCookies) { 395 url.SchemeIs(chrome::kChromeUIScheme) ||
491 base::AutoLock auto_lock(lock_); 396 url.SchemeIs(chrome::kExtensionScheme);
492 block_third_party_cookies_ = prefs_->GetBoolean(
493 prefs::kBlockThirdPartyCookies);
494 is_block_third_party_cookies_managed_ =
495 prefs_->IsManagedPreference(
496 prefs::kBlockThirdPartyCookies);
497 } else {
498 NOTREACHED() << "Unexpected preference observed";
499 return;
500 }
501 } else {
502 NOTREACHED() << "Unexpected notification";
503 }
504 } 397 }
505 398
506 HostContentSettingsMap::~HostContentSettingsMap() { 399 HostContentSettingsMap::~HostContentSettingsMap() {
507 DCHECK(!prefs_); 400 DCHECK(!prefs_);
508 } 401 }
509 402
510 bool HostContentSettingsMap::IsDefaultContentSettingManaged( 403 bool HostContentSettingsMap::IsDefaultContentSettingManaged(
511 ContentSettingsType content_type) const { 404 ContentSettingsType content_type) const {
512 for (ConstDefaultProviderIterator provider = 405 for (ConstDefaultProviderIterator provider =
513 default_content_settings_providers_.begin(); 406 default_content_settings_providers_.begin();
514 provider != default_content_settings_providers_.end(); ++provider) { 407 provider != default_content_settings_providers_.end(); ++provider) {
515 if ((*provider)->DefaultSettingIsManaged(content_type)) 408 if ((*provider)->DefaultSettingIsManaged(content_type))
516 return true; 409 return true;
517 } 410 }
518 return false; 411 return false;
519 } 412 }
520 413
521 void HostContentSettingsMap::ShutdownOnUIThread() { 414 void HostContentSettingsMap::ShutdownOnUIThread() {
522 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 415 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
523 DCHECK(prefs_); 416 DCHECK(prefs_);
524 pref_change_registrar_.RemoveAll(); 417
525 prefs_ = NULL; 418 prefs_ = NULL;
526 for (ProviderIterator it = content_settings_providers_.begin(); 419 for (ProviderIterator it = content_settings_providers_.begin();
527 it != content_settings_providers_.end(); 420 it != content_settings_providers_.end();
528 ++it) { 421 ++it) {
529 (*it)->ShutdownOnUIThread(); 422 (*it)->ShutdownOnUIThread();
530 } 423 }
531 for (DefaultProviderIterator it = default_content_settings_providers_.begin(); 424 for (DefaultProviderIterator it = default_content_settings_providers_.begin();
532 it != default_content_settings_providers_.end(); 425 it != default_content_settings_providers_.end();
533 ++it) { 426 ++it) {
534 (*it)->ShutdownOnUIThread(); 427 (*it)->ShutdownOnUIThread();
535 } 428 }
536 } 429 }
537
538 void HostContentSettingsMap::MigrateObsoleteCookiePref() {
539 if (prefs_->HasPrefPath(prefs::kCookieBehavior)) {
540 int cookie_behavior = prefs_->GetInteger(prefs::kCookieBehavior);
541 prefs_->ClearPref(prefs::kCookieBehavior);
542 if (!prefs_->HasPrefPath(prefs::kDefaultContentSettings)) {
543 SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES,
544 (cookie_behavior == net::StaticCookiePolicy::BLOCK_ALL_COOKIES) ?
545 CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW);
546 }
547 if (!prefs_->HasPrefPath(prefs::kBlockThirdPartyCookies)) {
548 SetBlockThirdPartyCookies(cookie_behavior ==
549 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES);
550 }
551 }
552 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698