Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 2146963004: Adding the creation flags back to pending extension info. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a test to update extension with flag before installtion Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 3000 matching lines...) Expand 10 before | Expand all | Expand 10 after
3011 3011
3012 // Use AddExtensionImpl() as AddFrom*() would balk. 3012 // Use AddExtensionImpl() as AddFrom*() would balk.
3013 service()->pending_extension_manager()->AddExtensionImpl( 3013 service()->pending_extension_manager()->AddExtensionImpl(
3014 good->id(), 3014 good->id(),
3015 std::string(), 3015 std::string(),
3016 extensions::ManifestURL::GetUpdateURL(good), 3016 extensions::ManifestURL::GetUpdateURL(good),
3017 Version(), 3017 Version(),
3018 &IsExtension, 3018 &IsExtension,
3019 kGoodIsFromSync, 3019 kGoodIsFromSync,
3020 Manifest::INTERNAL, 3020 Manifest::INTERNAL,
3021 Extension::NO_FLAGS,
3021 false, 3022 false,
3022 kGoodRemoteInstall); 3023 kGoodRemoteInstall);
3023 UpdateExtension(good->id(), path, ENABLED); 3024 UpdateExtension(good->id(), path, ENABLED);
3024 3025
3025 EXPECT_FALSE(service()->pending_extension_manager()->IsIdPending(kGoodId)); 3026 EXPECT_FALSE(service()->pending_extension_manager()->IsIdPending(kGoodId));
3026 } 3027 }
3027 3028
3028 #if defined(ENABLE_BLACKLIST_TESTS) 3029 #if defined(ENABLE_BLACKLIST_TESTS)
3029 // Tests blacklisting then unblacklisting extensions after the service has been 3030 // Tests blacklisting then unblacklisting extensions after the service has been
3030 // initialized. 3031 // initialized.
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after
4174 observer.Wait(); 4175 observer.Wait();
4175 4176
4176 ASSERT_EQ(1u, registry()->enabled_extensions().size()); 4177 ASSERT_EQ(1u, registry()->enabled_extensions().size());
4177 EXPECT_TRUE(service()->GetExtensionById(good_crx, false)); 4178 EXPECT_TRUE(service()->GetExtensionById(good_crx, false));
4178 const Extension* extension = service()->GetExtensionById(good_crx, false); 4179 const Extension* extension = service()->GetExtensionById(good_crx, false);
4179 EXPECT_TRUE(extension->from_webstore()); 4180 EXPECT_TRUE(extension->from_webstore());
4180 EXPECT_TRUE(extension->was_installed_by_default()); 4181 EXPECT_TRUE(extension->was_installed_by_default());
4181 } 4182 }
4182 #endif 4183 #endif
4183 4184
4185 TEST_F(ExtensionServiceTest, UpdatingPendingExternalExtensionWithFlags) {
Devlin 2016/07/15 19:02:40 Let's add a comment: // Regression test for crbug.
mamir 2016/07/15 19:06:20 Done.
4186 const char kPrefFromBookmark[] = "from_bookmark";
4187
4188 InitializeEmptyExtensionService();
4189
4190 base::FilePath path = data_dir().AppendASCII("good.crx");
4191 service()->set_extensions_enabled(true);
4192
4193 // Register and install an external extension.
4194 std::unique_ptr<Version> version(new Version("1.0.0.0"));
4195 content::WindowedNotificationObserver observer(
4196 extensions::NOTIFICATION_CRX_INSTALLER_DONE,
4197 content::NotificationService::AllSources());
4198 std::unique_ptr<ExternalInstallInfoFile> info(new ExternalInstallInfoFile(
4199 good_crx, std::move(version), path, Manifest::EXTERNAL_PREF,
4200 Extension::FROM_BOOKMARK, false /* mark_acknowledged */,
4201 false /* install_immediately */));
4202 ASSERT_TRUE(service()->OnExternalExtensionFileFound(*info));
4203 EXPECT_TRUE(service()->pending_extension_manager()->IsIdPending(good_crx));
4204
4205 // Upgrade to version 2.0, the flag should be preserved.
4206 path = data_dir().AppendASCII("good2.crx");
4207 UpdateExtension(good_crx, path, ENABLED);
4208 ASSERT_TRUE(ValidateBooleanPref(good_crx, kPrefFromBookmark, true));
4209 const Extension* extension = service()->GetExtensionById(good_crx, false);
4210 ASSERT_TRUE(extension);
4211 ASSERT_TRUE(extension->from_bookmark());
4212 }
4213
4184 // Tests disabling extensions 4214 // Tests disabling extensions
4185 TEST_F(ExtensionServiceTest, DisableExtension) { 4215 TEST_F(ExtensionServiceTest, DisableExtension) {
4186 InitializeEmptyExtensionService(); 4216 InitializeEmptyExtensionService();
4187 4217
4188 InstallCRX(data_dir().AppendASCII("good.crx"), INSTALL_NEW); 4218 InstallCRX(data_dir().AppendASCII("good.crx"), INSTALL_NEW);
4189 EXPECT_TRUE(service()->GetExtensionById(good_crx, true)); 4219 EXPECT_TRUE(service()->GetExtensionById(good_crx, true));
4190 EXPECT_TRUE(service()->GetExtensionById(good_crx, false)); 4220 EXPECT_TRUE(service()->GetExtensionById(good_crx, false));
4191 4221
4192 EXPECT_EQ(1u, registry()->enabled_extensions().size()); 4222 EXPECT_EQ(1u, registry()->enabled_extensions().size());
4193 EXPECT_EQ(0u, registry()->disabled_extensions().size()); 4223 EXPECT_EQ(0u, registry()->disabled_extensions().size());
(...skipping 2642 matching lines...) Expand 10 before | Expand all | Expand 10 after
6836 6866
6837 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 6867 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
6838 content::Source<Profile>(profile()), 6868 content::Source<Profile>(profile()),
6839 content::NotificationService::NoDetails()); 6869 content::NotificationService::NoDetails());
6840 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); 6870 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_);
6841 EXPECT_EQ(0u, registry()->enabled_extensions().size()); 6871 EXPECT_EQ(0u, registry()->enabled_extensions().size());
6842 EXPECT_EQ(0u, registry()->disabled_extensions().size()); 6872 EXPECT_EQ(0u, registry()->disabled_extensions().size());
6843 EXPECT_EQ(0u, registry()->terminated_extensions().size()); 6873 EXPECT_EQ(0u, registry()->terminated_extensions().size());
6844 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); 6874 EXPECT_EQ(0u, registry()->blacklisted_extensions().size());
6845 } 6875 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/pending_extension_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698