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

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, 4 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 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 "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
11 #include "chrome/browser/extensions/extension_prefs.h"
11 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h" 13 #include "content/public/browser/notification_registrar.h"
13 14
14 class Browser; 15 class Browser;
15 class ExtensionService; 16 class ExtensionService;
16 class PrefService; 17 class PrefService;
17 18
18 // Model for the browser actions toolbar. 19 // Model for the browser actions toolbar.
19 class ExtensionToolbarModel : public content::NotificationObserver { 20 class ExtensionToolbarModel : public content::NotificationObserver {
20 public: 21 public:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 Browser* browser, 66 Browser* browser,
66 GURL* popup_url_out); 67 GURL* popup_url_out);
67 // 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
68 // "show all actions". 69 // "show all actions".
69 void SetVisibleIconCount(int count); 70 void SetVisibleIconCount(int count);
70 // As above, a return value of -1 represents "show all actions". 71 // As above, a return value of -1 represents "show all actions".
71 int GetVisibleIconCount() const { return visible_icon_count_; } 72 int GetVisibleIconCount() const { return visible_icon_count_; }
72 73
73 bool extensions_initialized() const { return extensions_initialized_; } 74 bool extensions_initialized() const { return extensions_initialized_; }
74 75
75 size_t size() const { 76 const extensions::ExtensionList& toolbar_items() const {
76 return toolitems_.size(); 77 return toolbar_items_;
77 } 78 }
78 79
79 extensions::ExtensionList::iterator begin() {
80 return toolitems_.begin();
81 }
82
83 extensions::ExtensionList::iterator end() {
84 return toolitems_.end();
85 }
86
87 const extensions::Extension* GetExtensionByIndex(int index) const;
88
89 // Utility functions for converting between an index into the list of 80 // Utility functions for converting between an index into the list of
90 // incognito-enabled browser actions, and the list of all browser actions. 81 // incognito-enabled browser actions, and the list of all browser actions.
91 int IncognitoIndexToOriginal(int incognito_index); 82 int IncognitoIndexToOriginal(int incognito_index);
92 int OriginalIndexToIncognito(int original_index); 83 int OriginalIndexToIncognito(int original_index);
93 84
85 const extensions::ExtensionList& action_box_menu_items() const {
86 return action_box_menu_items_;
87 }
88
94 private: 89 private:
95 // content::NotificationObserver implementation. 90 // content::NotificationObserver implementation.
96 virtual void Observe(int type, 91 virtual void Observe(int type,
97 const content::NotificationSource& source, 92 const content::NotificationSource& source,
98 const content::NotificationDetails& details) OVERRIDE; 93 const content::NotificationDetails& details) OVERRIDE;
99 94
100 // To be called after the extension service is ready; gets loaded extensions 95 // To be called after the extension service is ready; gets loaded extensions
101 // from the extension service and their saved order from the pref service 96 // from the extension service and their saved order from the pref service
102 // and constructs |toolitems_| from these data. 97 // and constructs |toolbar_items_| and |action_box_items_| from these data.
103 void InitializeExtensionList(); 98 void InitializeExtensionLists();
99 void PopulateForActionBoxMode();
100 void PopulateForNonActionBoxMode();
101
102 // Fills |list| with extensions based on provided |order|.
103 void FillExtensionList(
104 const extensions::ExtensionPrefs::ExtensionIdSet& order,
105 extensions::ExtensionList* list);
104 106
105 // Save the model to prefs. 107 // Save the model to prefs.
106 void UpdatePrefs(); 108 void UpdatePrefs();
107 109
108 // Our observers. 110 // Our observers.
109 ObserverList<Observer> observers_; 111 ObserverList<Observer> observers_;
110 112
111 void AddExtension(const extensions::Extension* extension); 113 void AddExtension(const extensions::Extension* extension,
112 void RemoveExtension(const extensions::Extension* extension); 114 extensions::ExtensionList* list);
115 void RemoveExtension(const extensions::Extension* extension,
116 extensions::ExtensionList* list);
117
118 // Searches for the given |extension| in |toolbar_items_| and
119 // |action_box_menu_items_| and returns pointer to the list with it
120 // or NULL if not found.
121 extensions::ExtensionList* FindListWithExtension(
122 const extensions::Extension* extension);
113 123
114 // Our ExtensionService, guaranteed to outlive us. 124 // Our ExtensionService, guaranteed to outlive us.
115 ExtensionService* service_; 125 ExtensionService* service_;
116 126
117 PrefService* prefs_; 127 PrefService* prefs_;
118 128
119 // True if we've handled the initial EXTENSIONS_READY notification. 129 // True if we've handled the initial EXTENSIONS_READY notification.
120 bool extensions_initialized_; 130 bool extensions_initialized_;
121 131
122 // Ordered list of browser action buttons. 132 // Ordered list of browser action buttons.
123 extensions::ExtensionList toolitems_; 133 extensions::ExtensionList toolbar_items_;
134
135 // List of browser action buttons visible in an action box menu.
136 extensions::ExtensionList action_box_menu_items_;
124 137
125 // Keeps track of what the last extension to get disabled was. 138 // Keeps track of what the last extension to get disabled was.
126 std::string last_extension_removed_; 139 std::string last_extension_removed_;
127 140
128 // Keeps track of where the last extension to get disabled was in the list. 141 // Keeps track of where the last extension to get disabled was in the list.
129 size_t last_extension_removed_index_; 142 size_t last_extension_removed_index_;
130 143
131 // The number of icons visible (the rest should be hidden in the overflow 144 // The number of icons visible (the rest should be hidden in the overflow
132 // chevron). 145 // chevron).
133 int visible_icon_count_; 146 int visible_icon_count_;
134 147
135 content::NotificationRegistrar registrar_; 148 content::NotificationRegistrar registrar_;
136 149
137 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarModel); 150 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarModel);
138 }; 151 };
139 152
140 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ 153 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.cc ('k') | chrome/browser/extensions/extension_toolbar_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698