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

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

Issue 6823076: Fix functional tests notifications.NotificationsTest(s) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 8 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
« no previous file with comments | « no previous file | chrome/test/functional/notifications.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 resource_type_names_incorrect_size); 42 resource_type_names_incorrect_size);
43 43
44 // The default setting for each content type. 44 // The default setting for each content type.
45 const ContentSetting kDefaultSettings[] = { 45 const ContentSetting kDefaultSettings[] = {
46 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_COOKIES 46 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_COOKIES
47 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_IMAGES 47 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_IMAGES
48 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_JAVASCRIPT 48 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_JAVASCRIPT
49 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_PLUGINS 49 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_PLUGINS
50 CONTENT_SETTING_BLOCK, // CONTENT_SETTINGS_TYPE_POPUPS 50 CONTENT_SETTING_BLOCK, // CONTENT_SETTINGS_TYPE_POPUPS
51 CONTENT_SETTING_ASK, // Not used for Geolocation 51 CONTENT_SETTING_ASK, // Not used for Geolocation
52 CONTENT_SETTING_ASK, // Not used for Notifications 52 CONTENT_SETTING_ASK, // CONTENT_SETTINGS_TYPE_NOTIFICATIONS
53 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_PRERENDER 53 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_PRERENDER
54 }; 54 };
55 COMPILE_ASSERT(arraysize(kDefaultSettings) == CONTENT_SETTINGS_NUM_TYPES, 55 COMPILE_ASSERT(arraysize(kDefaultSettings) == CONTENT_SETTINGS_NUM_TYPES,
56 default_settings_incorrect_size); 56 default_settings_incorrect_size);
57 57
58 // The names of the ContentSettingsType values, for use with dictionary prefs. 58 // The names of the ContentSettingsType values, for use with dictionary prefs.
59 const char* kTypeNames[] = { 59 const char* kTypeNames[] = {
60 "cookies", 60 "cookies",
61 "images", 61 "images",
62 "javascript", 62 "javascript",
63 "plugins", 63 "plugins",
64 "popups", 64 "popups",
65 NULL, // Not used for Geolocation 65 NULL, // Not used for Geolocation
66 // TODO(markusheintz): Refactoring in progress. Content settings exceptions 66 // TODO(markusheintz): Refactoring in progress. Content settings exceptions
67 // for notifications will be added next. 67 // for notifications will be added next.
68 "notifications", // Only used for default Notifications settings. 68 "notifications", // Only used for default Notifications settings.
69 NULL, // Not used for Prerender 69 NULL, // Not used for Prerender
70 }; 70 };
71 COMPILE_ASSERT(arraysize(kTypeNames) == CONTENT_SETTINGS_NUM_TYPES, 71 COMPILE_ASSERT(arraysize(kTypeNames) == CONTENT_SETTINGS_NUM_TYPES,
72 type_names_incorrect_size); 72 type_names_incorrect_size);
73 73
74 void SetDefaultContentSettings(DictionaryValue* default_settings) {
75 default_settings->Clear();
76
77 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
78 if (kTypeNames[i] != NULL) {
79 default_settings->SetInteger(std::string(kTypeNames[i]),
kkania 2011/04/12 16:42:42 remove std::string
markusheintz_ 2011/04/12 17:21:49 Done.
80 kDefaultSettings[i]);
81 }
82 }
83 }
84
74 } // namespace 85 } // namespace
75 86
76 namespace content_settings { 87 namespace content_settings {
77 88
78 PrefDefaultProvider::PrefDefaultProvider(Profile* profile) 89 PrefDefaultProvider::PrefDefaultProvider(Profile* profile)
79 : profile_(profile), 90 : profile_(profile),
80 is_incognito_(profile_->IsOffTheRecord()), 91 is_incognito_(profile_->IsOffTheRecord()),
81 updating_preferences_(false) { 92 updating_preferences_(false) {
82 initializing_ = true; 93 initializing_ = true;
83 PrefService* prefs = profile->GetPrefs(); 94 PrefService* prefs = profile->GetPrefs();
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 if (prefs->HasPrefPath(prefs::kDesktopNotificationDefaultContentSetting)) { 288 if (prefs->HasPrefPath(prefs::kDesktopNotificationDefaultContentSetting)) {
278 ContentSetting setting = IntToContentSetting( 289 ContentSetting setting = IntToContentSetting(
279 prefs->GetInteger(prefs::kDesktopNotificationDefaultContentSetting)); 290 prefs->GetInteger(prefs::kDesktopNotificationDefaultContentSetting));
280 UpdateDefaultSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, setting); 291 UpdateDefaultSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, setting);
281 prefs->ClearPref(prefs::kDesktopNotificationDefaultContentSetting); 292 prefs->ClearPref(prefs::kDesktopNotificationDefaultContentSetting);
282 } 293 }
283 } 294 }
284 295
285 // static 296 // static
286 void PrefDefaultProvider::RegisterUserPrefs(PrefService* prefs) { 297 void PrefDefaultProvider::RegisterUserPrefs(PrefService* prefs) {
287 prefs->RegisterDictionaryPref(prefs::kDefaultContentSettings); 298 // If no default values are set explicitely for the
299 // prefs::kDefaultContentSettings preference an empty dictionary will be used
300 // as default value instead. This has some issues. For example pyauto tests
301 // can't get the default values for content settings as the default value of
302 // the preference prefs::kDefaultContentSettings is an empty dictionary. To
303 // prevent that functional tests need to know the default content settings
304 // expliciatly we set them here.
kkania 2011/04/12 16:42:42 this comment is a bit wordy yet confusing; part of
markusheintz_ 2011/04/12 17:21:49 Done.
305 // TODO(markusheintz): Write pyauto hooks for the content settings map, as the
306 // content settings map should be used as exclusive source for content
307 // settings.
308 DictionaryValue* default_content_settings = new DictionaryValue();
309 SetDefaultContentSettings(default_content_settings);
310 prefs->RegisterDictionaryPref(prefs::kDefaultContentSettings,
311 default_content_settings);
288 312
289 // Obsolete prefs, for migrations: 313 // Obsolete prefs, for migrations:
290 prefs->RegisterIntegerPref( 314 prefs->RegisterIntegerPref(
291 prefs::kDesktopNotificationDefaultContentSetting, 315 prefs::kDesktopNotificationDefaultContentSetting,
292 kDefaultSettings[CONTENT_SETTINGS_TYPE_NOTIFICATIONS]); 316 kDefaultSettings[CONTENT_SETTINGS_TYPE_NOTIFICATIONS]);
293 } 317 }
294 318
295 // //////////////////////////////////////////////////////////////////////////// 319 // ////////////////////////////////////////////////////////////////////////////
296 // PrefProvider: 320 // PrefProvider:
297 // 321 //
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 ContentSettingsPattern(host), 822 ContentSettingsPattern(host),
799 CONTENT_SETTINGS_TYPE_POPUPS, 823 CONTENT_SETTINGS_TYPE_POPUPS,
800 "", 824 "",
801 CONTENT_SETTING_ALLOW); 825 CONTENT_SETTING_ALLOW);
802 } 826 }
803 prefs->ClearPref(prefs::kPopupWhitelistedHosts); 827 prefs->ClearPref(prefs::kPopupWhitelistedHosts);
804 } 828 }
805 } 829 }
806 830
807 } // namespace content_settings 831 } // namespace content_settings
OLDNEW
« no previous file with comments | « no previous file | chrome/test/functional/notifications.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698