| 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 "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // including extension actions and component actions. | 29 // including extension actions and component actions. |
| 30 // This class manages the order of the actions, the actions' state, and owns the | 30 // This class manages the order of the actions, the actions' state, and owns the |
| 31 // action controllers, in addition to (for extensions) interfacing with the | 31 // action controllers, in addition to (for extensions) interfacing with the |
| 32 // extension toolbar model. Further, it manages dimensions for the bar, | 32 // extension toolbar model. Further, it manages dimensions for the bar, |
| 33 // excluding animations. | 33 // excluding animations. |
| 34 // This can come in two flavors, main and "overflow". The main bar is visible | 34 // This can come in two flavors, main and "overflow". The main bar is visible |
| 35 // next to the omnibox, and the overflow bar is visible inside the chrome | 35 // next to the omnibox, and the overflow bar is visible inside the chrome |
| 36 // (fka wrench) menu. The main bar can have only a single row of icons with | 36 // (fka wrench) menu. The main bar can have only a single row of icons with |
| 37 // flexible width, whereas the overflow bar has multiple rows of icons with a | 37 // flexible width, whereas the overflow bar has multiple rows of icons with a |
| 38 // fixed width (the width of the menu). | 38 // fixed width (the width of the menu). |
| 39 class ToolbarActionsBar : public extensions::ExtensionToolbarModel::Observer, | 39 class ToolbarActionsBar : public extensions::ExtensionToolbarModel::Observer { |
| 40 public ToolbarActionsBarBubbleDelegate { | |
| 41 public: | 40 public: |
| 42 // A struct to contain the platform settings. | 41 // A struct to contain the platform settings. |
| 43 struct PlatformSettings { | 42 struct PlatformSettings { |
| 44 explicit PlatformSettings(bool in_overflow_mode); | 43 explicit PlatformSettings(bool in_overflow_mode); |
| 45 | 44 |
| 46 // The padding that comes before the first icon in the container. | 45 // The padding that comes before the first icon in the container. |
| 47 int left_padding; | 46 int left_padding; |
| 48 // The padding following the final icon in the container. | 47 // The padding following the final icon in the container. |
| 49 int right_padding; | 48 int right_padding; |
| 50 // The spacing between each of the icons. | 49 // The spacing between each of the icons. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 115 |
| 117 // Notifies the ToolbarActionsBar that a user completed a drag and drop event, | 116 // Notifies the ToolbarActionsBar that a user completed a drag and drop event, |
| 118 // and dragged the view from |dragged_index| to |dropped_index|. | 117 // and dragged the view from |dragged_index| to |dropped_index|. |
| 119 // |drag_type| indicates whether or not the icon was dragged between the | 118 // |drag_type| indicates whether or not the icon was dragged between the |
| 120 // overflow and main containers. | 119 // overflow and main containers. |
| 121 // The main container should handle all drag/drop notifications. | 120 // The main container should handle all drag/drop notifications. |
| 122 void OnDragDrop(int dragged_index, | 121 void OnDragDrop(int dragged_index, |
| 123 int dropped_index, | 122 int dropped_index, |
| 124 DragType drag_type); | 123 DragType drag_type); |
| 125 | 124 |
| 126 // Returns true if the info bubble about the toolbar redesign should be shown. | |
| 127 bool ShouldShowInfoBubble(); | |
| 128 | |
| 129 const std::vector<ToolbarActionViewController*>& toolbar_actions() const { | 125 const std::vector<ToolbarActionViewController*>& toolbar_actions() const { |
| 130 return toolbar_actions_.get(); | 126 return toolbar_actions_.get(); |
| 131 } | 127 } |
| 132 bool enabled() const { return model_ != nullptr; } | 128 bool enabled() const { return model_ != nullptr; } |
| 133 bool suppress_layout() const { return suppress_layout_; } | 129 bool suppress_layout() const { return suppress_layout_; } |
| 134 bool suppress_animation() const { | 130 bool suppress_animation() const { |
| 135 return suppress_animation_ || disable_animations_for_testing_; | 131 return suppress_animation_ || disable_animations_for_testing_; |
| 136 } | 132 } |
| 137 bool is_highlighting() const { return model_ && model_->is_highlighting(); } | 133 bool is_highlighting() const { return model_ && model_->is_highlighting(); } |
| 138 const PlatformSettings& platform_settings() const { | 134 const PlatformSettings& platform_settings() const { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 int index) override; | 166 int index) override; |
| 171 void OnToolbarExtensionUpdated( | 167 void OnToolbarExtensionUpdated( |
| 172 const extensions::Extension* extension) override; | 168 const extensions::Extension* extension) override; |
| 173 bool ShowExtensionActionPopup(const extensions::Extension* extension, | 169 bool ShowExtensionActionPopup(const extensions::Extension* extension, |
| 174 bool grant_active_tab) override; | 170 bool grant_active_tab) override; |
| 175 void OnToolbarVisibleCountChanged() override; | 171 void OnToolbarVisibleCountChanged() override; |
| 176 void OnToolbarHighlightModeChanged(bool is_highlighting) override; | 172 void OnToolbarHighlightModeChanged(bool is_highlighting) override; |
| 177 void OnToolbarModelInitialized() override; | 173 void OnToolbarModelInitialized() override; |
| 178 Browser* GetBrowser() override; | 174 Browser* GetBrowser() override; |
| 179 | 175 |
| 180 // ToolbarActionsBarBubbleDelegate: | |
| 181 void OnToolbarActionsBarBubbleShown() override; | |
| 182 void OnToolbarActionsBarBubbleClosed(CloseAction action) override; | |
| 183 | |
| 184 // Resizes the delegate (if necessary) to the preferred size using the given | 176 // Resizes the delegate (if necessary) to the preferred size using the given |
| 185 // |tween_type| and optionally suppressing the chevron. | 177 // |tween_type| and optionally suppressing the chevron. |
| 186 void ResizeDelegate(gfx::Tween::Type tween_type, bool suppress_chevron); | 178 void ResizeDelegate(gfx::Tween::Type tween_type, bool suppress_chevron); |
| 187 | 179 |
| 188 // Returns the action for the given |id|, if one exists. | 180 // Returns the action for the given |id|, if one exists. |
| 189 ToolbarActionViewController* GetActionForId(const std::string& id); | 181 ToolbarActionViewController* GetActionForId(const std::string& id); |
| 190 | 182 |
| 191 // Returns the current web contents. | 183 // Returns the current web contents. |
| 192 content::WebContents* GetCurrentWebContents(); | 184 content::WebContents* GetCurrentWebContents(); |
| 193 | 185 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // True if we have checked to see if there is an extension bubble that should | 246 // True if we have checked to see if there is an extension bubble that should |
| 255 // be displayed, and, if there is, shown that bubble. | 247 // be displayed, and, if there is, shown that bubble. |
| 256 bool checked_extension_bubble_; | 248 bool checked_extension_bubble_; |
| 257 | 249 |
| 258 base::WeakPtrFactory<ToolbarActionsBar> weak_ptr_factory_; | 250 base::WeakPtrFactory<ToolbarActionsBar> weak_ptr_factory_; |
| 259 | 251 |
| 260 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBar); | 252 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBar); |
| 261 }; | 253 }; |
| 262 | 254 |
| 263 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_H_ | 255 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_H_ |
| OLD | NEW |