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

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

Issue 10875027: Restart running apps when chrome restarts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 22 matching lines...) Expand all
33 #if defined(OS_WIN) 33 #if defined(OS_WIN)
34 #include "base/win/metro.h" 34 #include "base/win/metro.h"
35 #endif // OS_WIN 35 #endif // OS_WIN
36 36
37 namespace extensions { 37 namespace extensions {
38 38
39 namespace { 39 namespace {
40 40
41 // Additional preferences keys 41 // Additional preferences keys
42 42
43 // Whether this extension was running when chrome last shutdown.
44 const char kPrefRunning[] = "running";
45
43 // Where an extension was installed from. (see Extension::Location) 46 // Where an extension was installed from. (see Extension::Location)
44 const char kPrefLocation[] = "location"; 47 const char kPrefLocation[] = "location";
45 48
46 // Enabled, disabled, killed, etc. (see Extension::State) 49 // Enabled, disabled, killed, etc. (see Extension::State)
47 const char kPrefState[] = "state"; 50 const char kPrefState[] = "state";
48 51
49 // The path to the current version's manifest file. 52 // The path to the current version's manifest file.
50 const char kPrefPath[] = "path"; 53 const char kPrefPath[] = "path";
51 54
52 // The dictionary containing the extension's manifest. 55 // The dictionary containing the extension's manifest.
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 void ExtensionPrefs::SetRegisteredEvents( 1138 void ExtensionPrefs::SetRegisteredEvents(
1136 const std::string& extension_id, const std::set<std::string>& events) { 1139 const std::string& extension_id, const std::set<std::string>& events) {
1137 ListValue* value = new ListValue(); 1140 ListValue* value = new ListValue();
1138 for (std::set<std::string>::const_iterator it = events.begin(); 1141 for (std::set<std::string>::const_iterator it = events.begin();
1139 it != events.end(); ++it) { 1142 it != events.end(); ++it) {
1140 value->Append(new StringValue(*it)); 1143 value->Append(new StringValue(*it));
1141 } 1144 }
1142 UpdateExtensionPref(extension_id, kRegisteredEvents, value); 1145 UpdateExtensionPref(extension_id, kRegisteredEvents, value);
1143 } 1146 }
1144 1147
1148 void ExtensionPrefs::SetExtensionRunning(const std::string& extension_id,
1149 bool is_running) {
1150 Value* value = Value::CreateBooleanValue(is_running);
1151 UpdateExtensionPref(extension_id, kPrefRunning, value);
1152 }
1153
1154 bool ExtensionPrefs::IsExtensionRunning(const std::string& extension_id) {
1155 const DictionaryValue* extension = GetExtensionPref(extension_id);
1156 if (!extension)
1157 return false;
1158 bool running = false;
1159 extension->GetBoolean(kPrefRunning, &running);
1160 return running;
1161 }
1162
1145 ExtensionOmniboxSuggestion 1163 ExtensionOmniboxSuggestion
1146 ExtensionPrefs::GetOmniboxDefaultSuggestion(const std::string& extension_id) { 1164 ExtensionPrefs::GetOmniboxDefaultSuggestion(const std::string& extension_id) {
1147 ExtensionOmniboxSuggestion suggestion; 1165 ExtensionOmniboxSuggestion suggestion;
1148 1166
1149 const DictionaryValue* extension = GetExtensionPref(extension_id); 1167 const DictionaryValue* extension = GetExtensionPref(extension_id);
1150 const DictionaryValue* dict = NULL; 1168 const DictionaryValue* dict = NULL;
1151 if (extension && extension->GetDictionary(kOmniboxDefaultSuggestion, &dict)) 1169 if (extension && extension->GetDictionary(kOmniboxDefaultSuggestion, &dict))
1152 suggestion.Populate(*dict, false); 1170 suggestion.Populate(*dict, false);
1153 1171
1154 return suggestion; 1172 return suggestion;
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 const ExtensionIdList& strings) { 2238 const ExtensionIdList& strings) {
2221 ListPrefUpdate update(prefs_, pref); 2239 ListPrefUpdate update(prefs_, pref);
2222 ListValue* list_of_values = update.Get(); 2240 ListValue* list_of_values = update.Get();
2223 list_of_values->Clear(); 2241 list_of_values->Clear();
2224 for (ExtensionIdList::const_iterator iter = strings.begin(); 2242 for (ExtensionIdList::const_iterator iter = strings.begin();
2225 iter != strings.end(); ++iter) 2243 iter != strings.end(); ++iter)
2226 list_of_values->Append(new StringValue(*iter)); 2244 list_of_values->Append(new StringValue(*iter));
2227 } 2245 }
2228 2246
2229 } // namespace extensions 2247 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.h ('k') | chrome/browser/extensions/platform_app_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698