| 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 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ |
| 7 | 7 |
| 8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
| 9 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 9 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
| 10 #include "chrome/browser/extensions/extension_toolbar_model.h" | 10 #include "chrome/browser/extensions/extension_toolbar_model.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 static const int kItemSpacing; | 134 static const int kItemSpacing; |
| 135 | 135 |
| 136 // Constructs a BrowserActionContainer for a particular |browser| object. For | 136 // Constructs a BrowserActionContainer for a particular |browser| object. For |
| 137 // documentation of |main_container|, see class comments. | 137 // documentation of |main_container|, see class comments. |
| 138 BrowserActionsContainer(Browser* browser, | 138 BrowserActionsContainer(Browser* browser, |
| 139 BrowserActionsContainer* main_container); | 139 BrowserActionsContainer* main_container); |
| 140 virtual ~BrowserActionsContainer(); | 140 virtual ~BrowserActionsContainer(); |
| 141 | 141 |
| 142 void Init(); | 142 void Init(); |
| 143 | 143 |
| 144 // Get the number of browser actions being displayed. | 144 // Get the number of actions being displayed. |
| 145 size_t num_browser_actions() const { return browser_action_views_.size(); } | 145 size_t num_browser_actions() const { return browser_action_views_.size(); } |
| 146 size_t num_chrome_actions() const { return chrome_action_views_.size(); } |
| 146 | 147 |
| 147 // Whether we are performing resize animation on the container. | 148 // Whether we are performing resize animation on the container. |
| 148 bool animating() const { return animation_target_size_ > 0; } | 149 bool animating() const { return animation_target_size_ > 0; } |
| 149 | 150 |
| 150 // Returns the chevron, if any. | 151 // Returns the chevron, if any. |
| 151 views::View* chevron() { return chevron_; } | 152 views::View* chevron() { return chevron_; } |
| 152 const views::View* chevron() const { return chevron_; } | 153 const views::View* chevron() const { return chevron_; } |
| 153 | 154 |
| 154 // Returns the profile this container is associated with. | 155 // Returns the profile this container is associated with. |
| 155 Profile* profile() const { return profile_; } | 156 Profile* profile() const { return profile_; } |
| 156 | 157 |
| 157 // The class that registers for keyboard shortcuts for extension commands. | 158 // The class that registers for keyboard shortcuts for extension commands. |
| 158 extensions::ExtensionKeybindingRegistry* extension_keybinding_registry() { | 159 extensions::ExtensionKeybindingRegistry* extension_keybinding_registry() { |
| 159 return extension_keybinding_registry_.get(); | 160 return extension_keybinding_registry_.get(); |
| 160 } | 161 } |
| 161 | 162 |
| 162 // Get a particular browser action view. | 163 // Get a particular browser action view. |
| 163 BrowserActionView* GetBrowserActionViewAt(int index) { | 164 BrowserActionView* GetBrowserActionViewAt(int index) { |
| 164 return browser_action_views_[index]; | 165 return browser_action_views_[index]; |
| 165 } | 166 } |
| 166 | 167 |
| 168 // Get a particular chrome action view. |
| 169 BrowserActionView* GetChromeActionViewAt(size_t index) { |
| 170 return chrome_action_views_[index]; |
| 171 } |
| 172 |
| 173 // Returns the extension of the view of the given |index|. |
| 174 const extensions::Extension* GetExtensionAt(size_t index) const; |
| 175 |
| 167 // Returns the BrowserActionView* associated with the given |extension|, or | 176 // Returns the BrowserActionView* associated with the given |extension|, or |
| 168 // NULL if none exists. | 177 // NULL if none exists. |
| 169 BrowserActionView* GetViewForExtension( | 178 BrowserActionView* GetViewForExtension( |
| 170 const extensions::Extension* extension); | 179 const extensions::Extension* extension); |
| 171 | 180 |
| 172 // Update the views to reflect the state of the browser action icons. | 181 // Update the views to reflect the current state of the actions. |
| 173 void RefreshBrowserActionViews(); | 182 void RefreshActionViews(); |
| 174 | 183 |
| 175 // Sets up the browser action view vector. | 184 // Sets up the browser action views and chrome action views vectors. |
| 176 void CreateBrowserActionViews(); | 185 void CreateActionViews(); |
| 177 | 186 |
| 178 // Delete all browser action views. | 187 // Delete all action views. |
| 179 void DeleteBrowserActionViews(); | 188 void DeleteActionViews(); |
| 180 | 189 |
| 181 // Returns how many browser actions are currently visible. If the intent is | 190 // Returns how many browser actions are currently visible. If the intent is |
| 182 // to find how many are visible once the container finishes animation, see | 191 // to find how many are visible once the container finishes animation, see |
| 183 // VisibleBrowserActionsAfterAnimation() below. | 192 // VisibleBrowserActionsAfterAnimation() below. |
| 184 size_t VisibleBrowserActions() const; | 193 size_t VisibleBrowserActions() const; |
| 185 | 194 |
| 186 // Returns how many browser actions will be visible once the container | 195 // Returns how many browser actions will be visible once the container |
| 187 // finishes animating to a new size, or (if not animating) the currently | 196 // finishes animating to a new size, or (if not animating) the currently |
| 188 // visible icons. | 197 // visible icons. |
| 189 size_t VisibleBrowserActionsAfterAnimation() const; | 198 size_t VisibleBrowserActionsAfterAnimation() const; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 virtual void AnimationProgressed(const gfx::Animation* animation) override; | 240 virtual void AnimationProgressed(const gfx::Animation* animation) override; |
| 232 virtual void AnimationEnded(const gfx::Animation* animation) override; | 241 virtual void AnimationEnded(const gfx::Animation* animation) override; |
| 233 | 242 |
| 234 // Overridden from BrowserActionView::Delegate: | 243 // Overridden from BrowserActionView::Delegate: |
| 235 virtual content::WebContents* GetCurrentWebContents() override; | 244 virtual content::WebContents* GetCurrentWebContents() override; |
| 236 virtual bool ShownInsideMenu() const override; | 245 virtual bool ShownInsideMenu() const override; |
| 237 virtual void OnBrowserActionViewDragDone() override; | 246 virtual void OnBrowserActionViewDragDone() override; |
| 238 virtual views::MenuButton* GetOverflowReferenceView() override; | 247 virtual views::MenuButton* GetOverflowReferenceView() override; |
| 239 virtual void SetPopupOwner(BrowserActionView* popup_owner) override; | 248 virtual void SetPopupOwner(BrowserActionView* popup_owner) override; |
| 240 virtual void HideActivePopup() override; | 249 virtual void HideActivePopup() override; |
| 241 virtual BrowserActionView* GetMainViewForExtension( | 250 virtual BrowserActionView* GetMainViewForAction( |
| 242 const extensions::Extension* extension) override; | 251 BrowserActionView* view) override; |
| 243 | 252 |
| 244 // Overridden from extension::ExtensionKeybindingRegistry::Delegate: | 253 // Overridden from extension::ExtensionKeybindingRegistry::Delegate: |
| 245 virtual extensions::ActiveTabPermissionGranter* | 254 virtual extensions::ActiveTabPermissionGranter* |
| 246 GetActiveTabPermissionGranter() override; | 255 GetActiveTabPermissionGranter() override; |
| 247 | 256 |
| 248 // Retrieve the current popup. This should only be used by unit tests. | 257 // Retrieve the current popup. This should only be used by unit tests. |
| 249 ExtensionPopup* TestGetPopup(); | 258 ExtensionPopup* TestGetPopup(); |
| 250 | 259 |
| 251 // Returns the width of an icon, optionally with its padding. | 260 // Returns the width of an icon, optionally with its padding. |
| 252 static int IconWidth(bool include_padding); | 261 static int IconWidth(bool include_padding); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 bool in_overflow_mode() const { return main_container_ != NULL; } | 342 bool in_overflow_mode() const { return main_container_ != NULL; } |
| 334 | 343 |
| 335 // Whether or not the container has been initialized. | 344 // Whether or not the container has been initialized. |
| 336 bool initialized_; | 345 bool initialized_; |
| 337 | 346 |
| 338 // The vector of browser actions (icons/image buttons for each action). Note | 347 // The vector of browser actions (icons/image buttons for each action). Note |
| 339 // that not every BrowserAction in the ToolbarModel will necessarily be in | 348 // that not every BrowserAction in the ToolbarModel will necessarily be in |
| 340 // this collection. Some extensions may be disabled in incognito windows. | 349 // this collection. Some extensions may be disabled in incognito windows. |
| 341 BrowserActionViews browser_action_views_; | 350 BrowserActionViews browser_action_views_; |
| 342 | 351 |
| 352 // The collection of views representing chrome actions. |
| 353 BrowserActionViews chrome_action_views_; |
| 354 |
| 343 Profile* profile_; | 355 Profile* profile_; |
| 344 | 356 |
| 345 // The Browser object the container is associated with. | 357 // The Browser object the container is associated with. |
| 346 Browser* browser_; | 358 Browser* browser_; |
| 347 | 359 |
| 348 // The main container we are serving as overflow for, or NULL if this | 360 // The main container we are serving as overflow for, or NULL if this |
| 349 // class is the the main container. See class comments for details on | 361 // class is the the main container. See class comments for details on |
| 350 // the difference between main and overflow. | 362 // the difference between main and overflow. |
| 351 BrowserActionsContainer* main_container_; | 363 BrowserActionsContainer* main_container_; |
| 352 | 364 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 ObserverList<BrowserActionsContainerObserver> observers_; | 407 ObserverList<BrowserActionsContainerObserver> observers_; |
| 396 | 408 |
| 397 // The maximum number of icons to show per row when in overflow mode (showing | 409 // The maximum number of icons to show per row when in overflow mode (showing |
| 398 // icons in the application menu). | 410 // icons in the application menu). |
| 399 static int icons_per_overflow_menu_row_; | 411 static int icons_per_overflow_menu_row_; |
| 400 | 412 |
| 401 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); | 413 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); |
| 402 }; | 414 }; |
| 403 | 415 |
| 404 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ | 416 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ |
| OLD | NEW |