Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: chrome/browser/extensions/extension_toolbar_model.h

Issue 10533086: Action box menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Action box menu Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #pragma once 7 #pragma once
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 GURL* popup_url_out); 67 GURL* popup_url_out);
68 // If count == size(), this will set the visible icon count to -1, meaning 68 // If count == size(), this will set the visible icon count to -1, meaning
69 // "show all actions". 69 // "show all actions".
70 void SetVisibleIconCount(int count); 70 void SetVisibleIconCount(int count);
71 // As above, a return value of -1 represents "show all actions". 71 // As above, a return value of -1 represents "show all actions".
72 int GetVisibleIconCount() const { return visible_icon_count_; } 72 int GetVisibleIconCount() const { return visible_icon_count_; }
73 73
74 bool extensions_initialized() const { return extensions_initialized_; } 74 bool extensions_initialized() const { return extensions_initialized_; }
75 75
76 size_t size() const { 76 size_t size() const {
77 return toolitems_.size(); 77 return toolbar_items_.size();
78 } 78 }
79 79
80 extensions::ExtensionList::iterator begin() { 80 extensions::ExtensionList::iterator begin() {
81 return toolitems_.begin(); 81 return toolbar_items_.begin();
82 } 82 }
83 83
84 extensions::ExtensionList::iterator end() { 84 extensions::ExtensionList::iterator end() {
85 return toolitems_.end(); 85 return toolbar_items_.end();
86 } 86 }
87 87
88 const extensions::Extension* GetExtensionByIndex(int index) const; 88 const extensions::Extension* GetExtensionByIndex(int index) const;
89 89
90 // Utility functions for converting between an index into the list of 90 // Utility functions for converting between an index into the list of
91 // incognito-enabled browser actions, and the list of all browser actions. 91 // incognito-enabled browser actions, and the list of all browser actions.
92 int IncognitoIndexToOriginal(int incognito_index); 92 int IncognitoIndexToOriginal(int incognito_index);
93 int OriginalIndexToIncognito(int original_index); 93 int OriginalIndexToIncognito(int original_index);
94 94
95 size_t action_box_extensions_size() {
96 return action_box_menu_items_.size();
97 }
98
99 const extensions::Extension* GetActionBoxExtensionByIndex(int index) const;
100
95 private: 101 private:
96 // content::NotificationObserver implementation. 102 // content::NotificationObserver implementation.
97 virtual void Observe(int type, 103 virtual void Observe(int type,
98 const content::NotificationSource& source, 104 const content::NotificationSource& source,
99 const content::NotificationDetails& details) OVERRIDE; 105 const content::NotificationDetails& details) OVERRIDE;
100 106
101 // To be called after the extension service is ready; gets loaded extensions 107 // To be called after the extension service is ready; gets loaded extensions
102 // from the extension service and their saved order from the pref service 108 // from the extension service and their saved order from the pref service
103 // and constructs |toolitems_| from these data. 109 // and constructs |toolbar_items_| and |action_box_items_| from these data.
104 void InitializeExtensionList(); 110 void InitializeExtensionLists();
111 void PopulateForActionBoxMode();
112 void PopulateForNonActionBoxMode();
113
114 // A couple helper functions to populate lists.
115 void AddToProperList(const extensions::Extension* extension,
116 const std::vector<std::string>& order,
117 extensions::ExtensionList* sorted,
118 extensions::ExtensionList* unsorted);
119 void MergeLists(const extensions::ExtensionList& sorted,
120 const extensions::ExtensionList& unsorted,
121 extensions::ExtensionList* result_list);
105 122
106 // Save the model to prefs. 123 // Save the model to prefs.
107 void UpdatePrefs(); 124 void UpdatePrefs();
108 125
109 // Our observers. 126 // Our observers.
110 ObserverList<Observer> observers_; 127 ObserverList<Observer> observers_;
111 128
112 void AddExtension(const extensions::Extension* extension); 129 void AddExtension(const extensions::Extension* extension);
113 void RemoveExtension(const extensions::Extension* extension); 130 void RemoveExtension(const extensions::Extension* extension);
114 131
115 // Our ExtensionService, guaranteed to outlive us. 132 // Our ExtensionService, guaranteed to outlive us.
116 ExtensionService* service_; 133 ExtensionService* service_;
117 134
118 PrefService* prefs_; 135 PrefService* prefs_;
119 136
120 // True if we've handled the initial EXTENSIONS_READY notification. 137 // True if we've handled the initial EXTENSIONS_READY notification.
121 bool extensions_initialized_; 138 bool extensions_initialized_;
122 139
123 // Ordered list of browser action buttons. 140 // Ordered list of browser action buttons.
124 extensions::ExtensionList toolitems_; 141 extensions::ExtensionList toolbar_items_;
142
143 // List of browser action buttons visible in an action box menu.
144 extensions::ExtensionList action_box_menu_items_;
125 145
126 // Keeps track of what the last extension to get disabled was. 146 // Keeps track of what the last extension to get disabled was.
127 std::string last_extension_removed_; 147 std::string last_extension_removed_;
128 148
129 // Keeps track of where the last extension to get disabled was in the list. 149 // Keeps track of where the last extension to get disabled was in the list.
130 size_t last_extension_removed_index_; 150 size_t last_extension_removed_index_;
131 151
132 // The number of icons visible (the rest should be hidden in the overflow 152 // The number of icons visible (the rest should be hidden in the overflow
133 // chevron). 153 // chevron).
134 int visible_icon_count_; 154 int visible_icon_count_;
135 155
136 content::NotificationRegistrar registrar_; 156 content::NotificationRegistrar registrar_;
137 157
138 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarModel); 158 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarModel);
139 }; 159 };
140 160
141 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ 161 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698