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 #include "chrome/browser/extensions/component_migration_helper.h" | 5 #include "chrome/browser/extensions/component_migration_helper.h" |
6 | 6 |
7 #include "base/prefs/pref_registry_simple.h" | 7 #include "base/prefs/pref_registry_simple.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 DCHECK(!extension_ids.empty()); | 106 DCHECK(!extension_ids.empty()); |
107 | 107 |
108 enabled_actions_.erase(component_action_id); | 108 enabled_actions_.erase(component_action_id); |
109 RemoveComponentActionPref(component_action_id); | 109 RemoveComponentActionPref(component_action_id); |
110 | 110 |
111 if (FeatureSwitch::extension_action_redesign()->IsEnabled() && | 111 if (FeatureSwitch::extension_action_redesign()->IsEnabled() && |
112 delegate_->HasComponentAction(component_action_id)) | 112 delegate_->HasComponentAction(component_action_id)) |
113 delegate_->RemoveComponentAction(component_action_id); | 113 delegate_->RemoveComponentAction(component_action_id); |
114 } | 114 } |
115 | 115 |
| 116 void ComponentMigrationHelper::OnActionRemoved( |
| 117 const std::string& component_action_id) { |
| 118 // Record preference for the future. |
| 119 SetComponentActionPref(component_action_id, false); |
| 120 |
| 121 // Remove the action. |
| 122 if (delegate_->HasComponentAction(component_action_id)) |
| 123 delegate_->RemoveComponentAction(component_action_id); |
| 124 } |
| 125 |
116 void ComponentMigrationHelper::OnExtensionReady( | 126 void ComponentMigrationHelper::OnExtensionReady( |
117 content::BrowserContext* browser_context, | 127 content::BrowserContext* browser_context, |
118 const Extension* extension) { | 128 const Extension* extension) { |
119 const ExtensionId& extension_id = extension->id(); | 129 const ExtensionId& extension_id = extension->id(); |
120 const std::string& component_action_id = | 130 const std::string& component_action_id = |
121 GetActionIdForExtensionId(extension_id); | 131 GetActionIdForExtensionId(extension_id); |
122 if (component_action_id.empty()) | 132 if (component_action_id.empty()) |
123 return; | 133 return; |
124 if (ContainsKey(enabled_actions_, component_action_id)) { | 134 if (ContainsKey(enabled_actions_, component_action_id)) { |
125 UnloadExtension(extension_id); | 135 UnloadExtension(extension_id); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 std::string ComponentMigrationHelper::GetActionIdForExtensionId( | 180 std::string ComponentMigrationHelper::GetActionIdForExtensionId( |
171 const ExtensionId& extension_id) const { | 181 const ExtensionId& extension_id) const { |
172 for (const auto& i : migrated_actions_) { | 182 for (const auto& i : migrated_actions_) { |
173 if (i.second == extension_id) | 183 if (i.second == extension_id) |
174 return i.first; | 184 return i.first; |
175 } | 185 } |
176 return ""; | 186 return ""; |
177 } | 187 } |
178 | 188 |
179 } // namespace extensions | 189 } // namespace extensions |
OLD | NEW |