| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extension_migrator.h" | 5 #include "chrome/browser/extensions/extension_migrator.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/values.h" | 9 #include "base/values.h" |
| 8 #include "chrome/browser/defaults.h" | 10 #include "chrome/browser/defaults.h" |
| 9 #include "chrome/browser/extensions/external_provider_impl.h" | 11 #include "chrome/browser/extensions/external_provider_impl.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 11 #include "extensions/browser/extension_registry.h" | 13 #include "extensions/browser/extension_registry.h" |
| 12 #include "extensions/common/extension_urls.h" | 14 #include "extensions/common/extension_urls.h" |
| 13 | 15 |
| 14 namespace extensions { | 16 namespace extensions { |
| 15 | 17 |
| 16 ExtensionMigrator::ExtensionMigrator(Profile* profile, | 18 ExtensionMigrator::ExtensionMigrator(Profile* profile, |
| 17 const std::string& old_id, | 19 const std::string& old_id, |
| 18 const std::string& new_id) | 20 const std::string& new_id) |
| 19 : profile_(profile), old_id_(old_id), new_id_(new_id) {} | 21 : profile_(profile), old_id_(old_id), new_id_(new_id) {} |
| 20 | 22 |
| 21 ExtensionMigrator::~ExtensionMigrator() { | 23 ExtensionMigrator::~ExtensionMigrator() { |
| 22 } | 24 } |
| 23 | 25 |
| 24 void ExtensionMigrator::StartLoading() { | 26 void ExtensionMigrator::StartLoading() { |
| 25 prefs_.reset(new base::DictionaryValue); | 27 prefs_.reset(new base::DictionaryValue); |
| 26 | 28 |
| 27 const bool should_have_extension = | 29 const bool should_have_extension = |
| 28 IsAppPresent(old_id_) || IsAppPresent(new_id_); | 30 IsAppPresent(old_id_) || IsAppPresent(new_id_); |
| 29 if (should_have_extension) { | 31 if (should_have_extension) { |
| 30 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); | 32 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); |
| 31 entry->SetStringWithoutPathExpansion( | 33 entry->SetStringWithoutPathExpansion( |
| 32 ExternalProviderImpl::kExternalUpdateUrl, | 34 ExternalProviderImpl::kExternalUpdateUrl, |
| 33 extension_urls::GetWebstoreUpdateUrl().spec()); | 35 extension_urls::GetWebstoreUpdateUrl().spec()); |
| 34 | 36 |
| 35 prefs_->SetWithoutPathExpansion(new_id_, entry.Pass()); | 37 prefs_->SetWithoutPathExpansion(new_id_, std::move(entry)); |
| 36 } | 38 } |
| 37 | 39 |
| 38 LoadFinished(); | 40 LoadFinished(); |
| 39 } | 41 } |
| 40 | 42 |
| 41 bool ExtensionMigrator::IsAppPresent(const std::string& app_id) { | 43 bool ExtensionMigrator::IsAppPresent(const std::string& app_id) { |
| 42 return !!ExtensionRegistry::Get(profile_)->GetInstalledExtension(app_id); | 44 return !!ExtensionRegistry::Get(profile_)->GetInstalledExtension(app_id); |
| 43 } | 45 } |
| 44 | 46 |
| 45 } // namespace extensions | 47 } // namespace extensions |
| OLD | NEW |