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 "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // Create prefs file to make the profile not new. | 44 // Create prefs file to make the profile not new. |
45 const char prefs[] = "{}"; | 45 const char prefs[] = "{}"; |
46 EXPECT_EQ(int(sizeof(prefs)), | 46 EXPECT_EQ(int(sizeof(prefs)), |
47 base::WriteFile(params.pref_file, prefs, sizeof(prefs))); | 47 base::WriteFile(params.pref_file, prefs, sizeof(prefs))); |
48 InitializeExtensionService(params); | 48 InitializeExtensionService(params); |
49 service()->Init(); | 49 service()->Init(); |
50 AddMigratorProvider(); | 50 AddMigratorProvider(); |
51 } | 51 } |
52 | 52 |
53 void AddMigratorProvider() { | 53 void AddMigratorProvider() { |
54 service()->AddProviderForTesting(new ExternalProviderImpl( | 54 service()->AddProviderForTesting(base::MakeUnique<ExternalProviderImpl>( |
55 service(), | 55 service(), new ExtensionMigrator(profile(), kOldId, kNewId), profile(), |
56 new ExtensionMigrator(profile(), kOldId, kNewId), | 56 Manifest::EXTERNAL_PREF, Manifest::EXTERNAL_PREF_DOWNLOAD, |
57 profile(), | |
58 Manifest::EXTERNAL_PREF, | |
59 Manifest::EXTERNAL_PREF_DOWNLOAD, | |
60 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT)); | 57 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT)); |
61 } | 58 } |
62 | 59 |
63 void AddExtension(const std::string& id) { | 60 void AddExtension(const std::string& id) { |
64 scoped_refptr<Extension> fake_app = CreateExtension(id); | 61 scoped_refptr<Extension> fake_app = CreateExtension(id); |
65 service()->AddExtension(fake_app.get()); | 62 service()->AddExtension(fake_app.get()); |
66 } | 63 } |
67 | 64 |
68 bool HasNewExtension() { | 65 bool HasNewExtension() { |
69 return service()->pending_extension_manager()->IsIdPending(kNewId) || | 66 return service()->pending_extension_manager()->IsIdPending(kNewId) || |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 InitWithExistingProfile(); | 99 InitWithExistingProfile(); |
103 AddExtension(kOldId); | 100 AddExtension(kOldId); |
104 AddExtension(kNewId); | 101 AddExtension(kNewId); |
105 service()->CheckForExternalUpdates(); | 102 service()->CheckForExternalUpdates(); |
106 base::RunLoop().RunUntilIdle(); | 103 base::RunLoop().RunUntilIdle(); |
107 EXPECT_TRUE(!!registry()->GetInstalledExtension(kOldId)); | 104 EXPECT_TRUE(!!registry()->GetInstalledExtension(kOldId)); |
108 EXPECT_TRUE(!!registry()->GetInstalledExtension(kNewId)); | 105 EXPECT_TRUE(!!registry()->GetInstalledExtension(kNewId)); |
109 } | 106 } |
110 | 107 |
111 } // namespace extensions | 108 } // namespace extensions |
OLD | NEW |