| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/views/toolbar/browser_actions_container.h" | 5 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "chrome/browser/extensions/extension_action_manager.h" | 9 #include "chrome/browser/extensions/extension_action_manager.h" |
| 10 #include "chrome/browser/extensions/extension_util.h" | 10 #include "chrome/browser/extensions/extension_util.h" |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 } | 1083 } |
| 1084 | 1084 |
| 1085 size_t BrowserActionsContainer::GetIconCount() const { | 1085 size_t BrowserActionsContainer::GetIconCount() const { |
| 1086 if (!model_) | 1086 if (!model_) |
| 1087 return 0u; | 1087 return 0u; |
| 1088 // Find the number of icons which could be displayed. | 1088 // Find the number of icons which could be displayed. |
| 1089 size_t displayable_icon_count = 0u; | 1089 size_t displayable_icon_count = 0u; |
| 1090 const extensions::ExtensionList& extensions = model_->toolbar_items(); | 1090 const extensions::ExtensionList& extensions = model_->toolbar_items(); |
| 1091 for (extensions::ExtensionList::const_iterator iter = extensions.begin(); | 1091 for (extensions::ExtensionList::const_iterator iter = extensions.begin(); |
| 1092 iter != extensions.end(); ++iter) { | 1092 iter != extensions.end(); ++iter) { |
| 1093 displayable_icon_count += ShouldDisplayBrowserAction(*iter) ? 1u : 0u; | 1093 displayable_icon_count += ShouldDisplayBrowserAction(iter->get()) ? 1u : 0u; |
| 1094 } | 1094 } |
| 1095 // Find the absolute value for the model's visible count. | 1095 // Find the absolute value for the model's visible count. |
| 1096 int model_size = model_->GetVisibleIconCount(); | 1096 int model_size = model_->GetVisibleIconCount(); |
| 1097 size_t absolute_model_size = | 1097 size_t absolute_model_size = |
| 1098 model_size == -1 ? extensions.size() : model_size; | 1098 model_size == -1 ? extensions.size() : model_size; |
| 1099 | 1099 |
| 1100 // The main container will try to show |model_size| icons, but reduce if there | 1100 // The main container will try to show |model_size| icons, but reduce if there |
| 1101 // aren't enough displayable icons to do so. | 1101 // aren't enough displayable icons to do so. |
| 1102 size_t main_displayed = std::min(displayable_icon_count, absolute_model_size); | 1102 size_t main_displayed = std::min(displayable_icon_count, absolute_model_size); |
| 1103 // The overflow will display the extras, if any. | 1103 // The overflow will display the extras, if any. |
| 1104 return in_overflow_mode() ? | 1104 return in_overflow_mode() ? |
| 1105 displayable_icon_count - main_displayed : main_displayed; | 1105 displayable_icon_count - main_displayed : main_displayed; |
| 1106 } | 1106 } |
| OLD | NEW |