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/ui/toolbar/toolbar_actions_model.h" | 5 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // We don't want to add the same extension twice. It may have already been | 221 // We don't want to add the same extension twice. It may have already been |
222 // added by EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED below, if the user | 222 // added by EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED below, if the user |
223 // hides the browser action and then disables and enables the extension. | 223 // hides the browser action and then disables and enables the extension. |
224 if (!HasItem(ToolbarItem(extension->id(), EXTENSION_ACTION))) | 224 if (!HasItem(ToolbarItem(extension->id(), EXTENSION_ACTION))) |
225 AddExtension(extension); | 225 AddExtension(extension); |
226 } | 226 } |
227 | 227 |
228 void ToolbarActionsModel::OnExtensionUnloaded( | 228 void ToolbarActionsModel::OnExtensionUnloaded( |
229 content::BrowserContext* browser_context, | 229 content::BrowserContext* browser_context, |
230 const extensions::Extension* extension, | 230 const extensions::Extension* extension, |
231 extensions::UnloadedExtensionInfo::Reason reason) { | 231 extensions::UnloadedExtensionReason reason) { |
232 bool was_visible_and_has_overflow = | 232 bool was_visible_and_has_overflow = |
233 IsActionVisible(extension->id()) && !all_icons_visible(); | 233 IsActionVisible(extension->id()) && !all_icons_visible(); |
234 RemoveExtension(extension); | 234 RemoveExtension(extension); |
235 // If the extension was previously visible and there are overflowed | 235 // If the extension was previously visible and there are overflowed |
236 // extensions, and this extension is being uninstalled, we reduce the visible | 236 // extensions, and this extension is being uninstalled, we reduce the visible |
237 // count so that we don't pop out a previously-hidden extension. | 237 // count so that we don't pop out a previously-hidden extension. |
238 if (was_visible_and_has_overflow && | 238 if (was_visible_and_has_overflow && |
239 reason == extensions::UnloadedExtensionInfo::REASON_UNINSTALL) | 239 reason == extensions::UnloadedExtensionReason::UNINSTALL) |
240 SetVisibleIconCount(visible_icon_count() - 1); | 240 SetVisibleIconCount(visible_icon_count() - 1); |
241 } | 241 } |
242 | 242 |
243 void ToolbarActionsModel::OnExtensionUninstalled( | 243 void ToolbarActionsModel::OnExtensionUninstalled( |
244 content::BrowserContext* browser_context, | 244 content::BrowserContext* browser_context, |
245 const extensions::Extension* extension, | 245 const extensions::Extension* extension, |
246 extensions::UninstallReason reason) { | 246 extensions::UninstallReason reason) { |
247 // Remove the extension id from the ordered list, if it exists (the extension | 247 // Remove the extension id from the ordered list, if it exists (the extension |
248 // might not be represented in the list because it might not have an icon). | 248 // might not be represented in the list because it might not have an icon). |
249 RemovePref(ToolbarItem(extension->id(), EXTENSION_ACTION)); | 249 RemovePref(ToolbarItem(extension->id(), EXTENSION_ACTION)); |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 return extension_registry_->enabled_extensions().GetByID(id); | 861 return extension_registry_->enabled_extensions().GetByID(id); |
862 } | 862 } |
863 | 863 |
864 bool ToolbarActionsModel::IsActionVisible(const std::string& action_id) const { | 864 bool ToolbarActionsModel::IsActionVisible(const std::string& action_id) const { |
865 size_t index = 0u; | 865 size_t index = 0u; |
866 while (toolbar_items().size() > index && | 866 while (toolbar_items().size() > index && |
867 toolbar_items()[index].id != action_id) | 867 toolbar_items()[index].id != action_id) |
868 ++index; | 868 ++index; |
869 return index < visible_icon_count(); | 869 return index < visible_icon_count(); |
870 } | 870 } |
OLD | NEW |