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

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

Issue 9764006: Make ExtensionPrefValueMap a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: -- Created 8 years, 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_pref_value_map.h" 5 #include "chrome/browser/extensions/extension_pref_value_map.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/prefs/pref_value_map.h" 9 #include "chrome/browser/prefs/pref_value_map.h"
10 10
11 struct ExtensionPrefValueMap::ExtensionEntry { 11 struct ExtensionPrefValueMap::ExtensionEntry {
12 // Installation time of the extension. 12 // Installation time of the extension.
13 base::Time install_time; 13 base::Time install_time;
14 // Whether extension is enabled in the profile. 14 // Whether extension is enabled in the profile.
15 bool enabled; 15 bool enabled;
16 // Extension controlled preferences for the regular profile. 16 // Extension controlled preferences for the regular profile.
17 PrefValueMap regular_profile_preferences; 17 PrefValueMap regular_profile_preferences;
18 // Persistent extension controlled preferences for the incognito profile, 18 // Persistent extension controlled preferences for the incognito profile,
19 // empty for regular profile ExtensionPrefStore. 19 // empty for regular profile ExtensionPrefStore.
20 PrefValueMap incognito_profile_preferences_persistent; 20 PrefValueMap incognito_profile_preferences_persistent;
21 // Session only extension controlled preferences for the incognito profile. 21 // Session only extension controlled preferences for the incognito profile.
22 // These preferences are deleted when the incognito profile is destroyed. 22 // These preferences are deleted when the incognito profile is destroyed.
23 PrefValueMap incognito_profile_preferences_session_only; 23 PrefValueMap incognito_profile_preferences_session_only;
24 }; 24 };
25 25
26 ExtensionPrefValueMap::ExtensionPrefValueMap() { 26 ExtensionPrefValueMap::ExtensionPrefValueMap() : destroyed_(false) {
27 } 27 }
28 28
29 ExtensionPrefValueMap::~ExtensionPrefValueMap() { 29 ExtensionPrefValueMap::~ExtensionPrefValueMap() {
30 NotifyOfDestruction(); 30 if (!destroyed_) {
31 NotifyOfDestruction();
32 destroyed_ = true;
33 }
31 STLDeleteValues(&entries_); 34 STLDeleteValues(&entries_);
32 entries_.clear(); 35 entries_.clear();
33 } 36 }
34 37
38 void ExtensionPrefValueMap::Shutdown() {
39 NotifyOfDestruction();
40 destroyed_ = true;
41 }
42
35 void ExtensionPrefValueMap::SetExtensionPref(const std::string& ext_id, 43 void ExtensionPrefValueMap::SetExtensionPref(const std::string& ext_id,
36 const std::string& key, 44 const std::string& key,
37 ExtensionPrefsScope scope, 45 ExtensionPrefsScope scope,
38 Value* value) { 46 Value* value) {
39 PrefValueMap* prefs = GetExtensionPrefValueMap(ext_id, scope); 47 PrefValueMap* prefs = GetExtensionPrefValueMap(ext_id, scope);
40 48
41 if (prefs->SetValue(key, value)) 49 if (prefs->SetValue(key, value))
42 NotifyPrefValueChanged(key); 50 NotifyPrefValueChanged(key);
43 } 51 }
44 52
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 322
315 void ExtensionPrefValueMap::NotifyPrefValueChanged(const std::string& key) { 323 void ExtensionPrefValueMap::NotifyPrefValueChanged(const std::string& key) {
316 FOR_EACH_OBSERVER(ExtensionPrefValueMap::Observer, observers_, 324 FOR_EACH_OBSERVER(ExtensionPrefValueMap::Observer, observers_,
317 OnPrefValueChanged(key)); 325 OnPrefValueChanged(key));
318 } 326 }
319 327
320 void ExtensionPrefValueMap::NotifyOfDestruction() { 328 void ExtensionPrefValueMap::NotifyOfDestruction() {
321 FOR_EACH_OBSERVER(ExtensionPrefValueMap::Observer, observers_, 329 FOR_EACH_OBSERVER(ExtensionPrefValueMap::Observer, observers_,
322 OnExtensionPrefValueMapDestruction()); 330 OnExtensionPrefValueMapDestruction());
323 } 331 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_pref_value_map.h ('k') | chrome/browser/extensions/extension_pref_value_map_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698