| 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/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_system_impl.h" | 10 #include "chrome/browser/extensions/extension_system_impl.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 } | 123 } |
| 124 | 124 |
| 125 void ComponentMigrationHelper::OnExtensionReady( | 125 void ComponentMigrationHelper::OnExtensionReady( |
| 126 content::BrowserContext* browser_context, | 126 content::BrowserContext* browser_context, |
| 127 const Extension* extension) { | 127 const Extension* extension) { |
| 128 const ExtensionId& extension_id = extension->id(); | 128 const ExtensionId& extension_id = extension->id(); |
| 129 const std::string& component_action_id = | 129 const std::string& component_action_id = |
| 130 GetActionIdForExtensionId(extension_id); | 130 GetActionIdForExtensionId(extension_id); |
| 131 if (component_action_id.empty()) | 131 if (component_action_id.empty()) |
| 132 return; | 132 return; |
| 133 if (ContainsKey(enabled_actions_, component_action_id)) { | 133 if (base::ContainsKey(enabled_actions_, component_action_id)) { |
| 134 UnloadExtension(extension_id); | 134 UnloadExtension(extension_id); |
| 135 SetComponentActionPref(component_action_id, true); | 135 SetComponentActionPref(component_action_id, true); |
| 136 | 136 |
| 137 if (!delegate_->HasComponentAction(component_action_id)) | 137 if (!delegate_->HasComponentAction(component_action_id)) |
| 138 delegate_->AddComponentAction(component_action_id); | 138 delegate_->AddComponentAction(component_action_id); |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 void ComponentMigrationHelper::SetComponentActionPref( | 142 void ComponentMigrationHelper::SetComponentActionPref( |
| 143 const std::string& component_action_id, | 143 const std::string& component_action_id, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 std::string ComponentMigrationHelper::GetActionIdForExtensionId( | 179 std::string ComponentMigrationHelper::GetActionIdForExtensionId( |
| 180 const ExtensionId& extension_id) const { | 180 const ExtensionId& extension_id) const { |
| 181 for (const auto& i : migrated_actions_) { | 181 for (const auto& i : migrated_actions_) { |
| 182 if (i.second == extension_id) | 182 if (i.second == extension_id) |
| 183 return i.first; | 183 return i.first; |
| 184 } | 184 } |
| 185 return ""; | 185 return ""; |
| 186 } | 186 } |
| 187 | 187 |
| 188 } // namespace extensions | 188 } // namespace extensions |
| OLD | NEW |