| OLD | NEW |
| 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 Loading... |
| 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. | 48 // The oauth client id used for app notification setup. |
| 49 const char kPrefAppNotificationSetup[] = "app_notif_setup"; | 49 const char kPrefAppNotificationClientId[] = "app_notif_client_id"; |
| 50 | 50 |
| 51 // Indicates whether the user has disabled notifications or not. | 51 // Indicates whether the user has disabled notifications or not. |
| 52 const char kPrefAppNotificationDisbaled[] = "app_notif_disabled"; | 52 const char kPrefAppNotificationDisbaled[] = "app_notif_disabled"; |
| 53 | 53 |
| 54 // Indicates whether the user has acknowledged various types of extensions. | 54 // Indicates whether the user has acknowledged various types of extensions. |
| 55 const char kPrefExternalAcknowledged[] = "ack_external"; | 55 const char kPrefExternalAcknowledged[] = "ack_external"; |
| 56 const char kPrefBlacklistAcknowledged[] = "ack_blacklist"; | 56 const char kPrefBlacklistAcknowledged[] = "ack_blacklist"; |
| 57 const char kPrefOrphanAcknowledged[] = "ack_orphan"; | 57 const char kPrefOrphanAcknowledged[] = "ack_orphan"; |
| 58 | 58 |
| 59 // Indicates whether to show an install warning when the user enables. | 59 // Indicates whether to show an install warning when the user enables. |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 } | 585 } |
| 586 | 586 |
| 587 bool ExtensionPrefs::SetAlertSystemFirstRun() { | 587 bool ExtensionPrefs::SetAlertSystemFirstRun() { |
| 588 if (prefs_->GetBoolean(prefs::kExtensionAlertsInitializedPref)) { | 588 if (prefs_->GetBoolean(prefs::kExtensionAlertsInitializedPref)) { |
| 589 return true; | 589 return true; |
| 590 } | 590 } |
| 591 prefs_->SetBoolean(prefs::kExtensionAlertsInitializedPref, true); | 591 prefs_->SetBoolean(prefs::kExtensionAlertsInitializedPref, true); |
| 592 return false; | 592 return false; |
| 593 } | 593 } |
| 594 | 594 |
| 595 bool ExtensionPrefs::IsAppNotificationSetupDone( | 595 std::string ExtensionPrefs::GetAppNotificationClientId( |
| 596 const std::string& extension_id) const { | 596 const std::string& extension_id) const { |
| 597 return ReadExtensionPrefBoolean( | 597 const DictionaryValue* dict = GetExtensionPref(extension_id); |
| 598 extension_id, kPrefAppNotificationSetup); | 598 if (!dict || !dict->HasKey(kPrefAppNotificationClientId)) |
| 599 return std::string(); |
| 600 |
| 601 std::string tmp; |
| 602 dict->GetString(kPrefAppNotificationClientId, &tmp); |
| 603 return tmp; |
| 599 } | 604 } |
| 600 | 605 |
| 601 void ExtensionPrefs::SetAppNotificationSetupDone( | 606 void ExtensionPrefs::SetAppNotificationClientId( |
| 602 const std::string& extension_id, | 607 const std::string& extension_id, |
| 603 bool value) { | 608 const std::string& oauth_client_id) { |
| 604 DCHECK(Extension::IdIsValid(extension_id)); | 609 DCHECK(Extension::IdIsValid(extension_id)); |
| 605 UpdateExtensionPref(extension_id, kPrefAppNotificationSetup, | 610 UpdateExtensionPref(extension_id, kPrefAppNotificationClientId, |
| 606 Value::CreateBooleanValue(value)); | 611 Value::CreateStringValue(oauth_client_id)); |
| 607 } | 612 } |
| 608 | 613 |
| 609 bool ExtensionPrefs::IsAppNotificationDisabled( | 614 bool ExtensionPrefs::IsAppNotificationDisabled( |
| 610 const std::string& extension_id) const { | 615 const std::string& extension_id) const { |
| 611 return ReadExtensionPrefBoolean(extension_id, kPrefAppNotificationDisbaled); | 616 return ReadExtensionPrefBoolean(extension_id, kPrefAppNotificationDisbaled); |
| 612 } | 617 } |
| 613 | 618 |
| 614 void ExtensionPrefs::SetAppNotificationDisabled( | 619 void ExtensionPrefs::SetAppNotificationDisabled( |
| 615 const std::string& extension_id, bool value) { | 620 const std::string& extension_id, bool value) { |
| 616 DCHECK(Extension::IdIsValid(extension_id)); | 621 DCHECK(Extension::IdIsValid(extension_id)); |
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1822 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, | 1827 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, |
| 1823 PrefService::UNSYNCABLE_PREF); | 1828 PrefService::UNSYNCABLE_PREF); |
| 1824 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, | 1829 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, |
| 1825 PrefService::UNSYNCABLE_PREF); | 1830 PrefService::UNSYNCABLE_PREF); |
| 1826 prefs->RegisterListPref(prefs::kExtensionInstallForceList, | 1831 prefs->RegisterListPref(prefs::kExtensionInstallForceList, |
| 1827 PrefService::UNSYNCABLE_PREF); | 1832 PrefService::UNSYNCABLE_PREF); |
| 1828 prefs->RegisterStringPref(kWebStoreLogin, | 1833 prefs->RegisterStringPref(kWebStoreLogin, |
| 1829 std::string() /* default_value */, | 1834 std::string() /* default_value */, |
| 1830 PrefService::UNSYNCABLE_PREF); | 1835 PrefService::UNSYNCABLE_PREF); |
| 1831 } | 1836 } |
| OLD | NEW |