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

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

Issue 567037: Initial work on making extensions work in incognito mode. (Closed)
Patch Set: added experimental requirement Created 10 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/string_util.h" 5 #include "base/string_util.h"
6 #include "chrome/browser/extensions/extension_prefs.h" 6 #include "chrome/browser/extensions/extension_prefs.h"
7 #include "chrome/common/extensions/extension.h" 7 #include "chrome/common/extensions/extension.h"
8 8
9 using base::Time; 9 using base::Time;
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 const wchar_t kExtensionShelf[] = L"extensions.shelf"; 42 const wchar_t kExtensionShelf[] = L"extensions.shelf";
43 43
44 // A preference that tracks browser action toolbar configuration. This is a list 44 // A preference that tracks browser action toolbar configuration. This is a list
45 // object stored in the Preferences file. The extensions are stored by ID. 45 // object stored in the Preferences file. The extensions are stored by ID.
46 const wchar_t kExtensionToolbar[] = L"extensions.toolbar"; 46 const wchar_t kExtensionToolbar[] = L"extensions.toolbar";
47 47
48 // The key for a serialized Time value indicating the start of the day (from the 48 // The key for a serialized Time value indicating the start of the day (from the
49 // server's perspective) an extension last included a "ping" parameter during 49 // server's perspective) an extension last included a "ping" parameter during
50 // its update check. 50 // its update check.
51 const wchar_t kLastPingDay[] = L"lastpingday"; 51 const wchar_t kLastPingDay[] = L"lastpingday";
52
53 // A preference that, if true, will allow this extension to run in incognito
54 // mode.
55 const wchar_t kPrefIncognitoEnabled[] = L"incognito";
52 } 56 }
53 57
54 //////////////////////////////////////////////////////////////////////////////// 58 ////////////////////////////////////////////////////////////////////////////////
55 59
56 ExtensionPrefs::ExtensionPrefs(PrefService* prefs, const FilePath& root_dir) 60 ExtensionPrefs::ExtensionPrefs(PrefService* prefs, const FilePath& root_dir)
57 : prefs_(prefs), 61 : prefs_(prefs),
58 install_directory_(root_dir) { 62 install_directory_(root_dir) {
59 if (!prefs_->FindPreference(kExtensionsPref)) 63 if (!prefs_->FindPreference(kExtensionsPref))
60 prefs_->RegisterDictionaryPref(kExtensionsPref); 64 prefs_->RegisterDictionaryPref(kExtensionsPref);
61 if (!prefs->FindPreference(kExtensionShelf)) 65 if (!prefs->FindPreference(kExtensionShelf))
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 254 }
251 255
252 void ExtensionPrefs::SetLastPingDay(const std::string& extension_id, 256 void ExtensionPrefs::SetLastPingDay(const std::string& extension_id,
253 const Time& time) { 257 const Time& time) {
254 std::string value = Int64ToString(time.ToInternalValue()); 258 std::string value = Int64ToString(time.ToInternalValue());
255 UpdateExtensionPref(extension_id, kLastPingDay, 259 UpdateExtensionPref(extension_id, kLastPingDay,
256 Value::CreateStringValue(value)); 260 Value::CreateStringValue(value));
257 prefs_->ScheduleSavePersistentPrefs(); 261 prefs_->ScheduleSavePersistentPrefs();
258 } 262 }
259 263
264 bool ExtensionPrefs::IsIncognitoEnabled(const std::string& extension_id) {
265 return ReadExtensionPrefBoolean(extension_id, kPrefIncognitoEnabled);
266 }
267
268 void ExtensionPrefs::SetIsIncognitoEnabled(const std::string& extension_id,
269 bool enabled) {
270 UpdateExtensionPref(extension_id, kPrefIncognitoEnabled,
271 Value::CreateBooleanValue(enabled));
272 prefs_->SavePersistentPrefs();
273 }
260 274
261 void ExtensionPrefs::GetKilledExtensionIds(std::set<std::string>* killed_ids) { 275 void ExtensionPrefs::GetKilledExtensionIds(std::set<std::string>* killed_ids) {
262 const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref); 276 const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref);
263 if (!dict || dict->empty()) 277 if (!dict || dict->empty())
264 return; 278 return;
265 279
266 for (DictionaryValue::key_iterator i = dict->begin_keys(); 280 for (DictionaryValue::key_iterator i = dict->begin_keys();
267 i != dict->end_keys(); ++i) { 281 i != dict->end_keys(); ++i) {
268 std::wstring key_name = *i; 282 std::wstring key_name = *i;
269 if (!Extension::IdIsValid(WideToASCII(key_name))) { 283 if (!Extension::IdIsValid(WideToASCII(key_name))) {
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 546
533 Extension::Location location = 547 Extension::Location location =
534 static_cast<Extension::Location>(location_value); 548 static_cast<Extension::Location>(location_value);
535 549
536 extensions_info->push_back(linked_ptr<ExtensionInfo>(new ExtensionInfo( 550 extensions_info->push_back(linked_ptr<ExtensionInfo>(new ExtensionInfo(
537 manifest, WideToASCII(*extension_id), FilePath(path), location))); 551 manifest, WideToASCII(*extension_id), FilePath(path), location)));
538 } 552 }
539 553
540 return extensions_info; 554 return extensions_info;
541 } 555 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.h ('k') | chrome/browser/extensions/extension_toolbar_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698