Chromium Code Reviews| 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 ExtensionPrefs::DisableReason ExtensionPrefs::GetDisableReason( | |
| 680 const std::string& extension_id) { | |
| 681 int value = -1; | |
| 682 if (ReadExtensionPrefInteger(extension_id, kPrefDisableReason, &value) && | |
| 683 (value == DISABLE_UNKNOWN || | |
| 684 value == DISABLE_USER_ACTION || | |
| 685 value == DISABLE_PERMISSIONS_INCREASE || | |
| 686 value == DISABLE_RELOAD)) | |
|
Aaron Boodman
2012/04/09 20:30:48
You could add a DISABLE_LAST to simplify this.
Yoyo Zhou
2012/04/10 01:57:36
I guess so.
| |
| 687 return static_cast<DisableReason>(value); | |
| 688 return DISABLE_UNKNOWN; | |
| 689 } | |
| 690 | |
| 691 void ExtensionPrefs::SetDisableReason(const std::string& extension_id, | |
| 692 DisableReason disable_reason) { | |
| 693 UpdateExtensionPref( | |
|
Aaron Boodman
2012/04/09 20:30:48
Consider removing the key in the case of UNKNOWN t
Yoyo Zhou
2012/04/10 01:57:36
Added a Remove* function.
| |
| 694 extension_id, kPrefDisableReason, | |
| 695 Value::CreateIntegerValue(static_cast<int>(disable_reason))); | |
| 696 } | |
| 697 | |
| 676 void ExtensionPrefs::UpdateBlacklist( | 698 void ExtensionPrefs::UpdateBlacklist( |
| 677 const std::set<std::string>& blacklist_set) { | 699 const std::set<std::string>& blacklist_set) { |
| 678 std::vector<std::string> remove_pref_ids; | 700 std::vector<std::string> remove_pref_ids; |
| 679 std::set<std::string> used_id_set; | 701 std::set<std::string> used_id_set; |
| 680 const DictionaryValue* extensions = prefs_->GetDictionary(kExtensionsPref); | 702 const DictionaryValue* extensions = prefs_->GetDictionary(kExtensionsPref); |
| 681 | 703 |
| 682 if (extensions) { | 704 if (extensions) { |
| 683 for (DictionaryValue::key_iterator extension_id = extensions->begin_keys(); | 705 for (DictionaryValue::key_iterator extension_id = extensions->begin_keys(); |
| 684 extension_id != extensions->end_keys(); ++extension_id) { | 706 extension_id != extensions->end_keys(); ++extension_id) { |
| 685 DictionaryValue* ext; | 707 DictionaryValue* ext; |
| (...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1793 prefs->RegisterStringPref(prefs::kExtensionBlacklistUpdateVersion, | 1815 prefs->RegisterStringPref(prefs::kExtensionBlacklistUpdateVersion, |
| 1794 "0", // default value | 1816 "0", // default value |
| 1795 PrefService::UNSYNCABLE_PREF); | 1817 PrefService::UNSYNCABLE_PREF); |
| 1796 prefs->RegisterInt64Pref(prefs::kLastExtensionsUpdateCheck, | 1818 prefs->RegisterInt64Pref(prefs::kLastExtensionsUpdateCheck, |
| 1797 0, // default value | 1819 0, // default value |
| 1798 PrefService::UNSYNCABLE_PREF); | 1820 PrefService::UNSYNCABLE_PREF); |
| 1799 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, | 1821 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, |
| 1800 0, // default value | 1822 0, // default value |
| 1801 PrefService::UNSYNCABLE_PREF); | 1823 PrefService::UNSYNCABLE_PREF); |
| 1802 } | 1824 } |
| OLD | NEW |