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

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

Issue 98463005: Enable/disable extensions upon changes in blacklist. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added UI, store blacklist state in prefs, +2 unittests. 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 (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 <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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 // The dictionary containing the extension's manifest. 61 // The dictionary containing the extension's manifest.
62 const char kPrefManifest[] = "manifest"; 62 const char kPrefManifest[] = "manifest";
63 63
64 // The version number. 64 // The version number.
65 const char kPrefVersion[] = "manifest.version"; 65 const char kPrefVersion[] = "manifest.version";
66 66
67 // Indicates whether an extension is blacklisted. 67 // Indicates whether an extension is blacklisted.
68 const char kPrefBlacklist[] = "blacklist"; 68 const char kPrefBlacklist[] = "blacklist";
69 69
70 // If extension is greylisted.
71 const char kPrefGreylist[] = "greylist";
72
70 // The count of how many times we prompted the user to acknowledge an 73 // The count of how many times we prompted the user to acknowledge an
71 // extension. 74 // extension.
72 const char kPrefAcknowledgePromptCount[] = "ack_prompt_count"; 75 const char kPrefAcknowledgePromptCount[] = "ack_prompt_count";
73 76
74 // Indicates whether the user has acknowledged various types of extensions. 77 // Indicates whether the user has acknowledged various types of extensions.
75 const char kPrefExternalAcknowledged[] = "ack_external"; 78 const char kPrefExternalAcknowledged[] = "ack_external";
76 const char kPrefBlacklistAcknowledged[] = "ack_blacklist"; 79 const char kPrefBlacklistAcknowledged[] = "ack_blacklist";
77 const char kPrefWipeoutAcknowledged[] = "ack_wiped"; 80 const char kPrefWipeoutAcknowledged[] = "ack_wiped";
78 81
79 // Indicates whether the external extension was installed during the first 82 // Indicates whether the external extension was installed during the first
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 1143
1141 void ExtensionPrefs::SetExtensionState(const std::string& extension_id, 1144 void ExtensionPrefs::SetExtensionState(const std::string& extension_id,
1142 Extension::State state) { 1145 Extension::State state) {
1143 UpdateExtensionPref(extension_id, kPrefState, 1146 UpdateExtensionPref(extension_id, kPrefState,
1144 new base::FundamentalValue(state)); 1147 new base::FundamentalValue(state));
1145 bool enabled = (state == Extension::ENABLED); 1148 bool enabled = (state == Extension::ENABLED);
1146 extension_pref_value_map_->SetExtensionState(extension_id, enabled); 1149 extension_pref_value_map_->SetExtensionState(extension_id, enabled);
1147 content_settings_store_->SetExtensionState(extension_id, enabled); 1150 content_settings_store_->SetExtensionState(extension_id, enabled);
1148 } 1151 }
1149 1152
1153 void ExtensionPrefs::SetExtensionBlacklistState(const std::string& extension_id,
1154 BlacklistState state) {
1155 SetExtensionBlacklisted(extension_id, state == BLACKLISTED_MALWARE);
1156 UpdateExtensionPref(extension_id, kPrefGreylist,
1157 new base::FundamentalValue(state));
1158 }
1159
1160 BlacklistState ExtensionPrefs::GetExtensionBlacklistState(
1161 const std::string& extension_id) {
1162 if (IsExtensionBlacklisted(extension_id))
1163 return BLACKLISTED_MALWARE;
1164 const base::DictionaryValue* ext_prefs = GetExtensionPref(extension_id);
1165 int int_value;
1166 if (ext_prefs && ext_prefs->GetInteger(kPrefGreylist, &int_value))
not at google - send to devlin 2014/01/22 22:24:39 "greylist" seems like a misnomer now [that this is
Oleg Eterevsky 2014/01/23 14:48:54 Done.
1167 return static_cast<BlacklistState>(int_value);
1168 else
not at google - send to devlin 2014/01/22 22:24:39 no else after return.
Oleg Eterevsky 2014/01/23 14:48:54 Done.
1169 return NOT_BLACKLISTED;
not at google - send to devlin 2014/01/22 22:24:39 could you test this logic in extension_prefs_unitt
Oleg Eterevsky 2014/01/23 14:48:54 Done.
1170 }
1171
1150 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) { 1172 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) {
1151 const base::DictionaryValue* extension = GetExtensionPref(extension_id); 1173 const base::DictionaryValue* extension = GetExtensionPref(extension_id);
1152 if (!extension) 1174 if (!extension)
1153 return std::string(); 1175 return std::string();
1154 1176
1155 std::string version; 1177 std::string version;
1156 extension->GetString(kPrefVersion, &version); 1178 extension->GetString(kPrefVersion, &version);
1157 1179
1158 return version; 1180 return version;
1159 } 1181 }
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 is_enabled = initial_state == Extension::ENABLED; 1906 is_enabled = initial_state == Extension::ENABLED;
1885 } 1907 }
1886 1908
1887 extension_pref_value_map_->RegisterExtension(extension_id, install_time, 1909 extension_pref_value_map_->RegisterExtension(extension_id, install_time,
1888 is_enabled); 1910 is_enabled);
1889 content_settings_store_->RegisterExtension(extension_id, install_time, 1911 content_settings_store_->RegisterExtension(extension_id, install_time,
1890 is_enabled); 1912 is_enabled);
1891 } 1913 }
1892 1914
1893 } // namespace extensions 1915 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698