Index: chrome/browser/extensions/extension_shelf_model.h |
=================================================================== |
--- chrome/browser/extensions/extension_shelf_model.h (revision 22246) |
+++ chrome/browser/extensions/extension_shelf_model.h (working copy) |
@@ -16,8 +16,37 @@ |
class Browser; |
class ExtensionPrefs; |
-class ExtensionShelfModelObserver; |
+// Objects implement this interface when they wish to be notified of changes to |
+// the ExtensionShelfModel. |
+// |
+// Register your ExtensionShelfModelObserver with the ExtensionShelfModel using |
+// Add/RemoveObserver methods. |
+class ExtensionShelfModelObserver { |
+ public: |
+ // A new toolstrip was inserted into ExtensionShelfModel at |index|. |
+ virtual void ToolstripInsertedAt(ExtensionHost* toolstrip, int index) {} |
+ |
+ // The specified toolstrip is being removed and destroyed. |
+ virtual void ToolstripRemovingAt(ExtensionHost* toolstrip, int index) {} |
+ |
+ // |toolstrip| moved from |from_index| to |to_index|. |
+ virtual void ToolstripMoved(ExtensionHost* toolstrip, |
+ int from_index, |
+ int to_index) {} |
+ |
+ // The specified toolstrip changed in some way (currently only size changes) |
+ virtual void ToolstripChangedAt(ExtensionHost* toolstrip, int index) {} |
+ |
+ // There are no more toolstrips in the model. |
+ virtual void ExtensionShelfEmpty() {} |
+ |
+ // The entire model may have changed. |
+ virtual void ShelfModelReloaded() {} |
+ |
+ // TODO(erikkay) - any more? |
+}; |
+ |
// The model representing the toolstrips on an ExtensionShelf. The order of |
// the toolstrips is common across all of the models for a given Profile, |
// but there are multiple models. Each model contains the hosts/views which |
@@ -31,13 +60,8 @@ |
ExtensionHost* host; |
Extension::ToolstripInfo info; |
void* data; |
- int height; |
- GURL url; |
}; |
- typedef std::vector<ToolstripItem> ToolstripList; |
- typedef ToolstripList::iterator iterator; |
- |
// Add and remove observers to changes within this ExtensionShelfModel. |
void AddObserver(ExtensionShelfModelObserver* observer); |
void RemoveObserver(ExtensionShelfModelObserver* observer); |
@@ -46,10 +70,6 @@ |
int count() const { return static_cast<int>(toolstrips_.size()); } |
bool empty() const { return toolstrips_.empty(); } |
- // Iterators for the toolstrips in the model. |
- iterator begin() { return toolstrips_.begin(); } |
- ExtensionShelfModel::iterator end() { return toolstrips_.end(); } |
- |
// Add |toolstrip| to the end of the shelf. |
void AppendToolstrip(const ToolstripItem& toolstrip); |
@@ -62,29 +82,19 @@ |
// Move the toolstrip at |index| to |to_index|. |
void MoveToolstripAt(int index, int to_index); |
- // Lookup the index of |host|. Returns -1 if not present. |
- int IndexOfHost(ExtensionHost* host); |
+ // Lookup the index of |toolstrip|. Returns -1 if not present. |
+ int IndexOfToolstrip(ExtensionHost* toolstrip); |
// Return the toolstrip at |index|. |
- const ToolstripItem& ToolstripAt(int index); |
+ ExtensionHost* ToolstripAt(int index); |
- // Return the ToolstripItem associated with |host| or NULL if it's not |
- // present. |
- ToolstripList::iterator ToolstripForHost(ExtensionHost* host); |
+ // Return the ToolstripInfo at |index|. |
+ Extension::ToolstripInfo& ToolstripInfoAt(int index); |
- // Set some arbitrary data associated with a particular toolstrip. |
+ // Get/Set some arbitrary data associated with a particular toolstrip. |
void SetToolstripDataAt(int index, void* data); |
+ void* ToolstripDataAt(int index); |
- // Update the ToolstripItem for |toolstrip| to set its |url| and |height| |
- // and then call ToolstripChanged for all observers. |
- // If |url| is empty, no navigation is requested. |
- void ExpandToolstrip(iterator toolstrip, const GURL& url, int height); |
- |
- // Update the ToolstripItem for |toolstrip| to set its |url| and its height |
- // to 0, and then call ToolstripChanged for all observers. |
- // If |url| is empty, no navigation is requested. |
- void CollapseToolstrip(iterator toolstrip, const GURL& url); |
- |
// NotificationObserver |
virtual void Observe(NotificationType type, |
const NotificationSource& source, |
@@ -116,7 +126,8 @@ |
NotificationRegistrar registrar_; |
// The Toolstrips loaded in this model. The model owns these objects. |
- ToolstripList toolstrips_; |
+ typedef std::vector<ToolstripItem> ExtensionToolstrips; |
+ ExtensionToolstrips toolstrips_; |
// Our observers. |
typedef ObserverList<ExtensionShelfModelObserver> |
@@ -129,36 +140,4 @@ |
DISALLOW_COPY_AND_ASSIGN(ExtensionShelfModel); |
}; |
-// Objects implement this interface when they wish to be notified of changes to |
-// the ExtensionShelfModel. |
-// |
-// Register your ExtensionShelfModelObserver with the ExtensionShelfModel using |
-// Add/RemoveObserver methods. |
-class ExtensionShelfModelObserver { |
- public: |
- // A new toolstrip was inserted into ExtensionShelfModel at |index|. |
- virtual void ToolstripInsertedAt(ExtensionHost* toolstrip, int index) {} |
- |
- // The specified toolstrip is being removed and destroyed. |
- virtual void ToolstripRemovingAt(ExtensionHost* toolstrip, int index) {} |
- |
- // |toolstrip| moved from |from_index| to |to_index|. |
- virtual void ToolstripMoved(ExtensionHost* toolstrip, |
- int from_index, |
- int to_index) {} |
- |
- // The specified toolstrip changed in some way (currently only size changes) |
- virtual void ToolstripChanged(ExtensionShelfModel::iterator toolstrip) {} |
- |
- // There are no more toolstrips in the model. |
- virtual void ExtensionShelfEmpty() {} |
- |
- // The entire model may have changed. |
- virtual void ShelfModelReloaded() {} |
- |
- // The model is being destroyed. |
- virtual void ShelfModelDeleting() {} |
-}; |
- |
- |
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SHELF_MODEL_H_ |