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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 | 71 |
72 // Signal that the model has entered or exited highlighting mode, or that | 72 // Signal that the model has entered or exited highlighting mode, or that |
73 // the extensions being highlighted have (probably*) changed. Highlighting | 73 // the extensions being highlighted have (probably*) changed. Highlighting |
74 // mode indicates that only a subset of the extensions are actively | 74 // mode indicates that only a subset of the extensions are actively |
75 // displayed, and those extensions should be highlighted for extra emphasis. | 75 // displayed, and those extensions should be highlighted for extra emphasis. |
76 // * probably, because if we are in highlight mode and receive a call to | 76 // * probably, because if we are in highlight mode and receive a call to |
77 // highlight a new set of extensions, we do not compare the current set | 77 // highlight a new set of extensions, we do not compare the current set |
78 // with the new set (and just assume the new set is different). | 78 // with the new set (and just assume the new set is different). |
79 virtual void ToolbarHighlightModeChanged(bool is_highlighting) = 0; | 79 virtual void ToolbarHighlightModeChanged(bool is_highlighting) = 0; |
80 | 80 |
81 // Signal that the toolbar needs to be reordered for the given | |
Peter Kasting
2014/10/30 22:05:59
Nit: "Signals" (see http://google-styleguide.googl
Devlin
2014/10/31 17:44:09
Yeah, this and the name itself were to match exist
| |
82 // |web_contents|. This is caused by an overflowed action wanting to run, | |
83 // and needing to "pop itself out". | |
84 virtual void ToolbarReorderNecessary( | |
Peter Kasting
2014/10/30 22:05:59
Nit: This is a strange name for a function. It so
Devlin
2014/10/31 17:44:09
/sigh... I know - it's bothered me most times I ad
Peter Kasting
2014/10/31 19:01:07
Doesn't bother me. Bonus points if you go write a
| |
85 content::WebContents* web_contents) = 0; | |
86 | |
81 // Returns the browser associated with the Observer. | 87 // Returns the browser associated with the Observer. |
82 virtual Browser* GetBrowser() = 0; | 88 virtual Browser* GetBrowser() = 0; |
83 | 89 |
84 protected: | 90 protected: |
85 virtual ~Observer() {} | 91 virtual ~Observer() {} |
86 }; | 92 }; |
87 | 93 |
88 // Convenience function to get the ExtensionToolbarModel for a Profile. | 94 // Convenience function to get the ExtensionToolbarModel for a Profile. |
89 static ExtensionToolbarModel* Get(Profile* profile); | 95 static ExtensionToolbarModel* Get(Profile* profile); |
90 | 96 |
91 // Add or remove an observer. | 97 // Add or remove an observer. |
92 void AddObserver(Observer* observer); | 98 void AddObserver(Observer* observer); |
93 void RemoveObserver(Observer* observer); | 99 void RemoveObserver(Observer* observer); |
94 | 100 |
95 // Moves the given |extension|'s icon to the given |index|. | 101 // Moves the given |extension|'s icon to the given |index|. |
96 void MoveExtensionIcon(const std::string& id, size_t index); | 102 void MoveExtensionIcon(const std::string& id, size_t index); |
97 | 103 |
98 // Sets the number of extension icons that should be visible. | 104 // Sets the number of extension icons that should be visible. |
99 // If count == size(), this will set the visible icon count to -1, meaning | 105 // If count == size(), this will set the visible icon count to -1, meaning |
100 // "show all actions". | 106 // "show all actions". |
101 void SetVisibleIconCount(int count); | 107 void SetVisibleIconCount(int count); |
102 | 108 |
103 // As above, a return value of -1 represents "show all actions". | 109 // As above, a return value of -1 represents "show all actions". |
104 int GetVisibleIconCount() const { return visible_icon_count_; } | 110 int GetVisibleIconCount() const { return visible_icon_count_; } |
105 | 111 |
112 // Returns the number of visible icons as an absolute value. | |
Peter Kasting
2014/10/30 22:05:59
Nit: I think this name/comment are misleading. Th
Devlin
2014/10/31 17:44:09
Yeah, I struggled with the name. The problem with
Peter Kasting
2014/10/31 19:01:07
Good resolution. I'm happy with it.
| |
113 size_t GetAbsoluteVisibleIconCount() const { | |
114 return visible_icon_count_ == -1 ? | |
115 toolbar_items().size() : static_cast<size_t>(visible_icon_count_); | |
116 } | |
117 | |
106 bool extensions_initialized() const { return extensions_initialized_; } | 118 bool extensions_initialized() const { return extensions_initialized_; } |
107 | 119 |
108 const ExtensionList& toolbar_items() const { | 120 const ExtensionList& toolbar_items() const { |
109 return is_highlighting_ ? highlighted_items_ : toolbar_items_; | 121 return is_highlighting_ ? highlighted_items_ : toolbar_items_; |
110 } | 122 } |
111 | 123 |
112 bool is_highlighting() const { return is_highlighting_; } | 124 bool is_highlighting() const { return is_highlighting_; } |
113 | 125 |
114 void OnExtensionToolbarPrefChange(); | 126 void OnExtensionToolbarPrefChange(); |
115 | 127 |
128 // Returns the item order for a given tab. This can be different from the | |
129 // base item order if the action wants to run on the given page, and needs to | |
130 // be popped out of overflow. | |
131 ExtensionList GetItemOrderForTab(content::WebContents* web_contents) const; | |
132 | |
133 // Returns the visible icon count for a given tab. This can be different from | |
134 // the base item order if the action wants to run on the given page and needs | |
135 // to be popped out of overflow. | |
136 // A result of -1 indicates "all icons". | |
137 int GetVisibleIconCountForTab(content::WebContents* web_contents) const; | |
138 | |
116 // Finds the Observer associated with |browser| and tells it to display a | 139 // Finds the Observer associated with |browser| and tells it to display a |
117 // popup for the given |extension|. If |grant_active_tab| is true, this | 140 // popup for the given |extension|. If |grant_active_tab| is true, this |
118 // grants active tab permissions to the |extension|; only do this because of | 141 // grants active tab permissions to the |extension|; only do this because of |
119 // a direct user action. | 142 // a direct user action. |
120 bool ShowExtensionActionPopup(const Extension* extension, | 143 bool ShowExtensionActionPopup(const Extension* extension, |
121 Browser* browser, | 144 Browser* browser, |
122 bool grant_active_tab); | 145 bool grant_active_tab); |
123 | 146 |
124 // Ensures that the extensions in the |extension_ids| list are visible on the | 147 // Ensures that the extensions in the |extension_ids| list are visible on the |
125 // toolbar. This might mean they need to be moved to the front (if they are in | 148 // toolbar. This might mean they need to be moved to the front (if they are in |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 base::Closure pref_change_callback_; | 269 base::Closure pref_change_callback_; |
247 | 270 |
248 base::WeakPtrFactory<ExtensionToolbarModel> weak_ptr_factory_; | 271 base::WeakPtrFactory<ExtensionToolbarModel> weak_ptr_factory_; |
249 | 272 |
250 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarModel); | 273 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarModel); |
251 }; | 274 }; |
252 | 275 |
253 } // namespace extensions | 276 } // namespace extensions |
254 | 277 |
255 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ | 278 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ |
OLD | NEW |