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 23 matching lines...) Expand all Loading... |
34 public: | 34 public: |
35 ExtensionToolbarModel(Profile* profile, ExtensionPrefs* extension_prefs); | 35 ExtensionToolbarModel(Profile* profile, ExtensionPrefs* extension_prefs); |
36 ~ExtensionToolbarModel() override; | 36 ~ExtensionToolbarModel() override; |
37 | 37 |
38 // A class which is informed of changes to the model; represents the view of | 38 // A class which is informed of changes to the model; represents the view of |
39 // MVC. Also used for signaling view changes such as showing extension popups. | 39 // MVC. Also used for signaling view changes such as showing extension popups. |
40 // TODO(devlin): Should this really be an observer? It acts more like a | 40 // TODO(devlin): Should this really be an observer? It acts more like a |
41 // delegate. | 41 // delegate. |
42 class Observer { | 42 class Observer { |
43 public: | 43 public: |
44 // TODO(devlin): Rename these methods to be OnFoo. | |
45 // Signals that an |extension| has been added to the toolbar at |index|. | 44 // Signals that an |extension| has been added to the toolbar at |index|. |
46 // This will *only* be called after the toolbar model has been initialized. | 45 // This will *only* be called after the toolbar model has been initialized. |
47 virtual void ToolbarExtensionAdded(const Extension* extension, | 46 virtual void OnToolbarExtensionAdded(const Extension* extension, |
48 int index) = 0; | 47 int index) = 0; |
49 | 48 |
50 // Signals that the given |extension| has been removed from the toolbar. | 49 // Signals that the given |extension| has been removed from the toolbar. |
51 virtual void ToolbarExtensionRemoved(const Extension* extension) = 0; | 50 virtual void OnToolbarExtensionRemoved(const Extension* extension) = 0; |
52 | 51 |
53 // Signals that the given |extension| has been moved to |index|. |index| is | 52 // Signals that the given |extension| has been moved to |index|. |index| is |
54 // the desired *final* index of the extension (that is, in the adjusted | 53 // the desired *final* index of the extension (that is, in the adjusted |
55 // order, extension should be at |index|). | 54 // order, extension should be at |index|). |
56 virtual void ToolbarExtensionMoved(const Extension* extension, | 55 virtual void OnToolbarExtensionMoved(const Extension* extension, |
57 int index) = 0; | 56 int index) = 0; |
58 | 57 |
59 // Signals that the browser action for the given |extension| has been | 58 // Signals that the browser action for the given |extension| has been |
60 // updated. | 59 // updated. |
61 virtual void ToolbarExtensionUpdated(const Extension* extension) = 0; | 60 virtual void OnToolbarExtensionUpdated(const Extension* extension) = 0; |
62 | 61 |
63 // Signals the |extension| to show the popup now in the active window. | 62 // Signals the |extension| to show the popup now in the active window. |
64 // If |grant_active_tab| is true, then active tab permissions should be | 63 // If |grant_active_tab| is true, then active tab permissions should be |
65 // given to the extension (only do this if this is through a user action). | 64 // given to the extension (only do this if this is through a user action). |
66 // Returns true if a popup was slated to be shown. | 65 // Returns true if a popup was slated to be shown. |
67 virtual bool ShowExtensionActionPopup(const Extension* extension, | 66 virtual bool ShowExtensionActionPopup(const Extension* extension, |
68 bool grant_active_tab) = 0; | 67 bool grant_active_tab) = 0; |
69 | 68 |
70 // Signals when the container needs to be redrawn because of a size change, | 69 // Signals when the container needs to be redrawn because of a size change, |
71 // and when the model has finished loading. | 70 // and when the model has finished loading. |
72 virtual void ToolbarVisibleCountChanged() = 0; | 71 virtual void OnToolbarVisibleCountChanged() = 0; |
73 | 72 |
74 // Signals that the model has entered or exited highlighting mode, or that | 73 // Signals that the model has entered or exited highlighting mode, or that |
75 // the extensions being highlighted have (probably*) changed. Highlighting | 74 // the extensions being highlighted have (probably*) changed. Highlighting |
76 // mode indicates that only a subset of the extensions are actively | 75 // mode indicates that only a subset of the extensions are actively |
77 // displayed, and those extensions should be highlighted for extra emphasis. | 76 // displayed, and those extensions should be highlighted for extra emphasis. |
78 // * probably, because if we are in highlight mode and receive a call to | 77 // * probably, because if we are in highlight mode and receive a call to |
79 // highlight a new set of extensions, we do not compare the current set | 78 // highlight a new set of extensions, we do not compare the current set |
80 // with the new set (and just assume the new set is different). | 79 // with the new set (and just assume the new set is different). |
81 virtual void ToolbarHighlightModeChanged(bool is_highlighting) = 0; | 80 virtual void OnToolbarHighlightModeChanged(bool is_highlighting) = 0; |
82 | 81 |
83 // Signals that the toolbar model has been initialized, so that if any | 82 // Signals that the toolbar model has been initialized, so that if any |
84 // observers were postponing animation during the initialization stage, they | 83 // observers were postponing animation during the initialization stage, they |
85 // can catch up. | 84 // can catch up. |
86 virtual void OnToolbarModelInitialized() = 0; | 85 virtual void OnToolbarModelInitialized() = 0; |
87 | 86 |
88 // Returns the browser associated with the Observer. | 87 // Returns the browser associated with the Observer. |
89 virtual Browser* GetBrowser() = 0; | 88 virtual Browser* GetBrowser() = 0; |
90 | 89 |
91 protected: | 90 protected: |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 base::Closure pref_change_callback_; | 265 base::Closure pref_change_callback_; |
267 | 266 |
268 base::WeakPtrFactory<ExtensionToolbarModel> weak_ptr_factory_; | 267 base::WeakPtrFactory<ExtensionToolbarModel> weak_ptr_factory_; |
269 | 268 |
270 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarModel); | 269 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarModel); |
271 }; | 270 }; |
272 | 271 |
273 } // namespace extensions | 272 } // namespace extensions |
274 | 273 |
275 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ | 274 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ |
OLD | NEW |