| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 const char kPrefAppNotificationDisbaled[] = "app_notif_disabled"; | 50 const char kPrefAppNotificationDisbaled[] = "app_notif_disabled"; |
| 51 | 51 |
| 52 // Indicates whether the user has acknowledged various types of extensions. | 52 // Indicates whether the user has acknowledged various types of extensions. |
| 53 const char kPrefExternalAcknowledged[] = "ack_external"; | 53 const char kPrefExternalAcknowledged[] = "ack_external"; |
| 54 const char kPrefBlacklistAcknowledged[] = "ack_blacklist"; | 54 const char kPrefBlacklistAcknowledged[] = "ack_blacklist"; |
| 55 const char kPrefOrphanAcknowledged[] = "ack_orphan"; | 55 const char kPrefOrphanAcknowledged[] = "ack_orphan"; |
| 56 | 56 |
| 57 // Indicates whether to show an install warning when the user enables. | 57 // Indicates whether to show an install warning when the user enables. |
| 58 const char kExtensionDidEscalatePermissions[] = "install_warning_on_enable"; | 58 const char kExtensionDidEscalatePermissions[] = "install_warning_on_enable"; |
| 59 | 59 |
| 60 // Indicates whether the extension was updated while it was disabled. |
| 61 const char kPrefDisableReason[] = "disable_reason"; |
| 62 |
| 60 // A preference that tracks browser action toolbar configuration. This is a list | 63 // A preference that tracks browser action toolbar configuration. This is a list |
| 61 // object stored in the Preferences file. The extensions are stored by ID. | 64 // object stored in the Preferences file. The extensions are stored by ID. |
| 62 const char kExtensionToolbar[] = "extensions.toolbar"; | 65 const char kExtensionToolbar[] = "extensions.toolbar"; |
| 63 | 66 |
| 64 // The key for a serialized Time value indicating the start of the day (from the | 67 // The key for a serialized Time value indicating the start of the day (from the |
| 65 // server's perspective) an extension last included a "ping" parameter during | 68 // server's perspective) an extension last included a "ping" parameter during |
| 66 // its update check. | 69 // its update check. |
| 67 const char kLastPingDay[] = "lastpingday"; | 70 const char kLastPingDay[] = "lastpingday"; |
| 68 | 71 |
| 69 // Similar to kLastPingDay, but for "active" instead of "rollcall" pings. | 72 // Similar to kLastPingDay, but for "active" instead of "rollcall" pings. |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 return ReadExtensionPrefBoolean(extension_id, | 669 return ReadExtensionPrefBoolean(extension_id, |
| 667 kExtensionDidEscalatePermissions); | 670 kExtensionDidEscalatePermissions); |
| 668 } | 671 } |
| 669 | 672 |
| 670 void ExtensionPrefs::SetDidExtensionEscalatePermissions( | 673 void ExtensionPrefs::SetDidExtensionEscalatePermissions( |
| 671 const Extension* extension, bool did_escalate) { | 674 const Extension* extension, bool did_escalate) { |
| 672 UpdateExtensionPref(extension->id(), kExtensionDidEscalatePermissions, | 675 UpdateExtensionPref(extension->id(), kExtensionDidEscalatePermissions, |
| 673 Value::CreateBooleanValue(did_escalate)); | 676 Value::CreateBooleanValue(did_escalate)); |
| 674 } | 677 } |
| 675 | 678 |
| 679 Extension::DisableReason ExtensionPrefs::GetDisableReason( |
| 680 const std::string& extension_id) { |
| 681 int value = -1; |
| 682 if (ReadExtensionPrefInteger(extension_id, kPrefDisableReason, &value) && |
| 683 value >= 0 && value < Extension::DISABLE_LAST) { |
| 684 return static_cast<Extension::DisableReason>(value); |
| 685 } |
| 686 return Extension::DISABLE_UNKNOWN; |
| 687 } |
| 688 |
| 689 void ExtensionPrefs::SetDisableReason(const std::string& extension_id, |
| 690 Extension::DisableReason disable_reason) { |
| 691 UpdateExtensionPref( |
| 692 extension_id, kPrefDisableReason, |
| 693 Value::CreateIntegerValue(static_cast<int>(disable_reason))); |
| 694 } |
| 695 |
| 696 void ExtensionPrefs::RemoveDisableReason(const std::string& extension_id) { |
| 697 UpdateExtensionPref(extension_id, kPrefDisableReason, NULL); |
| 698 } |
| 699 |
| 676 void ExtensionPrefs::UpdateBlacklist( | 700 void ExtensionPrefs::UpdateBlacklist( |
| 677 const std::set<std::string>& blacklist_set) { | 701 const std::set<std::string>& blacklist_set) { |
| 678 std::vector<std::string> remove_pref_ids; | 702 std::vector<std::string> remove_pref_ids; |
| 679 std::set<std::string> used_id_set; | 703 std::set<std::string> used_id_set; |
| 680 const DictionaryValue* extensions = prefs_->GetDictionary(kExtensionsPref); | 704 const DictionaryValue* extensions = prefs_->GetDictionary(kExtensionsPref); |
| 681 | 705 |
| 682 if (extensions) { | 706 if (extensions) { |
| 683 for (DictionaryValue::key_iterator extension_id = extensions->begin_keys(); | 707 for (DictionaryValue::key_iterator extension_id = extensions->begin_keys(); |
| 684 extension_id != extensions->end_keys(); ++extension_id) { | 708 extension_id != extensions->end_keys(); ++extension_id) { |
| 685 DictionaryValue* ext; | 709 DictionaryValue* ext; |
| (...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1793 prefs->RegisterStringPref(prefs::kExtensionBlacklistUpdateVersion, | 1817 prefs->RegisterStringPref(prefs::kExtensionBlacklistUpdateVersion, |
| 1794 "0", // default value | 1818 "0", // default value |
| 1795 PrefService::UNSYNCABLE_PREF); | 1819 PrefService::UNSYNCABLE_PREF); |
| 1796 prefs->RegisterInt64Pref(prefs::kLastExtensionsUpdateCheck, | 1820 prefs->RegisterInt64Pref(prefs::kLastExtensionsUpdateCheck, |
| 1797 0, // default value | 1821 0, // default value |
| 1798 PrefService::UNSYNCABLE_PREF); | 1822 PrefService::UNSYNCABLE_PREF); |
| 1799 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, | 1823 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, |
| 1800 0, // default value | 1824 0, // default value |
| 1801 PrefService::UNSYNCABLE_PREF); | 1825 PrefService::UNSYNCABLE_PREF); |
| 1802 } | 1826 } |
| OLD | NEW |