Chromium Code Reviews| Index: chrome/browser/extensions/extension_toolbar_model.h |
| diff --git a/chrome/browser/extensions/extension_toolbar_model.h b/chrome/browser/extensions/extension_toolbar_model.h |
| index 950366e7768daa6bb3cbb5b9f9d845ef54b30d6e..9e4806d8c387c5954cc92615a315ef515aefe7fe 100644 |
| --- a/chrome/browser/extensions/extension_toolbar_model.h |
| +++ b/chrome/browser/extensions/extension_toolbar_model.h |
| @@ -41,16 +41,17 @@ class ExtensionToolbarModel : public content::NotificationObserver, |
| // delegate. |
| class Observer { |
| public: |
| - // An extension has been added to the toolbar and should go at |index|. |
| + // TODO(devlin): Rename these methods to be OnFoo. |
| + // Signals that an |extension| has been added to the toolbar at |index|. |
| virtual void ToolbarExtensionAdded(const Extension* extension, |
| int index) = 0; |
| - // The given |extension| should be removed from the toolbar. |
| + // Signals that the given |extension| has been removed from the toolbar. |
| virtual void ToolbarExtensionRemoved(const Extension* extension) = 0; |
| - // The given |extension| has been moved to |index|. |index| is the desired |
| - // *final* index of the extension (that is, in the adjusted order, extension |
| - // should be at |index|). |
| + // Signals that the given |extension| has been moved to |index|. |index| is |
| + // the desired *final* index of the extension (that is, in the adjusted |
| + // order, extension should be at |index|). |
| virtual void ToolbarExtensionMoved(const Extension* extension, |
| int index) = 0; |
| @@ -58,18 +59,18 @@ class ExtensionToolbarModel : public content::NotificationObserver, |
| // updated. |
| virtual void ToolbarExtensionUpdated(const Extension* extension) = 0; |
| - // Signal the |extension| to show the popup now in the active window. |
| + // Signals the |extension| to show the popup now in the active window. |
| // If |grant_active_tab| is true, then active tab permissions should be |
| // given to the extension (only do this if this is through a user action). |
| // Returns true if a popup was slated to be shown. |
| virtual bool ShowExtensionActionPopup(const Extension* extension, |
| bool grant_active_tab) = 0; |
| - // Signal when the container needs to be redrawn because of a size change, |
| + // Signals when the container needs to be redrawn because of a size change, |
| // and when the model has finished loading. |
| virtual void ToolbarVisibleCountChanged() = 0; |
| - // Signal that the model has entered or exited highlighting mode, or that |
| + // Signals that the model has entered or exited highlighting mode, or that |
| // the extensions being highlighted have (probably*) changed. Highlighting |
| // mode indicates that only a subset of the extensions are actively |
| // displayed, and those extensions should be highlighted for extra emphasis. |
| @@ -78,6 +79,12 @@ class ExtensionToolbarModel : public content::NotificationObserver, |
| // with the new set (and just assume the new set is different). |
| virtual void ToolbarHighlightModeChanged(bool is_highlighting) = 0; |
| + // Signals that the toolbar needs to be reordered for the given |
| + // |web_contents|. This is caused by an overflowed action wanting to run, |
| + // and needing to "pop itself out". |
| + virtual void OnToolbarReorderNecessary( |
| + content::WebContents* web_contents) = 0; |
| + |
| // Returns the browser associated with the Observer. |
| virtual Browser* GetBrowser() = 0; |
| @@ -88,7 +95,7 @@ class ExtensionToolbarModel : public content::NotificationObserver, |
| // Convenience function to get the ExtensionToolbarModel for a Profile. |
| static ExtensionToolbarModel* Get(Profile* profile); |
| - // Add or remove an observer. |
| + // Adds or removes an observer. |
| void AddObserver(Observer* observer); |
| void RemoveObserver(Observer* observer); |
| @@ -98,10 +105,15 @@ class ExtensionToolbarModel : public content::NotificationObserver, |
| // Sets the number of extension icons that should be visible. |
| // If count == size(), this will set the visible icon count to -1, meaning |
| // "show all actions". |
| - void SetVisibleIconCount(int count); |
| + void SetVisibleIconCount(size_t count); |
| + |
| + // Returns the number of visible icons. |
| + size_t visible_icon_count() const { |
| + return visible_icon_count_ == -1 ? |
| + toolbar_items().size() : static_cast<size_t>(visible_icon_count_); |
|
Peter Kasting
2014/10/31 19:01:08
Nit: So... now that we have both these accessors,
Devlin
2014/10/31 20:49:30
Yeah, I was thinking the same thing, but I'll post
|
| + } |
| - // As above, a return value of -1 represents "show all actions". |
| - int GetVisibleIconCount() const { return visible_icon_count_; } |
| + bool all_icons_visible() const { return visible_icon_count_ == -1; } |
| bool extensions_initialized() const { return extensions_initialized_; } |
| @@ -113,6 +125,16 @@ class ExtensionToolbarModel : public content::NotificationObserver, |
| void OnExtensionToolbarPrefChange(); |
| + // Returns the item order for a given tab. This can be different from the |
| + // base item order if the action wants to run on the given page, and needs to |
| + // be popped out of overflow. |
| + ExtensionList GetItemOrderForTab(content::WebContents* web_contents) const; |
| + |
| + // Returns the visible icon count for a given tab. This can be different from |
| + // the base item order if the action wants to run on the given page and needs |
| + // to be popped out of overflow. |
| + size_t GetVisibleIconCountForTab(content::WebContents* web_contents) const; |
| + |
| // Finds the Observer associated with |browser| and tells it to display a |
| // popup for the given |extension|. If |grant_active_tab| is true, this |
| // grants active tab permissions to the |extension|; only do this because of |
| @@ -126,7 +148,7 @@ class ExtensionToolbarModel : public content::NotificationObserver, |
| // the overflow bucket). |
| void EnsureVisibility(const ExtensionIdList& extension_ids); |
| - // Highlight the extensions specified by |extension_ids|. This will cause |
| + // Highlights the extensions specified by |extension_ids|. This will cause |
| // the ToolbarModel to only display those extensions. |
| // Highlighting mode is only entered if there is at least one extension to |
| // be shown. |
| @@ -229,7 +251,7 @@ class ExtensionToolbarModel : public content::NotificationObserver, |
| ExtensionIdList last_known_positions_; |
| // The number of icons visible (the rest should be hidden in the overflow |
| - // chevron). |
| + // chevron). A value of -1 indicates that all icons should be visible. |
| int visible_icon_count_; |
| content::NotificationRegistrar registrar_; |