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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 content::WebContents* web_contents, | 155 content::WebContents* web_contents, |
156 content::BrowserContext* browser_context) { | 156 content::BrowserContext* browser_context) { |
157 // Notify observers if the extension exists and is in the model. | 157 // Notify observers if the extension exists and is in the model. |
158 if (HasItem( | 158 if (HasItem( |
159 ToolbarItem(extension_action->extension_id(), EXTENSION_ACTION))) { | 159 ToolbarItem(extension_action->extension_id(), EXTENSION_ACTION))) { |
160 for (Observer& observer : observers_) | 160 for (Observer& observer : observers_) |
161 observer.OnToolbarActionUpdated(extension_action->extension_id()); | 161 observer.OnToolbarActionUpdated(extension_action->extension_id()); |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 ScopedVector<ToolbarActionViewController> ToolbarActionsModel::CreateActions( | 165 std::vector<std::unique_ptr<ToolbarActionViewController>> |
166 Browser* browser, | 166 ToolbarActionsModel::CreateActions(Browser* browser, ToolbarActionsBar* bar) { |
167 ToolbarActionsBar* bar) { | |
168 DCHECK(browser); | 167 DCHECK(browser); |
169 DCHECK(bar); | 168 DCHECK(bar); |
170 ScopedVector<ToolbarActionViewController> action_list; | 169 std::vector<std::unique_ptr<ToolbarActionViewController>> action_list; |
171 | 170 |
172 // toolbar_items() might not equate to toolbar_items_ in the case where a | 171 // toolbar_items() might not equate to toolbar_items_ in the case where a |
173 // subset is highlighted. | 172 // subset is highlighted. |
174 for (const ToolbarItem& item : toolbar_items()) | 173 for (const ToolbarItem& item : toolbar_items()) |
175 action_list.push_back(CreateActionForItem(browser, bar, item).release()); | 174 action_list.push_back(CreateActionForItem(browser, bar, item)); |
176 | 175 |
177 return action_list; | 176 return action_list; |
178 } | 177 } |
179 | 178 |
180 std::unique_ptr<ToolbarActionViewController> | 179 std::unique_ptr<ToolbarActionViewController> |
181 ToolbarActionsModel::CreateActionForItem(Browser* browser, | 180 ToolbarActionsModel::CreateActionForItem(Browser* browser, |
182 ToolbarActionsBar* bar, | 181 ToolbarActionsBar* bar, |
183 const ToolbarItem& item) { | 182 const ToolbarItem& item) { |
184 std::unique_ptr<ToolbarActionViewController> result; | 183 std::unique_ptr<ToolbarActionViewController> result; |
185 switch (item.type) { | 184 switch (item.type) { |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 return extension_registry_->enabled_extensions().GetByID(id); | 859 return extension_registry_->enabled_extensions().GetByID(id); |
861 } | 860 } |
862 | 861 |
863 bool ToolbarActionsModel::IsActionVisible(const std::string& action_id) const { | 862 bool ToolbarActionsModel::IsActionVisible(const std::string& action_id) const { |
864 size_t index = 0u; | 863 size_t index = 0u; |
865 while (toolbar_items().size() > index && | 864 while (toolbar_items().size() > index && |
866 toolbar_items()[index].id != action_id) | 865 toolbar_items()[index].id != action_id) |
867 ++index; | 866 ++index; |
868 return index < visible_icon_count(); | 867 return index < visible_icon_count(); |
869 } | 868 } |
OLD | NEW |