OLD | NEW |
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-inl.h" | 7 #include "base/stl_util-inl.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 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 delete i->second; | 95 delete i->second; |
96 entries_.erase(i); | 96 entries_.erase(i); |
97 | 97 |
98 NotifyPrefValueChanged(keys); | 98 NotifyPrefValueChanged(keys); |
99 } | 99 } |
100 | 100 |
101 void ExtensionPrefValueMap::SetExtensionState(const std::string& ext_id, | 101 void ExtensionPrefValueMap::SetExtensionState(const std::string& ext_id, |
102 bool is_enabled) { | 102 bool is_enabled) { |
103 ExtensionEntryMap::const_iterator i = entries_.find(ext_id); | 103 ExtensionEntryMap::const_iterator i = entries_.find(ext_id); |
104 CHECK(i != entries_.end()); | 104 // This may happen when sync sets the extension state for an |
| 105 // extension that is not installed. |
| 106 if (i == entries_.end()) |
| 107 return; |
105 if (i->second->enabled == is_enabled) | 108 if (i->second->enabled == is_enabled) |
106 return; | 109 return; |
107 std::set<std::string> keys; // keys set by this extension | 110 std::set<std::string> keys; // keys set by this extension |
108 GetExtensionControlledKeys(*(i->second), &keys); | 111 GetExtensionControlledKeys(*(i->second), &keys); |
109 i->second->enabled = is_enabled; | 112 i->second->enabled = is_enabled; |
110 NotifyPrefValueChanged(keys); | 113 NotifyPrefValueChanged(keys); |
111 } | 114 } |
112 | 115 |
113 PrefValueMap* ExtensionPrefValueMap::GetExtensionPrefValueMap( | 116 PrefValueMap* ExtensionPrefValueMap::GetExtensionPrefValueMap( |
114 const std::string& ext_id, | 117 const std::string& ext_id, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 239 |
237 void ExtensionPrefValueMap::NotifyPrefValueChanged(const std::string& key) { | 240 void ExtensionPrefValueMap::NotifyPrefValueChanged(const std::string& key) { |
238 FOR_EACH_OBSERVER(ExtensionPrefValueMap::Observer, observers_, | 241 FOR_EACH_OBSERVER(ExtensionPrefValueMap::Observer, observers_, |
239 OnPrefValueChanged(key)); | 242 OnPrefValueChanged(key)); |
240 } | 243 } |
241 | 244 |
242 void ExtensionPrefValueMap::NotifyOfDestruction() { | 245 void ExtensionPrefValueMap::NotifyOfDestruction() { |
243 FOR_EACH_OBSERVER(ExtensionPrefValueMap::Observer, observers_, | 246 FOR_EACH_OBSERVER(ExtensionPrefValueMap::Observer, observers_, |
244 OnExtensionPrefValueMapDestruction()); | 247 OnExtensionPrefValueMapDestruction()); |
245 } | 248 } |
OLD | NEW |