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_pref_value_map.h" | 5 #include "chrome/browser/extensions/extension_pref_value_map.h" |
6 | 6 |
7 #include "base/prefs/pref_value_map.h" | 7 #include "base/prefs/pref_value_map.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 | 10 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 ExtensionEntryMap::const_iterator winner = | 109 ExtensionEntryMap::const_iterator winner = |
110 GetEffectivePrefValueController(pref_key, incognito, from_incognito); | 110 GetEffectivePrefValueController(pref_key, incognito, from_incognito); |
111 if (winner == entries_.end()) | 111 if (winner == entries_.end()) |
112 return false; | 112 return false; |
113 return winner->first == extension_id; | 113 return winner->first == extension_id; |
114 } | 114 } |
115 | 115 |
116 void ExtensionPrefValueMap::RegisterExtension(const std::string& ext_id, | 116 void ExtensionPrefValueMap::RegisterExtension(const std::string& ext_id, |
117 const base::Time& install_time, | 117 const base::Time& install_time, |
118 bool is_enabled) { | 118 bool is_enabled) { |
119 if (entries_.find(ext_id) != entries_.end()) | 119 if (entries_.find(ext_id) == entries_.end()) { |
120 UnregisterExtension(ext_id); | 120 entries_[ext_id] = new ExtensionEntry; |
121 entries_[ext_id] = new ExtensionEntry; | 121 |
122 entries_[ext_id]->install_time = install_time; | 122 // Only update the install time if the extension is newly installed. |
| 123 entries_[ext_id]->install_time = install_time; |
| 124 } |
| 125 |
123 entries_[ext_id]->enabled = is_enabled; | 126 entries_[ext_id]->enabled = is_enabled; |
124 } | 127 } |
125 | 128 |
126 void ExtensionPrefValueMap::UnregisterExtension(const std::string& ext_id) { | 129 void ExtensionPrefValueMap::UnregisterExtension(const std::string& ext_id) { |
127 ExtensionEntryMap::iterator i = entries_.find(ext_id); | 130 ExtensionEntryMap::iterator i = entries_.find(ext_id); |
128 if (i == entries_.end()) | 131 if (i == entries_.end()) |
129 return; | 132 return; |
130 std::set<std::string> keys; // keys set by this extension | 133 std::set<std::string> keys; // keys set by this extension |
131 GetExtensionControlledKeys(*(i->second), &keys); | 134 GetExtensionControlledKeys(*(i->second), &keys); |
132 | 135 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 358 |
356 void ExtensionPrefValueMap::NotifyPrefValueChanged(const std::string& key) { | 359 void ExtensionPrefValueMap::NotifyPrefValueChanged(const std::string& key) { |
357 FOR_EACH_OBSERVER(ExtensionPrefValueMap::Observer, observers_, | 360 FOR_EACH_OBSERVER(ExtensionPrefValueMap::Observer, observers_, |
358 OnPrefValueChanged(key)); | 361 OnPrefValueChanged(key)); |
359 } | 362 } |
360 | 363 |
361 void ExtensionPrefValueMap::NotifyOfDestruction() { | 364 void ExtensionPrefValueMap::NotifyOfDestruction() { |
362 FOR_EACH_OBSERVER(ExtensionPrefValueMap::Observer, observers_, | 365 FOR_EACH_OBSERVER(ExtensionPrefValueMap::Observer, observers_, |
363 OnExtensionPrefValueMapDestruction()); | 366 OnExtensionPrefValueMapDestruction()); |
364 } | 367 } |
OLD | NEW |