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_toolbar_model.h" | 5 #include "chrome/browser/extensions/extension_toolbar_model.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/metrics/histogram_base.h" | 10 #include "base/metrics/histogram_base.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 if (pos != last_known_positions_.end()) { | 203 if (pos != last_known_positions_.end()) { |
204 last_known_positions_.erase(pos); | 204 last_known_positions_.erase(pos); |
205 UpdatePrefs(); | 205 UpdatePrefs(); |
206 } | 206 } |
207 } | 207 } |
208 | 208 |
209 void ExtensionToolbarModel::Observe( | 209 void ExtensionToolbarModel::Observe( |
210 int type, | 210 int type, |
211 const content::NotificationSource& source, | 211 const content::NotificationSource& source, |
212 const content::NotificationDetails& details) { | 212 const content::NotificationDetails& details) { |
213 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, | 213 DCHECK_EQ( |
214 type); | 214 extensions::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, |
| 215 type); |
215 const Extension* extension = | 216 const Extension* extension = |
216 ExtensionRegistry::Get(profile_)->GetExtensionById( | 217 ExtensionRegistry::Get(profile_)->GetExtensionById( |
217 *content::Details<const std::string>(details).ptr(), | 218 *content::Details<const std::string>(details).ptr(), |
218 ExtensionRegistry::EVERYTHING); | 219 ExtensionRegistry::EVERYTHING); |
219 if (ExtensionActionAPI::GetBrowserActionVisibility(extension_prefs_, | 220 if (ExtensionActionAPI::GetBrowserActionVisibility(extension_prefs_, |
220 extension->id())) | 221 extension->id())) |
221 AddExtension(extension); | 222 AddExtension(extension); |
222 else | 223 else |
223 RemoveExtension(extension); | 224 RemoveExtension(extension); |
224 } | 225 } |
225 | 226 |
226 void ExtensionToolbarModel::OnReady() { | 227 void ExtensionToolbarModel::OnReady() { |
227 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); | 228 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); |
228 InitializeExtensionList(registry->enabled_extensions()); | 229 InitializeExtensionList(registry->enabled_extensions()); |
229 // Wait until the extension system is ready before observing any further | 230 // Wait until the extension system is ready before observing any further |
230 // changes so that the toolbar buttons can be shown in their stable ordering | 231 // changes so that the toolbar buttons can be shown in their stable ordering |
231 // taken from prefs. | 232 // taken from prefs. |
232 extension_registry_observer_.Add(registry); | 233 extension_registry_observer_.Add(registry); |
233 registrar_.Add( | 234 registrar_.Add( |
234 this, | 235 this, |
235 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, | 236 extensions::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, |
236 content::Source<ExtensionPrefs>(extension_prefs_)); | 237 content::Source<ExtensionPrefs>(extension_prefs_)); |
237 } | 238 } |
238 | 239 |
239 size_t ExtensionToolbarModel::FindNewPositionFromLastKnownGood( | 240 size_t ExtensionToolbarModel::FindNewPositionFromLastKnownGood( |
240 const Extension* extension) { | 241 const Extension* extension) { |
241 // See if we have last known good position for this extension. | 242 // See if we have last known good position for this extension. |
242 size_t new_index = 0; | 243 size_t new_index = 0; |
243 // Loop through the ID list of known positions, to count the number of visible | 244 // Loop through the ID list of known positions, to count the number of visible |
244 // browser action icons preceding |extension|. | 245 // browser action icons preceding |extension|. |
245 for (ExtensionIdList::const_iterator iter_id = last_known_positions_.begin(); | 246 for (ExtensionIdList::const_iterator iter_id = last_known_positions_.begin(); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 is_highlighting_ = false; | 584 is_highlighting_ = false; |
584 if (old_visible_icon_count_ != visible_icon_count_) { | 585 if (old_visible_icon_count_ != visible_icon_count_) { |
585 SetVisibleIconCount(old_visible_icon_count_); | 586 SetVisibleIconCount(old_visible_icon_count_); |
586 FOR_EACH_OBSERVER(Observer, observers_, VisibleCountChanged()); | 587 FOR_EACH_OBSERVER(Observer, observers_, VisibleCountChanged()); |
587 } | 588 } |
588 FOR_EACH_OBSERVER(Observer, observers_, HighlightModeChanged(false)); | 589 FOR_EACH_OBSERVER(Observer, observers_, HighlightModeChanged(false)); |
589 } | 590 } |
590 } | 591 } |
591 | 592 |
592 } // namespace extensions | 593 } // namespace extensions |
OLD | NEW |