OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_COMPONENT_MIGRATION_HELPER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_COMPONENT_MIGRATION_HELPER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_COMPONENT_MIGRATION_HELPER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_COMPONENT_MIGRATION_HELPER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // extension loading. | 100 // extension loading. |
101 void OnFeatureDisabled(const std::string& component_action_id); | 101 void OnFeatureDisabled(const std::string& component_action_id); |
102 | 102 |
103 // Call when the user manually removes the component action from the toolbar. | 103 // Call when the user manually removes the component action from the toolbar. |
104 void OnActionRemoved(const std::string& component_action_id); | 104 void OnActionRemoved(const std::string& component_action_id); |
105 | 105 |
106 // extensions::ExtensionRegistryObserver: | 106 // extensions::ExtensionRegistryObserver: |
107 void OnExtensionReady(content::BrowserContext* browser_context, | 107 void OnExtensionReady(content::BrowserContext* browser_context, |
108 const Extension* extension) override; | 108 const Extension* extension) override; |
109 | 109 |
110 protected: | 110 // Gets and sets the preference for whether to put the component action with |
111 // Protected for unit testing. | 111 // the given ID on the toolbar (or in the overflow menu). |
| 112 // GetComponentActionPref() returns false if the pref has not been set. |
| 113 bool GetComponentActionPref(const std::string& component_action_id) const; |
112 void SetComponentActionPref(const std::string& component_action_id, | 114 void SetComponentActionPref(const std::string& component_action_id, |
113 bool enabled); | 115 bool enabled); |
114 | 116 |
| 117 protected: |
115 // A set of component action ids whose features are currently enabled. | 118 // A set of component action ids whose features are currently enabled. |
116 // Protected for unit testing. | 119 // Protected for unit testing. |
117 std::set<std::string> enabled_actions_; | 120 std::set<std::string> enabled_actions_; |
118 | 121 |
119 private: | 122 private: |
120 bool IsExtensionInstalledAndEnabled(const ExtensionId& extension_id) const; | 123 bool IsExtensionInstalledAndEnabled(const ExtensionId& extension_id) const; |
121 void UnloadExtension(const ExtensionId& extension_id); | 124 void UnloadExtension(const ExtensionId& extension_id); |
122 void RemoveComponentActionPref(const std::string& component_action_id); | 125 void RemoveComponentActionPref(const std::string& component_action_id); |
123 std::vector<std::string> GetExtensionIdsForActionId( | 126 std::vector<std::string> GetExtensionIdsForActionId( |
124 const std::string& component_action_id) const; | 127 const std::string& component_action_id) const; |
(...skipping 11 matching lines...) Expand all Loading... |
136 | 139 |
137 // A list of pairs of component action ids and extension ids. | 140 // A list of pairs of component action ids and extension ids. |
138 std::vector<std::pair<std::string, ExtensionId>> migrated_actions_; | 141 std::vector<std::pair<std::string, ExtensionId>> migrated_actions_; |
139 | 142 |
140 DISALLOW_COPY_AND_ASSIGN(ComponentMigrationHelper); | 143 DISALLOW_COPY_AND_ASSIGN(ComponentMigrationHelper); |
141 }; | 144 }; |
142 | 145 |
143 } // namespace extensions | 146 } // namespace extensions |
144 | 147 |
145 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_MIGRATION_HELPER_H_ | 148 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_MIGRATION_HELPER_H_ |
OLD | NEW |