[Extensions] Remove deprecated ExtensionService member function.
This CL removes ExtensionService::GetExtensionById().
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
Bug: 489687
Change-Id: I3919bd1b0b76f32190750a63f3088cfe528e6a03
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1704521
Commit-Queue: David Bertoni <[email protected]>
Reviewed-by: Karan Bhatia <[email protected]>
Cr-Commit-Position: refs/heads/master@{#683709}
diff --git a/chrome/browser/apps/platform_apps/app_browsertest.cc b/chrome/browser/apps/platform_apps/app_browsertest.cc
index 6709938..d96e2642 100644
--- a/chrome/browser/apps/platform_apps/app_browsertest.cc
+++ b/chrome/browser/apps/platform_apps/app_browsertest.cc
@@ -1221,8 +1221,8 @@
IN_PROC_BROWSER_TEST_F(PlatformAppIncognitoBrowserTest,
MAYBE_IncognitoComponentApp) {
// Get the file manager app.
- const Extension* file_manager = extension_service()->GetExtensionById(
- "hhaomjibdihmijegdhdafkllkbggdgoj", false);
+ const Extension* file_manager = extension_registry()->GetExtensionById(
+ "hhaomjibdihmijegdhdafkllkbggdgoj", ExtensionRegistry::ENABLED);
ASSERT_TRUE(file_manager != NULL);
Profile* incognito_profile = profile()->GetOffTheRecordProfile();
ASSERT_TRUE(incognito_profile != NULL);
diff --git a/chrome/browser/background/background_contents_service.cc b/chrome/browser/background/background_contents_service.cc
index 274063c..675f6cfd 100644
--- a/chrome/browser/background/background_contents_service.cc
+++ b/chrome/browser/background/background_contents_service.cc
@@ -474,14 +474,14 @@
prefs_->GetDictionary(prefs::kRegisteredBackgroundContents);
if (!contents)
return;
- extensions::ExtensionService* extensions_service =
- extensions::ExtensionSystem::Get(profile)->extension_service();
- DCHECK(extensions_service);
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(profile);
+ DCHECK(extension_registry);
for (base::DictionaryValue::Iterator it(*contents); !it.IsAtEnd();
it.Advance()) {
// Check to make sure that the parent extension is still enabled.
- const Extension* extension =
- extensions_service->GetExtensionById(it.key(), false);
+ const Extension* extension = extension_registry->GetExtensionById(
+ it.key(), extensions::ExtensionRegistry::ENABLED);
if (!extension) {
// We should never reach here - it should not be possible for an app
// to become uninstalled without the associated BackgroundContents being
@@ -523,9 +523,9 @@
Profile* profile,
const std::string& extension_id) {
// First look if the manifest specifies a background page.
- const Extension* extension = extensions::ExtensionSystem::Get(profile)
- ->extension_service()
- ->GetExtensionById(extension_id, false);
+ const Extension* extension =
+ extensions::ExtensionRegistry::Get(profile)->GetExtensionById(
+ extension_id, extensions::ExtensionRegistry::ENABLED);
DCHECK(!extension || extension->is_hosted_app());
if (extension && BackgroundInfo::HasBackgroundPage(extension)) {
LoadBackgroundContents(profile, BackgroundInfo::GetBackgroundURL(extension),
@@ -742,24 +742,21 @@
// Do not register in the pref if the extension has a manifest-specified
// background page.
const std::string& appid = GetParentApplicationId(contents);
- extensions::ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(profile_)->extension_service();
- // extension_service can be nullptr when running tests.
- if (extension_service) {
- const Extension* extension =
- extension_service->GetExtensionById(appid, false);
- if (extension && BackgroundInfo::HasBackgroundPage(extension))
- return;
- }
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(profile_);
+ const Extension* extension = extension_registry->GetExtensionById(
+ appid, extensions::ExtensionRegistry::ENABLED);
+ if (extension && BackgroundInfo::HasBackgroundPage(extension))
+ return;
RegisterBackgroundContents(contents);
}
void BackgroundContentsService::OnBackgroundContentsTerminated(
BackgroundContents* contents) {
HandleExtensionCrashed(
- extensions::ExtensionSystem::Get(profile_)
- ->extension_service()
- ->GetExtensionById(GetParentApplicationId(contents), false));
+ extensions::ExtensionRegistry::Get(profile_)->GetExtensionById(
+ GetParentApplicationId(contents),
+ extensions::ExtensionRegistry::ENABLED));
}
void BackgroundContentsService::OnBackgroundContentsClosed(
diff --git a/chrome/browser/chromeos/app_mode/startup_app_launcher_unittest.cc b/chrome/browser/chromeos/app_mode/startup_app_launcher_unittest.cc
index 3ffa0c53..0f43410 100644
--- a/chrome/browser/chromeos/app_mode/startup_app_launcher_unittest.cc
+++ b/chrome/browser/chromeos/app_mode/startup_app_launcher_unittest.cc
@@ -207,8 +207,10 @@
: public extensions::ExternalProviderInterface::VisitorInterface {
public:
TestKioskLoaderVisitor(content::BrowserContext* browser_context,
+ extensions::ExtensionRegistry* extension_registry,
extensions::ExtensionService* extension_service)
: browser_context_(browser_context),
+ extension_registry_(extension_registry),
extension_service_(extension_service) {}
~TestKioskLoaderVisitor() override = default;
@@ -263,7 +265,8 @@
bool OnExternalExtensionFileFound(
const ExternalInstallInfoFile& info) override {
const extensions::Extension* existing =
- extension_service_->GetExtensionById(info.extension_id, true);
+ extension_registry_->GetExtensionById(
+ info.extension_id, extensions::ExtensionRegistry::COMPATIBILITY);
// Alredy exists, and does not require update.
if (existing && existing->version().CompareTo(info.version) >= 0)
return false;
@@ -282,7 +285,8 @@
bool OnExternalExtensionUpdateUrlFound(
const ExternalInstallInfoUpdateUrl& info,
bool is_initial_load) override {
- if (extension_service_->GetExtensionById(info.extension_id, true))
+ if (extension_registry_->GetExtensionById(
+ info.extension_id, extensions::ExtensionRegistry::COMPATIBILITY))
return false;
if (!extension_service_->pending_extension_manager()
@@ -320,6 +324,7 @@
private:
content::BrowserContext* const browser_context_;
+ extensions::ExtensionRegistry* const extension_registry_;
extensions::ExtensionService* const extension_service_;
std::set<std::string> pending_crx_files_;
@@ -349,8 +354,8 @@
extensions::ExtensionServiceTestBase::SetUp();
InitializeEmptyExtensionService();
- external_apps_loader_handler_ =
- std::make_unique<TestKioskLoaderVisitor>(browser_context(), service());
+ external_apps_loader_handler_ = std::make_unique<TestKioskLoaderVisitor>(
+ browser_context(), registry(), service());
CreateAndInitializeKioskAppsProviders(external_apps_loader_handler_.get());
extensions::TestEventRouter* event_router =
diff --git a/chrome/browser/chromeos/file_manager/file_tasks_unittest.cc b/chrome/browser/chromeos/file_manager/file_tasks_unittest.cc
index 259f967..650d89f 100644
--- a/chrome/browser/chromeos/file_manager/file_tasks_unittest.cc
+++ b/chrome/browser/chromeos/file_manager/file_tasks_unittest.cc
@@ -31,6 +31,7 @@
#include "content/public/test/test_browser_thread_bundle.h"
#include "extensions/browser/entry_info.h"
#include "extensions/browser/extension_prefs.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_builder.h"
@@ -565,8 +566,10 @@
graphr.AddFlags(extensions::Extension::InitFromValueFlags::FROM_BOOKMARK);
extension_service_->AddExtension(graphr.Build().get());
- const extensions::Extension* extension =
- extension_service_->GetExtensionById(kGraphrId, false);
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(&test_profile_);
+ const extensions::Extension* extension = registry->GetExtensionById(
+ kGraphrId, extensions::ExtensionRegistry::ENABLED);
ASSERT_EQ(extension->GetType(), extensions::Manifest::Type::TYPE_HOSTED_APP);
ASSERT_TRUE(extension->from_bookmark());
diff --git a/chrome/browser/chromeos/first_run/drive_first_run_controller.cc b/chrome/browser/chromeos/first_run/drive_first_run_controller.cc
index c64a3c1..4511e19 100644
--- a/chrome/browser/chromeos/first_run/drive_first_run_controller.cc
+++ b/chrome/browser/chromeos/first_run/drive_first_run_controller.cc
@@ -23,7 +23,6 @@
#include "chrome/browser/background/background_contents_service_observer.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/notifications/notification_display_service.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/browser/ui/singleton_tabs.h"
@@ -323,9 +322,10 @@
return;
}
- extensions::ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(profile_)->extension_service();
- if (!extension_service->GetExtensionById(drive_hosted_app_id_, false)) {
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(profile_);
+ if (!extension_registry->GetExtensionById(
+ drive_hosted_app_id_, extensions::ExtensionRegistry::ENABLED)) {
LOG(WARNING) << "Drive app is not installed.";
OnOfflineInit(false, OUTCOME_APP_NOT_INSTALLED);
return;
@@ -403,11 +403,11 @@
}
void DriveFirstRunController::ShowNotification() {
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(profile_)->extension_service();
- DCHECK(service);
- const extensions::Extension* extension =
- service->GetExtensionById(drive_hosted_app_id_, false);
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(profile_);
+ DCHECK(registry);
+ const extensions::Extension* extension = registry->GetExtensionById(
+ drive_hosted_app_id_, extensions::ExtensionRegistry::ENABLED);
DCHECK(extension);
message_center::RichNotificationData data;
diff --git a/chrome/browser/chromeos/first_run/first_run.cc b/chrome/browser/chromeos/first_run/first_run.cc
index 823d7b81..de7fa8d 100644
--- a/chrome/browser/chromeos/first_run/first_run.cc
+++ b/chrome/browser/chromeos/first_run/first_run.cc
@@ -17,7 +17,6 @@
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/prefs/pref_service_syncable_util.h"
#include "chrome/browser/profiles/profile.h"
@@ -38,7 +37,7 @@
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h"
#include "content/public/common/content_switches.h"
-#include "extensions/browser/extension_system.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/common/constants.h"
#include "ui/gfx/geometry/rect.h"
@@ -48,13 +47,14 @@
namespace {
void LaunchDialogForProfile(Profile* profile) {
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(profile)->extension_service();
- if (!service)
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(profile);
+ if (!registry)
return;
const extensions::Extension* extension =
- service->GetExtensionById(extension_misc::kFirstRunDialogId, false);
+ registry->GetExtensionById(extension_misc::kFirstRunDialogId,
+ extensions::ExtensionRegistry::ENABLED);
if (!extension)
return;
diff --git a/chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc b/chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc
index 45a3623..2827393 100644
--- a/chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc
+++ b/chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc
@@ -25,6 +25,7 @@
#include "chrome/grit/browser_resources.h"
#include "extensions/browser/extension_pref_value_map.h"
#include "extensions/browser/extension_pref_value_map_factory.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_constants.h"
@@ -94,12 +95,11 @@
const std::string& extension_id,
const std::string& manifest,
const base::FilePath& file_path) {
- extensions::ExtensionSystem* extension_system =
- extensions::ExtensionSystem::Get(profile);
- extensions::ExtensionService* extension_service =
- extension_system->extension_service();
- DCHECK(extension_service);
- if (extension_service->GetExtensionById(extension_id, false)) {
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(profile);
+ DCHECK(extension_registry);
+ if (extension_registry->GetExtensionById(
+ extension_id, extensions::ExtensionRegistry::ENABLED)) {
VLOG(1) << "the IME extension(id=\"" << extension_id
<< "\") is already enabled";
return;
@@ -119,6 +119,11 @@
true, // is_enabled.
true); // is_incognito_enabled.
DCHECK_EQ(loaded_extension_id, extension_id);
+ extensions::ExtensionSystem* extension_system =
+ extensions::ExtensionSystem::Get(profile);
+ extensions::ExtensionService* extension_service =
+ extension_system->extension_service();
+ DCHECK(extension_service);
if (!extension_service->IsExtensionEnabled(loaded_extension_id)) {
LOG(ERROR) << "An IME extension(id=\"" << loaded_extension_id
<< "\") is not enabled after loading";
diff --git a/chrome/browser/chromeos/login/demo_mode/demo_app_launcher.cc b/chrome/browser/chromeos/login/demo_mode/demo_app_launcher.cc
index 0170865..f31b091e 100644
--- a/chrome/browser/chromeos/login/demo_mode/demo_app_launcher.cc
+++ b/chrome/browser/chromeos/login/demo_mode/demo_app_launcher.cc
@@ -23,6 +23,7 @@
#include "components/account_id/account_id.h"
#include "components/session_manager/core/session_manager.h"
#include "components/user_manager/user_names.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
@@ -77,8 +78,10 @@
const std::string extension_id = extension_service->component_loader()->Add(
IDR_DEMO_APP_MANIFEST, *demo_app_path_);
- const extensions::Extension* extension =
- extension_service->GetExtensionById(extension_id, true);
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(profile);
+ const extensions::Extension* extension = extension_registry->GetExtensionById(
+ extension_id, extensions::ExtensionRegistry::COMPATIBILITY);
if (!extension) {
// We've already done too much setup at this point to just return out, it
// is safer to just restart.
diff --git a/chrome/browser/chromeos/policy/device_local_account_browsertest.cc b/chrome/browser/chromeos/policy/device_local_account_browsertest.cc
index 6b821a19..038279f 100644
--- a/chrome/browser/chromeos/policy/device_local_account_browsertest.cc
+++ b/chrome/browser/chromeos/policy/device_local_account_browsertest.cc
@@ -1129,12 +1129,14 @@
// Verify that the hosted app was installed.
Profile* profile = GetProfileForTest();
ASSERT_TRUE(profile);
- extensions::ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(profile)->extension_service();
- EXPECT_TRUE(extension_service->GetExtensionById(kHostedAppID, true));
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(profile);
+ EXPECT_TRUE(extension_registry->GetExtensionById(
+ kHostedAppID, extensions::ExtensionRegistry::COMPATIBILITY));
// Verify that the extension was not installed.
- EXPECT_FALSE(extension_service->GetExtensionById(kGoodExtensionID, true));
+ EXPECT_FALSE(extension_registry->GetExtensionById(
+ kGoodExtensionID, extensions::ExtensionRegistry::COMPATIBILITY));
// Verify that the app was downloaded to the account's extension cache.
base::FilePath test_dir;
@@ -1213,12 +1215,14 @@
// Verify that the hosted app was installed.
Profile* profile = GetProfileForTest();
ASSERT_TRUE(profile);
- extensions::ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(profile)->extension_service();
- EXPECT_TRUE(extension_service->GetExtensionById(kHostedAppID, true));
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(profile);
+ EXPECT_TRUE(extension_registry->GetExtensionById(
+ kHostedAppID, extensions::ExtensionRegistry::COMPATIBILITY));
// Verify that the extension was not installed.
- EXPECT_FALSE(extension_service->GetExtensionById(kGoodExtensionID, true));
+ EXPECT_FALSE(extension_registry->GetExtensionById(
+ kGoodExtensionID, extensions::ExtensionRegistry::COMPATIBILITY));
// Verify that the app is still in the account's extension cache.
{
@@ -2301,9 +2305,10 @@
// Verify that the app was installed.
Profile* profile = GetProfileForTest();
ASSERT_TRUE(profile);
- extensions::ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(profile)->extension_service();
- EXPECT_TRUE(extension_service->GetExtensionById(kShowManagedStorageID, true));
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(profile);
+ EXPECT_TRUE(extension_registry->GetExtensionById(
+ kShowManagedStorageID, extensions::ExtensionRegistry::COMPATIBILITY));
// Wait for the app policy if it hasn't been fetched yet.
ProfilePolicyConnector* connector = profile->GetProfilePolicyConnector();
diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc
index aec13d0..b8f779b 100644
--- a/chrome/browser/download/download_browsertest.cc
+++ b/chrome/browser/download/download_browsertest.cc
@@ -53,7 +53,6 @@
#include "chrome/browser/download/download_shelf.h"
#include "chrome/browser/download/download_target_determiner.h"
#include "chrome/browser/download/download_test_file_activity_observer.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/install_verifier.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/infobars/infobar_service.h"
@@ -115,6 +114,7 @@
#include "content/public/test/test_file_error_injector.h"
#include "content/public/test/test_navigation_observer.h"
#include "extensions/browser/extension_dialog_auto_confirm.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/scoped_ignore_content_verifier_for_test.h"
#include "net/base/filename_util.h"
@@ -2217,10 +2217,10 @@
EXPECT_TRUE(VerifyNoDownloads());
// Check that the CRX is not installed.
- extensions::ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
- ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false));
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(browser()->profile());
+ ASSERT_FALSE(extension_registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::ENABLED));
}
// Download an extension. Expect a dangerous download warning.
@@ -2254,10 +2254,10 @@
downloads[0], base::Bind(&WasAutoOpened)).WaitForEvent();
// Check that the extension was not installed.
- extensions::ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
- ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false));
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(browser()->profile());
+ ASSERT_FALSE(extension_registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::ENABLED));
}
// Download an extension. Expect a dangerous download warning.
@@ -2294,10 +2294,10 @@
downloads[0], base::Bind(&WasAutoOpened)).WaitForEvent();
// Check that the extension was installed.
- extensions::ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
- ASSERT_TRUE(extension_service->GetExtensionById(kGoodCrxId, false));
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(browser()->profile());
+ ASSERT_TRUE(extension_registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::ENABLED));
}
// Test installing a CRX that fails integrity checks.
@@ -2322,10 +2322,10 @@
CheckDownloadStates(1, DownloadItem::COMPLETE);
// Check that the extension was not installed.
- extensions::ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
- ASSERT_FALSE(extension_service->GetExtensionById(kGoodCrxId, false));
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(browser()->profile());
+ ASSERT_FALSE(extension_registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::ENABLED));
}
// Install a large (100kb) theme.
@@ -2361,10 +2361,10 @@
downloads[0], base::Bind(&WasAutoOpened)).WaitForEvent();
// Check that the extension was installed.
- extensions::ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
- ASSERT_TRUE(extension_service->GetExtensionById(kLargeThemeCrxId, false));
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(browser()->profile());
+ ASSERT_TRUE(extension_registry->GetExtensionById(
+ kLargeThemeCrxId, extensions::ExtensionRegistry::ENABLED));
}
// Tests for download initiation functions.
diff --git a/chrome/browser/extensions/active_tab_apitest.cc b/chrome/browser/extensions/active_tab_apitest.cc
index 34a2bd2..ba85bf4 100644
--- a/chrome/browser/extensions/active_tab_apitest.cc
+++ b/chrome/browser/extensions/active_tab_apitest.cc
@@ -268,8 +268,8 @@
};
auto can_load_file_iframe = [this, &extension_id]() {
- const Extension* extension =
- extension_service()->GetExtensionById(extension_id, false);
+ const Extension* extension = extension_registry()->GetExtensionById(
+ extension_id, ExtensionRegistry::ENABLED);
// Load an extension page with a file iframe.
GURL page = extension->GetResourceURL("file_iframe.html");
diff --git a/chrome/browser/extensions/api/commands/command_service_browsertest.cc b/chrome/browser/extensions/api/commands/command_service_browsertest.cc
index c9ecdae1..a6a2e01 100644
--- a/chrome/browser/extensions/api/commands/command_service_browsertest.cc
+++ b/chrome/browser/extensions/api/commands/command_service_browsertest.cc
@@ -10,11 +10,11 @@
#include "build/build_config.h"
#include "chrome/browser/extensions/api/commands/command_service.h"
#include "chrome/browser/extensions/extension_apitest.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_utils.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/common/manifest_constants.h"
namespace {
@@ -64,15 +64,14 @@
scoped_temp_dir.GetPath().AppendASCII("v2.crx"),
pem_path, base::FilePath());
- ExtensionService* service = ExtensionSystem::Get(browser()->profile())->
- extension_service();
+ ExtensionRegistry* registry = ExtensionRegistry::Get(browser()->profile());
CommandService* command_service = CommandService::Get(browser()->profile());
const char kId[] = "pgoakhfeplldmjheffidklpoklkppipp";
// Install v1 of the extension.
ASSERT_TRUE(InstallExtension(path_v1, 1));
- EXPECT_TRUE(service->GetExtensionById(kId, false) != NULL);
+ EXPECT_TRUE(registry->GetExtensionById(kId, ExtensionRegistry::ENABLED));
// Verify it has a command of Alt+Shift+F.
ui::Accelerator accelerator = command_service->FindCommandByName(
@@ -93,7 +92,7 @@
// Update to version 2.
EXPECT_TRUE(UpdateExtension(kId, path_v2, 0));
- EXPECT_TRUE(service->GetExtensionById(kId, false) != NULL);
+ EXPECT_TRUE(registry->GetExtensionById(kId, ExtensionRegistry::ENABLED));
// Verify it is still set to nothing.
accelerator = command_service->FindCommandByName(
diff --git a/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc b/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc
index 66c7af00..83b28ca 100644
--- a/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc
+++ b/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc
@@ -31,7 +31,6 @@
#include "build/build_config.h"
#include "chrome/browser/extensions/extension_action_runner.h"
#include "chrome/browser/extensions/extension_browsertest.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/load_error_reporter.h"
#include "chrome/browser/extensions/scripting_permissions_modifier.h"
@@ -1688,8 +1687,8 @@
set_has_background_script(true);
LoadExtensionWithRules({});
- const Extension* dnr_extension = extension_service()->GetExtensionById(
- last_loaded_extension_id(), false /*include_disabled*/);
+ const Extension* dnr_extension = extension_registry()->GetExtensionById(
+ last_loaded_extension_id(), extensions::ExtensionRegistry::ENABLED);
ASSERT_TRUE(dnr_extension);
EXPECT_EQ("Test extension", dnr_extension->name());
@@ -2046,8 +2045,8 @@
const GURL unblocked_url = embedded_test_server()->GetURL(
"yahoo.com", "/pages_with_script/index.html");
- const Extension* extension = extension_service()->GetExtensionById(
- extension_id, false /*include_disabled*/);
+ const Extension* extension = extension_registry()->GetExtensionById(
+ extension_id, ExtensionRegistry::ENABLED);
RulesetSource static_source = RulesetSource::CreateStatic(*extension);
RulesetSource dynamic_source =
RulesetSource::CreateDynamic(profile(), *extension);
@@ -2288,8 +2287,8 @@
ASSERT_NO_FATAL_FAILURE(LoadExtensionWithRules(
{rule}, "extension" /* directory */, host_permissions));
- const Extension* extension = extension_service()->GetExtensionById(
- last_loaded_extension_id(), false /*include_disabled*/);
+ const Extension* extension = extension_registry()->GetExtensionById(
+ last_loaded_extension_id(), ExtensionRegistry::ENABLED);
ASSERT_TRUE(extension);
auto verify_script_redirected = [this, extension](
@@ -2414,8 +2413,8 @@
ASSERT_NO_FATAL_FAILURE(LoadExtensionWithRules(
{rule}, "test_extension", {URLPattern::kAllUrlsPattern}));
- const Extension* extension = extension_service()->GetExtensionById(
- last_loaded_extension_id(), false /*include_disabled*/);
+ const Extension* extension = extension_registry()->GetExtensionById(
+ last_loaded_extension_id(), ExtensionRegistry::ENABLED);
ASSERT_TRUE(extension);
EXPECT_TRUE(extension->permissions_data()->HasEffectiveAccessToAllHosts());
diff --git a/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc b/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc
index 7ad5b39..8fd11ee 100644
--- a/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc
+++ b/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc
@@ -10,7 +10,6 @@
#include "chrome/browser/extensions/extension_action.h"
#include "chrome/browser/extensions/extension_action_manager.h"
#include "chrome/browser/extensions/extension_apitest.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/sessions/session_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
@@ -29,7 +28,6 @@
#include "content/public/browser/notification_types.h"
#include "content/public/common/page_zoom.h"
#include "extensions/browser/extension_registry.h"
-#include "extensions/browser/extension_system.h"
#include "extensions/browser/notification_types.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
@@ -341,9 +339,10 @@
return;
OpenPopupViaAPI(false);
- ExtensionService* service = extensions::ExtensionSystem::Get(
- browser()->profile())->extension_service();
- ASSERT_FALSE(service->GetExtensionById(last_loaded_extension_id(), false)
+ ExtensionRegistry* registry = ExtensionRegistry::Get(browser()->profile());
+ ASSERT_FALSE(registry
+ ->GetExtensionById(last_loaded_extension_id(),
+ ExtensionRegistry::ENABLED)
->permissions_data()
->HasAPIPermissionForTab(
SessionTabHelper::IdForTab(
diff --git a/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.cc b/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.cc
index 3d419c95..697de915 100644
--- a/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.cc
+++ b/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.cc
@@ -16,12 +16,12 @@
#include "chrome/browser/chromeos/login/lock/screen_locker.h"
#include "chrome/browser/chromeos/login/session/user_session_manager.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.h"
#include "chrome/common/extensions/api/input_ime.h"
#include "chrome/common/extensions/api/input_method_private.h"
-#include "extensions/browser/extension_system.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/process_manager.h"
#include "extensions/common/manifest_handlers/background_info.h"
#include "ui/base/ime/chromeos/component_extension_ime_manager.h"
#include "ui/base/ime/chromeos/extension_ime_util.h"
@@ -271,12 +271,12 @@
// events (e.g. runtime.onMessage) from its other pages.
// This is to save memory for steady state Chrome OS on which the users
// don't want any IME features.
- extensions::ExtensionSystem* extension_system =
- extensions::ExtensionSystem::Get(profile_);
- if (extension_system) {
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(profile_);
+ if (extension_registry) {
const extensions::Extension* extension =
- extension_system->extension_service()->GetExtensionById(
- extension_id_, false /* include_disabled */);
+ extension_registry->GetExtensionById(
+ extension_id_, extensions::ExtensionRegistry::ENABLED);
if (!extension)
return;
extensions::ProcessManager* process_manager =
diff --git a/chrome/browser/extensions/api/management/management_api_browsertest.cc b/chrome/browser/extensions/api/management/management_api_browsertest.cc
index 16f29ac9..93f3c8d 100644
--- a/chrome/browser/extensions/api/management/management_api_browsertest.cc
+++ b/chrome/browser/extensions/api/management/management_api_browsertest.cc
@@ -26,7 +26,7 @@
#include "extensions/browser/extension_dialog_auto_confirm.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_prefs.h"
-#include "extensions/browser/extension_system.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/notification_types.h"
#include "extensions/common/extension_builder.h"
#include "extensions/test/extension_test_message_listener.h"
@@ -243,17 +243,17 @@
scoped_temp_dir_.GetPath().AppendASCII("permissions2.crx"), pem_path,
base::FilePath());
- ExtensionService* service = ExtensionSystem::Get(browser()->profile())->
- extension_service();
-
// Install low-permission version of the extension.
ASSERT_TRUE(InstallExtension(path_v1, 1));
- EXPECT_TRUE(service->GetExtensionById(kId, false) != NULL);
+ EXPECT_TRUE(extension_registry()->GetExtensionById(
+ kId, ExtensionRegistry::ENABLED));
// Update to a high-permission version - it should get disabled.
EXPECT_FALSE(UpdateExtension(kId, path_v2, -1));
- EXPECT_TRUE(service->GetExtensionById(kId, false) == NULL);
- EXPECT_TRUE(service->GetExtensionById(kId, true) != NULL);
+ EXPECT_FALSE(extension_registry()->GetExtensionById(
+ kId, ExtensionRegistry::ENABLED));
+ EXPECT_TRUE(extension_registry()->GetExtensionById(
+ kId, ExtensionRegistry::COMPATIBILITY));
EXPECT_TRUE(ExtensionPrefs::Get(browser()->profile())
->DidExtensionEscalatePermissions(kId));
}
@@ -344,14 +344,11 @@
// Register the target extension with extension service.
scoped_refptr<const Extension> target_extension =
ExtensionBuilder("TargetExtension").SetID(kId).Build();
- ExtensionService* const service =
- ExtensionSystem::Get(browser()->profile())->extension_service();
- service->AddExtension(target_extension.get());
+ extension_service()->AddExtension(target_extension.get());
SetEnabled(false, true, std::string(), source_extension);
SetEnabled(true, true, std::string(), source_extension);
- const Extension* extension = ExtensionSystem::Get(browser()->profile())
- ->extension_service()
- ->GetExtensionById(kId, false);
+ const Extension* extension =
+ extension_registry()->GetExtensionById(kId, ExtensionRegistry::ENABLED);
EXPECT_TRUE(extension);
}
}
diff --git a/chrome/browser/extensions/api/management/management_apitest.cc b/chrome/browser/extensions/api/management/management_apitest.cc
index e1a883c..7d76485f 100644
--- a/chrome/browser/extensions/api/management/management_apitest.cc
+++ b/chrome/browser/extensions/api/management/management_apitest.cc
@@ -22,6 +22,7 @@
#include "chrome/common/extensions/extension_constants.h"
#include "extensions/browser/api/management/management_api.h"
#include "extensions/browser/extension_dialog_auto_confirm.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/test_management_policy.h"
#include "extensions/common/manifest.h"
@@ -281,11 +282,11 @@
LoadExtensions();
extensions::ScopedTestDialogAutoConfirm auto_confirm(
extensions::ScopedTestDialogAutoConfirm::ACCEPT);
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
- EXPECT_TRUE(service->GetExtensionById(extension_ids_["enabled_extension"],
- false));
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(browser()->profile());
+ EXPECT_TRUE(
+ registry->GetExtensionById(extension_ids_["enabled_extension"],
+ extensions::ExtensionRegistry::ENABLED));
// Ensure that all actions are allowed.
extensions::ExtensionSystem::Get(
@@ -294,8 +295,9 @@
ASSERT_TRUE(RunExtensionSubtest("management/management_policy",
"allowed.html"));
// The last thing the test does is uninstall the "enabled_extension".
- EXPECT_FALSE(service->GetExtensionById(extension_ids_["enabled_extension"],
- true));
+ EXPECT_FALSE(
+ registry->GetExtensionById(extension_ids_["enabled_extension"],
+ extensions::ExtensionRegistry::COMPATIBILITY));
}
// Fails often on Windows dbg bots. http://crbug.com/177163
@@ -308,11 +310,11 @@
IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest,
MAYBE_ManagementPolicyProhibited) {
LoadExtensions();
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
- EXPECT_TRUE(service->GetExtensionById(extension_ids_["enabled_extension"],
- false));
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(browser()->profile());
+ EXPECT_TRUE(
+ registry->GetExtensionById(extension_ids_["enabled_extension"],
+ extensions::ExtensionRegistry::ENABLED));
// Prohibit status changes.
extensions::ManagementPolicy* policy = extensions::ExtensionSystem::Get(
@@ -326,10 +328,6 @@
}
IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, LaunchPanelApp) {
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
-
// Load an extension that calls launchApp() on any app that gets
// installed.
ExtensionTestMessageListener launcher_loaded("launcher loaded", false);
@@ -351,10 +349,13 @@
// Close the app panel.
CloseBrowserSynchronously(app_browser);
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(browser()->profile());
// Unload the extension.
UninstallExtension(app_id);
ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile()));
- ASSERT_FALSE(service->GetExtensionById(app_id, true));
+ ASSERT_FALSE(registry->GetExtensionById(
+ app_id, extensions::ExtensionRegistry::COMPATIBILITY));
// Set a pref indicating that the user wants to launch in a regular tab.
// This should be ignored, because panel apps always load in a popup.
@@ -386,10 +387,6 @@
#endif
IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, MAYBE_LaunchTabApp) {
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
-
// Load an extension that calls launchApp() on any app that gets
// installed.
ExtensionTestMessageListener launcher_loaded("launcher loaded", false);
@@ -411,10 +408,13 @@
ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile()));
ASSERT_EQ(2, browser()->tab_strip_model()->count());
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(browser()->profile());
// Unload the extension.
UninstallExtension(app_id);
ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile()));
- ASSERT_FALSE(service->GetExtensionById(app_id, true));
+ ASSERT_FALSE(registry->GetExtensionById(
+ app_id, extensions::ExtensionRegistry::COMPATIBILITY));
// Set a pref indicating that the user wants to launch in a window.
extensions::SetLaunchType(browser()->profile(), app_id,
diff --git a/chrome/browser/extensions/api/management/management_browsertest.cc b/chrome/browser/extensions/api/management/management_browsertest.cc
index b05f8f0..f21eeb5 100644
--- a/chrome/browser/extensions/api/management/management_browsertest.cc
+++ b/chrome/browser/extensions/api/management/management_browsertest.cc
@@ -46,10 +46,11 @@
using content::BrowserThread;
using extensions::Extension;
using extensions::ExtensionRegistry;
+using extensions::ExtensionService;
using extensions::Manifest;
using policy::PolicyMap;
-using testing::Return;
using testing::_;
+using testing::Return;
namespace {
@@ -207,12 +208,10 @@
IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, MAYBE_InstallRequiresConfirm) {
// Installing the extension without an auto confirming UI should result in
// it being disabled, since good.crx has permissions that require approval.
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
std::string id = "ldnnhddmnhbkjipkidpdiheffobcpfmf";
ASSERT_FALSE(InstallExtension(test_data_dir_.AppendASCII("good.crx"), 0));
- ASSERT_TRUE(service->GetExtensionById(id, true));
+ ASSERT_TRUE(extension_registry()->GetExtensionById(
+ id, ExtensionRegistry::COMPATIBILITY));
UninstallExtension(id);
// And the install should succeed when the permissions are accepted.
@@ -373,10 +372,8 @@
// Install version 1 of the extension.
ExtensionTestMessageListener listener1("v1 installed", false);
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
- ExtensionRegistry* registry = ExtensionRegistry::Get(browser()->profile());
+ ExtensionService* service = extension_service();
+ ExtensionRegistry* registry = extension_registry();
const size_t size_before = registry->enabled_extensions().size();
ASSERT_TRUE(registry->disabled_extensions().is_empty());
const Extension* extension = InstallExtension(v1_path, 1);
@@ -397,8 +394,8 @@
install_observer.WaitForExtensionWillBeInstalled();
EXPECT_TRUE(listener2.WaitUntilSatisfied());
ASSERT_EQ(size_before + 1, registry->enabled_extensions().size());
- extension = service->GetExtensionById(
- "ogjcoiohnmldgjemafoockdghcjciccf", false);
+ extension = registry->GetExtensionById("ogjcoiohnmldgjemafoockdghcjciccf",
+ ExtensionRegistry::ENABLED);
ASSERT_TRUE(extension);
ASSERT_EQ("2.0", extension->VersionString());
ASSERT_TRUE(notification_listener.started());
@@ -422,8 +419,8 @@
// Make sure the extension state is the same as before.
ASSERT_EQ(size_before + 1, registry->enabled_extensions().size());
- extension = service->GetExtensionById(
- "ogjcoiohnmldgjemafoockdghcjciccf", false);
+ extension = registry->GetExtensionById("ogjcoiohnmldgjemafoockdghcjciccf",
+ ExtensionRegistry::ENABLED);
ASSERT_TRUE(extension);
ASSERT_EQ("2.0", extension->VersionString());
}
@@ -474,10 +471,8 @@
// Install version 1 of the extension.
ExtensionTestMessageListener listener1("v1 installed", false);
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
- ExtensionRegistry* registry = ExtensionRegistry::Get(browser()->profile());
+ ExtensionService* service = extension_service();
+ ExtensionRegistry* registry = extension_registry();
const size_t enabled_size_before = registry->enabled_extensions().size();
const size_t disabled_size_before = registry->disabled_extensions().size();
const Extension* extension = InstallExtension(v1_path, 1);
@@ -500,11 +495,11 @@
install_observer.WaitForExtensionWillBeInstalled();
ASSERT_EQ(disabled_size_before + 1, registry->disabled_extensions().size());
ASSERT_EQ(enabled_size_before, registry->enabled_extensions().size());
- extension = service->GetExtensionById(
- "ogjcoiohnmldgjemafoockdghcjciccf", true);
+ extension = registry->GetExtensionById("ogjcoiohnmldgjemafoockdghcjciccf",
+ ExtensionRegistry::COMPATIBILITY);
ASSERT_TRUE(extension);
- ASSERT_FALSE(service->GetExtensionById(
- "ogjcoiohnmldgjemafoockdghcjciccf", false));
+ ASSERT_FALSE(registry->GetExtensionById("ogjcoiohnmldgjemafoockdghcjciccf",
+ ExtensionRegistry::ENABLED));
ASSERT_EQ("2.0", extension->VersionString());
// The extension should have not made the callback because it is disabled.
@@ -520,9 +515,7 @@
}
IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalUrlUpdate) {
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
+ ExtensionService* service = extension_service();
const char kExtensionId[] = "ogjcoiohnmldgjemafoockdghcjciccf";
base::ScopedAllowBlockingForTesting allow_blocking;
@@ -550,7 +543,7 @@
return false;
}));
- ExtensionRegistry* registry = ExtensionRegistry::Get(browser()->profile());
+ ExtensionRegistry* registry = extension_registry();
const size_t size_before = registry->enabled_extensions().size();
ASSERT_TRUE(registry->disabled_extensions().is_empty());
@@ -576,7 +569,8 @@
service->updater()->CheckNow(extensions::ExtensionUpdater::CheckParams());
install_observer.WaitForExtensionWillBeInstalled();
ASSERT_EQ(size_before + 1, registry->enabled_extensions().size());
- const Extension* extension = service->GetExtensionById(kExtensionId, false);
+ const Extension* extension =
+ registry->GetExtensionById(kExtensionId, ExtensionRegistry::ENABLED);
ASSERT_TRUE(extension);
ASSERT_EQ("2.0", extension->VersionString());
@@ -629,9 +623,6 @@
// See http://crbug.com/57378 for flakiness details.
IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalPolicyRefresh) {
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
const char kExtensionId[] = "ogjcoiohnmldgjemafoockdghcjciccf";
base::ScopedAllowBlockingForTesting allow_blocking;
@@ -683,7 +674,8 @@
// Check if the extension got installed.
ASSERT_EQ(size_before + 1, registry->enabled_extensions().size());
- const Extension* extension = service->GetExtensionById(kExtensionId, false);
+ const Extension* extension =
+ registry->GetExtensionById(kExtensionId, ExtensionRegistry::ENABLED);
ASSERT_TRUE(extension);
ASSERT_EQ("2.0", extension->VersionString());
EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location());
@@ -708,7 +700,8 @@
policies.Erase(policy::key::kExtensionInstallForcelist);
UpdateProviderPolicy(policies);
EXPECT_EQ(size_before + 1, registry->enabled_extensions().size());
- EXPECT_FALSE(service->GetExtensionById(kExtensionId, true));
+ EXPECT_FALSE(registry->GetExtensionById(kExtensionId,
+ ExtensionRegistry::COMPATIBILITY));
}
// See http://crbug.com/103371 and http://crbug.com/120640.
@@ -763,7 +756,8 @@
// User install of the extension.
ASSERT_TRUE(InstallExtension(v2_path, 1));
ASSERT_EQ(size_before + 1, registry->enabled_extensions().size());
- const Extension* extension = service->GetExtensionById(kExtensionId, false);
+ const Extension* extension =
+ registry->GetExtensionById(kExtensionId, ExtensionRegistry::ENABLED);
ASSERT_TRUE(extension);
EXPECT_EQ(Manifest::INTERNAL, extension->location());
EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
@@ -782,7 +776,8 @@
install_observer.WaitForExtensionWillBeInstalled();
ASSERT_EQ(size_before + 1, registry->enabled_extensions().size());
- extension = service->GetExtensionById(kExtensionId, false);
+ extension =
+ registry->GetExtensionById(kExtensionId, ExtensionRegistry::ENABLED);
ASSERT_TRUE(extension);
EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location());
EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
@@ -794,13 +789,15 @@
policies.Erase(policy::key::kExtensionInstallForcelist);
UpdateProviderPolicy(policies);
ASSERT_EQ(size_before, registry->enabled_extensions().size());
- extension = service->GetExtensionById(kExtensionId, true);
+ extension = registry->GetExtensionById(kExtensionId,
+ ExtensionRegistry::COMPATIBILITY);
EXPECT_FALSE(extension);
// User install again, but have it disabled too before setting the policy.
ASSERT_TRUE(InstallExtension(v2_path, 1));
ASSERT_EQ(size_before + 1, registry->enabled_extensions().size());
- extension = service->GetExtensionById(kExtensionId, false);
+ extension =
+ registry->GetExtensionById(kExtensionId, ExtensionRegistry::ENABLED);
ASSERT_TRUE(extension);
EXPECT_EQ(Manifest::INTERNAL, extension->location());
EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
@@ -808,7 +805,8 @@
DisableExtension(kExtensionId);
EXPECT_EQ(1u, registry->disabled_extensions().size());
- extension = service->GetExtensionById(kExtensionId, true);
+ extension = registry->GetExtensionById(kExtensionId,
+ ExtensionRegistry::COMPATIBILITY);
EXPECT_TRUE(extension);
EXPECT_FALSE(service->IsExtensionEnabled(kExtensionId));
@@ -824,7 +822,8 @@
extension_observer.WaitForExtensionWillBeInstalled();
ASSERT_EQ(size_before + 1, registry->enabled_extensions().size());
- extension = service->GetExtensionById(kExtensionId, false);
+ extension =
+ registry->GetExtensionById(kExtensionId, ExtensionRegistry::ENABLED);
ASSERT_TRUE(extension);
EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location());
EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc
index b06f9750..ac34f48 100644
--- a/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc
+++ b/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc
@@ -23,7 +23,6 @@
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
#include "chrome/browser/extensions/extension_apitest.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu_test_util.h"
#include "chrome/browser/ui/browser.h"
@@ -44,7 +43,7 @@
#include "content/public/test/download_test_observer.h"
#include "content/public/test/no_renderer_crashes_assertion.h"
#include "content/public/test/test_utils.h"
-#include "extensions/browser/extension_system.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/common/switches.h"
#include "extensions/test/result_catcher.h"
#include "net/dns/mock_host_resolver.h"
@@ -360,10 +359,9 @@
ResultCatcher catcher;
- ExtensionService* service = extensions::ExtensionSystem::Get(
- browser()->profile())->extension_service();
const extensions::Extension* extension =
- service->GetExtensionById(last_loaded_extension_id(), false);
+ extension_registry()->GetExtensionById(last_loaded_extension_id(),
+ ExtensionRegistry::ENABLED);
GURL url = extension->GetResourceURL(
"a.html?" + base::NumberToString(embedded_test_server()->port()));
@@ -400,10 +398,9 @@
ResultCatcher catcher;
- ExtensionService* service = extensions::ExtensionSystem::Get(
- browser()->profile())->extension_service();
const extensions::Extension* extension =
- service->GetExtensionById(last_loaded_extension_id(), false);
+ extension_registry()->GetExtensionById(last_loaded_extension_id(),
+ ExtensionRegistry::ENABLED);
GURL url = extension->GetResourceURL("a.html");
ui_test_utils::NavigateToURL(browser(), url);
diff --git a/chrome/browser/extensions/api/web_request/web_request_apitest.cc b/chrome/browser/extensions/api/web_request/web_request_apitest.cc
index 1398d76..2c2f8533 100644
--- a/chrome/browser/extensions/api/web_request/web_request_apitest.cc
+++ b/chrome/browser/extensions/api/web_request/web_request_apitest.cc
@@ -78,7 +78,8 @@
#include "extensions/browser/api/web_request/web_request_api.h"
#include "extensions/browser/blocked_action_type.h"
#include "extensions/browser/extension_prefs.h"
-#include "extensions/browser/extension_system.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/process_manager.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/features/feature.h"
@@ -652,10 +653,9 @@
ResultCatcher catcher;
- ExtensionService* service =
- ExtensionSystem::Get(browser()->profile())->extension_service();
- const Extension* extension =
- service->GetExtensionById(last_loaded_extension_id(), false);
+ ExtensionRegistry* registry = ExtensionRegistry::Get(browser()->profile());
+ const Extension* extension = registry->GetExtensionById(
+ last_loaded_extension_id(), extensions::ExtensionRegistry::ENABLED);
GURL url = extension->GetResourceURL("newTab/a.html");
ui_test_utils::NavigateToURL(browser(), url);
@@ -949,9 +949,7 @@
.Build())
.Build())
.Build();
- ExtensionSystem::Get(browser()->profile())
- ->extension_service()
- ->AddExtension(hosted_app.get());
+ extension_service()->AddExtension(hosted_app.get());
ExtensionTestMessageListener listener1("main_frame", false);
ExtensionTestMessageListener listener2("xmlhttprequest", false);
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc
index d45553f6..e552a77 100644
--- a/chrome/browser/extensions/crx_installer.cc
+++ b/chrome/browser/extensions/crx_installer.cc
@@ -536,9 +536,10 @@
if (SharedModuleInfo::ImportsModules(extension())) {
const std::vector<SharedModuleInfo::ImportInfo>& imports =
SharedModuleInfo::GetImports(extension());
+ ExtensionRegistry* registry = ExtensionRegistry::Get(service->profile());
for (const auto& import : imports) {
- const Extension* imported_module =
- service->GetExtensionById(import.extension_id, true);
+ const Extension* imported_module = registry->GetExtensionById(
+ import.extension_id, ExtensionRegistry::COMPATIBILITY);
if (!imported_module)
continue;
diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc
index ce4679a..924cda0 100644
--- a/chrome/browser/extensions/extension_browsertest.cc
+++ b/chrome/browser/extensions/extension_browsertest.cc
@@ -393,20 +393,18 @@
const Extension* ExtensionBrowserTest::LoadExtensionAsComponentWithManifest(
const base::FilePath& path,
const base::FilePath::CharType* manifest_relative_path) {
- ExtensionService* service =
- ExtensionSystem::Get(profile())->extension_service();
- ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
-
base::ScopedAllowBlockingForTesting allow_blocking;
std::string manifest;
if (!base::ReadFileToString(path.Append(manifest_relative_path), &manifest)) {
return NULL;
}
- service->component_loader()->set_ignore_whitelist_for_testing(true);
- std::string extension_id = service->component_loader()->Add(manifest, path);
+ extension_service()->component_loader()->set_ignore_whitelist_for_testing(
+ true);
+ std::string extension_id =
+ extension_service()->component_loader()->Add(manifest, path);
const Extension* extension =
- registry->enabled_extensions().GetByID(extension_id);
+ extension_registry()->enabled_extensions().GetByID(extension_id);
if (!extension)
return NULL;
observer_->set_last_loaded_extension_id(extension->id());
@@ -569,9 +567,7 @@
Extension::InitFromValueFlags creation_flags,
bool install_immediately,
bool grant_permissions) {
- ExtensionService* service =
- ExtensionSystem::Get(profile())->extension_service();
- ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
+ ExtensionRegistry* registry = extension_registry();
size_t num_before = registry->enabled_extensions().size();
{
@@ -609,7 +605,7 @@
browser->tab_strip_model()->GetActiveWebContents()));
}
scoped_refptr<CrxInstaller> installer(
- CrxInstaller::Create(service, std::move(install_ui)));
+ CrxInstaller::Create(extension_service(), std::move(install_ui)));
installer->set_expected_id(id);
installer->set_creation_flags(creation_flags);
installer->set_install_source(install_source);
@@ -650,16 +646,16 @@
if (!observer_->WaitForExtensionViewsToLoad())
return NULL;
- return service->GetExtensionById(last_loaded_extension_id(), false);
+ return registry->GetExtensionById(last_loaded_extension_id(),
+ ExtensionRegistry::ENABLED);
}
void ExtensionBrowserTest::ReloadExtension(const std::string& extension_id) {
- ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
- const Extension* extension = registry->GetInstalledExtension(extension_id);
+ const Extension* extension =
+ extension_registry()->GetInstalledExtension(extension_id);
ASSERT_TRUE(extension);
- TestExtensionRegistryObserver observer(registry, extension_id);
- ExtensionSystem::Get(profile())->extension_service()->ReloadExtension(
- extension_id);
+ TestExtensionRegistryObserver observer(extension_registry(), extension_id);
+ extension_service()->ReloadExtension(extension_id);
observer.WaitForExtensionLoaded();
// We need to let other ExtensionRegistryObservers handle the extension load
@@ -671,27 +667,22 @@
}
void ExtensionBrowserTest::UnloadExtension(const std::string& extension_id) {
- ExtensionService* service =
- ExtensionSystem::Get(profile())->extension_service();
- service->UnloadExtension(extension_id, UnloadedExtensionReason::DISABLE);
+ extension_service()->UnloadExtension(extension_id,
+ UnloadedExtensionReason::DISABLE);
}
void ExtensionBrowserTest::UninstallExtension(const std::string& extension_id) {
- ExtensionService* service =
- ExtensionSystem::Get(profile())->extension_service();
- service->UninstallExtension(extension_id, UNINSTALL_REASON_FOR_TESTING, NULL);
+ extension_service()->UninstallExtension(
+ extension_id, UNINSTALL_REASON_FOR_TESTING, nullptr);
}
void ExtensionBrowserTest::DisableExtension(const std::string& extension_id) {
- ExtensionService* service =
- ExtensionSystem::Get(profile())->extension_service();
- service->DisableExtension(extension_id, disable_reason::DISABLE_USER_ACTION);
+ extension_service()->DisableExtension(extension_id,
+ disable_reason::DISABLE_USER_ACTION);
}
void ExtensionBrowserTest::EnableExtension(const std::string& extension_id) {
- ExtensionService* service =
- ExtensionSystem::Get(profile())->extension_service();
- service->EnableExtension(extension_id);
+ extension_service()->EnableExtension(extension_id);
}
void ExtensionBrowserTest::OpenWindow(content::WebContents* contents,
diff --git a/chrome/browser/extensions/extension_browsertest.h b/chrome/browser/extensions/extension_browsertest.h
index 5a556db..5ae8898 100644
--- a/chrome/browser/extensions/extension_browsertest.h
+++ b/chrome/browser/extensions/extension_browsertest.h
@@ -24,6 +24,7 @@
#include "extensions/browser/extension_creator.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_protocols.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/sandboxed_unpacker.h"
#include "extensions/browser/scoped_ignore_content_verifier_for_test.h"
@@ -88,6 +89,10 @@
return ExtensionSystem::Get(profile())->extension_service();
}
+ ExtensionRegistry* extension_registry() {
+ return ExtensionRegistry::Get(profile());
+ }
+
const std::string& last_loaded_extension_id() {
return observer_->last_loaded_extension_id();
}
diff --git a/chrome/browser/extensions/extension_disabled_ui_browsertest.cc b/chrome/browser/extensions/extension_disabled_ui_browsertest.cc
index 2ac4f6b..26a9bd97a 100644
--- a/chrome/browser/extensions/extension_disabled_ui_browsertest.cc
+++ b/chrome/browser/extensions/extension_disabled_ui_browsertest.cc
@@ -58,8 +58,6 @@
void SetUpOnMainThread() override {
extensions::ExtensionBrowserTest::SetUpOnMainThread();
EXPECT_TRUE(scoped_temp_dir_.CreateUniqueTempDir());
- service_ = extensions::ExtensionSystem::Get(profile())->extension_service();
- registry_ = ExtensionRegistry::Get(profile());
const base::FilePath test_dir =
test_data_dir_.AppendASCII("permissions_increase");
const base::FilePath pem_path = test_dir.AppendASCII("permissions.pem");
@@ -86,11 +84,11 @@
// Install the initial version, which should happen just fine.
const Extension* InstallIncreasingPermissionExtensionV1() {
- size_t size_before = registry_->enabled_extensions().size();
+ size_t size_before = extension_registry()->enabled_extensions().size();
const Extension* extension = InstallExtension(path_v1_, 1);
if (!extension)
return NULL;
- if (registry_->enabled_extensions().size() != size_before + 1)
+ if (extension_registry()->enabled_extensions().size() != size_before + 1)
return NULL;
return extension;
}
@@ -101,16 +99,16 @@
const Extension* extension,
const base::FilePath& crx_path,
int expected_change) {
- size_t size_before = registry_->enabled_extensions().size();
+ size_t size_before = extension_registry()->enabled_extensions().size();
if (UpdateExtension(extension->id(), crx_path, expected_change))
return NULL;
content::RunAllTasksUntilIdle();
EXPECT_EQ(size_before + expected_change,
- registry_->enabled_extensions().size());
- if (registry_->disabled_extensions().size() != 1u)
+ extension_registry()->enabled_extensions().size());
+ if (extension_registry()->disabled_extensions().size() != 1u)
return NULL;
- return registry_->disabled_extensions().begin()->get();
+ return extension_registry()->disabled_extensions().begin()->get();
}
// Helper function to install an extension and upgrade it to a version
@@ -121,8 +119,6 @@
return extension;
}
- extensions::ExtensionService* service_;
- ExtensionRegistry* registry_;
base::ScopedTempDir scoped_temp_dir_;
base::FilePath path_v1_;
base::FilePath path_v2_;
@@ -135,13 +131,13 @@
const Extension* extension = InstallAndUpdateIncreasingPermissionsExtension();
ASSERT_TRUE(extension);
ASSERT_TRUE(GetExtensionDisabledGlobalError());
- const size_t size_before = registry_->enabled_extensions().size();
+ const size_t size_before = extension_registry()->enabled_extensions().size();
ExtensionTestMessageListener listener("v2.onInstalled", false);
listener.set_failure_message("FAILED");
- service_->GrantPermissionsAndEnableExtension(extension);
- EXPECT_EQ(size_before + 1, registry_->enabled_extensions().size());
- EXPECT_EQ(0u, registry_->disabled_extensions().size());
+ extension_service()->GrantPermissionsAndEnableExtension(extension);
+ EXPECT_EQ(size_before + 1, extension_registry()->enabled_extensions().size());
+ EXPECT_EQ(0u, extension_registry()->disabled_extensions().size());
ASSERT_FALSE(GetExtensionDisabledGlobalError());
// Expect onInstalled event to fire.
EXPECT_TRUE(listener.WaitUntilSatisfied());
@@ -152,11 +148,11 @@
const Extension* extension = InstallAndUpdateIncreasingPermissionsExtension();
ASSERT_TRUE(extension);
ASSERT_TRUE(GetExtensionDisabledGlobalError());
- const size_t size_before = registry_->enabled_extensions().size();
+ const size_t size_before = extension_registry()->enabled_extensions().size();
UninstallExtension(extension->id());
- EXPECT_EQ(size_before, registry_->enabled_extensions().size());
- EXPECT_EQ(0u, registry_->disabled_extensions().size());
+ EXPECT_EQ(size_before, extension_registry()->enabled_extensions().size());
+ EXPECT_EQ(0u, extension_registry()->disabled_extensions().size());
ASSERT_FALSE(GetExtensionDisabledGlobalError());
}
@@ -173,13 +169,13 @@
ASSERT_TRUE(error);
// The "cancel" button is the uninstall button on the browser.
- extensions::TestExtensionRegistryObserver test_observer(registry_,
+ extensions::TestExtensionRegistryObserver test_observer(extension_registry(),
extension_id);
error->BubbleViewCancelButtonPressed(browser());
test_observer.WaitForExtensionUninstalled();
- EXPECT_FALSE(registry_->GetExtensionById(extension_id,
- ExtensionRegistry::EVERYTHING));
+ EXPECT_FALSE(extension_registry()->GetExtensionById(
+ extension_id, ExtensionRegistry::EVERYTHING));
EXPECT_FALSE(GetExtensionDisabledGlobalError());
}
@@ -253,7 +249,8 @@
syncer::EXTENSIONS, syncer::SyncDataList(),
base::WrapUnique(new syncer::FakeSyncChangeProcessor()),
base::WrapUnique(new syncer::SyncErrorFactoryMock()));
- extensions::TestExtensionRegistryObserver install_observer(registry_);
+ extensions::TestExtensionRegistryObserver install_observer(
+ extension_registry());
sync_service->ProcessSyncChanges(
FROM_HERE,
syncer::SyncChangeList(
@@ -262,12 +259,13 @@
install_observer.WaitForExtensionWillBeInstalled();
content::RunAllTasksUntilIdle();
- extension = service_->GetExtensionById(extension_id, true);
+ extension = extension_registry()->GetExtensionById(
+ extension_id, ExtensionRegistry::COMPATIBILITY);
ASSERT_TRUE(extension);
EXPECT_EQ("2", extension->VersionString());
- EXPECT_EQ(1u, registry_->disabled_extensions().size());
+ EXPECT_EQ(1u, extension_registry()->disabled_extensions().size());
EXPECT_EQ(extensions::disable_reason::DISABLE_PERMISSIONS_INCREASE,
- ExtensionPrefs::Get(service_->profile())
+ ExtensionPrefs::Get(extension_service()->profile())
->GetDisableReasons(extension_id));
EXPECT_TRUE(GetExtensionDisabledGlobalError());
}
@@ -311,7 +309,8 @@
syncer::EXTENSIONS, syncer::SyncDataList(),
base::WrapUnique(new syncer::FakeSyncChangeProcessor()),
base::WrapUnique(new syncer::SyncErrorFactoryMock()));
- extensions::TestExtensionRegistryObserver install_observer(registry_);
+ extensions::TestExtensionRegistryObserver install_observer(
+ extension_registry());
sync_service->ProcessSyncChanges(
FROM_HERE,
syncer::SyncChangeList(
@@ -321,12 +320,13 @@
install_observer.WaitForExtensionWillBeInstalled();
content::RunAllTasksUntilIdle();
- const Extension* extension = service_->GetExtensionById(extension_id, true);
+ const Extension* extension = extension_registry()->GetExtensionById(
+ extension_id, ExtensionRegistry::COMPATIBILITY);
ASSERT_TRUE(extension);
EXPECT_EQ("2", extension->VersionString());
- EXPECT_EQ(1u, registry_->disabled_extensions().size());
+ EXPECT_EQ(1u, extension_registry()->disabled_extensions().size());
EXPECT_EQ(extensions::disable_reason::DISABLE_REMOTE_INSTALL,
- ExtensionPrefs::Get(service_->profile())
+ ExtensionPrefs::Get(extension_service()->profile())
->GetDisableReasons(extension_id));
EXPECT_TRUE(GetExtensionDisabledGlobalError());
}
diff --git a/chrome/browser/extensions/extension_nacl_browsertest.cc b/chrome/browser/extensions/extension_nacl_browsertest.cc
index 4b08748..ad4b505e 100644
--- a/chrome/browser/extensions/extension_nacl_browsertest.cc
+++ b/chrome/browser/extensions/extension_nacl_browsertest.cc
@@ -8,7 +8,6 @@
#include "base/test/bind_test_util.h"
#include "chrome/browser/extensions/crx_installer.h"
#include "chrome/browser/extensions/extension_browsertest.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -21,7 +20,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/common/webplugininfo.h"
#include "content/public/test/browser_test_utils.h"
-#include "extensions/browser/extension_system.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/test/test_extension_dir.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
@@ -54,6 +53,7 @@
INSTALL_TYPE_FROM_WEBSTORE,
INSTALL_TYPE_NON_WEBSTORE,
};
+
enum PluginType {
PLUGIN_TYPE_NONE = 0,
PLUGIN_TYPE_EMBED = 1,
@@ -62,40 +62,41 @@
PLUGIN_TYPE_CONTENT_HANDLER,
};
-
const Extension* InstallExtension(const base::FilePath& file_path,
InstallType install_type) {
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
- const Extension* extension = NULL;
+ extensions::ExtensionRegistry* registry = extension_registry();
+ const Extension* extension = nullptr;
switch (install_type) {
case INSTALL_TYPE_COMPONENT:
if (LoadExtensionAsComponent(file_path)) {
- extension = service->GetExtensionById(kExtensionId, false);
+ extension = registry->GetExtensionById(
+ kExtensionId, extensions::ExtensionRegistry::ENABLED);
}
break;
case INSTALL_TYPE_UNPACKED:
// Install the extension from a folder so it's unpacked.
if (LoadExtension(file_path)) {
- extension = service->GetExtensionById(kExtensionId, false);
+ extension = registry->GetExtensionById(
+ kExtensionId, extensions::ExtensionRegistry::ENABLED);
}
break;
case INSTALL_TYPE_FROM_WEBSTORE:
// Install native_client.crx from the webstore.
if (InstallExtensionFromWebstore(file_path, 1)) {
- extension = service->GetExtensionById(last_loaded_extension_id(),
- false);
+ extension = registry->GetExtensionById(
+ last_loaded_extension_id(),
+ extensions::ExtensionRegistry::ENABLED);
}
break;
case INSTALL_TYPE_NON_WEBSTORE:
// Install native_client.crx but not from the webstore.
if (extensions::ExtensionBrowserTest::InstallExtension(file_path, 1)) {
- extension = service->GetExtensionById(last_loaded_extension_id(),
- false);
+ extension = registry->GetExtensionById(
+ last_loaded_extension_id(),
+ extensions::ExtensionRegistry::ENABLED);
}
break;
}
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 84e0ec8..3c32077 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -212,7 +212,8 @@
info.extension_id);
}
- const Extension* extension = GetExtensionById(info.extension_id, true);
+ const Extension* extension = registry_->GetExtensionById(
+ info.extension_id, ExtensionRegistry::COMPATIBILITY);
if (extension) {
// Already installed. Skip this install if the current location has higher
// priority than |info.download_location|, and we aren't doing a
@@ -380,19 +381,6 @@
this);
}
-const Extension* ExtensionService::GetExtensionById(
- const std::string& id, bool include_disabled) const {
- int include_mask = ExtensionRegistry::ENABLED;
- if (include_disabled) {
- // Include blacklisted and blocked extensions here because there are
- // hundreds of callers of this function, and many might assume that this
- // includes those that have been disabled due to blacklisting or blocking.
- include_mask |= ExtensionRegistry::DISABLED |
- ExtensionRegistry::BLACKLISTED | ExtensionRegistry::BLOCKED;
- }
- return registry_->GetExtensionById(id, include_mask);
-}
-
void ExtensionService::Init() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
TRACE_EVENT0("browser,startup", "ExtensionService::Init");
@@ -769,7 +757,8 @@
Manifest::IsComponentLocation(source_extension->location()));
}
- const Extension* extension = GetExtensionById(extension_id, true);
+ const Extension* extension = registry_->GetExtensionById(
+ extension_id, ExtensionRegistry::COMPATIBILITY);
CHECK(system_->management_policy()->ExtensionMayModifySettings(
source_extension, extension, nullptr));
extension_registrar_.DisableExtension(extension_id, disable_reasons);
@@ -1154,7 +1143,7 @@
void ExtensionService::RemoveComponentExtension(
const std::string& extension_id) {
scoped_refptr<const Extension> extension(
- GetExtensionById(extension_id, false));
+ registry_->GetExtensionById(extension_id, ExtensionRegistry::ENABLED));
UnloadExtension(extension_id, UnloadedExtensionReason::UNINSTALL);
if (extension.get()) {
ExtensionRegistry::Get(profile_)->TriggerOnUninstalled(
@@ -1703,7 +1692,8 @@
// Before even bothering to unpack, check and see if we already have this
// version. This is important because these extensions are going to get
// installed on every startup.
- const Extension* existing = GetExtensionById(info.extension_id, true);
+ const Extension* existing = registry_->GetExtensionById(
+ info.extension_id, ExtensionRegistry::COMPATIBILITY);
if (existing) {
// The default apps will have the location set as INTERNAL. Since older
@@ -1821,7 +1811,8 @@
// idle to update. Check all imports of these extensions, too.
std::set<std::string> import_ids;
for (auto it = extension_ids.begin(); it != extension_ids.end(); ++it) {
- const Extension* extension = GetExtensionById(*it, true);
+ const Extension* extension = registry_->GetExtensionById(
+ *it, ExtensionRegistry::COMPATIBILITY);
if (!extension)
continue;
const std::vector<SharedModuleInfo::ImportInfo>& imports =
diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h
index 2c88f65d..8564a67 100644
--- a/chrome/browser/extensions/extension_service.h
+++ b/chrome/browser/extensions/extension_service.h
@@ -89,27 +89,6 @@
bool file_ownership_passed,
CrxInstaller** out_crx_installer) = 0;
- // DEPRECATED. Use ExtensionRegistry instead.
- //
- // Looks up an extension by its ID.
- //
- // If |include_disabled| is false then this will only include enabled
- // extensions. Use instead:
- //
- // ExtensionRegistry::enabled_extensions().GetByID(id).
- //
- // If |include_disabled| is true then this will also include disabled and
- // blacklisted extensions (not terminated extensions). Use instead:
- //
- // ExtensionRegistry::GetExtensionById(
- // id, ExtensionRegistry::ENABLED |
- // ExtensionRegistry::DISABLED |
- // ExtensionRegistry::BLACKLISTED)
- //
- // Or don't, because it's probably not something you ever need to know.
- virtual const Extension* GetExtensionById(const std::string& id,
- bool include_disabled) const = 0;
-
// DEPRECATED: Use ExtensionRegistry instead.
//
// Looks up an extension by ID, regardless of whether it's enabled,
@@ -199,8 +178,6 @@
//
// NOTE: Many of these methods are DEPRECATED. See the interface for details.
PendingExtensionManager* pending_extension_manager() override;
- const Extension* GetExtensionById(const std::string& id,
- bool include_disabled) const override;
const Extension* GetInstalledExtension(const std::string& id) const override;
bool UpdateExtension(const CRXFileInfo& file,
bool file_ownership_passed,
diff --git a/chrome/browser/extensions/extension_service_sync_unittest.cc b/chrome/browser/extensions/extension_service_sync_unittest.cc
index 163b4b9..b7e69b88 100644
--- a/chrome/browser/extensions/extension_service_sync_unittest.cc
+++ b/chrome/browser/extensions/extension_service_sync_unittest.cc
@@ -73,15 +73,16 @@
#include "chrome/common/pref_names.h"
#endif
-using extensions::api_test_utils::RunFunctionAndReturnSingleResult;
using extensions::AppSorting;
using extensions::Extension;
using extensions::ExtensionPrefs;
+using extensions::ExtensionRegistry;
using extensions::ExtensionSyncData;
using extensions::ExtensionSystem;
using extensions::Manifest;
using extensions::PermissionSet;
using extensions::WebstorePrivateIsPendingCustodianApprovalFunction;
+using extensions::api_test_utils::RunFunctionAndReturnSingleResult;
using syncer::SyncChange;
using syncer::SyncChangeList;
using testing::Mock;
@@ -361,7 +362,8 @@
ASSERT_EQ(3u, loaded_.size());
// We start enabled.
- const Extension* extension = service()->GetExtensionById(good0, true);
+ const Extension* extension =
+ registry()->GetExtensionById(good0, ExtensionRegistry::COMPATIBILITY);
ASSERT_TRUE(extension);
ASSERT_TRUE(service()->IsExtensionEnabled(good0));
@@ -560,8 +562,10 @@
extensions::disable_reason::DISABLE_USER_ACTION);
ASSERT_FALSE(service()->IsExtensionEnabled(good2));
- const Extension* extension0 = service()->GetExtensionById(good0, true);
- const Extension* extension2 = service()->GetExtensionById(good2, true);
+ const Extension* extension0 =
+ registry()->GetExtensionById(good0, ExtensionRegistry::COMPATIBILITY);
+ const Extension* extension2 =
+ registry()->GetExtensionById(good2, ExtensionRegistry::COMPATIBILITY);
ASSERT_TRUE(extensions::sync_helper::IsSyncable(extension0));
ASSERT_TRUE(extensions::sync_helper::IsSyncable(extension2));
@@ -619,7 +623,8 @@
// any outgoing changes.
{
- const Extension* extension = service()->GetExtensionById(good0, true);
+ const Extension* extension =
+ registry()->GetExtensionById(good0, ExtensionRegistry::COMPATIBILITY);
ASSERT_TRUE(extension);
// Disable the extension.
@@ -634,7 +639,8 @@
}
{
- const Extension* extension = service()->GetExtensionById(good0, true);
+ const Extension* extension =
+ registry()->GetExtensionById(good0, ExtensionRegistry::COMPATIBILITY);
ASSERT_TRUE(extension);
// Set incognito enabled to true.
@@ -649,7 +655,8 @@
}
{
- const Extension* extension = service()->GetExtensionById(good0, true);
+ const Extension* extension =
+ registry()->GetExtensionById(good0, ExtensionRegistry::COMPATIBILITY);
ASSERT_TRUE(extension);
// Add another disable reason.
@@ -666,7 +673,8 @@
}
{
- const Extension* extension = service()->GetExtensionById(good0, true);
+ const Extension* extension =
+ registry()->GetExtensionById(good0, ExtensionRegistry::COMPATIBILITY);
ASSERT_TRUE(extension);
// Uninstall the extension.
@@ -1073,20 +1081,24 @@
// Should do nothing.
extension_sync_service()->ProcessSyncChanges(FROM_HERE, list);
- EXPECT_FALSE(service()->GetExtensionById(good_crx, true));
+ EXPECT_FALSE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::COMPATIBILITY));
// Install the extension.
base::FilePath extension_path = data_dir().AppendASCII("good.crx");
InstallCRX(extension_path, INSTALL_NEW);
- EXPECT_TRUE(service()->GetExtensionById(good_crx, true));
+ EXPECT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::COMPATIBILITY));
// Should uninstall the extension.
extension_sync_service()->ProcessSyncChanges(FROM_HERE, list);
- EXPECT_FALSE(service()->GetExtensionById(good_crx, true));
+ EXPECT_FALSE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::COMPATIBILITY));
// Should again do nothing.
extension_sync_service()->ProcessSyncChanges(FROM_HERE, list);
- EXPECT_FALSE(service()->GetExtensionById(good_crx, true));
+ EXPECT_FALSE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::COMPATIBILITY));
}
TEST_F(ExtensionServiceSyncTest, ProcessSyncDataWrongType) {
@@ -1097,7 +1109,8 @@
// Install the extension.
base::FilePath extension_path = data_dir().AppendASCII("good.crx");
InstallCRX(extension_path, INSTALL_NEW);
- EXPECT_TRUE(service()->GetExtensionById(good_crx, true));
+ EXPECT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::COMPATIBILITY));
sync_pb::EntitySpecifics specifics;
sync_pb::AppSpecifics* app_specifics = specifics.mutable_app();
@@ -1115,7 +1128,8 @@
// Should do nothing
extension_sync_service()->ProcessSyncChanges(FROM_HERE, list);
- EXPECT_TRUE(service()->GetExtensionById(good_crx, true));
+ EXPECT_TRUE(registry()->GetExtensionById(good_crx,
+ ExtensionRegistry::COMPATIBILITY));
}
{
@@ -1126,7 +1140,8 @@
// Should again do nothing.
extension_sync_service()->ProcessSyncChanges(FROM_HERE, list);
- EXPECT_TRUE(service()->GetExtensionById(good_crx, false));
+ EXPECT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
}
}
diff --git a/chrome/browser/extensions/extension_service_test_with_install.cc b/chrome/browser/extensions/extension_service_test_with_install.cc
index 4409829..762ca33a 100644
--- a/chrome/browser/extensions/extension_service_test_with_install.cc
+++ b/chrome/browser/extensions/extension_service_test_with_install.cc
@@ -226,7 +226,8 @@
EXPECT_EQ(expected_extensions_count_, actual_extension_count) <<
path.value();
extension = loaded_[0].get();
- EXPECT_TRUE(service()->GetExtensionById(extension->id(), false))
+ EXPECT_TRUE(registry()->GetExtensionById(extension->id(),
+ ExtensionRegistry::ENABLED))
<< path.value();
}
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index 5ef1873..1696559 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -841,7 +841,8 @@
EXPECT_EQ(std::string("The first extension that I made."),
loaded_[0]->description());
EXPECT_EQ(Manifest::INTERNAL, loaded_[0]->location());
- EXPECT_TRUE(service()->GetExtensionById(loaded_[0]->id(), false));
+ EXPECT_TRUE(registry()->GetExtensionById(loaded_[0]->id(),
+ ExtensionRegistry::ENABLED));
EXPECT_EQ(expected_num_extensions, registry()->enabled_extensions().size());
ValidatePrefKeyCount(3);
@@ -1212,7 +1213,8 @@
provider->UpdateOrAddExtension(std::move(info));
WaitForExternalExtensionInstalled();
- const Extension* extension = service()->GetExtensionById(good_crx, false);
+ const Extension* extension =
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED);
ASSERT_TRUE(extension);
ASSERT_TRUE(extension->from_bookmark());
ASSERT_TRUE(ValidateBooleanPref(good_crx, kPrefFromBookmark, true));
@@ -1221,7 +1223,8 @@
path = data_dir().AppendASCII("good2.crx");
UpdateExtension(good_crx, path, ENABLED);
ASSERT_TRUE(ValidateBooleanPref(good_crx, kPrefFromBookmark, true));
- extension = service()->GetExtensionById(good_crx, false);
+ extension =
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED);
ASSERT_TRUE(extension);
ASSERT_TRUE(extension->from_bookmark());
}
@@ -1242,7 +1245,8 @@
provider->UpdateOrAddExtension(std::move(info));
WaitForExternalExtensionInstalled();
- ASSERT_TRUE(service()->GetExtensionById(good_crx, false));
+ ASSERT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
// Uninstall it and check that its killbit gets set.
UninstallExtension(good_crx);
@@ -1254,7 +1258,8 @@
Manifest::EXTERNAL_PREF, Extension::NO_FLAGS);
provider->UpdateOrAddExtension(std::move(info));
content::RunAllTasksUntilIdle();
- ASSERT_FALSE(service()->GetExtensionById(good_crx, false));
+ ASSERT_FALSE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
EXPECT_TRUE(prefs->IsExternalExtensionUninstalled(good_crx));
std::string newer_version = "1.0.0.1";
@@ -1264,7 +1269,8 @@
Manifest::EXTERNAL_PREF, Extension::NO_FLAGS);
provider->UpdateOrAddExtension(std::move(info));
content::RunAllTasksUntilIdle();
- ASSERT_FALSE(service()->GetExtensionById(good_crx, false));
+ ASSERT_FALSE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
EXPECT_TRUE(prefs->IsExternalExtensionUninstalled(good_crx));
// Try adding the same extension from an external update URL.
@@ -1338,14 +1344,16 @@
Manifest::EXTERNAL_PREF, Extension::NO_FLAGS);
provider->UpdateOrAddExtension(std::move(info));
WaitForExternalExtensionInstalled();
- ASSERT_FALSE(service()->GetExtensionById(good_crx, false));
+ ASSERT_FALSE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
// Try again with the right ID. Expect success.
info = CreateExternalExtension(correct_id, version_str, path,
Manifest::EXTERNAL_PREF, Extension::NO_FLAGS);
provider->UpdateOrAddExtension(std::move(info));
WaitForExternalExtensionInstalled();
- ASSERT_TRUE(service()->GetExtensionById(good_crx, false));
+ ASSERT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
}
// Test that external extensions with incorrect versions are not installed.
@@ -1363,7 +1371,8 @@
Manifest::EXTERNAL_PREF, Extension::NO_FLAGS);
provider->UpdateOrAddExtension(std::move(wrong_info));
WaitForExternalExtensionInstalled();
- ASSERT_FALSE(service()->GetExtensionById(good_crx, false));
+ ASSERT_FALSE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
// Try again with the right version. Expect success.
service()->pending_extension_manager()->Remove(good_crx);
@@ -1372,7 +1381,8 @@
Manifest::EXTERNAL_PREF, Extension::NO_FLAGS);
provider->UpdateOrAddExtension(std::move(correct_info));
WaitForExternalExtensionInstalled();
- ASSERT_TRUE(service()->GetExtensionById(good_crx, false));
+ ASSERT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
}
// Install a user script (they get converted automatically to an extension)
@@ -1398,7 +1408,8 @@
EXPECT_EQ(0u, errors.size())
<< "There were errors: "
<< base::JoinString(errors, base::ASCIIToUTF16(","));
- EXPECT_TRUE(service()->GetExtensionById(loaded_[0]->id(), false))
+ EXPECT_TRUE(registry()->GetExtensionById(loaded_[0]->id(),
+ ExtensionRegistry::ENABLED))
<< path.value();
installed_ = NULL;
@@ -2462,7 +2473,10 @@
extensions_path.AppendASCII("v2.crx"),
ENABLED);
ASSERT_EQ(std::string("2"),
- service()->GetExtensionById(id, false)->version().GetString());
+ registry()
+ ->GetExtensionById(id, ExtensionRegistry::ENABLED)
+ ->version()
+ .GetString());
}
// Verifies that the NTP page and launch ordinals are kept when updating apps.
@@ -2490,7 +2504,10 @@
// Now try updating to v2.
UpdateExtension(id, extensions_path.AppendASCII("v2.crx"), ENABLED);
ASSERT_EQ(std::string("2"),
- service()->GetExtensionById(id, false)->version().GetString());
+ registry()
+ ->GetExtensionById(id, ExtensionRegistry::ENABLED)
+ ->version()
+ .GetString());
// Verify that the ordinals match.
ASSERT_TRUE(new_page_ordinal.Equals(sorting->GetPageOrdinal(id)));
@@ -2641,7 +2658,7 @@
// Reload so extension gets reinitialized with new value.
service()->ReloadExtensionsForTest();
- extension = service()->GetExtensionById(id, false);
+ extension = registry()->GetExtensionById(id, ExtensionRegistry::ENABLED);
ASSERT_TRUE(extension->from_webstore());
// Upgrade to version 2.0
@@ -2666,7 +2683,7 @@
// Also test that the extension's old and new title are correctly retrieved.
path = data_dir().AppendASCII("good2.crx");
InstallCRX(path, INSTALL_UPDATED, Extension::NO_FLAGS, "My extension 1");
- extension = service()->GetExtensionById(id, false);
+ extension = registry()->GetExtensionById(id, ExtensionRegistry::ENABLED);
ASSERT_EQ("1.0.0.1", extension->version().GetString());
ASSERT_EQ("My updated extension 1", extension->name());
@@ -2698,9 +2715,11 @@
path = data_dir().AppendASCII("good2.crx");
UpdateExtension(good_crx, path, ENABLED);
- ASSERT_EQ(
- "1.0.0.1",
- service()->GetExtensionById(good_crx, false)->version().GetString());
+ ASSERT_EQ("1.0.0.1",
+ registry()
+ ->GetExtensionById(good_crx, ExtensionRegistry::ENABLED)
+ ->version()
+ .GetString());
}
// Extensions should not be updated during browser shutdown.
@@ -2720,9 +2739,11 @@
bool updated = service()->UpdateExtension(
CRXFileInfo(good_crx, GetTestVerifierFormat(), path), true, NULL);
ASSERT_FALSE(updated);
- ASSERT_EQ(
- "1.0.0.0",
- service()->GetExtensionById(good_crx, false)->version().GetString());
+ ASSERT_EQ("1.0.0.0",
+ registry()
+ ->GetExtensionById(good_crx, ExtensionRegistry::ENABLED)
+ ->version()
+ .GetString());
}
// Test updating a not-already-installed extension - this should fail
@@ -2751,9 +2772,11 @@
// Change path from good2.crx -> good.crx
path = data_dir().AppendASCII("good.crx");
UpdateExtension(good_crx, path, FAILED);
- ASSERT_EQ(
- "1.0.0.1",
- service()->GetExtensionById(good_crx, false)->version().GetString());
+ ASSERT_EQ("1.0.0.1",
+ registry()
+ ->GetExtensionById(good_crx, ExtensionRegistry::ENABLED)
+ ->version()
+ .GetString());
}
// Make sure calling update with an identical version does nothing
@@ -2785,7 +2808,8 @@
path = data_dir().AppendASCII("good2.crx");
UpdateExtension(good_crx, path, INSTALLED);
ASSERT_EQ(1u, registry()->disabled_extensions().size());
- const Extension* good2 = service()->GetExtensionById(good_crx, true);
+ const Extension* good2 =
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::COMPATIBILITY);
ASSERT_EQ("1.0.0.1", good2->version().GetString());
EXPECT_TRUE(util::IsIncognitoEnabled(good2->id(), profile()));
EXPECT_EQ(disable_reason::DISABLE_USER_ACTION,
@@ -2805,7 +2829,8 @@
path = data_dir().AppendASCII("good2.crx");
UpdateExtension(good_crx, path, ENABLED);
- const Extension* good2 = service()->GetExtensionById(good_crx, false);
+ const Extension* good2 =
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED);
ASSERT_EQ("1.0.0.1", good2->version().GetString());
EXPECT_EQ(good2->location(), Manifest::EXTERNAL_PREF);
}
@@ -2936,7 +2961,8 @@
EXPECT_FALSE(service()->pending_extension_manager()->IsIdPending(kGoodId));
- const Extension* extension = service()->GetExtensionById(kGoodId, true);
+ const Extension* extension =
+ registry()->GetExtensionById(kGoodId, ExtensionRegistry::COMPATIBILITY);
EXPECT_TRUE(extension);
}
@@ -2965,7 +2991,8 @@
// It should still have been installed though.
EXPECT_FALSE(service()->pending_extension_manager()->IsIdPending(kGoodId));
- const Extension* extension = service()->GetExtensionById(kGoodId, true);
+ const Extension* extension =
+ registry()->GetExtensionById(kGoodId, ExtensionRegistry::COMPATIBILITY);
EXPECT_TRUE(extension);
}
@@ -2989,7 +3016,8 @@
EXPECT_FALSE(service()->pending_extension_manager()->IsIdPending(theme_crx));
- const Extension* extension = service()->GetExtensionById(theme_crx, true);
+ const Extension* extension =
+ registry()->GetExtensionById(theme_crx, ExtensionRegistry::COMPATIBILITY);
ASSERT_TRUE(extension);
EXPECT_FALSE(
@@ -3017,7 +3045,8 @@
EXPECT_FALSE(service()->pending_extension_manager()->IsIdPending(theme_crx));
- const Extension* extension = service()->GetExtensionById(theme_crx, true);
+ const Extension* extension =
+ registry()->GetExtensionById(theme_crx, ExtensionRegistry::COMPATIBILITY);
ASSERT_TRUE(extension);
EXPECT_FALSE(
@@ -3094,7 +3123,8 @@
EXPECT_FALSE(service()->pending_extension_manager()->IsIdPending(theme_crx));
- const Extension* extension = service()->GetExtensionById(theme_crx, true);
+ const Extension* extension =
+ registry()->GetExtensionById(theme_crx, ExtensionRegistry::COMPATIBILITY);
ASSERT_FALSE(extension);
}
@@ -3789,12 +3819,12 @@
// Extension should be installed despite blacklist.
ASSERT_EQ(1u, registry()->enabled_extensions().size());
- EXPECT_TRUE(service()->GetExtensionById(good0, false));
+ EXPECT_TRUE(registry()->GetExtensionById(good0, ExtensionRegistry::ENABLED));
// Poke external providers and make sure the extension is still present.
service()->CheckForExternalUpdates();
ASSERT_EQ(1u, registry()->enabled_extensions().size());
- EXPECT_TRUE(service()->GetExtensionById(good0, false));
+ EXPECT_TRUE(registry()->GetExtensionById(good0, ExtensionRegistry::ENABLED));
// Extension should not be uninstalled on blacklist changes.
{
@@ -3803,7 +3833,7 @@
}
content::RunAllTasksUntilIdle();
ASSERT_EQ(1u, registry()->enabled_extensions().size());
- EXPECT_TRUE(service()->GetExtensionById(good0, false));
+ EXPECT_TRUE(registry()->GetExtensionById(good0, ExtensionRegistry::ENABLED));
}
// Tests that active permissions are not revoked from component extensions
@@ -3824,8 +3854,8 @@
service()->Init();
// Extension should have the "tabs" permission.
- EXPECT_TRUE(service()
- ->GetExtensionById(good0, false)
+ EXPECT_TRUE(registry()
+ ->GetExtensionById(good0, ExtensionRegistry::ENABLED)
->permissions_data()
->active_permissions()
.HasAPIPermission(APIPermission::kTab));
@@ -3838,8 +3868,8 @@
service()->OnExtensionManagementSettingsChanged();
content::RunAllTasksUntilIdle();
- EXPECT_TRUE(service()
- ->GetExtensionById(good0, false)
+ EXPECT_TRUE(registry()
+ ->GetExtensionById(good0, ExtensionRegistry::ENABLED)
->permissions_data()
->active_permissions()
.HasAPIPermission(APIPermission::kTab));
@@ -3870,7 +3900,8 @@
// Extension should be installed despite blacklist.
ASSERT_EQ(1u, registry()->enabled_extensions().size());
- EXPECT_TRUE(service()->GetExtensionById(good_crx, false));
+ EXPECT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
// Blacklist update should not uninstall the extension.
{
@@ -3879,7 +3910,8 @@
}
content::RunAllTasksUntilIdle();
ASSERT_EQ(1u, registry()->enabled_extensions().size());
- EXPECT_TRUE(service()->GetExtensionById(good_crx, false));
+ EXPECT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
}
// Tests that extensions cannot be installed if the policy provider prohibits
@@ -3952,7 +3984,8 @@
service()->DisableExtension(good_crx, disable_reason::DISABLE_USER_ACTION);
EXPECT_EQ(1u, registry()->enabled_extensions().size());
- EXPECT_TRUE(service()->GetExtensionById(good_crx, false));
+ EXPECT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
EXPECT_EQ(0u, registry()->disabled_extensions().size());
EXPECT_EQ(disable_reason::DISABLE_NONE,
ExtensionPrefs::Get(profile())->GetDisableReasons(good_crx));
@@ -3964,8 +3997,10 @@
EXPECT_EQ(0u, registry()->enabled_extensions().size());
EXPECT_EQ(1u, registry()->disabled_extensions().size());
- EXPECT_TRUE(service()->GetExtensionById(good_crx, true));
- EXPECT_FALSE(service()->GetExtensionById(good_crx, false));
+ EXPECT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::COMPATIBILITY));
+ EXPECT_FALSE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
EXPECT_EQ(disable_reason::DISABLE_CORRUPTED,
ExtensionPrefs::Get(profile())->GetDisableReasons(good_crx));
}
@@ -3988,7 +4023,8 @@
good_crx, UNINSTALL_REASON_FOR_TESTING, NULL));
EXPECT_EQ(1u, registry()->enabled_extensions().size());
- EXPECT_TRUE(service()->GetExtensionById(good_crx, false));
+ EXPECT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
}
// Tests that previously installed extensions that are now prohibited from
@@ -4190,7 +4226,8 @@
PackAndInstallCRX(path2, pem_path, INSTALL_FAILED);
// Verify that the old version is still enabled.
- updated = service()->GetExtensionById(permissions_blocklist, false);
+ updated = registry()->GetExtensionById(permissions_blocklist,
+ ExtensionRegistry::ENABLED);
ASSERT_TRUE(updated);
EXPECT_EQ(old_version, updated->VersionString());
}
@@ -4298,8 +4335,10 @@
observer.Wait();
ASSERT_EQ(2u, registry()->enabled_extensions().size());
- EXPECT_TRUE(service()->GetExtensionById(good_crx, false));
- EXPECT_TRUE(service()->GetExtensionById(page_action, false));
+ EXPECT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
+ EXPECT_TRUE(
+ registry()->GetExtensionById(page_action, ExtensionRegistry::ENABLED));
ExtensionPrefs* prefs = ExtensionPrefs::Get(profile());
ASSERT_TRUE(!prefs->IsExternalExtensionAcknowledged(good_crx));
ASSERT_TRUE(prefs->IsExternalExtensionAcknowledged(page_action));
@@ -4477,8 +4516,10 @@
WaitForExternalExtensionInstalled();
ASSERT_EQ(1u, registry()->enabled_extensions().size());
- EXPECT_TRUE(service()->GetExtensionById(good_crx, false));
- const Extension* extension = service()->GetExtensionById(good_crx, false);
+ EXPECT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
+ const Extension* extension =
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED);
EXPECT_TRUE(extension->from_webstore());
EXPECT_TRUE(extension->was_installed_by_default());
}
@@ -4517,7 +4558,8 @@
path = data_dir().AppendASCII("good2.crx");
UpdateExtension(good_crx, path, ENABLED);
ASSERT_TRUE(ValidateBooleanPref(good_crx, kPrefFromBookmark, true));
- const Extension* extension = service()->GetExtensionById(good_crx, false);
+ const Extension* extension =
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED);
ASSERT_TRUE(extension);
ASSERT_TRUE(extension->from_bookmark());
}
@@ -4527,8 +4569,10 @@
InitializeEmptyExtensionService();
InstallCRX(data_dir().AppendASCII("good.crx"), INSTALL_NEW);
- EXPECT_TRUE(service()->GetExtensionById(good_crx, true));
- EXPECT_TRUE(service()->GetExtensionById(good_crx, false));
+ EXPECT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::COMPATIBILITY));
+ EXPECT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
EXPECT_EQ(1u, registry()->enabled_extensions().size());
EXPECT_EQ(0u, registry()->disabled_extensions().size());
@@ -4538,8 +4582,10 @@
// Disable it.
service()->DisableExtension(good_crx, disable_reason::DISABLE_USER_ACTION);
- EXPECT_TRUE(service()->GetExtensionById(good_crx, true));
- EXPECT_FALSE(service()->GetExtensionById(good_crx, false));
+ EXPECT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::COMPATIBILITY));
+ EXPECT_FALSE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::ENABLED));
EXPECT_EQ(0u, registry()->enabled_extensions().size());
EXPECT_EQ(1u, registry()->disabled_extensions().size());
EXPECT_EQ(0u, registry()->terminated_extensions().size());
@@ -4576,7 +4622,8 @@
EXPECT_FALSE(
registry()->GetExtensionById(good_crx, ExtensionRegistry::TERMINATED));
- EXPECT_TRUE(service()->GetExtensionById(good_crx, true));
+ EXPECT_TRUE(
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::COMPATIBILITY));
EXPECT_EQ(0u, registry()->enabled_extensions().size());
EXPECT_EQ(1u, registry()->disabled_extensions().size());
@@ -4622,7 +4669,8 @@
service()->ReloadExtensionsForTest();
// The creation flags should not change when reloading the extension.
- const Extension* extension = service()->GetExtensionById(good_crx, true);
+ const Extension* extension =
+ registry()->GetExtensionById(good_crx, ExtensionRegistry::COMPATIBILITY);
EXPECT_TRUE(extension->from_webstore());
EXPECT_TRUE(extension->was_installed_by_default());
EXPECT_FALSE(extension->from_bookmark());
@@ -6374,7 +6422,8 @@
// Is an extension installed?
bool IsCrxInstalled() {
- return (service()->GetExtensionById(crx_id_, true) != NULL);
+ return (registry()->GetExtensionById(
+ crx_id_, ExtensionRegistry::COMPATIBILITY) != nullptr);
}
protected:
diff --git a/chrome/browser/extensions/external_provider_impl.cc b/chrome/browser/extensions/external_provider_impl.cc
index 8e9ffd2..ed3461e 100644
--- a/chrome/browser/extensions/external_provider_impl.cc
+++ b/chrome/browser/extensions/external_provider_impl.cc
@@ -27,7 +27,6 @@
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/extensions/extension_management.h"
#include "chrome/browser/extensions/extension_migrator.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/external_component_loader.h"
#include "chrome/browser/extensions/external_policy_loader.h"
#include "chrome/browser/extensions/external_pref_loader.h"
@@ -41,7 +40,7 @@
#include "components/crx_file/id_util.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
-#include "extensions/browser/extension_system.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/external_install_info.h"
#include "extensions/browser/external_provider_interface.h"
#include "extensions/common/extension.h"
@@ -339,10 +338,12 @@
bool keep_if_present = false;
if (extension->GetBoolean(kKeepIfPresent, &keep_if_present) &&
keep_if_present && profile_) {
- ExtensionServiceInterface* extension_service =
- ExtensionSystem::Get(profile_)->extension_service();
- const Extension* extension = extension_service ?
- extension_service->GetExtensionById(extension_id, true) : NULL;
+ ExtensionRegistry* extension_registry = ExtensionRegistry::Get(profile_);
+ const Extension* extension =
+ extension_registry
+ ? extension_registry->GetExtensionById(
+ extension_id, ExtensionRegistry::COMPATIBILITY)
+ : nullptr;
if (!extension) {
unsupported_extensions.insert(extension_id);
InstallationReporter::ReportFailure(
diff --git a/chrome/browser/extensions/navigation_observer.cc b/chrome/browser/extensions/navigation_observer.cc
index d4831ad..2e3782e 100644
--- a/chrome/browser/extensions/navigation_observer.cc
+++ b/chrome/browser/extensions/navigation_observer.cc
@@ -121,10 +121,9 @@
if (in_progress_prompt_extension_id_.empty())
return;
- ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(profile_)->extension_service();
- const Extension* extension = extension_service->GetExtensionById(
- in_progress_prompt_extension_id_, true);
+ ExtensionRegistry* extension_registry = ExtensionRegistry::Get(profile_);
+ const Extension* extension = extension_registry->GetExtensionById(
+ in_progress_prompt_extension_id_, ExtensionRegistry::COMPATIBILITY);
CHECK(extension);
if (result == ExtensionInstallPrompt::Result::ACCEPTED) {
@@ -132,6 +131,8 @@
in_progress_prompt_navigation_controller_;
CHECK(nav_controller);
+ ExtensionService* extension_service =
+ ExtensionSystem::Get(profile_)->extension_service();
// Grant permissions, re-enable the extension, and then reload the tab.
extension_service->GrantPermissionsAndEnableExtension(extension);
nav_controller->Reload(content::ReloadType::NORMAL, true);
@@ -148,7 +149,7 @@
histogram_name.c_str());
}
- in_progress_prompt_extension_id_ = std::string();
+ in_progress_prompt_extension_id_.clear();
in_progress_prompt_navigation_controller_ = nullptr;
extension_install_prompt_.reset();
}
diff --git a/chrome/browser/extensions/test_extension_service.cc b/chrome/browser/extensions/test_extension_service.cc
index c70f75c..f81a8d1 100644
--- a/chrome/browser/extensions/test_extension_service.cc
+++ b/chrome/browser/extensions/test_extension_service.cc
@@ -24,12 +24,6 @@
return false;
}
-const Extension* TestExtensionService::GetExtensionById(
- const std::string& id, bool include_disabled) const {
- ADD_FAILURE();
- return NULL;
-}
-
const Extension* TestExtensionService::GetInstalledExtension(
const std::string& id) const {
ADD_FAILURE();
diff --git a/chrome/browser/extensions/test_extension_service.h b/chrome/browser/extensions/test_extension_service.h
index 42a65073..0e43c76 100644
--- a/chrome/browser/extensions/test_extension_service.h
+++ b/chrome/browser/extensions/test_extension_service.h
@@ -28,9 +28,6 @@
bool UpdateExtension(const extensions::CRXFileInfo& file,
bool file_ownership_passed,
extensions::CrxInstaller** out_crx_installer) override;
- const extensions::Extension* GetExtensionById(
- const std::string& id,
- bool include_disabled) const override;
const extensions::Extension* GetInstalledExtension(
const std::string& id) const override;
const extensions::Extension* GetPendingExtensionUpdate(
diff --git a/chrome/browser/extensions/unpacked_installer.cc b/chrome/browser/extensions/unpacked_installer.cc
index 8102059..c4ab305 100644
--- a/chrome/browser/extensions/unpacked_installer.cc
+++ b/chrome/browser/extensions/unpacked_installer.cc
@@ -26,6 +26,7 @@
#include "extensions/browser/api/declarative_net_request/ruleset_source.h"
#include "extensions/browser/extension_file_task_runner.h"
#include "extensions/browser/extension_prefs.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/install_flag.h"
#include "extensions/browser/path_util.h"
#include "extensions/browser/policy_check.h"
@@ -168,10 +169,11 @@
const std::vector<SharedModuleInfo::ImportInfo>& imports =
SharedModuleInfo::GetImports(extension());
std::vector<SharedModuleInfo::ImportInfo>::const_iterator i;
+ ExtensionRegistry* registry = ExtensionRegistry::Get(service->profile());
for (i = imports.begin(); i != imports.end(); ++i) {
base::Version version_required(i->minimum_version);
- const Extension* imported_module =
- service->GetExtensionById(i->extension_id, true);
+ const Extension* imported_module = registry->GetExtensionById(
+ i->extension_id, ExtensionRegistry::COMPATIBILITY);
if (!imported_module) {
ReportExtensionLoadError(kImportMissing);
return;
diff --git a/chrome/browser/extensions/updater/extension_updater.cc b/chrome/browser/extensions/updater/extension_updater.cc
index 45ece00..2646817 100644
--- a/chrome/browser/extensions/updater/extension_updater.cc
+++ b/chrome/browser/extensions/updater/extension_updater.cc
@@ -145,6 +145,7 @@
extension_prefs_(extension_prefs),
prefs_(prefs),
profile_(profile),
+ registry_(ExtensionRegistry::Get(profile)),
next_request_id_(0),
crx_install_is_running_(false),
extension_cache_(cache) {
@@ -179,6 +180,7 @@
DCHECK(prefs_);
DCHECK(profile_);
DCHECK(!weak_ptr_factory_.HasWeakPtrs());
+ DCHECK(registry_);
alive_ = true;
// Check soon, and set up the first delayed check.
if (!g_skip_scheduled_checks_for_tests) {
@@ -190,13 +192,14 @@
void ExtensionUpdater::Stop() {
weak_ptr_factory_.InvalidateWeakPtrs();
alive_ = false;
- service_ = NULL;
- extension_prefs_ = NULL;
- prefs_ = NULL;
- profile_ = NULL;
+ service_ = nullptr;
+ extension_prefs_ = nullptr;
+ prefs_ = nullptr;
+ profile_ = nullptr;
will_check_soon_ = false;
downloader_.reset();
update_service_ = nullptr;
+ registry_ = nullptr;
}
void ExtensionUpdater::ScheduleNextCheck() {
@@ -338,14 +341,14 @@
}
}
- ExtensionRegistry* registry = ExtensionRegistry::Get(profile_);
- AddToDownloader(®istry->enabled_extensions(), pending_ids, request_id,
+ AddToDownloader(®istry_->enabled_extensions(), pending_ids, request_id,
params.fetch_priority, &update_check_params);
- AddToDownloader(®istry->disabled_extensions(), pending_ids, request_id,
+ AddToDownloader(®istry_->disabled_extensions(), pending_ids, request_id,
params.fetch_priority, &update_check_params);
} else {
for (const std::string& id : params.ids) {
- const Extension* extension = service_->GetExtensionById(id, true);
+ const Extension* extension = registry_->GetExtensionById(
+ id, extensions::ExtensionRegistry::COMPATIBILITY);
if (extension) {
if (update_service_->CanUpdate(id)) {
update_check_params.update_info[id] = ExtensionUpdateData();
@@ -521,7 +524,8 @@
bool ExtensionUpdater::GetExtensionExistingVersion(const std::string& id,
std::string* version) {
DCHECK(alive_);
- const Extension* extension = service_->GetExtensionById(id, true);
+ const Extension* extension = registry_->GetExtensionById(
+ id, extensions::ExtensionRegistry::COMPATIBILITY);
if (!extension)
return false;
const Extension* update = service_->GetPendingExtensionUpdate(id);
diff --git a/chrome/browser/extensions/updater/extension_updater.h b/chrome/browser/extensions/updater/extension_updater.h
index 7eb875e0..d09c9a2 100644
--- a/chrome/browser/extensions/updater/extension_updater.h
+++ b/chrome/browser/extensions/updater/extension_updater.h
@@ -34,6 +34,7 @@
class ExtensionCache;
class ExtensionPrefs;
+class ExtensionRegistry;
class ExtensionServiceInterface;
class ExtensionSet;
struct ExtensionUpdateCheckParams;
@@ -270,6 +271,8 @@
PrefService* prefs_;
Profile* profile_;
+ ExtensionRegistry* registry_;
+
std::map<int, InProgressCheck> requests_in_progress_;
int next_request_id_;
diff --git a/chrome/browser/extensions/updater/extension_updater_unittest.cc b/chrome/browser/extensions/updater/extension_updater_unittest.cc
index cc7a34b..1170374 100644
--- a/chrome/browser/extensions/updater/extension_updater_unittest.cc
+++ b/chrome/browser/extensions/updater/extension_updater_unittest.cc
@@ -400,14 +400,6 @@
~ServiceForManifestTests() override {}
- const Extension* GetExtensionById(const std::string& id,
- bool include_disabled) const override {
- const Extension* result = registry_->enabled_extensions().GetByID(id);
- if (result || !include_disabled)
- return result;
- return registry_->disabled_extensions().GetByID(id);
- }
-
PendingExtensionManager* pending_extension_manager() override {
return &pending_extension_manager_;
}
@@ -469,12 +461,6 @@
return &pending_extension_manager_;
}
- const Extension* GetExtensionById(const std::string& id,
- bool) const override {
- last_inquired_extension_id_ = id;
- return NULL;
- }
-
const std::string& extension_id() const { return extension_id_; }
const base::FilePath& install_path() const { return install_path_; }
@@ -488,12 +474,6 @@
std::string extension_id_;
base::FilePath install_path_;
GURL download_url_;
-
- // The last extension ID that GetExtensionById was called with.
- // Mutable because the method that sets it (GetExtensionById) is const
- // in the actual extension service, but must record the last extension
- // ID in this test class.
- mutable std::string last_inquired_extension_id_;
};
static const int kUpdateFrequencySecs = 15;
@@ -2554,7 +2534,8 @@
ASSERT_EQ(1u, tmp.size());
ExtensionId id = tmp.front()->id();
- ASSERT_TRUE(service.GetExtensionById(id, false));
+ ExtensionRegistry* registry = ExtensionRegistry::Get(service.profile());
+ ASSERT_TRUE(registry->GetExtensionById(id, ExtensionRegistry::ENABLED));
ExtensionUpdater updater(&service,
service.extension_prefs(),
@@ -2569,7 +2550,7 @@
updater.CheckNow(std::move(params));
service.set_extensions(ExtensionList(), ExtensionList());
- ASSERT_FALSE(service.GetExtensionById(id, false));
+ ASSERT_FALSE(registry->GetExtensionById(id, ExtensionRegistry::ENABLED));
// RunUntilIdle is needed to make sure that the UpdateService instance that
// runs the extension update process has a chance to exit gracefully; without
diff --git a/chrome/browser/extensions/webstore_standalone_installer.cc b/chrome/browser/extensions/webstore_standalone_installer.cc
index 3ea8fa9..85726d21 100644
--- a/chrome/browser/extensions/webstore_standalone_installer.cc
+++ b/chrome/browser/extensions/webstore_standalone_installer.cc
@@ -192,14 +192,15 @@
std::unique_ptr<WebstoreInstaller::Approval> approval = CreateApproval();
- ExtensionService* extension_service =
- ExtensionSystem::Get(profile_)->extension_service();
- const Extension* installed_extension =
- extension_service->GetExtensionById(id_, true /* include disabled */);
+ ExtensionRegistry* extension_registry = ExtensionRegistry::Get(profile_);
+ const Extension* installed_extension = extension_registry->GetExtensionById(
+ id_, ExtensionRegistry::COMPATIBILITY);
if (installed_extension) {
std::string install_message;
webstore_install::Result install_result = webstore_install::SUCCESS;
+ ExtensionService* extension_service =
+ ExtensionSystem::Get(profile_)->extension_service();
if (ExtensionPrefs::Get(profile_)->IsExtensionBlacklisted(id_)) {
// Don't install a blacklisted extension.
install_result = webstore_install::BLACKLISTED;
diff --git a/chrome/browser/media_galleries/fileapi/media_file_system_backend.cc b/chrome/browser/media_galleries/fileapi/media_file_system_backend.cc
index aa6b3732..cd8f37b 100644
--- a/chrome/browser/media_galleries/fileapi/media_file_system_backend.cc
+++ b/chrome/browser/media_galleries/fileapi/media_file_system_backend.cc
@@ -21,19 +21,19 @@
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/media_galleries/fileapi/media_file_validator_factory.h"
#include "chrome/browser/media_galleries/fileapi/media_path_filter.h"
#include "chrome/browser/media_galleries/fileapi/native_media_file_util.h"
#include "chrome/browser/media_galleries/media_file_system_registry.h"
#include "chrome/browser/media_galleries/media_galleries_histograms.h"
#include "chrome/browser/profiles/profile.h"
+#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
-#include "extensions/browser/extension_system.h"
+#include "extensions/browser/extension_registry.h"
#include "net/url_request/url_request.h"
#include "storage/browser/fileapi/copy_or_move_file_validator.h"
#include "storage/browser/fileapi/file_stream_reader.h"
@@ -93,11 +93,11 @@
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
- extensions::ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(profile)->extension_service();
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(profile);
const extensions::Extension* extension =
- extension_service->GetExtensionById(storage_domain,
- false /*include disabled*/);
+ extension_registry->GetExtensionById(
+ storage_domain, extensions::ExtensionRegistry::ENABLED);
std::string expected_mount_prefix =
MediaFileSystemBackend::ConstructMountName(
profile->GetPath(), storage_domain, kInvalidMediaGalleryPrefId);
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index 4259f49b..35376ff 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -876,6 +876,10 @@
return system->extension_service();
}
+ extensions::ExtensionRegistry* extension_registry() {
+ return extensions::ExtensionRegistry::Get(browser()->profile());
+ }
+
const extensions::Extension* InstallExtension(
const base::FilePath::StringType& name) {
base::FilePath extension_path(ui_test_utils::GetTestFilePath(
@@ -925,8 +929,7 @@
void UninstallExtension(const std::string& id, bool expect_success) {
if (expect_success) {
- extensions::TestExtensionRegistryObserver observer(
- extensions::ExtensionRegistry::Get(browser()->profile()));
+ extensions::TestExtensionRegistryObserver observer(extension_registry());
extension_service()->UninstallExtension(
id, extensions::UNINSTALL_REASON_FOR_TESTING, NULL);
observer.WaitForExtensionUninstalled();
@@ -943,8 +946,7 @@
}
void DisableExtension(const std::string& id) {
- extensions::TestExtensionRegistryObserver observer(
- extensions::ExtensionRegistry::Get(browser()->profile()));
+ extensions::TestExtensionRegistryObserver observer(extension_registry());
extension_service()->DisableExtension(
id, extensions::disable_reason::DISABLE_USER_ACTION);
observer.WaitForExtensionUnloaded();
@@ -2144,9 +2146,11 @@
IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallBlacklistSelective) {
// Verifies that blacklisted extensions can't be installed.
- extensions::ExtensionService* service = extension_service();
- ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true));
- ASSERT_FALSE(service->GetExtensionById(kSimpleWithIconCrxId, true));
+ extensions::ExtensionRegistry* registry = extension_registry();
+ ASSERT_FALSE(registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
+ ASSERT_FALSE(registry->GetExtensionById(
+ kSimpleWithIconCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
base::ListValue blacklist;
blacklist.AppendString(kGoodCrxId);
PolicyMap policies;
@@ -2157,15 +2161,18 @@
// "good.crx" is blacklisted.
EXPECT_FALSE(InstallExtension(kGoodCrxName));
- EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true));
+ EXPECT_FALSE(registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
// "simple_with_icon.crx" is not.
const extensions::Extension* simple_with_icon =
InstallExtension(kSimpleWithIconCrxName);
ASSERT_TRUE(simple_with_icon);
EXPECT_EQ(kSimpleWithIconCrxId, simple_with_icon->id());
- EXPECT_EQ(simple_with_icon,
- service->GetExtensionById(kSimpleWithIconCrxId, true));
+ EXPECT_EQ(
+ simple_with_icon,
+ registry->GetExtensionById(kSimpleWithIconCrxId,
+ extensions::ExtensionRegistry::COMPATIBILITY));
}
// Ensure that bookmark apps are not blocked by the ExtensionInstallBlacklist
@@ -2208,8 +2215,7 @@
policies.Set(key::kExtensionSettings, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
dict_value.CreateDeepCopy(), nullptr);
- extensions::TestExtensionRegistryObserver observer(
- extensions::ExtensionRegistry::Get(browser()->profile()));
+ extensions::TestExtensionRegistryObserver observer(extension_registry());
UpdateProviderPolicy(policies);
observer.WaitForExtensionUnloaded();
@@ -2233,8 +2239,7 @@
policies.Set(key::kExtensionSettings, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
dict_value.CreateDeepCopy(), nullptr);
- extensions::TestExtensionRegistryObserver observer(
- extensions::ExtensionRegistry::Get(browser()->profile()));
+ extensions::TestExtensionRegistryObserver observer(extension_registry());
UpdateProviderPolicy(policies);
observer.WaitForExtensionUnloaded();
@@ -2328,8 +2333,11 @@
// Verify that a wildcard blacklist takes effect.
EXPECT_TRUE(InstallExtension(kSimpleWithIconCrxName));
extensions::ExtensionService* service = extension_service();
- ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true));
- ASSERT_TRUE(service->GetExtensionById(kSimpleWithIconCrxId, true));
+ extensions::ExtensionRegistry* registry = extension_registry();
+ ASSERT_FALSE(registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
+ ASSERT_TRUE(registry->GetExtensionById(
+ kSimpleWithIconCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
base::ListValue blacklist;
blacklist.AppendString("*");
PolicyMap policies;
@@ -2339,7 +2347,8 @@
UpdateProviderPolicy(policies);
// "simple_with_icon" should be disabled.
- EXPECT_TRUE(service->GetExtensionById(kSimpleWithIconCrxId, true));
+ EXPECT_TRUE(registry->GetExtensionById(
+ kSimpleWithIconCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
EXPECT_FALSE(service->IsExtensionEnabled(kSimpleWithIconCrxId));
// It shouldn't be possible to re-enable "simple_with_icon", until it
@@ -2349,7 +2358,8 @@
// It shouldn't be possible to install good.crx.
EXPECT_FALSE(InstallExtension(kGoodCrxName));
- EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true));
+ EXPECT_FALSE(registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
}
IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallBlacklistSharedModules) {
@@ -2378,8 +2388,11 @@
// Verify that the extensions are not installed initially.
extensions::ExtensionService* service = extension_service();
- ASSERT_FALSE(service->GetExtensionById(kImporterId, true));
- ASSERT_FALSE(service->GetExtensionById(kSharedModuleId, true));
+ extensions::ExtensionRegistry* registry = extension_registry();
+ ASSERT_FALSE(registry->GetExtensionById(
+ kImporterId, extensions::ExtensionRegistry::COMPATIBILITY));
+ ASSERT_FALSE(registry->GetExtensionById(
+ kSharedModuleId, extensions::ExtensionRegistry::COMPATIBILITY));
// Mock the webstore update URL. This is where the shared module extension
// will be installed from.
@@ -2402,8 +2415,6 @@
POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
forcelist.CreateDeepCopy(), nullptr);
- extensions::ExtensionRegistry* registry =
- extensions::ExtensionRegistry::Get(browser()->profile());
extensions::TestExtensionRegistryObserver observe_importer(
registry, kImporterId);
extensions::TestExtensionRegistryObserver observe_shared_module(
@@ -2413,12 +2424,12 @@
observe_shared_module.WaitForExtensionLoaded();
// Verify that both extensions got installed.
- const extensions::Extension* importer =
- service->GetExtensionById(kImporterId, true);
+ const extensions::Extension* importer = registry->GetExtensionById(
+ kImporterId, extensions::ExtensionRegistry::COMPATIBILITY);
ASSERT_TRUE(importer);
EXPECT_EQ(kImporterId, importer->id());
- const extensions::Extension* shared_module =
- service->GetExtensionById(kSharedModuleId, true);
+ const extensions::Extension* shared_module = registry->GetExtensionById(
+ kSharedModuleId, extensions::ExtensionRegistry::COMPATIBILITY);
ASSERT_TRUE(shared_module);
EXPECT_EQ(kSharedModuleId, shared_module->id());
EXPECT_TRUE(shared_module->is_shared_module());
@@ -2438,9 +2449,11 @@
IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallWhitelist) {
// Verifies that the whitelist can open exceptions to the blacklist.
- extensions::ExtensionService* service = extension_service();
- ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true));
- ASSERT_FALSE(service->GetExtensionById(kSimpleWithIconCrxId, true));
+ extensions::ExtensionRegistry* registry = extension_registry();
+ ASSERT_FALSE(registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
+ ASSERT_FALSE(registry->GetExtensionById(
+ kSimpleWithIconCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
base::ListValue blacklist;
blacklist.AppendString("*");
base::ListValue whitelist;
@@ -2455,12 +2468,15 @@
UpdateProviderPolicy(policies);
// "simple_with_icon.crx" is blacklisted.
EXPECT_FALSE(InstallExtension(kSimpleWithIconCrxName));
- EXPECT_FALSE(service->GetExtensionById(kSimpleWithIconCrxId, true));
+ EXPECT_FALSE(registry->GetExtensionById(
+ kSimpleWithIconCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
// "good.crx" has a whitelist exception.
const extensions::Extension* good = InstallExtension(kGoodCrxName);
ASSERT_TRUE(good);
EXPECT_EQ(kGoodCrxId, good->id());
- EXPECT_EQ(good, service->GetExtensionById(kGoodCrxId, true));
+ EXPECT_EQ(good,
+ registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
// The user can also remove this extension.
UninstallExtension(kGoodCrxId, true);
}
@@ -2525,7 +2541,9 @@
ExtensionRequestInterceptor interceptor;
extensions::ExtensionService* service = extension_service();
- ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true));
+ extensions::ExtensionRegistry* registry = extension_registry();
+ ASSERT_FALSE(registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
// Extensions that are force-installed come from an update URL, which defaults
// to the webstore. Use a test URL for this test with an update manifest
@@ -2542,15 +2560,15 @@
policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
forcelist.CreateDeepCopy(), nullptr);
- extensions::TestExtensionRegistryObserver observer(
- extensions::ExtensionRegistry::Get(browser()->profile()));
+ extensions::TestExtensionRegistryObserver observer(extension_registry());
UpdateProviderPolicy(policies);
observer.WaitForExtensionWillBeInstalled();
// Note: Cannot check that the notification details match the expected
// exception, since the details object has already been freed prior to
// the completion of observer.WaitForExtensionWillBeInstalled().
- EXPECT_TRUE(service->GetExtensionById(kGoodCrxId, true));
+ EXPECT_TRUE(registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
// The user is not allowed to uninstall force-installed extensions.
UninstallExtension(kGoodCrxId, false);
@@ -2574,7 +2592,11 @@
ASSERT_TRUE(extension);
const std::string old_version_number =
- service->GetExtensionById(kGoodCrxId, true)->version().GetString();
+ registry
+ ->GetExtensionById(kGoodCrxId,
+ extensions::ExtensionRegistry::COMPATIBILITY)
+ ->version()
+ .GetString();
content::WindowedNotificationObserver new_process_observer(
content::NOTIFICATION_RENDERER_PROCESS_CREATED,
@@ -2585,12 +2607,15 @@
extensions::ExtensionUpdater::CheckParams params;
params.install_immediately = true;
extensions::TestExtensionRegistryObserver update_observer(
- extensions::ExtensionRegistry::Get(browser()->profile()));
+ extension_registry());
updater->CheckNow(std::move(params));
update_observer.WaitForExtensionWillBeInstalled();
const base::Version& new_version =
- service->GetExtensionById(kGoodCrxId, true)->version();
+ registry
+ ->GetExtensionById(kGoodCrxId,
+ extensions::ExtensionRegistry::COMPATIBILITY)
+ ->version();
ASSERT_TRUE(new_version.IsValid());
base::Version old_version(old_version_number);
ASSERT_TRUE(old_version.IsValid());
@@ -2630,7 +2655,7 @@
extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED,
content::NotificationService::AllSources());
extensions::TestExtensionRegistryObserver extension_loaded_observer(
- extensions::ExtensionRegistry::Get(browser()->profile()), kGoodCrxId);
+ extension_registry(), kGoodCrxId);
extensions::ExtensionHost* extension_host =
extensions::ProcessManager::Get(browser()->profile())
->GetBackgroundHostForExtension(kGoodCrxId);
@@ -2649,8 +2674,9 @@
ExtensionRequestInterceptor interceptor;
- extensions::ExtensionService* service = extension_service();
- ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true));
+ extensions::ExtensionRegistry* registry = extension_registry();
+ ASSERT_FALSE(registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
// Setting the forcelist extension should install "good_v1.crx".
base::ListValue forcelist;
@@ -2659,12 +2685,12 @@
policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
forcelist.CreateDeepCopy(), nullptr);
- extensions::TestExtensionRegistryObserver observer(
- extensions::ExtensionRegistry::Get(browser()->profile()));
+ extensions::TestExtensionRegistryObserver observer(registry);
UpdateProviderPolicy(policies);
observer.WaitForExtensionWillBeInstalled();
- EXPECT_TRUE(service->GetExtensionById(kGoodCrxId, true));
+ EXPECT_TRUE(registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
}
IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionRecommendedInstallationMode) {
@@ -2686,7 +2712,9 @@
#endif
extensions::ExtensionService* service = extension_service();
- ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true));
+ extensions::ExtensionRegistry* registry = extension_registry();
+ ASSERT_FALSE(registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
// Setting the forcelist extension should install "good_v1.crx".
base::DictionaryValue dict_value;
@@ -2700,12 +2728,12 @@
policies.Set(key::kExtensionSettings, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
dict_value.CreateDeepCopy(), nullptr);
- extensions::TestExtensionRegistryObserver observer(
- extensions::ExtensionRegistry::Get(browser()->profile()));
+ extensions::TestExtensionRegistryObserver observer(registry);
UpdateProviderPolicy(policies);
observer.WaitForExtensionWillBeInstalled();
- EXPECT_TRUE(service->GetExtensionById(kGoodCrxId, true));
+ EXPECT_TRUE(registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
// The user is not allowed to uninstall recommended-installed extensions.
UninstallExtension(kGoodCrxId, false);
@@ -2722,9 +2750,11 @@
IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionAllowedTypes) {
// Verifies that extensions are blocked if policy specifies an allowed types
// list and the extension's type is not on that list.
- extensions::ExtensionService* service = extension_service();
- ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true));
- ASSERT_FALSE(service->GetExtensionById(kHostedAppCrxId, true));
+ extensions::ExtensionRegistry* registry = extension_registry();
+ ASSERT_FALSE(registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
+ ASSERT_FALSE(registry->GetExtensionById(
+ kHostedAppCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
base::ListValue allowed_types;
allowed_types.AppendString("hosted_app");
@@ -2736,13 +2766,16 @@
// "good.crx" is blocked.
EXPECT_FALSE(InstallExtension(kGoodCrxName));
- EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true));
+ EXPECT_FALSE(registry->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
// "hosted_app.crx" is of a whitelisted type.
const extensions::Extension* hosted_app = InstallExtension(kHostedAppCrxName);
ASSERT_TRUE(hosted_app);
EXPECT_EQ(kHostedAppCrxId, hosted_app->id());
- EXPECT_EQ(hosted_app, service->GetExtensionById(kHostedAppCrxId, true));
+ EXPECT_EQ(hosted_app,
+ registry->GetExtensionById(
+ kHostedAppCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
// The user can remove the extension.
UninstallExtension(kHostedAppCrxId, true);
@@ -2789,8 +2822,7 @@
install_sources.CreateDeepCopy(), nullptr);
UpdateProviderPolicy(policies);
- extensions::TestExtensionRegistryObserver observer(
- extensions::ExtensionRegistry::Get(browser()->profile()));
+ extensions::TestExtensionRegistryObserver observer(extension_registry());
PerformClick(1, 0);
observer.WaitForExtensionWillBeInstalled();
// Note: Cannot check that the notification details match the expected
@@ -2798,9 +2830,10 @@
// the completion of observer.WaitForExtensionWillBeInstalled().
// The first extension shouldn't be present, the second should be there.
- EXPECT_FALSE(extension_service()->GetExtensionById(kGoodCrxId, true));
- EXPECT_TRUE(
- extension_service()->GetExtensionById(kSimpleWithIconCrxId, false));
+ EXPECT_FALSE(extension_registry()->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::COMPATIBILITY));
+ EXPECT_TRUE(extension_registry()->GetExtensionById(
+ kSimpleWithIconCrxId, extensions::ExtensionRegistry::ENABLED));
}
// Verifies that extensions with version older than the minimum version required
@@ -2834,8 +2867,7 @@
}));
extensions::ExtensionService* service = extension_service();
- extensions::ExtensionRegistry* registry =
- extensions::ExtensionRegistry::Get(browser()->profile());
+ extensions::ExtensionRegistry* registry = extension_registry();
extensions::ExtensionPrefs* extension_prefs =
extensions::ExtensionPrefs::Get(browser()->profile());
@@ -2871,8 +2903,7 @@
// via the update URL in the manifest of the older version.
EXPECT_TRUE(update_extension_count.IsOne());
{
- extensions::TestExtensionRegistryObserver update_observer(
- extensions::ExtensionRegistry::Get(browser()->profile()));
+ extensions::TestExtensionRegistryObserver update_observer(registry);
service->updater()->CheckSoon();
update_observer.WaitForExtensionWillBeInstalled();
}
@@ -2904,8 +2935,7 @@
}));
extensions::ExtensionService* service = extension_service();
- extensions::ExtensionRegistry* registry =
- extensions::ExtensionRegistry::Get(browser()->profile());
+ extensions::ExtensionRegistry* registry = extension_registry();
extensions::ExtensionPrefs* extension_prefs =
extensions::ExtensionPrefs::Get(browser()->profile());
@@ -2927,8 +2957,7 @@
// An extension management policy update should trigger an update as well.
EXPECT_TRUE(update_extension_count.IsZero());
{
- extensions::TestExtensionRegistryObserver update_observer(
- extensions::ExtensionRegistry::Get(browser()->profile()));
+ extensions::TestExtensionRegistryObserver update_observer(registry);
{
// Set a higher minimum version, just intend to trigger a policy update.
extensions::ExtensionManagementPolicyUpdater management_policy(
@@ -2969,8 +2998,7 @@
#if defined(OS_WIN)
base::win::ScopedDomainStateForTesting scoped_domain(true);
#endif
- extensions::ExtensionRegistry* registry =
- extensions::ExtensionRegistry::Get(browser()->profile());
+ extensions::ExtensionRegistry* registry = extension_registry();
extensions::ExtensionPrefs* extension_prefs =
extensions::ExtensionPrefs::Get(browser()->profile());
@@ -2981,8 +3009,7 @@
// Set policy to force-install the extension, it should be installed and
// enabled.
- extensions::TestExtensionRegistryObserver install_observer(
- extensions::ExtensionRegistry::Get(browser()->profile()));
+ extensions::TestExtensionRegistryObserver install_observer(registry);
EXPECT_FALSE(registry->enabled_extensions().Contains(kGoodCrxId));
{
extensions::ExtensionManagementPolicyUpdater management_policy(&provider_);
@@ -6616,8 +6643,7 @@
};
IN_PROC_BROWSER_TEST_F(WebAppInstallForceListPolicyTest, StartUpInstallation) {
- extensions::TestExtensionRegistryObserver observer(
- extensions::ExtensionRegistry::Get(browser()->profile()));
+ extensions::TestExtensionRegistryObserver observer(extension_registry());
const extensions::Extension* installed_extension =
observer.WaitForExtensionWillBeInstalled();
diff --git a/chrome/browser/prefs/tracked/pref_hash_browsertest.cc b/chrome/browser/prefs/tracked/pref_hash_browsertest.cc
index eb1fcc7..949f5c1 100644
--- a/chrome/browser/prefs/tracked/pref_hash_browsertest.cc
+++ b/chrome/browser/prefs/tracked/pref_hash_browsertest.cc
@@ -22,7 +22,6 @@
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/extension_browsertest.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/prefs/chrome_pref_service_factory.h"
#include "chrome/browser/prefs/profile_pref_store_manager.h"
#include "chrome/browser/prefs/session_startup_pref.h"
@@ -32,6 +31,8 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/prefs/pref_service.h"
+#include "components/prefs/scoped_user_pref_update.h"
#include "components/search_engines/default_search_manager.h"
#include "components/search_engines/template_url_data.h"
#include "content/public/test/test_launcher.h"
@@ -175,7 +176,7 @@
// verify preferenes throughout the tests provided by this fixture.
// 2) Instantiate their test via the PREF_HASH_BROWSER_TEST macro above.
// Based on top of ExtensionBrowserTest to allow easy interaction with the
-// ExtensionService.
+// ExtensionRegistry.
class PrefHashBrowserTestBase
: public extensions::ExtensionBrowserTest,
public testing::WithParamInterface<std::string> {
@@ -540,7 +541,8 @@
EXPECT_EQ("http://example.com",
profile()->GetPrefs()->GetString(prefs::kHomePage));
- EXPECT_TRUE(extension_service()->GetExtensionById(kGoodCrxId, false));
+ EXPECT_TRUE(extension_registry()->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::ENABLED));
// Reaction should be identical to unattacked default prefs.
PrefHashBrowserTestUnchangedDefault::VerifyReactionToPrefAttack();
@@ -924,7 +926,9 @@
BEGIN_ALLOW_SINGLE_BUCKET + 5));
EXPECT_EQ(protection_level_ < PROTECTION_ENABLED_EXTENSIONS,
- extension_service()->GetExtensionById(kGoodCrxId, true) != NULL);
+ extension_registry()->GetExtensionById(
+ kGoodCrxId, extensions::ExtensionRegistry::COMPATIBILITY) !=
+ nullptr);
// Nothing else should have triggered.
EXPECT_EQ(
diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu.cc b/chrome/browser/renderer_context_menu/render_view_context_menu.cc
index 7af7d439..3326cbc 100644
--- a/chrome/browser/renderer_context_menu/render_view_context_menu.cc
+++ b/chrome/browser/renderer_context_menu/render_view_context_menu.cc
@@ -33,6 +33,7 @@
#include "chrome/browser/data_reduction_proxy/data_reduction_proxy_chrome_settings_factory.h"
#include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/download/download_stats.h"
+#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/language/language_model_manager_factory.h"
#include "chrome/browser/media/router/media_router_dialog_controller.h"
@@ -126,6 +127,8 @@
#include "content/public/browser/web_contents.h"
#include "content/public/common/menu_item.h"
#include "content/public/common/url_utils.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/extension_system.h"
#include "extensions/buildflags/buildflags.h"
#include "media/base/media_switches.h"
#include "net/base/escape.h"
@@ -685,10 +688,8 @@
void RenderViewContextMenu::AppendAllExtensionItems() {
extension_items_.Clear();
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(browser_context_)->extension_service();
- if (!service)
- return; // In unit-tests, we may not have an ExtensionService.
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(browser_context_);
MenuManager* menu_manager = MenuManager::Get(browser_context_);
if (!menu_manager)
@@ -704,8 +705,8 @@
std::map<base::string16, std::vector<const Extension*>>
title_to_extensions_map;
for (auto iter = ids.begin(); iter != ids.end(); ++iter) {
- const Extension* extension =
- service->GetExtensionById(iter->extension_id, false);
+ const Extension* extension = registry->GetExtensionById(
+ iter->extension_id, extensions::ExtensionRegistry::ENABLED);
// Platform apps have their context menus created directly in
// AppendPlatformAppItems.
if (extension && !extension->is_platform_app()) {
diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc
index 2cc2f16..0a72399 100644
--- a/chrome/browser/task_manager/task_manager_browsertest.cc
+++ b/chrome/browser/task_manager/task_manager_browsertest.cc
@@ -19,7 +19,6 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/devtools/devtools_window_testing.h"
#include "chrome/browser/extensions/extension_browsertest.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/notifications/notification_test_util.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
@@ -48,7 +47,7 @@
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/no_renderer_crashes_assertion.h"
#include "content/public/test/test_navigation_observer.h"
-#include "extensions/browser/extension_system.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
@@ -399,11 +398,9 @@
ShowTaskManager();
ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("packaged_app")));
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
const extensions::Extension* extension =
- service->GetExtensionById(last_loaded_extension_id(), false);
+ extension_registry()->GetExtensionById(
+ last_loaded_extension_id(), extensions::ExtensionRegistry::ENABLED);
ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab()));
ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
@@ -442,11 +439,9 @@
IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTab) {
ASSERT_TRUE(LoadExtension(
test_data_dir_.AppendASCII("packaged_app")));
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
const extensions::Extension* extension =
- service->GetExtensionById(last_loaded_extension_id(), false);
+ extension_registry()->GetExtensionById(
+ last_loaded_extension_id(), extensions::ExtensionRegistry::ENABLED);
// Open a new tab to the app's launch URL and make sure we notice that.
GURL url(extension->GetResourceURL("main.html"));
diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc
index 64b9221..0dfb252 100644
--- a/chrome/browser/themes/theme_service.cc
+++ b/chrome/browser/themes/theme_service.cc
@@ -932,10 +932,12 @@
}
void ThemeService::MigrateTheme() {
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(profile_)->extension_service();
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(profile_);
const Extension* extension =
- service ? service->GetExtensionById(GetThemeID(), false) : nullptr;
+ registry ? registry->GetExtensionById(
+ GetThemeID(), extensions::ExtensionRegistry::ENABLED)
+ : nullptr;
if (extension) {
DLOG(ERROR) << "Migrating theme";
// Theme migration is done on the UI thread. Blocking the UI from appearing
diff --git a/chrome/browser/themes/theme_syncable_service.cc b/chrome/browser/themes/theme_syncable_service.cc
index cf65501..63060de 100644
--- a/chrome/browser/themes/theme_syncable_service.cc
+++ b/chrome/browser/themes/theme_syncable_service.cc
@@ -21,6 +21,7 @@
#include "components/sync/protocol/theme_specifics.pb.h"
#include "extensions/browser/disable_reason.h"
#include "extensions/browser/extension_prefs.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/manifest_url_handlers.h"
@@ -217,11 +218,15 @@
string id(theme_specifics.custom_theme_id());
GURL update_url(theme_specifics.custom_theme_update_url());
DVLOG(1) << "Applying theme " << id << " with update_url " << update_url;
- extensions::ExtensionService* extensions_service =
+ extensions::ExtensionService* extension_service =
extensions::ExtensionSystem::Get(profile_)->extension_service();
- CHECK(extensions_service);
+ CHECK(extension_service);
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(profile_);
+ CHECK(extension_registry);
const extensions::Extension* extension =
- extensions_service->GetExtensionById(id, true);
+ extension_registry->GetExtensionById(
+ id, extensions::ExtensionRegistry::COMPATIBILITY);
if (extension) {
if (!extension->is_theme()) {
DVLOG(1) << "Extension " << id << " is not a theme; aborting";
@@ -229,7 +234,7 @@
}
int disabled_reasons =
extensions::ExtensionPrefs::Get(profile_)->GetDisableReasons(id);
- if (!extensions_service->IsExtensionEnabled(id) &&
+ if (!extension_service->IsExtensionEnabled(id) &&
disabled_reasons != extensions::disable_reason::DISABLE_USER_ACTION) {
DVLOG(1) << "Theme " << id << " is disabled with reason "
<< disabled_reasons << "; aborting";
@@ -243,12 +248,12 @@
// so by adding it as a pending extension and then triggering an
// auto-update cycle.
const bool kRemoteInstall = false;
- if (!extensions_service->pending_extension_manager()->AddFromSync(
+ if (!extension_service->pending_extension_manager()->AddFromSync(
id, update_url, base::Version(), &IsTheme, kRemoteInstall)) {
LOG(WARNING) << "Could not add pending extension for " << id;
return;
}
- extensions_service->CheckForUpdatesSoon();
+ extension_service->CheckForUpdatesSoon();
}
} else if (theme_specifics.has_autogenerated_theme()) {
DVLOG(1) << "Applying autogenerated theme";
@@ -268,9 +273,9 @@
const extensions::Extension* current_extension =
theme_service_->UsingExtensionTheme() &&
!theme_service_->UsingDefaultTheme()
- ? extensions::ExtensionSystem::Get(profile_)
- ->extension_service()
- ->GetExtensionById(theme_service_->GetThemeID(), false)
+ ? extensions::ExtensionRegistry::Get(profile_)->GetExtensionById(
+ theme_service_->GetThemeID(),
+ extensions::ExtensionRegistry::ENABLED)
: nullptr;
if (current_extension &&
!extensions::sync_helper::IsSyncable(current_extension)) {
diff --git a/chrome/browser/ui/app_list/app_list_syncable_service.cc b/chrome/browser/ui/app_list/app_list_syncable_service.cc
index 42b66b0..903ef94 100644
--- a/chrome/browser/ui/app_list/app_list_syncable_service.cc
+++ b/chrome/browser/ui/app_list/app_list_syncable_service.cc
@@ -49,6 +49,7 @@
#include "components/sync/model/sync_merge_result.h"
#include "components/sync/protocol/sync.pb.h"
#include "extensions/browser/extension_prefs.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/uninstall_reason.h"
#include "extensions/common/constants.h"
@@ -1261,8 +1262,10 @@
if (!extension_system_->extension_service())
return false;
- const extensions::Extension* extension =
- extension_system_->extension_service()->GetExtensionById(id, true);
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(profile_);
+ const extensions::Extension* extension = registry->GetExtensionById(
+ id, extensions::ExtensionRegistry::COMPATIBILITY);
return extension && extension->was_installed_by_oem();
}
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
index 35ed470..f4adeca 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
@@ -210,10 +210,8 @@
WindowOpenDisposition disposition) {
EXPECT_TRUE(LoadExtension(test_data_dir_.AppendASCII(name)));
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(profile())->extension_service();
- const Extension* extension =
- service->GetExtensionById(last_loaded_extension_id(), false);
+ const Extension* extension = extension_registry()->GetExtensionById(
+ last_loaded_extension_id(), extensions::ExtensionRegistry::ENABLED);
EXPECT_TRUE(extension);
apps::LaunchService::Get(profile())->OpenApplication(
@@ -223,13 +221,11 @@
}
ash::ShelfID CreateShortcut(const char* name) {
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(profile())->extension_service();
LoadExtension(test_data_dir_.AppendASCII(name));
// First get app_id.
- const Extension* extension =
- service->GetExtensionById(last_loaded_extension_id(), false);
+ const Extension* extension = extension_registry()->GetExtensionById(
+ last_loaded_extension_id(), extensions::ExtensionRegistry::ENABLED);
const std::string app_id = extension->id();
// Then create a shortcut.
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc
index 17400e8..273b72d 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc
@@ -119,6 +119,7 @@
#include "extensions/browser/app_window/app_window_contents.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/app_window/native_app_window.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_constants.h"
@@ -321,6 +322,9 @@
base::CommandLine::ForCurrentProcess(), base::FilePath(), false);
extension_service_->Init();
+ DCHECK(profile());
+ extension_registry_ = extensions::ExtensionRegistry::Get(profile());
+
bool flush_app_service_mojo_calls = false;
if (app_service_proxy_connector_) {
DCHECK(profile());
@@ -750,8 +754,8 @@
} else if (app == extensionYoutubeApp_->id()) {
result += "youtube";
} else {
- const auto* extension = extension_service_->GetExtensionById(
- app, /*include_disabled=*/true);
+ const auto* extension = extension_registry_->GetExtensionById(
+ app, extensions::ExtensionRegistry::COMPATIBILITY);
if (extension && !extension->name().empty()) {
std::string name = extension->name();
name[0] = std::tolower(name[0]);
@@ -803,8 +807,8 @@
}
}
if (!arc_app_found) {
- const auto* extension = extension_service_->GetExtensionById(
- app, /*include_disabled=*/true);
+ const auto* extension = extension_registry_->GetExtensionById(
+ app, extensions::ExtensionRegistry::COMPATIBILITY);
if (extension && !extension->name().empty()) {
std::string name = extension->name();
name[0] = std::toupper(name[0]);
@@ -964,6 +968,8 @@
// |item_delegate_manager_| owns |test_controller_|.
ash::ShelfItemDelegate* test_controller_ = nullptr;
+ extensions::ExtensionRegistry* extension_registry_ = nullptr;
+
extensions::ExtensionService* extension_service_ = nullptr;
app_list::AppListSyncableService* app_list_syncable_service_ = nullptr;
diff --git a/chrome/browser/ui/ash/wallpaper_controller_client.cc b/chrome/browser/ui/ash/wallpaper_controller_client.cc
index 2ab8287..45707cc 100644
--- a/chrome/browser/ui/ash/wallpaper_controller_client.cc
+++ b/chrome/browser/ui/ash/wallpaper_controller_client.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/chromeos/customization/customization_wallpaper_util.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/policy/device_local_account.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -22,11 +21,12 @@
#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/cryptohome/system_salt_getter.h"
#include "chromeos/settings/cros_settings_names.h"
+#include "components/prefs/pref_service.h"
#include "components/session_manager/core/session_manager.h"
#include "components/user_manager/known_user.h"
#include "components/user_manager/user_manager.h"
#include "content/public/common/service_manager_connection.h"
-#include "extensions/browser/extension_system.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/common/constants.h"
#include "services/service_manager/public/cpp/connector.h"
@@ -482,13 +482,12 @@
void WallpaperControllerClient::OpenWallpaperPicker() {
Profile* profile = ProfileManager::GetActiveUserProfile();
DCHECK(profile);
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(profile)->extension_service();
- if (!service)
- return;
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(profile);
- const extensions::Extension* extension = service->GetExtensionById(
- extension_misc::kWallpaperManagerId, false /*include_disabled=*/);
+ const extensions::Extension* extension =
+ registry->GetExtensionById(extension_misc::kWallpaperManagerId,
+ extensions::ExtensionRegistry::ENABLED);
if (!extension)
return;
diff --git a/chrome/browser/ui/extensions/application_launch.cc b/chrome/browser/ui/extensions/application_launch.cc
index ade9f90..5dcf424 100644
--- a/chrome/browser/ui/extensions/application_launch.cc
+++ b/chrome/browser/ui/extensions/application_launch.cc
@@ -59,6 +59,7 @@
using extensions::Extension;
using extensions::ExtensionPrefs;
using extensions::ExtensionRegistry;
+using extensions::ExtensionService;
namespace {
@@ -66,11 +67,13 @@
// This class manages its own lifetime.
class EnableViaDialogFlow : public ExtensionEnableFlowDelegate {
public:
- EnableViaDialogFlow(extensions::ExtensionService* service,
+ EnableViaDialogFlow(ExtensionService* service,
+ ExtensionRegistry* registry,
Profile* profile,
const std::string& extension_id,
const base::Closure& callback)
: service_(service),
+ registry_(registry),
profile_(profile),
extension_id_(extension_id),
callback_(callback) {}
@@ -87,7 +90,7 @@
// ExtensionEnableFlowDelegate overrides.
void ExtensionEnableFlowFinished() override {
const Extension* extension =
- service_->GetExtensionById(extension_id_, false);
+ registry_->GetExtensionById(extension_id_, ExtensionRegistry::ENABLED);
if (!extension)
return;
callback_.Run();
@@ -96,7 +99,8 @@
void ExtensionEnableFlowAborted(bool user_initiated) override { delete this; }
- extensions::ExtensionService* service_;
+ ExtensionService* service_;
+ ExtensionRegistry* registry_;
Profile* profile_;
std::string extension_id_;
base::Closure callback_;
@@ -448,19 +452,20 @@
return;
Profile* profile = params.profile;
- extensions::ExtensionService* service =
+ ExtensionService* service =
extensions::ExtensionSystem::Get(profile)->extension_service();
+ ExtensionRegistry* registry = ExtensionRegistry::Get(profile);
if (!service->IsExtensionEnabled(extension->id()) ||
- extensions::ExtensionRegistry::Get(profile)->GetExtensionById(
- extension->id(), extensions::ExtensionRegistry::TERMINATED)) {
- base::Callback<gfx::NativeWindow(void)> dialog_parent_window_getter;
- // TODO(pkotwicz): Figure out which window should be used as the parent for
- // the "enable application" dialog in Athena.
- (new EnableViaDialogFlow(
- service, profile, extension->id(),
- base::Bind(base::IgnoreResult(OpenEnabledApplication), params)))
- ->Run();
- return;
+ registry->GetExtensionById(extension->id(),
+ ExtensionRegistry::TERMINATED)) {
+ base::Callback<gfx::NativeWindow(void)> dialog_parent_window_getter;
+ // TODO(pkotwicz): Figure out which window should be used as the parent for
+ // the "enable application" dialog in Athena.
+ (new EnableViaDialogFlow(
+ service, registry, profile, extension->id(),
+ base::Bind(base::IgnoreResult(OpenEnabledApplication), params)))
+ ->Run();
+ return;
}
OpenEnabledApplication(params);
diff --git a/chrome/browser/ui/extensions/extension_enable_flow.cc b/chrome/browser/ui/extensions/extension_enable_flow.cc
index e3e758c..3315e33 100644
--- a/chrome/browser/ui/extensions/extension_enable_flow.cc
+++ b/chrome/browser/ui/extensions/extension_enable_flow.cc
@@ -59,9 +59,12 @@
void ExtensionEnableFlow::Run() {
extensions::ExtensionService* service =
extensions::ExtensionSystem::Get(profile_)->extension_service();
- const Extension* extension = service->GetExtensionById(extension_id_, true);
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(profile_);
+ const Extension* extension = registry->GetExtensionById(
+ extension_id_, extensions::ExtensionRegistry::COMPATIBILITY);
if (!extension) {
- extension = extensions::ExtensionRegistry::Get(profile_)->GetExtensionById(
+ extension = registry->GetExtensionById(
extension_id_, extensions::ExtensionRegistry::TERMINATED);
// It's possible (though unlikely) the app could have been uninstalled since
// the user clicked on it.
@@ -71,7 +74,8 @@
service->ReloadExtension(extension_id_);
// ReloadExtension reallocates the Extension object.
- extension = service->GetExtensionById(extension_id_, true);
+ extension = registry->GetExtensionById(
+ extension_id_, extensions::ExtensionRegistry::COMPATIBILITY);
// |extension| could be NULL for asynchronous load, such as the case of
// an unpacked extension. Wait for the load to continue the flow.
@@ -88,7 +92,10 @@
extensions::ExtensionSystem* system =
extensions::ExtensionSystem::Get(profile_);
extensions::ExtensionService* service = system->extension_service();
- const Extension* extension = service->GetExtensionById(extension_id_, true);
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(profile_);
+ const Extension* extension = registry->GetExtensionById(
+ extension_id_, extensions::ExtensionRegistry::COMPATIBILITY);
bool abort =
!extension ||
@@ -184,10 +191,12 @@
if (result == ExtensionInstallPrompt::Result::ACCEPTED) {
extensions::ExtensionService* service =
extensions::ExtensionSystem::Get(profile_)->extension_service();
-
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(profile_);
// The extension can be uninstalled in another window while the UI was
// showing. Treat it as a cancellation and notify |delegate_|.
- const Extension* extension = service->GetExtensionById(extension_id_, true);
+ const Extension* extension = registry->GetExtensionById(
+ extension_id_, extensions::ExtensionRegistry::COMPATIBILITY);
if (!extension) {
delegate_->ExtensionEnableFlowAborted(true);
return;
diff --git a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
index c0f9406..bbbb7b7 100644
--- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
@@ -21,7 +21,6 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_browsertest.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/launch_util.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/infobars/infobar_service.h"
@@ -65,7 +64,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
-#include "extensions/browser/extension_system.h"
+#include "extensions/browser/extension_registry.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -172,11 +171,8 @@
const Extension** out_app_extension) {
ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(app_name.c_str())));
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_service();
- *out_app_extension = service->GetExtensionById(
- last_loaded_extension_id(), false);
+ *out_app_extension = extension_registry()->GetExtensionById(
+ last_loaded_extension_id(), extensions::ExtensionRegistry::ENABLED);
ASSERT_TRUE(*out_app_extension);
// Code that opens a new browser assumes we start with exactly one.
diff --git a/chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views_unittest.cc b/chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views_unittest.cc
index 2746faa..5337cb7 100644
--- a/chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views_unittest.cc
+++ b/chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views_unittest.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_header_panel.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_profile.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/constants.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -135,9 +136,8 @@
void ShowAppInfoForProfile(const std::string& app_id, Profile* profile) {
const extensions::Extension* extension =
- extensions::ExtensionSystem::Get(profile)
- ->extension_service()
- ->GetExtensionById(app_id, true);
+ extensions::ExtensionRegistry::Get(profile)->GetExtensionById(
+ app_id, extensions::ExtensionRegistry::COMPATIBILITY);
DCHECK(extension);
DCHECK(!widget_);
diff --git a/chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_panel.cc b/chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_panel.cc
index f882522..1e97c39 100644
--- a/chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_panel.cc
+++ b/chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_panel.cc
@@ -12,13 +12,12 @@
#include "base/callback_forward.h"
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/launch_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/grit/generated_resources.h"
#include "extensions/browser/extension_prefs.h"
-#include "extensions/browser/extension_system.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/path_util.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
@@ -309,15 +308,16 @@
return std::vector<GURL>();
std::vector<GURL> license_urls;
- extensions::ExtensionService* service =
- extensions::ExtensionSystem::Get(profile_)->extension_service();
- DCHECK(service);
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(profile_);
+ DCHECK(registry);
const std::vector<extensions::SharedModuleInfo::ImportInfo>& imports =
extensions::SharedModuleInfo::GetImports(app_);
for (const auto& shared_module : imports) {
- const extensions::Extension* imported_module =
- service->GetExtensionById(shared_module.extension_id, true);
+ const extensions::Extension* imported_module = registry->GetExtensionById(
+ shared_module.extension_id,
+ extensions::ExtensionRegistry::COMPATIBILITY);
DCHECK(imported_module);
GURL about_page = extensions::ManifestURL::GetAboutPage(imported_module);
diff --git a/chrome/browser/ui/webui/downloads/downloads_list_tracker.cc b/chrome/browser/ui/webui/downloads/downloads_list_tracker.cc
index 8b51693..b270bdb 100644
--- a/chrome/browser/ui/webui/downloads/downloads_list_tracker.cc
+++ b/chrome/browser/ui/webui/downloads/downloads_list_tracker.cc
@@ -21,14 +21,13 @@
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_query.h"
#include "chrome/browser/extensions/api/downloads/downloads_api.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "components/download/public/common/download_danger_type.h"
#include "components/download/public/common/download_item.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/download_item_utils.h"
#include "content/public/browser/download_manager.h"
-#include "extensions/browser/extension_system.h"
+#include "extensions/browser/extension_registry.h"
#include "net/base/filename_util.h"
#include "third_party/icu/source/i18n/unicode/datefmt.h"
#include "ui/base/l10n/time_format.h"
@@ -224,13 +223,11 @@
// Lookup the extension's current name() in case the user changed their
// language. This won't work if the extension was uninstalled, so the name
// might be the wrong language.
- bool include_disabled = true;
auto* profile = Profile::FromBrowserContext(
content::DownloadItemUtils::GetBrowserContext(download_item));
- auto* service =
- extensions::ExtensionSystem::Get(profile)->extension_service();
- const extensions::Extension* extension =
- service->GetExtensionById(by_ext->id(), include_disabled);
+ auto* registry = extensions::ExtensionRegistry::Get(profile);
+ const extensions::Extension* extension = registry->GetExtensionById(
+ by_ext->id(), extensions::ExtensionRegistry::COMPATIBILITY);
if (extension)
by_ext_name = extension->name();
}
diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
index d3ca7d1..ff10ec3 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -488,8 +488,11 @@
CHECK(launch_bucket >= 0 &&
launch_bucket < extension_misc::APP_LAUNCH_BUCKET_BOUNDARY);
+ Profile* profile = extension_service_->profile();
+
const Extension* extension =
- extension_service_->GetExtensionById(extension_id, false);
+ extensions::ExtensionRegistry::Get(profile)->GetExtensionById(
+ extension_id, extensions::ExtensionRegistry::ENABLED);
// Prompt the user to re-enable the application if disabled.
if (!extension) {
@@ -497,8 +500,6 @@
return;
}
- Profile* profile = extension_service_->profile();
-
WindowOpenDisposition disposition =
args->GetSize() > 3 ? webui::GetDispositionFromClick(args, 3)
: WindowOpenDisposition::CURRENT_TAB;
@@ -564,7 +565,9 @@
CHECK(args->GetDouble(1, &launch_type));
const Extension* extension =
- extension_service_->GetExtensionById(extension_id, true);
+ extensions::ExtensionRegistry::Get(extension_service_->profile())
+ ->GetExtensionById(extension_id,
+ extensions::ExtensionRegistry::COMPATIBILITY);
if (!extension)
return;
@@ -616,7 +619,9 @@
CHECK(args->GetString(0, &extension_id));
const Extension* extension =
- extension_service_->GetExtensionById(extension_id, true);
+ extensions::ExtensionRegistry::Get(extension_service_->profile())
+ ->GetExtensionById(extension_id,
+ extensions::ExtensionRegistry::COMPATIBILITY);
if (!extension)
return;
@@ -632,7 +637,9 @@
CHECK(args->GetString(0, &extension_id));
const Extension* extension =
- extension_service_->GetExtensionById(extension_id, true);
+ extensions::ExtensionRegistry::Get(extension_service_->profile())
+ ->GetExtensionById(extension_id,
+ extensions::ExtensionRegistry::COMPATIBILITY);
if (!extension)
return;
@@ -655,7 +662,9 @@
CHECK(args->GetString(0, &extension_id));
const Extension* extension =
- extension_service_->GetExtensionById(extension_id, true);
+ extensions::ExtensionRegistry::Get(extension_service_->profile())
+ ->GetExtensionById(extension_id,
+ extensions::ExtensionRegistry::COMPATIBILITY);
if (!extension)
return;
@@ -863,7 +872,9 @@
// We record the histograms here because ExtensionUninstallCanceled is also
// called when the extension uninstall dialog is canceled.
const Extension* extension =
- extension_service_->GetExtensionById(extension_id_prompting_, true);
+ extensions::ExtensionRegistry::Get(extension_service_->profile())
+ ->GetExtensionById(extension_id_prompting_,
+ extensions::ExtensionRegistry::COMPATIBILITY);
std::string histogram_name = user_initiated ? "ReEnableCancel"
: "ReEnableAbort";
extensions::ExtensionService::RecordPermissionMessagesHistogram(
diff --git a/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc b/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc
index cf5c1ba9..d21278e 100644
--- a/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc
+++ b/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/sync_file_system/sync_file_system_service_factory.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h"
@@ -28,6 +29,10 @@
namespace {
+// TODO(crbug.com/989631): Break this and GetExtensionStatusesAsDictionary
+// into a separate library, so the callbacks can use weak pointers to the
+// calling instances. This will also break the dependency between
+// ExtensionStatusesHandler and FileMetadataHandler.
void ConvertExtensionStatusToDictionary(
const base::WeakPtr<extensions::ExtensionService>& extension_service,
const base::Callback<void(const base::ListValue&)>& callback,
@@ -37,13 +42,17 @@
return;
}
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(extension_service->profile());
+
base::ListValue list;
for (auto itr = status_map.begin(); itr != status_map.end(); ++itr) {
std::string extension_id = itr->first.HostNoBrackets();
// Join with human readable extension name.
const extensions::Extension* extension =
- extension_service->GetExtensionById(extension_id, true);
+ extension_registry->GetExtensionById(
+ extension_id, extensions::ExtensionRegistry::COMPATIBILITY);
if (!extension)
continue;
diff --git a/extensions/browser/extension_registry.h b/extensions/browser/extension_registry.h
index 2d2514b..ac89481 100644
--- a/extensions/browser/extension_registry.h
+++ b/extensions/browser/extension_registry.h
@@ -45,6 +45,11 @@
TERMINATED = 1 << 2,
BLACKLISTED = 1 << 3,
BLOCKED = 1 << 4,
+ // Used for compatibility with ExtensionService::GetExtensionById.
+ // DO NOT USE THIS FOR NEW CODE!
+ // TODO(489687): Analyze uses of this enum and replace them with either a
+ // more-specific one, or EVERYTHING as appropriate.
+ COMPATIBILITY = ENABLED | DISABLED | BLACKLISTED | BLOCKED,
EVERYTHING = (1 << 5) - 1,
};