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

Side by Side Diff: chrome/browser/extensions/extension_prefs.cc

Issue 8399022: Add a couple of notifications related settings to app/extensions sync: (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/extensions/extension_prefs.h" 5 #include "chrome/browser/extensions/extension_prefs.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/extension_pref_store.h" 10 #include "chrome/browser/extensions/extension_pref_store.h"
(...skipping 27 matching lines...) Expand all
38 38
39 // The dictionary containing the extension's manifest. 39 // The dictionary containing the extension's manifest.
40 const char kPrefManifest[] = "manifest"; 40 const char kPrefManifest[] = "manifest";
41 41
42 // The version number. 42 // The version number.
43 const char kPrefVersion[] = "manifest.version"; 43 const char kPrefVersion[] = "manifest.version";
44 44
45 // Indicates whether an extension is blacklisted. 45 // Indicates whether an extension is blacklisted.
46 const char kPrefBlacklist[] = "blacklist"; 46 const char kPrefBlacklist[] = "blacklist";
47 47
48 // Indicates whether the user has done app notifications setup or not.
49 const char kPrefAppNotificationSetup[] = "app_notif_setup";
50
51 // Indicates whether the user has disabled notifications or not.
52 const char kPrefAppNotificationDisbaled[] = "app_notif_disabled";
53
48 // Indicates whether the user has acknowledged various types of extensions. 54 // Indicates whether the user has acknowledged various types of extensions.
49 const char kPrefExternalAcknowledged[] = "ack_external"; 55 const char kPrefExternalAcknowledged[] = "ack_external";
50 const char kPrefBlacklistAcknowledged[] = "ack_blacklist"; 56 const char kPrefBlacklistAcknowledged[] = "ack_blacklist";
51 const char kPrefOrphanAcknowledged[] = "ack_orphan"; 57 const char kPrefOrphanAcknowledged[] = "ack_orphan";
52 58
53 // Indicates whether to show an install warning when the user enables. 59 // Indicates whether to show an install warning when the user enables.
54 const char kExtensionDidEscalatePermissions[] = "install_warning_on_enable"; 60 const char kExtensionDidEscalatePermissions[] = "install_warning_on_enable";
55 61
56 // A preference that tracks browser action toolbar configuration. This is a list 62 // A preference that tracks browser action toolbar configuration. This is a list
57 // object stored in the Preferences file. The extensions are stored by ID. 63 // object stored in the Preferences file. The extensions are stored by ID.
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 366
361 // static 367 // static
362 bool ExtensionPrefs::ReadBooleanFromPref( 368 bool ExtensionPrefs::ReadBooleanFromPref(
363 const DictionaryValue* ext, const std::string& pref_key) { 369 const DictionaryValue* ext, const std::string& pref_key) {
364 bool bool_value = false; 370 bool bool_value = false;
365 ext->GetBoolean(pref_key, &bool_value); 371 ext->GetBoolean(pref_key, &bool_value);
366 return bool_value; 372 return bool_value;
367 } 373 }
368 374
369 bool ExtensionPrefs::ReadExtensionPrefBoolean( 375 bool ExtensionPrefs::ReadExtensionPrefBoolean(
370 const std::string& extension_id, const std::string& pref_key) { 376 const std::string& extension_id, const std::string& pref_key) const {
371 const DictionaryValue* ext = GetExtensionPref(extension_id); 377 const DictionaryValue* ext = GetExtensionPref(extension_id);
372 if (!ext) { 378 if (!ext) {
373 // No such extension yet. 379 // No such extension yet.
374 return false; 380 return false;
375 } 381 }
376 return ReadBooleanFromPref(ext, pref_key); 382 return ReadBooleanFromPref(ext, pref_key);
377 } 383 }
378 384
379 // static 385 // static
380 bool ExtensionPrefs::ReadIntegerFromPref( 386 bool ExtensionPrefs::ReadIntegerFromPref(
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 } 585 }
580 586
581 bool ExtensionPrefs::SetAlertSystemFirstRun() { 587 bool ExtensionPrefs::SetAlertSystemFirstRun() {
582 if (prefs_->GetBoolean(prefs::kExtensionAlertsInitializedPref)) { 588 if (prefs_->GetBoolean(prefs::kExtensionAlertsInitializedPref)) {
583 return true; 589 return true;
584 } 590 }
585 prefs_->SetBoolean(prefs::kExtensionAlertsInitializedPref, true); 591 prefs_->SetBoolean(prefs::kExtensionAlertsInitializedPref, true);
586 return false; 592 return false;
587 } 593 }
588 594
595 bool ExtensionPrefs::IsAppNotificationSetupDone(
596 const std::string& extension_id) const {
597 return ReadExtensionPrefBoolean(
598 extension_id, kPrefAppNotificationSetup);
599 }
600
601 void ExtensionPrefs::SetAppNotificationSetupDone(
602 const std::string& extension_id,
603 bool value) {
604 DCHECK(Extension::IdIsValid(extension_id));
asargent_no_longer_on_chrome 2011/10/27 19:49:41 nit: UpdateExtensionPref already checks IdIsValid,
605 UpdateExtensionPref(extension_id, kPrefAppNotificationSetup,
606 Value::CreateBooleanValue(value));
607 }
608
609 bool ExtensionPrefs::IsAppNotificationDisabled(
610 const std::string& extension_id) const {
611 return ReadExtensionPrefBoolean(extension_id, kPrefAppNotificationDisbaled);
612 }
613
614 void ExtensionPrefs::SetAppNotificationDisabled(
615 const std::string& extension_id, bool value) {
616 DCHECK(Extension::IdIsValid(extension_id));
asargent_no_longer_on_chrome 2011/10/27 19:49:41 nit: UpdateExtensionPref already checks IdIsValid,
617 UpdateExtensionPref(extension_id, kPrefAppNotificationDisbaled,
618 Value::CreateBooleanValue(value));
619 }
620
589 bool ExtensionPrefs::IsExtensionAllowedByPolicy( 621 bool ExtensionPrefs::IsExtensionAllowedByPolicy(
590 const std::string& extension_id) { 622 const std::string& extension_id) {
591 std::string string_value; 623 std::string string_value;
592 624
593 const ListValue* blacklist = 625 const ListValue* blacklist =
594 prefs_->GetList(prefs::kExtensionInstallDenyList); 626 prefs_->GetList(prefs::kExtensionInstallDenyList);
595 if (!blacklist || blacklist->empty()) 627 if (!blacklist || blacklist->empty())
596 return true; 628 return true;
597 629
598 // Check the whitelist first. 630 // Check the whitelist first.
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, 1824 prefs->RegisterListPref(prefs::kExtensionInstallAllowList,
1793 PrefService::UNSYNCABLE_PREF); 1825 PrefService::UNSYNCABLE_PREF);
1794 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, 1826 prefs->RegisterListPref(prefs::kExtensionInstallDenyList,
1795 PrefService::UNSYNCABLE_PREF); 1827 PrefService::UNSYNCABLE_PREF);
1796 prefs->RegisterListPref(prefs::kExtensionInstallForceList, 1828 prefs->RegisterListPref(prefs::kExtensionInstallForceList,
1797 PrefService::UNSYNCABLE_PREF); 1829 PrefService::UNSYNCABLE_PREF);
1798 prefs->RegisterStringPref(kWebStoreLogin, 1830 prefs->RegisterStringPref(kWebStoreLogin,
1799 std::string() /* default_value */, 1831 std::string() /* default_value */,
1800 PrefService::UNSYNCABLE_PREF); 1832 PrefService::UNSYNCABLE_PREF);
1801 } 1833 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.h ('k') | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698