Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / extension_migrator.cc
blob4f10a7c3a9be5dfb9fa72e25587cc1e398a88fdf
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
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/extension_migrator.h"
7 #include "base/values.h"
8 #include "chrome/browser/defaults.h"
9 #include "chrome/browser/extensions/external_provider_impl.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "extensions/browser/extension_registry.h"
12 #include "extensions/common/extension_urls.h"
14 namespace extensions {
16 ExtensionMigrator::ExtensionMigrator(Profile* profile,
17 const std::string& old_id,
18 const std::string& new_id)
19 : profile_(profile), old_id_(old_id), new_id_(new_id) {}
21 ExtensionMigrator::~ExtensionMigrator() {
24 void ExtensionMigrator::StartLoading() {
25 prefs_.reset(new base::DictionaryValue);
27 const bool should_have_extension =
28 IsAppPresent(old_id_) || IsAppPresent(new_id_);
29 if (should_have_extension) {
30 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue);
31 entry->SetStringWithoutPathExpansion(
32 ExternalProviderImpl::kExternalUpdateUrl,
33 extension_urls::GetWebstoreUpdateUrl().spec());
35 prefs_->SetWithoutPathExpansion(new_id_, entry.Pass());
38 LoadFinished();
41 bool ExtensionMigrator::IsAppPresent(const std::string& app_id) {
42 return !!ExtensionRegistry::Get(profile_)->GetInstalledExtension(app_id);
45 } // namespace extensions