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 30 matching lines...) Expand all Loading... | |
41 virtual void BrowserActionAdded(const extensions::Extension* extension, | 41 virtual void BrowserActionAdded(const extensions::Extension* extension, |
42 int index) {} | 42 int index) {} |
43 | 43 |
44 // The browser action button for |extension| should no longer show. | 44 // The browser action button for |extension| should no longer show. |
45 virtual void BrowserActionRemoved(const extensions::Extension* extension) {} | 45 virtual void BrowserActionRemoved(const extensions::Extension* extension) {} |
46 | 46 |
47 // The browser action button for |extension| has been moved to |index|. | 47 // The browser action button for |extension| has been moved to |index|. |
48 virtual void BrowserActionMoved(const extensions::Extension* extension, | 48 virtual void BrowserActionMoved(const extensions::Extension* extension, |
49 int index) {} | 49 int index) {} |
50 | 50 |
51 // The browser action button for |extension| should show the popup now if it | |
52 // is in the active window. | |
53 virtual void BrowserActionShowPopup(const extensions::Extension* extension) | |
54 {} | |
55 | |
51 // Called when the model has finished loading. | 56 // Called when the model has finished loading. |
52 virtual void ModelLoaded() {} | 57 virtual void ModelLoaded() {} |
53 | 58 |
54 protected: | 59 protected: |
55 virtual ~Observer() {} | 60 virtual ~Observer() {} |
56 }; | 61 }; |
57 | 62 |
58 // Functions called by the view. | 63 // Functions called by the view. |
59 void AddObserver(Observer* observer); | 64 void AddObserver(Observer* observer); |
60 void RemoveObserver(Observer* observer); | 65 void RemoveObserver(Observer* observer); |
61 void MoveBrowserAction(const extensions::Extension* extension, int index); | 66 void MoveBrowserAction(const extensions::Extension* extension, int index); |
62 // Executes the browser action for an extension and returns the action that | 67 // Executes the browser action for an extension and returns the action that |
63 // the UI should perform in response. | 68 // the UI should perform in response. |
64 // |popup_url_out| will be set if the extension should show a popup, with | 69 // |popup_url_out| will be set if the extension should show a popup, with |
65 // the URL that should be shown, if non-NULL. | 70 // the URL that should be shown, if non-NULL. |should_grant| controls whether |
71 // the browser action should grant the page tab permissions. The showPopup API | |
72 // does not grant permissions. | |
73 Action ExecuteBrowserAction(const extensions::Extension* extension, | |
74 Browser* browser, | |
75 GURL* popup_url_out, | |
76 bool should_grant); | |
Finnur
2013/10/16 15:01:26
These kinds of optional params (should_grant) are
justinlin
2013/10/16 19:31:29
Hmm.. according to this, this should be the prefer
Finnur
2013/10/17 14:58:34
The public style guide seems to be down (my cowork
justinlin
2013/10/17 18:32:53
Done.
| |
66 Action ExecuteBrowserAction(const extensions::Extension* extension, | 77 Action ExecuteBrowserAction(const extensions::Extension* extension, |
67 Browser* browser, | 78 Browser* browser, |
68 GURL* popup_url_out); | 79 GURL* popup_url_out); |
69 // If count == size(), this will set the visible icon count to -1, meaning | 80 // If count == size(), this will set the visible icon count to -1, meaning |
70 // "show all actions". | 81 // "show all actions". |
71 void SetVisibleIconCount(int count); | 82 void SetVisibleIconCount(int count); |
72 // As above, a return value of -1 represents "show all actions". | 83 // As above, a return value of -1 represents "show all actions". |
73 int GetVisibleIconCount() const { return visible_icon_count_; } | 84 int GetVisibleIconCount() const { return visible_icon_count_; } |
74 | 85 |
75 bool extensions_initialized() const { return extensions_initialized_; } | 86 bool extensions_initialized() const { return extensions_initialized_; } |
76 | 87 |
77 const extensions::ExtensionList& toolbar_items() const { | 88 const extensions::ExtensionList& toolbar_items() const { |
78 return toolbar_items_; | 89 return toolbar_items_; |
79 } | 90 } |
80 | 91 |
81 // Utility functions for converting between an index into the list of | 92 // Utility functions for converting between an index into the list of |
82 // incognito-enabled browser actions, and the list of all browser actions. | 93 // incognito-enabled browser actions, and the list of all browser actions. |
83 int IncognitoIndexToOriginal(int incognito_index); | 94 int IncognitoIndexToOriginal(int incognito_index); |
84 int OriginalIndexToIncognito(int original_index); | 95 int OriginalIndexToIncognito(int original_index); |
85 | 96 |
86 void OnExtensionToolbarPrefChange(); | 97 void OnExtensionToolbarPrefChange(); |
98 // Tells observers to display a popup without granting tab permissions. | |
Finnur
2013/10/16 15:01:26
nit: Line break before this line.
justinlin
2013/10/16 19:31:29
Done.
| |
99 void ShowBrowserActionPopup(const extensions::Extension* extension); | |
87 | 100 |
88 private: | 101 private: |
89 // content::NotificationObserver implementation. | 102 // content::NotificationObserver implementation. |
90 virtual void Observe(int type, | 103 virtual void Observe(int type, |
91 const content::NotificationSource& source, | 104 const content::NotificationSource& source, |
92 const content::NotificationDetails& details) OVERRIDE; | 105 const content::NotificationDetails& details) OVERRIDE; |
93 | 106 |
94 // 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 |
95 // 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 |
96 // and constructs |toolbar_items_| from these data. | 109 // and constructs |toolbar_items_| from these data. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 // For observing change of toolbar order preference by external entity (sync). | 150 // For observing change of toolbar order preference by external entity (sync). |
138 PrefChangeRegistrar pref_change_registrar_; | 151 PrefChangeRegistrar pref_change_registrar_; |
139 base::Closure pref_change_callback_; | 152 base::Closure pref_change_callback_; |
140 | 153 |
141 base::WeakPtrFactory<ExtensionToolbarModel> weak_ptr_factory_; | 154 base::WeakPtrFactory<ExtensionToolbarModel> weak_ptr_factory_; |
142 | 155 |
143 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarModel); | 156 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarModel); |
144 }; | 157 }; |
145 | 158 |
146 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ | 159 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLBAR_MODEL_H_ |
OLD | NEW |