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/admin_policy.h" | 10 #include "chrome/browser/extensions/admin_policy.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
26 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
28 | 28 |
29 namespace extensions { | 29 namespace extensions { |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 // Additional preferences keys | 33 // Additional preferences keys |
34 | 34 |
| 35 // Whether this extension was running when chrome last shutdown. |
| 36 const char kPrefRunning[] = "running"; |
| 37 |
35 // Where an extension was installed from. (see Extension::Location) | 38 // Where an extension was installed from. (see Extension::Location) |
36 const char kPrefLocation[] = "location"; | 39 const char kPrefLocation[] = "location"; |
37 | 40 |
38 // Enabled, disabled, killed, etc. (see Extension::State) | 41 // Enabled, disabled, killed, etc. (see Extension::State) |
39 const char kPrefState[] = "state"; | 42 const char kPrefState[] = "state"; |
40 | 43 |
41 // The path to the current version's manifest file. | 44 // The path to the current version's manifest file. |
42 const char kPrefPath[] = "path"; | 45 const char kPrefPath[] = "path"; |
43 | 46 |
44 // The dictionary containing the extension's manifest. | 47 // The dictionary containing the extension's manifest. |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 void ExtensionPrefs::SetRegisteredEvents( | 1089 void ExtensionPrefs::SetRegisteredEvents( |
1087 const std::string& extension_id, const std::set<std::string>& events) { | 1090 const std::string& extension_id, const std::set<std::string>& events) { |
1088 ListValue* value = new ListValue(); | 1091 ListValue* value = new ListValue(); |
1089 for (std::set<std::string>::const_iterator it = events.begin(); | 1092 for (std::set<std::string>::const_iterator it = events.begin(); |
1090 it != events.end(); ++it) { | 1093 it != events.end(); ++it) { |
1091 value->Append(new StringValue(*it)); | 1094 value->Append(new StringValue(*it)); |
1092 } | 1095 } |
1093 UpdateExtensionPref(extension_id, kRegisteredEvents, value); | 1096 UpdateExtensionPref(extension_id, kRegisteredEvents, value); |
1094 } | 1097 } |
1095 | 1098 |
| 1099 void ExtensionPrefs::SetExtensionRunning(const std::string& extension_id, |
| 1100 bool is_running) { |
| 1101 Value* value = Value::CreateBooleanValue(is_running); |
| 1102 UpdateExtensionPref(extension_id, kPrefRunning, value); |
| 1103 } |
| 1104 |
| 1105 bool ExtensionPrefs::IsExtensionRunning(const std::string& extension_id) { |
| 1106 const DictionaryValue* extension = GetExtensionPref(extension_id); |
| 1107 if (!extension) |
| 1108 return false; |
| 1109 bool running = false; |
| 1110 extension->GetBoolean(kPrefRunning, &running); |
| 1111 return running; |
| 1112 } |
| 1113 |
1096 ExtensionOmniboxSuggestion | 1114 ExtensionOmniboxSuggestion |
1097 ExtensionPrefs::GetOmniboxDefaultSuggestion(const std::string& extension_id) { | 1115 ExtensionPrefs::GetOmniboxDefaultSuggestion(const std::string& extension_id) { |
1098 ExtensionOmniboxSuggestion suggestion; | 1116 ExtensionOmniboxSuggestion suggestion; |
1099 | 1117 |
1100 const DictionaryValue* extension = GetExtensionPref(extension_id); | 1118 const DictionaryValue* extension = GetExtensionPref(extension_id); |
1101 const DictionaryValue* dict = NULL; | 1119 const DictionaryValue* dict = NULL; |
1102 if (extension && extension->GetDictionary(kOmniboxDefaultSuggestion, &dict)) | 1120 if (extension && extension->GetDictionary(kOmniboxDefaultSuggestion, &dict)) |
1103 suggestion.Populate(*dict, false); | 1121 suggestion.Populate(*dict, false); |
1104 | 1122 |
1105 return suggestion; | 1123 return suggestion; |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2151 const ExtensionIds& strings) { | 2169 const ExtensionIds& strings) { |
2152 ListPrefUpdate update(prefs_, pref); | 2170 ListPrefUpdate update(prefs_, pref); |
2153 ListValue* list_of_values = update.Get(); | 2171 ListValue* list_of_values = update.Get(); |
2154 list_of_values->Clear(); | 2172 list_of_values->Clear(); |
2155 for (ExtensionIds::const_iterator iter = strings.begin(); | 2173 for (ExtensionIds::const_iterator iter = strings.begin(); |
2156 iter != strings.end(); ++iter) | 2174 iter != strings.end(); ++iter) |
2157 list_of_values->Append(new StringValue(*iter)); | 2175 list_of_values->Append(new StringValue(*iter)); |
2158 } | 2176 } |
2159 | 2177 |
2160 } // namespace extensions | 2178 } // namespace extensions |
OLD | NEW |