OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_H_ | 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_H_ |
6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_H_ | 6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> |
11 | 12 |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/scoped_vector.h" | |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "base/scoped_observer.h" | 17 #include "base/scoped_observer.h" |
18 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
19 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_bubble_delegate.h" | 19 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_bubble_delegate.h" |
20 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" | 20 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" |
21 #include "ui/gfx/animation/tween.h" | 21 #include "ui/gfx/animation/tween.h" |
22 #include "ui/gfx/geometry/size.h" | 22 #include "ui/gfx/geometry/size.h" |
23 | 23 |
24 namespace user_prefs { | 24 namespace user_prefs { |
(...skipping 15 matching lines...) Expand all Loading... |
40 // re-ordering. | 40 // re-ordering. |
41 // | 41 // |
42 // This can come in two flavors, main and "overflow". The main bar is visible | 42 // This can come in two flavors, main and "overflow". The main bar is visible |
43 // next to the omnibox, and the overflow bar is visible inside the chrome | 43 // next to the omnibox, and the overflow bar is visible inside the chrome |
44 // app menu. The main bar can have only a single row of icons with flexible | 44 // app menu. The main bar can have only a single row of icons with flexible |
45 // width, whereas the overflow bar has multiple rows of icons with a fixed | 45 // width, whereas the overflow bar has multiple rows of icons with a fixed |
46 // width (the width of the menu). | 46 // width (the width of the menu). |
47 class ToolbarActionsBar : public ToolbarActionsModel::Observer, | 47 class ToolbarActionsBar : public ToolbarActionsModel::Observer, |
48 public TabStripModelObserver { | 48 public TabStripModelObserver { |
49 public: | 49 public: |
| 50 using ToolbarActions = |
| 51 std::vector<std::unique_ptr<ToolbarActionViewController>>; |
| 52 |
50 // A struct to contain the platform settings. | 53 // A struct to contain the platform settings. |
51 struct PlatformSettings { | 54 struct PlatformSettings { |
52 PlatformSettings(); | 55 PlatformSettings(); |
53 | 56 |
54 // The spacing between each of the icons, between the start of the | 57 // The spacing between each of the icons, between the start of the |
55 // container and the first item, and between the last item and end of | 58 // container and the first item, and between the last item and end of |
56 // the container. | 59 // the container. |
57 int item_spacing; | 60 int item_spacing; |
58 // The number of icons per row in the overflow menu. | 61 // The number of icons per row in the overflow menu. |
59 int icons_per_overflow_menu_row; | 62 int icons_per_overflow_menu_row; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 217 |
215 // Displays the given |bubble| once the toolbar is no longer animating. | 218 // Displays the given |bubble| once the toolbar is no longer animating. |
216 void ShowToolbarActionBubble( | 219 void ShowToolbarActionBubble( |
217 std::unique_ptr<ToolbarActionsBarBubbleDelegate> bubble); | 220 std::unique_ptr<ToolbarActionsBarBubbleDelegate> bubble); |
218 // Same as above, but uses PostTask() in all cases. | 221 // Same as above, but uses PostTask() in all cases. |
219 void ShowToolbarActionBubbleAsync( | 222 void ShowToolbarActionBubbleAsync( |
220 std::unique_ptr<ToolbarActionsBarBubbleDelegate> bubble); | 223 std::unique_ptr<ToolbarActionsBarBubbleDelegate> bubble); |
221 | 224 |
222 // Returns the underlying toolbar actions, but does not order them. Primarily | 225 // Returns the underlying toolbar actions, but does not order them. Primarily |
223 // for use in testing. | 226 // for use in testing. |
224 const std::vector<ToolbarActionViewController*>& toolbar_actions_unordered() | 227 const ToolbarActions& toolbar_actions_unordered() const { |
225 const { | 228 return toolbar_actions_; |
226 return toolbar_actions_.get(); | |
227 } | 229 } |
228 bool enabled() const { return model_ != nullptr; } | 230 bool enabled() const { return model_ != nullptr; } |
229 bool suppress_layout() const { return suppress_layout_; } | 231 bool suppress_layout() const { return suppress_layout_; } |
230 bool suppress_animation() const { | 232 bool suppress_animation() const { |
231 return suppress_animation_ || disable_animations_for_testing_; | 233 return suppress_animation_ || disable_animations_for_testing_; |
232 } | 234 } |
233 bool is_highlighting() const { return model_ && model_->is_highlighting(); } | 235 bool is_highlighting() const { return model_ && model_->is_highlighting(); } |
234 ToolbarActionsModel::HighlightType highlight_type() const { | 236 ToolbarActionsModel::HighlightType highlight_type() const { |
235 return model_ ? model_->highlight_type() | 237 return model_ ? model_->highlight_type() |
236 : ToolbarActionsModel::HIGHLIGHT_NONE; | 238 : ToolbarActionsModel::HIGHLIGHT_NONE; |
(...skipping 11 matching lines...) Expand all Loading... |
248 ToolbarActionsBarDelegate* delegate_for_test() { return delegate_; } | 250 ToolbarActionsBarDelegate* delegate_for_test() { return delegate_; } |
249 | 251 |
250 // During testing we can disable animations by setting this flag to true, | 252 // During testing we can disable animations by setting this flag to true, |
251 // so that the bar resizes instantly, instead of having to poll it while it | 253 // so that the bar resizes instantly, instead of having to poll it while it |
252 // animates to open/closed status. | 254 // animates to open/closed status. |
253 static bool disable_animations_for_testing_; | 255 static bool disable_animations_for_testing_; |
254 static void set_extension_bubble_appearance_wait_time_for_testing( | 256 static void set_extension_bubble_appearance_wait_time_for_testing( |
255 int time_in_seconds); | 257 int time_in_seconds); |
256 | 258 |
257 private: | 259 private: |
258 using ToolbarActions = ScopedVector<ToolbarActionViewController>; | |
259 | |
260 // ToolbarActionsModel::Observer: | 260 // ToolbarActionsModel::Observer: |
261 void OnToolbarActionAdded(const ToolbarActionsModel::ToolbarItem& item, | 261 void OnToolbarActionAdded(const ToolbarActionsModel::ToolbarItem& item, |
262 int index) override; | 262 int index) override; |
263 void OnToolbarActionRemoved(const std::string& action_id) override; | 263 void OnToolbarActionRemoved(const std::string& action_id) override; |
264 void OnToolbarActionMoved(const std::string& action_id, int index) override; | 264 void OnToolbarActionMoved(const std::string& action_id, int index) override; |
265 void OnToolbarActionUpdated(const std::string& action_id) override; | 265 void OnToolbarActionUpdated(const std::string& action_id) override; |
266 void OnToolbarVisibleCountChanged() override; | 266 void OnToolbarVisibleCountChanged() override; |
267 void OnToolbarHighlightModeChanged(bool is_highlighting) override; | 267 void OnToolbarHighlightModeChanged(bool is_highlighting) override; |
268 void OnToolbarModelInitialized() override; | 268 void OnToolbarModelInitialized() override; |
269 | 269 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 ScopedObserver<TabStripModel, TabStripModelObserver> tab_strip_observer_; | 360 ScopedObserver<TabStripModel, TabStripModelObserver> tab_strip_observer_; |
361 | 361 |
362 base::ObserverList<ToolbarActionsBarObserver> observers_; | 362 base::ObserverList<ToolbarActionsBarObserver> observers_; |
363 | 363 |
364 base::WeakPtrFactory<ToolbarActionsBar> weak_ptr_factory_; | 364 base::WeakPtrFactory<ToolbarActionsBar> weak_ptr_factory_; |
365 | 365 |
366 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBar); | 366 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBar); |
367 }; | 367 }; |
368 | 368 |
369 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_H_ | 369 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_H_ |
OLD | NEW |