| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/extension_prefs.h" | 5 #include "extensions/browser/extension_prefs.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 const char kPrefAcknowledgePromptCount[] = "ack_prompt_count"; | 76 const char kPrefAcknowledgePromptCount[] = "ack_prompt_count"; |
| 77 | 77 |
| 78 // Indicates whether the user has acknowledged various types of extensions. | 78 // Indicates whether the user has acknowledged various types of extensions. |
| 79 const char kPrefExternalAcknowledged[] = "ack_external"; | 79 const char kPrefExternalAcknowledged[] = "ack_external"; |
| 80 const char kPrefBlacklistAcknowledged[] = "ack_blacklist"; | 80 const char kPrefBlacklistAcknowledged[] = "ack_blacklist"; |
| 81 | 81 |
| 82 // Indicates whether the external extension was installed during the first | 82 // Indicates whether the external extension was installed during the first |
| 83 // run of this profile. | 83 // run of this profile. |
| 84 const char kPrefExternalInstallFirstRun[] = "external_first_run"; | 84 const char kPrefExternalInstallFirstRun[] = "external_first_run"; |
| 85 | 85 |
| 86 // Indicates whether to show an install warning when the user enables. | |
| 87 const char kExtensionDidEscalatePermissions[] = "install_warning_on_enable"; | |
| 88 | |
| 89 // DO NOT USE, use kPrefDisableReasons instead. | 86 // DO NOT USE, use kPrefDisableReasons instead. |
| 90 // Indicates whether the extension was updated while it was disabled. | 87 // Indicates whether the extension was updated while it was disabled. |
| 91 const char kDeprecatedPrefDisableReason[] = "disable_reason"; | 88 const char kDeprecatedPrefDisableReason[] = "disable_reason"; |
| 92 | 89 |
| 93 // A bitmask of all the reasons an extension is disabled. | 90 // A bitmask of all the reasons an extension is disabled. |
| 94 const char kPrefDisableReasons[] = "disable_reasons"; | 91 const char kPrefDisableReasons[] = "disable_reasons"; |
| 95 | 92 |
| 96 // The key for a serialized Time value indicating the start of the day (from the | 93 // The key for a serialized Time value indicating the start of the day (from the |
| 97 // server's perspective) an extension last included a "ping" parameter during | 94 // server's perspective) an extension last included a "ping" parameter during |
| 98 // its update check. | 95 // its update check. |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 bool ExtensionPrefs::SetAlertSystemFirstRun() { | 719 bool ExtensionPrefs::SetAlertSystemFirstRun() { |
| 723 if (prefs_->GetBoolean(pref_names::kAlertsInitialized)) { | 720 if (prefs_->GetBoolean(pref_names::kAlertsInitialized)) { |
| 724 return true; | 721 return true; |
| 725 } | 722 } |
| 726 prefs_->SetBoolean(pref_names::kAlertsInitialized, true); | 723 prefs_->SetBoolean(pref_names::kAlertsInitialized, true); |
| 727 return false; | 724 return false; |
| 728 } | 725 } |
| 729 | 726 |
| 730 bool ExtensionPrefs::DidExtensionEscalatePermissions( | 727 bool ExtensionPrefs::DidExtensionEscalatePermissions( |
| 731 const std::string& extension_id) const { | 728 const std::string& extension_id) const { |
| 732 return ReadPrefAsBooleanAndReturn(extension_id, | 729 return HasDisableReason(extension_id, |
| 733 kExtensionDidEscalatePermissions); | 730 Extension::DISABLE_PERMISSIONS_INCREASE) || |
| 734 } | 731 HasDisableReason(extension_id, Extension::DISABLE_REMOTE_INSTALL); |
| 735 | |
| 736 void ExtensionPrefs::SetDidExtensionEscalatePermissions( | |
| 737 const Extension* extension, bool did_escalate) { | |
| 738 UpdateExtensionPref(extension->id(), kExtensionDidEscalatePermissions, | |
| 739 new base::FundamentalValue(did_escalate)); | |
| 740 } | 732 } |
| 741 | 733 |
| 742 int ExtensionPrefs::GetDisableReasons(const std::string& extension_id) const { | 734 int ExtensionPrefs::GetDisableReasons(const std::string& extension_id) const { |
| 743 int value = -1; | 735 int value = -1; |
| 744 if (ReadPrefAsInteger(extension_id, kPrefDisableReasons, &value) && | 736 if (ReadPrefAsInteger(extension_id, kPrefDisableReasons, &value) && |
| 745 value >= 0) { | 737 value >= 0) { |
| 746 return value; | 738 return value; |
| 747 } | 739 } |
| 748 return Extension::DISABLE_NONE; | 740 return Extension::DISABLE_NONE; |
| 749 } | 741 } |
| (...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2117 extension_pref_value_map_->RegisterExtension( | 2109 extension_pref_value_map_->RegisterExtension( |
| 2118 extension_id, install_time, is_enabled, is_incognito_enabled); | 2110 extension_id, install_time, is_enabled, is_incognito_enabled); |
| 2119 | 2111 |
| 2120 FOR_EACH_OBSERVER( | 2112 FOR_EACH_OBSERVER( |
| 2121 ExtensionPrefsObserver, | 2113 ExtensionPrefsObserver, |
| 2122 observer_list_, | 2114 observer_list_, |
| 2123 OnExtensionRegistered(extension_id, install_time, is_enabled)); | 2115 OnExtensionRegistered(extension_id, install_time, is_enabled)); |
| 2124 } | 2116 } |
| 2125 | 2117 |
| 2126 } // namespace extensions | 2118 } // namespace extensions |
| OLD | NEW |