| 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 18 matching lines...) Expand all Loading... |
| 29 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
| 30 #include "base/win/metro.h" | 30 #include "base/win/metro.h" |
| 31 #endif // OS_WIN | 31 #endif // OS_WIN |
| 32 | 32 |
| 33 namespace extensions { | 33 namespace extensions { |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 // Additional preferences keys | 37 // Additional preferences keys |
| 38 | 38 |
| 39 // Whether this extension was running when chrome last shutdown. | |
| 40 const char kPrefRunning[] = "running"; | |
| 41 | |
| 42 // Where an extension was installed from. (see Extension::Location) | 39 // Where an extension was installed from. (see Extension::Location) |
| 43 const char kPrefLocation[] = "location"; | 40 const char kPrefLocation[] = "location"; |
| 44 | 41 |
| 45 // Enabled, disabled, killed, etc. (see Extension::State) | 42 // Enabled, disabled, killed, etc. (see Extension::State) |
| 46 const char kPrefState[] = "state"; | 43 const char kPrefState[] = "state"; |
| 47 | 44 |
| 48 // The path to the current version's manifest file. | 45 // The path to the current version's manifest file. |
| 49 const char kPrefPath[] = "path"; | 46 const char kPrefPath[] = "path"; |
| 50 | 47 |
| 51 // The dictionary containing the extension's manifest. | 48 // The dictionary containing the extension's manifest. |
| (...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 void ExtensionPrefs::SetRegisteredEvents( | 1090 void ExtensionPrefs::SetRegisteredEvents( |
| 1094 const std::string& extension_id, const std::set<std::string>& events) { | 1091 const std::string& extension_id, const std::set<std::string>& events) { |
| 1095 ListValue* value = new ListValue(); | 1092 ListValue* value = new ListValue(); |
| 1096 for (std::set<std::string>::const_iterator it = events.begin(); | 1093 for (std::set<std::string>::const_iterator it = events.begin(); |
| 1097 it != events.end(); ++it) { | 1094 it != events.end(); ++it) { |
| 1098 value->Append(new StringValue(*it)); | 1095 value->Append(new StringValue(*it)); |
| 1099 } | 1096 } |
| 1100 UpdateExtensionPref(extension_id, kRegisteredEvents, value); | 1097 UpdateExtensionPref(extension_id, kRegisteredEvents, value); |
| 1101 } | 1098 } |
| 1102 | 1099 |
| 1103 void ExtensionPrefs::SetExtensionRunning(const std::string& extension_id, | |
| 1104 bool is_running) { | |
| 1105 Value* value = Value::CreateBooleanValue(is_running); | |
| 1106 UpdateExtensionPref(extension_id, kPrefRunning, value); | |
| 1107 } | |
| 1108 | |
| 1109 bool ExtensionPrefs::IsExtensionRunning(const std::string& extension_id) { | |
| 1110 const DictionaryValue* extension = GetExtensionPref(extension_id); | |
| 1111 if (!extension) | |
| 1112 return false; | |
| 1113 bool running = false; | |
| 1114 extension->GetBoolean(kPrefRunning, &running); | |
| 1115 return running; | |
| 1116 } | |
| 1117 | |
| 1118 ExtensionOmniboxSuggestion | 1100 ExtensionOmniboxSuggestion |
| 1119 ExtensionPrefs::GetOmniboxDefaultSuggestion(const std::string& extension_id) { | 1101 ExtensionPrefs::GetOmniboxDefaultSuggestion(const std::string& extension_id) { |
| 1120 ExtensionOmniboxSuggestion suggestion; | 1102 ExtensionOmniboxSuggestion suggestion; |
| 1121 | 1103 |
| 1122 const DictionaryValue* extension = GetExtensionPref(extension_id); | 1104 const DictionaryValue* extension = GetExtensionPref(extension_id); |
| 1123 const DictionaryValue* dict = NULL; | 1105 const DictionaryValue* dict = NULL; |
| 1124 if (extension && extension->GetDictionary(kOmniboxDefaultSuggestion, &dict)) | 1106 if (extension && extension->GetDictionary(kOmniboxDefaultSuggestion, &dict)) |
| 1125 suggestion.Populate(*dict, false); | 1107 suggestion.Populate(*dict, false); |
| 1126 | 1108 |
| 1127 return suggestion; | 1109 return suggestion; |
| (...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 const ExtensionIds& strings) { | 2161 const ExtensionIds& strings) { |
| 2180 ListPrefUpdate update(prefs_, pref); | 2162 ListPrefUpdate update(prefs_, pref); |
| 2181 ListValue* list_of_values = update.Get(); | 2163 ListValue* list_of_values = update.Get(); |
| 2182 list_of_values->Clear(); | 2164 list_of_values->Clear(); |
| 2183 for (ExtensionIds::const_iterator iter = strings.begin(); | 2165 for (ExtensionIds::const_iterator iter = strings.begin(); |
| 2184 iter != strings.end(); ++iter) | 2166 iter != strings.end(); ++iter) |
| 2185 list_of_values->Append(new StringValue(*iter)); | 2167 list_of_values->Append(new StringValue(*iter)); |
| 2186 } | 2168 } |
| 2187 | 2169 |
| 2188 } // namespace extensions | 2170 } // namespace extensions |
| OLD | NEW |