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

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: Created 6 years, 10 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
« no previous file with comments | « extensions/browser/extension_prefs.h ('k') | extensions/common/extension.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 ids.insert(it.key()); 757 ids.insert(it.key());
755 } 758 }
756 } 759 }
757 760
758 return ids; 761 return ids;
759 } 762 }
760 763
761 void ExtensionPrefs::SetExtensionBlacklisted(const std::string& extension_id, 764 void ExtensionPrefs::SetExtensionBlacklisted(const std::string& extension_id,
762 bool is_blacklisted) { 765 bool is_blacklisted) {
763 bool currently_blacklisted = IsExtensionBlacklisted(extension_id); 766 bool currently_blacklisted = IsExtensionBlacklisted(extension_id);
764 if (is_blacklisted == currently_blacklisted) { 767 if (is_blacklisted == currently_blacklisted)
765 NOTREACHED() << extension_id << " is " <<
766 (currently_blacklisted ? "already" : "not") <<
767 " blacklisted";
768 return; 768 return;
769 }
770 769
771 // Always make sure the "acknowledged" bit is cleared since the blacklist bit 770 // Always make sure the "acknowledged" bit is cleared since the blacklist bit
772 // is changing. 771 // is changing.
773 UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged, NULL); 772 UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged, NULL);
774 773
775 if (is_blacklisted) { 774 if (is_blacklisted) {
776 UpdateExtensionPref(extension_id, 775 UpdateExtensionPref(extension_id,
777 kPrefBlacklist, 776 kPrefBlacklist,
778 new base::FundamentalValue(true)); 777 new base::FundamentalValue(true));
779 } else { 778 } else {
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 1138
1140 void ExtensionPrefs::SetExtensionState(const std::string& extension_id, 1139 void ExtensionPrefs::SetExtensionState(const std::string& extension_id,
1141 Extension::State state) { 1140 Extension::State state) {
1142 UpdateExtensionPref(extension_id, kPrefState, 1141 UpdateExtensionPref(extension_id, kPrefState,
1143 new base::FundamentalValue(state)); 1142 new base::FundamentalValue(state));
1144 bool enabled = (state == Extension::ENABLED); 1143 bool enabled = (state == Extension::ENABLED);
1145 extension_pref_value_map_->SetExtensionState(extension_id, enabled); 1144 extension_pref_value_map_->SetExtensionState(extension_id, enabled);
1146 content_settings_store_->SetExtensionState(extension_id, enabled); 1145 content_settings_store_->SetExtensionState(extension_id, enabled);
1147 } 1146 }
1148 1147
1148 void ExtensionPrefs::SetExtensionBlacklistState(const std::string& extension_id,
1149 BlacklistState state) {
1150 SetExtensionBlacklisted(extension_id, state == BLACKLISTED_MALWARE);
1151 UpdateExtensionPref(extension_id, kPrefBlacklistState,
1152 new base::FundamentalValue(state));
1153 }
1154
1155 BlacklistState ExtensionPrefs::GetExtensionBlacklistState(
1156 const std::string& extension_id) {
1157 if (IsExtensionBlacklisted(extension_id))
1158 return BLACKLISTED_MALWARE;
1159 const base::DictionaryValue* ext_prefs = GetExtensionPref(extension_id);
1160 int int_value;
1161 if (ext_prefs && ext_prefs->GetInteger(kPrefBlacklistState, &int_value))
1162 return static_cast<BlacklistState>(int_value);
1163
1164 return NOT_BLACKLISTED;
1165 }
1166
1149 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) { 1167 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) {
1150 const base::DictionaryValue* extension = GetExtensionPref(extension_id); 1168 const base::DictionaryValue* extension = GetExtensionPref(extension_id);
1151 if (!extension) 1169 if (!extension)
1152 return std::string(); 1170 return std::string();
1153 1171
1154 std::string version; 1172 std::string version;
1155 extension->GetString(kPrefVersion, &version); 1173 extension->GetString(kPrefVersion, &version);
1156 1174
1157 return version; 1175 return version;
1158 } 1176 }
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 is_enabled = initial_state == Extension::ENABLED; 1901 is_enabled = initial_state == Extension::ENABLED;
1884 } 1902 }
1885 1903
1886 extension_pref_value_map_->RegisterExtension(extension_id, install_time, 1904 extension_pref_value_map_->RegisterExtension(extension_id, install_time,
1887 is_enabled); 1905 is_enabled);
1888 content_settings_store_->RegisterExtension(extension_id, install_time, 1906 content_settings_store_->RegisterExtension(extension_id, install_time,
1889 is_enabled); 1907 is_enabled);
1890 } 1908 }
1891 1909
1892 } // namespace extensions 1910 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/extension_prefs.h ('k') | extensions/common/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698