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

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

Issue 8539004: Replace SetContentSetting method of the content_settings::Provider interface with GetWebsiteSetting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 1 month 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/content_settings_pref_provider.h" 5 #include "chrome/browser/content_settings/content_settings_pref_provider.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 144 }
145 145
146 pref_change_registrar_.Init(prefs_); 146 pref_change_registrar_.Init(prefs_);
147 pref_change_registrar_.Add(prefs::kContentSettingsPatterns, this); 147 pref_change_registrar_.Add(prefs::kContentSettingsPatterns, this);
148 pref_change_registrar_.Add(prefs::kContentSettingsPatternPairs, this); 148 pref_change_registrar_.Add(prefs::kContentSettingsPatternPairs, this);
149 pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this); 149 pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this);
150 pref_change_registrar_.Add(prefs::kDesktopNotificationAllowedOrigins, this); 150 pref_change_registrar_.Add(prefs::kDesktopNotificationAllowedOrigins, this);
151 pref_change_registrar_.Add(prefs::kDesktopNotificationDeniedOrigins, this); 151 pref_change_registrar_.Add(prefs::kDesktopNotificationDeniedOrigins, this);
152 } 152 }
153 153
154 void PrefProvider::SetContentSetting( 154 void PrefProvider::SetWebsiteSetting(
155 const ContentSettingsPattern& primary_pattern, 155 const ContentSettingsPattern& primary_pattern,
156 const ContentSettingsPattern& secondary_pattern, 156 const ContentSettingsPattern& secondary_pattern,
157 ContentSettingsType content_type, 157 ContentSettingsType content_type,
158 const ResourceIdentifier& resource_identifier, 158 const ResourceIdentifier& resource_identifier,
159 ContentSetting setting) { 159 const Value* value) {
160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
161 DCHECK(prefs_); 161 DCHECK(prefs_);
162 162
163 // Update in memory value map. 163 // Update in memory value map.
164 OriginIdentifierValueMap* map_to_modify = &incognito_value_map_; 164 OriginIdentifierValueMap* map_to_modify = &incognito_value_map_;
165 if (!is_incognito_) 165 if (!is_incognito_)
166 map_to_modify = &value_map_; 166 map_to_modify = &value_map_;
167 167
168 { 168 {
169 base::AutoLock auto_lock(lock_); 169 base::AutoLock auto_lock(lock_);
170 if (setting == CONTENT_SETTING_DEFAULT) { 170 if (value == NULL) {
171 map_to_modify->DeleteValue( 171 map_to_modify->DeleteValue(
172 primary_pattern, 172 primary_pattern,
173 secondary_pattern, 173 secondary_pattern,
174 content_type, 174 content_type,
175 resource_identifier); 175 resource_identifier);
176 } else { 176 } else {
177 map_to_modify->SetValue( 177 map_to_modify->SetValue(
178 primary_pattern, 178 primary_pattern,
179 secondary_pattern, 179 secondary_pattern,
180 content_type, 180 content_type,
181 resource_identifier, 181 resource_identifier,
182 Value::CreateIntegerValue(setting)); 182 value->DeepCopy());
183 } 183 }
184 } 184 }
185 // Update the content settings preference. 185 // Update the content settings preference.
186 if (!is_incognito_) { 186 if (!is_incognito_) {
187 UpdatePref(primary_pattern, 187 UpdatePref(primary_pattern,
188 secondary_pattern, 188 secondary_pattern,
189 content_type, 189 content_type,
190 resource_identifier, 190 resource_identifier,
191 setting); 191 value);
192 prefs_->ScheduleSavePersistentPrefs(); 192 prefs_->ScheduleSavePersistentPrefs();
193 } 193 }
194 194
195 NotifyObservers( 195 NotifyObservers(
196 primary_pattern, secondary_pattern, content_type, resource_identifier); 196 primary_pattern, secondary_pattern, content_type, resource_identifier);
197 } 197 }
198 198
199 void PrefProvider::ClearAllContentSettingsRules( 199 void PrefProvider::ClearAllContentSettingsRules(
200 ContentSettingsType content_type) { 200 ContentSettingsType content_type) {
201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 16 matching lines...) Expand all
218 prefs_->ScheduleSavePersistentPrefs(); 218 prefs_->ScheduleSavePersistentPrefs();
219 } 219 }
220 220
221 for (std::vector<Rule>::const_iterator it = rules_to_delete.begin(); 221 for (std::vector<Rule>::const_iterator it = rules_to_delete.begin();
222 it != rules_to_delete.end(); ++it) { 222 it != rules_to_delete.end(); ++it) {
223 UpdatePref( 223 UpdatePref(
224 it->primary_pattern, 224 it->primary_pattern,
225 it->secondary_pattern, 225 it->secondary_pattern,
226 content_type, 226 content_type,
227 "", 227 "",
228 CONTENT_SETTING_DEFAULT); 228 NULL);
229 } 229 }
230 NotifyObservers(ContentSettingsPattern(), 230 NotifyObservers(ContentSettingsPattern(),
231 ContentSettingsPattern(), 231 ContentSettingsPattern(),
232 content_type, 232 content_type,
233 std::string()); 233 std::string());
234 } 234 }
235 235
236 void PrefProvider::Observe( 236 void PrefProvider::Observe(
237 int type, 237 int type,
238 const content::NotificationSource& source, 238 const content::NotificationSource& source,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } 290 }
291 291
292 // //////////////////////////////////////////////////////////////////////////// 292 // ////////////////////////////////////////////////////////////////////////////
293 // Private 293 // Private
294 294
295 void PrefProvider::UpdatePref( 295 void PrefProvider::UpdatePref(
296 const ContentSettingsPattern& primary_pattern, 296 const ContentSettingsPattern& primary_pattern,
297 const ContentSettingsPattern& secondary_pattern, 297 const ContentSettingsPattern& secondary_pattern,
298 ContentSettingsType content_type, 298 ContentSettingsType content_type,
299 const ResourceIdentifier& resource_identifier, 299 const ResourceIdentifier& resource_identifier,
300 ContentSetting setting) { 300 const base::Value* value) {
301 // Ensure that |lock_| is not held by this thread, since this function will 301 // Ensure that |lock_| is not held by this thread, since this function will
302 // send out notifications (by |~DictionaryPrefUpdate|). 302 // send out notifications (by |~DictionaryPrefUpdate|).
303 AssertLockNotHeld(); 303 AssertLockNotHeld();
304 304
305 AutoReset<bool> auto_reset(&updating_preferences_, true); 305 AutoReset<bool> auto_reset(&updating_preferences_, true);
306 { 306 {
307 DictionaryPrefUpdate update(prefs_, 307 DictionaryPrefUpdate update(prefs_,
308 prefs::kContentSettingsPatternPairs); 308 prefs::kContentSettingsPatternPairs);
309 DictionaryValue* pattern_pairs_settings = update.Get(); 309 DictionaryValue* pattern_pairs_settings = update.Get();
310 UpdatePatternPairsSettings(primary_pattern, 310 UpdatePatternPairsSettings(primary_pattern,
311 secondary_pattern, 311 secondary_pattern,
312 content_type, 312 content_type,
313 resource_identifier, 313 resource_identifier,
314 setting, 314 value,
315 pattern_pairs_settings); 315 pattern_pairs_settings);
316 } 316 }
317 if (content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION && 317 if (content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION &&
318 content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { 318 content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
319 UpdateObsoletePatternsPref(primary_pattern, 319 UpdateObsoletePatternsPref(primary_pattern,
320 secondary_pattern, 320 secondary_pattern,
321 content_type, 321 content_type,
322 resource_identifier, 322 resource_identifier,
323 setting); 323 ValueToContentSetting(value));
324 } else if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { 324 } else if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
325 UpdateObsoleteGeolocationPref(primary_pattern, secondary_pattern, setting); 325 UpdateObsoleteGeolocationPref(
326 primary_pattern,
327 secondary_pattern,
328 ValueToContentSetting(value));
326 } else if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { 329 } else if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
327 ListPrefUpdate update_allowed_sites( 330 ListPrefUpdate update_allowed_sites(
328 prefs_, prefs::kDesktopNotificationAllowedOrigins); 331 prefs_, prefs::kDesktopNotificationAllowedOrigins);
329 ListPrefUpdate update_denied_sites( 332 ListPrefUpdate update_denied_sites(
330 prefs_, prefs::kDesktopNotificationDeniedOrigins); 333 prefs_, prefs::kDesktopNotificationDeniedOrigins);
331 UpdateObsoleteNotificationsSettings(primary_pattern, 334 UpdateObsoleteNotificationsSettings(primary_pattern,
332 secondary_pattern, 335 secondary_pattern,
333 setting, 336 ValueToContentSetting(value),
334 update_allowed_sites.Get(), 337 update_allowed_sites.Get(),
335 update_denied_sites.Get()); 338 update_denied_sites.Get());
336 } 339 }
337 } 340 }
338 341
339 void PrefProvider::ReadContentSettingsFromPref(bool overwrite) { 342 void PrefProvider::ReadContentSettingsFromPref(bool overwrite) {
340 // |DictionaryPrefUpdate| sends out notifications when destructed. This 343 // |DictionaryPrefUpdate| sends out notifications when destructed. This
341 // construction order ensures |AutoLock| gets destroyed first and |lock_| is 344 // construction order ensures |AutoLock| gets destroyed first and |lock_| is
342 // not held when the notifications are sent. Also, |auto_reset| must be still 345 // not held when the notifications are sent. Also, |auto_reset| must be still
343 // valid when the notifications are sent, so that |Observe| skips the 346 // valid when the notifications are sent, so that |Observe| skips the
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 } 503 }
501 } 504 }
502 } 505 }
503 } 506 }
504 507
505 void PrefProvider::UpdatePatternPairsSettings( 508 void PrefProvider::UpdatePatternPairsSettings(
506 const ContentSettingsPattern& primary_pattern, 509 const ContentSettingsPattern& primary_pattern,
507 const ContentSettingsPattern& secondary_pattern, 510 const ContentSettingsPattern& secondary_pattern,
508 ContentSettingsType content_type, 511 ContentSettingsType content_type,
509 const ResourceIdentifier& resource_identifier, 512 const ResourceIdentifier& resource_identifier,
510 ContentSetting setting, 513 const base::Value* value,
511 DictionaryValue* pattern_pairs_settings) { 514 DictionaryValue* pattern_pairs_settings) {
512 // Get settings dictionary for the given patterns. 515 // Get settings dictionary for the given patterns.
513 std::string pattern_str(CreatePatternString(primary_pattern, 516 std::string pattern_str(CreatePatternString(primary_pattern,
514 secondary_pattern)); 517 secondary_pattern));
515 DictionaryValue* settings_dictionary = NULL; 518 DictionaryValue* settings_dictionary = NULL;
516 bool found = pattern_pairs_settings->GetDictionaryWithoutPathExpansion( 519 bool found = pattern_pairs_settings->GetDictionaryWithoutPathExpansion(
517 pattern_str, &settings_dictionary); 520 pattern_str, &settings_dictionary);
518 521
519 if (!found && (setting != CONTENT_SETTING_DEFAULT)) { 522 if (!found && (value != NULL)) {
Bernhard Bauer 2011/11/11 14:00:40 Nit: the |!= NULL| is unnecessary.
markusheintz_ 2011/11/14 11:15:10 Done.
520 settings_dictionary = new DictionaryValue; 523 settings_dictionary = new DictionaryValue;
521 pattern_pairs_settings->SetWithoutPathExpansion( 524 pattern_pairs_settings->SetWithoutPathExpansion(
522 pattern_str, settings_dictionary); 525 pattern_str, settings_dictionary);
523 } 526 }
524 527
525 if (settings_dictionary) { 528 if (settings_dictionary) {
526 std::string res_dictionary_path; 529 std::string res_dictionary_path;
527 if (GetResourceTypeName(content_type, &res_dictionary_path)) { 530 if (GetResourceTypeName(content_type, &res_dictionary_path)) {
528 DictionaryValue* resource_dictionary = NULL; 531 DictionaryValue* resource_dictionary = NULL;
529 found = settings_dictionary->GetDictionary( 532 found = settings_dictionary->GetDictionary(
530 res_dictionary_path, &resource_dictionary); 533 res_dictionary_path, &resource_dictionary);
531 if (!found) { 534 if (!found) {
532 if (setting == CONTENT_SETTING_DEFAULT) 535 if (value == NULL)
533 return; // Nothing to remove. Exit early. 536 return; // Nothing to remove. Exit early.
534 resource_dictionary = new DictionaryValue; 537 resource_dictionary = new DictionaryValue;
535 settings_dictionary->Set(res_dictionary_path, resource_dictionary); 538 settings_dictionary->Set(res_dictionary_path, resource_dictionary);
536 } 539 }
537 // Update resource dictionary. 540 // Update resource dictionary.
538 if (setting == CONTENT_SETTING_DEFAULT) { 541 if (value == NULL) {
539 resource_dictionary->RemoveWithoutPathExpansion(resource_identifier, 542 resource_dictionary->RemoveWithoutPathExpansion(resource_identifier,
540 NULL); 543 NULL);
541 if (resource_dictionary->empty()) { 544 if (resource_dictionary->empty()) {
542 settings_dictionary->RemoveWithoutPathExpansion( 545 settings_dictionary->RemoveWithoutPathExpansion(
543 res_dictionary_path, NULL); 546 res_dictionary_path, NULL);
544 } 547 }
545 } else { 548 } else {
546 resource_dictionary->SetWithoutPathExpansion( 549 resource_dictionary->SetWithoutPathExpansion(
547 resource_identifier, Value::CreateIntegerValue(setting)); 550 resource_identifier, value->DeepCopy());
548 } 551 }
549 } else { 552 } else {
550 // Update settings dictionary. 553 // Update settings dictionary.
551 std::string setting_path = GetTypeName(content_type); 554 std::string setting_path = GetTypeName(content_type);
552 if (setting == CONTENT_SETTING_DEFAULT) { 555 if (value == NULL) {
553 settings_dictionary->RemoveWithoutPathExpansion(setting_path, 556 settings_dictionary->RemoveWithoutPathExpansion(setting_path,
554 NULL); 557 NULL);
555 } else { 558 } else {
556 settings_dictionary->SetWithoutPathExpansion( 559 settings_dictionary->SetWithoutPathExpansion(
557 setting_path, Value::CreateIntegerValue(setting)); 560 setting_path, value->DeepCopy());
558 } 561 }
559 } 562 }
560 // Remove the settings dictionary if it is empty. 563 // Remove the settings dictionary if it is empty.
561 if (settings_dictionary->empty()) { 564 if (settings_dictionary->empty()) {
562 pattern_pairs_settings->RemoveWithoutPathExpansion( 565 pattern_pairs_settings->RemoveWithoutPathExpansion(
563 pattern_str, NULL); 566 pattern_str, NULL);
564 } 567 }
565 } 568 }
566 } 569 }
567 570
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 ContentSettingsType content_type = static_cast<ContentSettingsType>(i); 718 ContentSettingsType content_type = static_cast<ContentSettingsType>(i);
716 719
717 int setting_int_value = CONTENT_SETTING_DEFAULT; 720 int setting_int_value = CONTENT_SETTING_DEFAULT;
718 if (host_settings_dictionary->GetIntegerWithoutPathExpansion( 721 if (host_settings_dictionary->GetIntegerWithoutPathExpansion(
719 GetTypeName(content_type), &setting_int_value)) { 722 GetTypeName(content_type), &setting_int_value)) {
720 ContentSetting setting = IntToContentSetting(setting_int_value); 723 ContentSetting setting = IntToContentSetting(setting_int_value);
721 724
722 setting = FixObsoleteCookiePromptMode(content_type, setting); 725 setting = FixObsoleteCookiePromptMode(content_type, setting);
723 setting = ClickToPlayFixup(content_type, setting); 726 setting = ClickToPlayFixup(content_type, setting);
724 727
725 // TODO(markusheintz): Maybe this check can be removed. 728 scoped_ptr<base::Value> value(Value::CreateIntegerValue(setting));
726 if (setting != CONTENT_SETTING_DEFAULT) { 729 if (setting != CONTENT_SETTING_DEFAULT) {
727 SetContentSetting( 730 SetWebsiteSetting(
728 pattern, 731 pattern,
729 pattern, 732 pattern,
730 content_type, 733 content_type,
731 "", 734 "",
732 setting); 735 value.get());
733 } 736 }
734 } 737 }
735 } 738 }
736 } 739 }
737 prefs_->ClearPref(prefs::kPerHostContentSettings); 740 prefs_->ClearPref(prefs::kPerHostContentSettings);
738 } 741 }
739 } 742 }
740 743
741 void PrefProvider::MigrateObsoletePopupsPref() { 744 void PrefProvider::MigrateObsoletePopupsPref() {
742 if (prefs_->HasPrefPath(prefs::kPopupWhitelistedHosts)) { 745 if (prefs_->HasPrefPath(prefs::kPopupWhitelistedHosts)) {
743 const ListValue* whitelist_pref = 746 const ListValue* whitelist_pref =
744 prefs_->GetList(prefs::kPopupWhitelistedHosts); 747 prefs_->GetList(prefs::kPopupWhitelistedHosts);
745 for (ListValue::const_iterator i(whitelist_pref->begin()); 748 for (ListValue::const_iterator i(whitelist_pref->begin());
746 i != whitelist_pref->end(); ++i) { 749 i != whitelist_pref->end(); ++i) {
747 std::string host; 750 std::string host;
748 (*i)->GetAsString(&host); 751 (*i)->GetAsString(&host);
749 SetContentSetting(ContentSettingsPattern::FromString(host), 752 scoped_ptr<base::Value> value(Value::CreateIntegerValue(
753 CONTENT_SETTING_ALLOW));
754 SetWebsiteSetting(ContentSettingsPattern::FromString(host),
750 ContentSettingsPattern::FromString(host), 755 ContentSettingsPattern::FromString(host),
751 CONTENT_SETTINGS_TYPE_POPUPS, 756 CONTENT_SETTINGS_TYPE_POPUPS,
752 "", 757 "",
753 CONTENT_SETTING_ALLOW); 758 value.get());
754 } 759 }
755 prefs_->ClearPref(prefs::kPopupWhitelistedHosts); 760 prefs_->ClearPref(prefs::kPopupWhitelistedHosts);
756 } 761 }
757 } 762 }
758 763
759 void PrefProvider::MigrateObsoleteContentSettingsPatternPref() { 764 void PrefProvider::MigrateObsoleteContentSettingsPatternPref() {
760 // Ensure that |lock_| is not held by this thread, since this function will 765 // Ensure that |lock_| is not held by this thread, since this function will
761 // send out notifications (by |~DictionaryPrefUpdate|). 766 // send out notifications (by |~DictionaryPrefUpdate|).
762 AssertLockNotHeld(); 767 AssertLockNotHeld();
763 768
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 DCHECK(found); 929 DCHECK(found);
925 930
926 for (DictionaryValue::key_iterator j = 931 for (DictionaryValue::key_iterator j =
927 requesting_origin_settings->begin_keys(); 932 requesting_origin_settings->begin_keys();
928 j != requesting_origin_settings->end_keys(); 933 j != requesting_origin_settings->end_keys();
929 ++j) { 934 ++j) {
930 const std::string& secondary_key(*j); 935 const std::string& secondary_key(*j);
931 GURL secondary_url(secondary_key); 936 GURL secondary_url(secondary_key);
932 DCHECK(secondary_url.is_valid()); 937 DCHECK(secondary_url.is_valid());
933 938
934 int setting_value; 939 base::Value* value = NULL;
935 found = requesting_origin_settings->GetIntegerWithoutPathExpansion( 940 found = requesting_origin_settings->GetWithoutPathExpansion(
936 secondary_key, &setting_value); 941 secondary_key, &value);
937 DCHECK(found); 942 DCHECK(found);
938 943
939 ContentSettingsPattern primary_pattern = 944 ContentSettingsPattern primary_pattern =
940 ContentSettingsPattern::FromURLNoWildcard(primary_url); 945 ContentSettingsPattern::FromURLNoWildcard(primary_url);
941 ContentSettingsPattern secondary_pattern = 946 ContentSettingsPattern secondary_pattern =
942 ContentSettingsPattern::FromURLNoWildcard(secondary_url); 947 ContentSettingsPattern::FromURLNoWildcard(secondary_url);
943 DCHECK(primary_pattern.IsValid() && secondary_pattern.IsValid()); 948 DCHECK(primary_pattern.IsValid() && secondary_pattern.IsValid());
944 949
945 UpdatePatternPairsSettings(primary_pattern, 950 UpdatePatternPairsSettings(primary_pattern,
946 secondary_pattern, 951 secondary_pattern,
947 CONTENT_SETTINGS_TYPE_GEOLOCATION, 952 CONTENT_SETTINGS_TYPE_GEOLOCATION,
948 std::string(), 953 std::string(),
949 IntToContentSetting(setting_value), 954 value,
950 pattern_pairs_settings); 955 pattern_pairs_settings);
951 } 956 }
952 } 957 }
953 } 958 }
954 959
955 void PrefProvider::MigrateObsoleteNotificationsPrefs() { 960 void PrefProvider::MigrateObsoleteNotificationsPrefs() {
956 // Ensure that |lock_| is not held by this thread, since this function will 961 // Ensure that |lock_| is not held by this thread, since this function will
957 // send out notifications (by |~DictionaryPrefUpdate|). 962 // send out notifications (by |~DictionaryPrefUpdate|).
958 AssertLockNotHeld(); 963 AssertLockNotHeld();
959 964
960 // The notifications settings in the preferences 965 // The notifications settings in the preferences
961 // prefs::kContentSettingsPatternPairs do not contain the latest 966 // prefs::kContentSettingsPatternPairs do not contain the latest
962 // notifications settings. So all notification settings are cleared and 967 // notifications settings. So all notification settings are cleared and
963 // migrated from the obsolete preferences for notifications settings that 968 // migrated from the obsolete preferences for notifications settings that
964 // contain the latest settings. 969 // contain the latest settings.
965 DictionaryPrefUpdate update(prefs_, prefs::kContentSettingsPatternPairs); 970 DictionaryPrefUpdate update(prefs_, prefs::kContentSettingsPatternPairs);
966 DictionaryValue* pattern_pairs_settings = update.Get(); 971 DictionaryValue* pattern_pairs_settings = update.Get();
967 ClearSettings(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, pattern_pairs_settings); 972 ClearSettings(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, pattern_pairs_settings);
968 973
969 const ListValue* allowed_origins = 974 const ListValue* allowed_origins =
970 prefs_->GetList(prefs::kDesktopNotificationAllowedOrigins); 975 prefs_->GetList(prefs::kDesktopNotificationAllowedOrigins);
971 for (size_t i = 0; i < allowed_origins->GetSize(); ++i) { 976 for (size_t i = 0; i < allowed_origins->GetSize(); ++i) {
972 std::string url_string; 977 std::string url_string;
973 bool status = allowed_origins->GetString(i, &url_string); 978 bool status = allowed_origins->GetString(i, &url_string);
974 DCHECK(status); 979 DCHECK(status);
975 ContentSettingsPattern primary_pattern = 980 ContentSettingsPattern primary_pattern =
976 ContentSettingsPattern::FromURLNoWildcard(GURL(url_string)); 981 ContentSettingsPattern::FromURLNoWildcard(GURL(url_string));
977 DCHECK(primary_pattern.IsValid()); 982 DCHECK(primary_pattern.IsValid());
983 scoped_ptr<base::Value> value(
984 Value::CreateIntegerValue(CONTENT_SETTING_ALLOW));
978 UpdatePatternPairsSettings(primary_pattern, 985 UpdatePatternPairsSettings(primary_pattern,
979 ContentSettingsPattern::Wildcard(), 986 ContentSettingsPattern::Wildcard(),
980 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 987 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
981 std::string(), 988 std::string(),
982 CONTENT_SETTING_ALLOW, 989 value.get(),
983 pattern_pairs_settings); 990 pattern_pairs_settings);
984 } 991 }
985 992
986 const ListValue* denied_origins = 993 const ListValue* denied_origins =
987 prefs_->GetList(prefs::kDesktopNotificationDeniedOrigins); 994 prefs_->GetList(prefs::kDesktopNotificationDeniedOrigins);
988 for (size_t i = 0; i < denied_origins->GetSize(); ++i) { 995 for (size_t i = 0; i < denied_origins->GetSize(); ++i) {
989 std::string url_string; 996 std::string url_string;
990 bool status = denied_origins->GetString(i, &url_string); 997 bool status = denied_origins->GetString(i, &url_string);
991 DCHECK(status); 998 DCHECK(status);
992 ContentSettingsPattern primary_pattern = 999 ContentSettingsPattern primary_pattern =
993 ContentSettingsPattern::FromURLNoWildcard(GURL(url_string)); 1000 ContentSettingsPattern::FromURLNoWildcard(GURL(url_string));
994 DCHECK(primary_pattern.IsValid()); 1001 DCHECK(primary_pattern.IsValid());
1002 scoped_ptr<base::Value> value(
1003 Value::CreateIntegerValue(CONTENT_SETTING_BLOCK));
995 UpdatePatternPairsSettings(primary_pattern, 1004 UpdatePatternPairsSettings(primary_pattern,
996 ContentSettingsPattern::Wildcard(), 1005 ContentSettingsPattern::Wildcard(),
997 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 1006 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
998 std::string(), 1007 std::string(),
999 CONTENT_SETTING_BLOCK, 1008 value.get(),
1000 pattern_pairs_settings); 1009 pattern_pairs_settings);
1001 } 1010 }
1002 } 1011 }
1003 1012
1004 void PrefProvider::SyncObsoletePrefs() { 1013 void PrefProvider::SyncObsoletePrefs() {
1005 // Ensure that |lock_| is not held by this thread, since this function will 1014 // Ensure that |lock_| is not held by this thread, since this function will
1006 // send out notifications (by |~DictionaryPrefUpdate|). 1015 // send out notifications (by |~DictionaryPrefUpdate|).
1007 AssertLockNotHeld(); 1016 AssertLockNotHeld();
1008 1017
1009 DCHECK(prefs_); 1018 DCHECK(prefs_);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 1068
1060 void PrefProvider::AssertLockNotHeld() const { 1069 void PrefProvider::AssertLockNotHeld() const {
1061 #if !defined(NDEBUG) 1070 #if !defined(NDEBUG)
1062 // |Lock::Acquire()| will assert if the lock is held by this thread. 1071 // |Lock::Acquire()| will assert if the lock is held by this thread.
1063 lock_.Acquire(); 1072 lock_.Acquire();
1064 lock_.Release(); 1073 lock_.Release();
1065 #endif 1074 #endif
1066 } 1075 }
1067 1076
1068 } // namespace content_settings 1077 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698