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

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

Issue 98463005: Enable/disable extensions upon changes in blacklist. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Show blacklist state together with location. Created 6 years, 11 months 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 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/prefs/pref_notifier.h" 10 #include "base/prefs/pref_notifier.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 // The dictionary containing the extension's manifest. 60 // The dictionary containing the extension's manifest.
61 const char kPrefManifest[] = "manifest"; 61 const char kPrefManifest[] = "manifest";
62 62
63 // The version number. 63 // The version number.
64 const char kPrefVersion[] = "manifest.version"; 64 const char kPrefVersion[] = "manifest.version";
65 65
66 // Indicates whether an extension is blacklisted. 66 // Indicates whether an extension is blacklisted.
67 const char kPrefBlacklist[] = "blacklist"; 67 const char kPrefBlacklist[] = "blacklist";
68 68
69 // If extension is greylisted.
70 const char kPrefBlacklistState[] = "blacklist_state";
71
69 // The count of how many times we prompted the user to acknowledge an 72 // The count of how many times we prompted the user to acknowledge an
70 // extension. 73 // extension.
71 const char kPrefAcknowledgePromptCount[] = "ack_prompt_count"; 74 const char kPrefAcknowledgePromptCount[] = "ack_prompt_count";
72 75
73 // Indicates whether the user has acknowledged various types of extensions. 76 // Indicates whether the user has acknowledged various types of extensions.
74 const char kPrefExternalAcknowledged[] = "ack_external"; 77 const char kPrefExternalAcknowledged[] = "ack_external";
75 const char kPrefBlacklistAcknowledged[] = "ack_blacklist"; 78 const char kPrefBlacklistAcknowledged[] = "ack_blacklist";
76 const char kPrefWipeoutAcknowledged[] = "ack_wiped"; 79 const char kPrefWipeoutAcknowledged[] = "ack_wiped";
77 80
78 // Indicates whether the external extension was installed during the first 81 // Indicates whether the external extension was installed during the first
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 1142
1140 void ExtensionPrefs::SetExtensionState(const std::string& extension_id, 1143 void ExtensionPrefs::SetExtensionState(const std::string& extension_id,
1141 Extension::State state) { 1144 Extension::State state) {
1142 UpdateExtensionPref(extension_id, kPrefState, 1145 UpdateExtensionPref(extension_id, kPrefState,
1143 new base::FundamentalValue(state)); 1146 new base::FundamentalValue(state));
1144 bool enabled = (state == Extension::ENABLED); 1147 bool enabled = (state == Extension::ENABLED);
1145 extension_pref_value_map_->SetExtensionState(extension_id, enabled); 1148 extension_pref_value_map_->SetExtensionState(extension_id, enabled);
1146 content_settings_store_->SetExtensionState(extension_id, enabled); 1149 content_settings_store_->SetExtensionState(extension_id, enabled);
1147 } 1150 }
1148 1151
1152 void ExtensionPrefs::SetExtensionBlacklistState(const std::string& extension_id,
1153 BlacklistState state) {
1154 SetExtensionBlacklisted(extension_id, state == BLACKLISTED_MALWARE);
1155 UpdateExtensionPref(extension_id, kPrefBlacklistState,
1156 new base::FundamentalValue(state));
1157 }
1158
1159 BlacklistState ExtensionPrefs::GetExtensionBlacklistState(
1160 const std::string& extension_id) {
1161 if (IsExtensionBlacklisted(extension_id))
1162 return BLACKLISTED_MALWARE;
1163 const base::DictionaryValue* ext_prefs = GetExtensionPref(extension_id);
1164 int int_value;
1165 if (ext_prefs && ext_prefs->GetInteger(kPrefBlacklistState, &int_value))
1166 return static_cast<BlacklistState>(int_value);
1167
1168 return NOT_BLACKLISTED;
1169 }
1170
1149 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) { 1171 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) {
1150 const base::DictionaryValue* extension = GetExtensionPref(extension_id); 1172 const base::DictionaryValue* extension = GetExtensionPref(extension_id);
1151 if (!extension) 1173 if (!extension)
1152 return std::string(); 1174 return std::string();
1153 1175
1154 std::string version; 1176 std::string version;
1155 extension->GetString(kPrefVersion, &version); 1177 extension->GetString(kPrefVersion, &version);
1156 1178
1157 return version; 1179 return version;
1158 } 1180 }
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 is_enabled = initial_state == Extension::ENABLED; 1905 is_enabled = initial_state == Extension::ENABLED;
1884 } 1906 }
1885 1907
1886 extension_pref_value_map_->RegisterExtension(extension_id, install_time, 1908 extension_pref_value_map_->RegisterExtension(extension_id, install_time,
1887 is_enabled); 1909 is_enabled);
1888 content_settings_store_->RegisterExtension(extension_id, install_time, 1910 content_settings_store_->RegisterExtension(extension_id, install_time,
1889 is_enabled); 1911 is_enabled);
1890 } 1912 }
1891 1913
1892 } // namespace extensions 1914 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698