summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormacourteau <macourteau@chromium.org>2015-01-21 08:41:47 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-21 16:42:45 +0000
commit3f7a8d0427d48dddd9cbdd11d22c602182f9b6b5 (patch)
tree6d4174bdf01ffbbc58525ff65728d7a1b5b93044
parentfb5251d1ff4f36ea296da4be72ddf26a9e3e5643 (diff)
downloadchromium_src-3f7a8d0427d48dddd9cbdd11d22c602182f9b6b5.zip
chromium_src-3f7a8d0427d48dddd9cbdd11d22c602182f9b6b5.tar.gz
chromium_src-3f7a8d0427d48dddd9cbdd11d22c602182f9b6b5.tar.bz2
Revert of Use ExtensionRegistry on SetLaunchType instead of ExtensionService (patchset #2 id:60001 of https://codereview.chromium.org/836473007/)
Reason for revert: Speculative revert, seems to have broken lots of sync_integration_tests: http://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%281%29/builds/34622 Original issue's description: > Use ExtensionRegistry on SetLaunchType instead of ExtensionService > > Part of the refactoring of moving calls querying extensions from > the ExtensionService to ExtensionRegistry. > > BUG=332979 > > Committed: https://crrev.com/d892fde82106439d8ca5dd8bdf07ac2462558677 > Cr-Commit-Position: refs/heads/master@{#312364} TBR=yoz@chromium.org,jamescook@chromium.org,thestig@chromium.org,thiago.santos@intel.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=332979 Review URL: https://codereview.chromium.org/860423002 Cr-Commit-Position: refs/heads/master@{#312397}
-rw-r--r--chrome/browser/apps/app_shim/app_shim_interactive_uitest_mac.mm6
-rw-r--r--chrome/browser/extensions/api/management/chrome_management_api_delegate.cc4
-rw-r--r--chrome/browser/extensions/api/management/management_apitest.cc6
-rw-r--r--chrome/browser/extensions/extension_sync_service.cc8
-rw-r--r--chrome/browser/extensions/extension_sync_service.h4
-rw-r--r--chrome/browser/extensions/extension_sync_service_factory.cc6
-rw-r--r--chrome/browser/extensions/extension_sync_service_factory.h6
-rw-r--r--chrome/browser/extensions/launch_util.cc19
-rw-r--r--chrome/browser/extensions/launch_util.h6
-rw-r--r--chrome/browser/sync/test/integration/two_client_apps_sync_test.cc18
-rw-r--r--chrome/browser/ui/app_list/app_list_controller_delegate.cc5
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc5
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.mm2
-rw-r--r--chrome/browser/ui/startup/startup_browser_creator_browsertest.cc4
-rw-r--r--chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_panel.cc4
-rw-r--r--chrome/browser/ui/views/extensions/bookmark_app_bubble_view.cc4
-rw-r--r--chrome/browser/ui/webui/ntp/app_launcher_handler.cc3
17 files changed, 65 insertions, 45 deletions
diff --git a/chrome/browser/apps/app_shim/app_shim_interactive_uitest_mac.mm b/chrome/browser/apps/app_shim/app_shim_interactive_uitest_mac.mm
index 59c61d6..5ea5e69 100644
--- a/chrome/browser/apps/app_shim/app_shim_interactive_uitest_mac.mm
+++ b/chrome/browser/apps/app_shim/app_shim_interactive_uitest_mac.mm
@@ -34,6 +34,7 @@
#include "content/public/test/test_utils.h"
#include "extensions/browser/app_window/native_app_window.h"
#include "extensions/browser/extension_prefs.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/test/extension_test_message_listener.h"
#import "ui/events/test/cocoa_test_event_utils.h"
@@ -374,8 +375,9 @@ IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, MAYBE_HostedAppLaunch) {
NSString* bundle_id = GetBundleID(shim_path);
// Explicitly set the launch type to open in a new window.
- extensions::SetLaunchType(profile(), app->id(),
- extensions::LAUNCH_TYPE_WINDOW);
+ extensions::SetLaunchType(
+ extensions::ExtensionSystem::Get(profile())->extension_service(),
+ app->id(), extensions::LAUNCH_TYPE_WINDOW);
// Case 1: Launch the hosted app, it should start the shim.
{
diff --git a/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc b/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc
index 23a0df4..ad32f10 100644
--- a/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc
+++ b/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc
@@ -301,7 +301,9 @@ void ChromeManagementAPIDelegate::SetLaunchType(
content::BrowserContext* context,
const std::string& extension_id,
extensions::LaunchType launch_type) const {
- extensions::SetLaunchType(context, extension_id, launch_type);
+ extensions::SetLaunchType(
+ extensions::ExtensionSystem::Get(context)->extension_service(),
+ extension_id, launch_type);
}
GURL ChromeManagementAPIDelegate::GetIconURL(
diff --git a/chrome/browser/extensions/api/management/management_apitest.cc b/chrome/browser/extensions/api/management/management_apitest.cc
index f0ba11c..9b0f132 100644
--- a/chrome/browser/extensions/api/management/management_apitest.cc
+++ b/chrome/browser/extensions/api/management/management_apitest.cc
@@ -240,8 +240,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, DISABLED_LaunchPanelApp) {
// 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.
- extensions::SetLaunchType(browser()->profile(), app_id,
- extensions::LAUNCH_TYPE_REGULAR);
+ extensions::SetLaunchType(service, app_id, extensions::LAUNCH_TYPE_REGULAR);
// Load the extension again.
std::string app_id_new;
@@ -300,8 +299,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, MAYBE_LaunchTabApp) {
ASSERT_FALSE(service->GetExtensionById(app_id, true));
// Set a pref indicating that the user wants to launch in a window.
- extensions::SetLaunchType(browser()->profile(), app_id,
- extensions::LAUNCH_TYPE_WINDOW);
+ extensions::SetLaunchType(service, app_id, extensions::LAUNCH_TYPE_WINDOW);
std::string app_id_new;
LoadAndWaitForLaunch("management/launch_app_tab", &app_id_new);
diff --git a/chrome/browser/extensions/extension_sync_service.cc b/chrome/browser/extensions/extension_sync_service.cc
index ccb04ec..cd8d3aa 100644
--- a/chrome/browser/extensions/extension_sync_service.cc
+++ b/chrome/browser/extensions/extension_sync_service.cc
@@ -88,9 +88,8 @@ ExtensionSyncService::ExtensionSyncService(Profile* profile,
ExtensionSyncService::~ExtensionSyncService() {}
// static
-ExtensionSyncService* ExtensionSyncService::Get(
- content::BrowserContext* context) {
- return ExtensionSyncServiceFactory::GetForBrowserContext(context);
+ExtensionSyncService* ExtensionSyncService::Get(Profile* profile) {
+ return ExtensionSyncServiceFactory::GetForProfile(profile);
}
syncer::SyncChange ExtensionSyncService::PrepareToSyncUninstallExtension(
@@ -347,7 +346,8 @@ bool ExtensionSyncService::ProcessAppSyncData(
// is in AppSyncData::PopulateAppSpecifics.
if (app_sync_data.launch_type() >= extensions::LAUNCH_TYPE_FIRST &&
app_sync_data.launch_type() < extensions::NUM_LAUNCH_TYPES) {
- extensions::SetLaunchType(profile_, id, app_sync_data.launch_type());
+ extensions::SetLaunchType(extension_service_, id,
+ app_sync_data.launch_type());
}
if (!app_sync_data.bookmark_app_url().empty())
diff --git a/chrome/browser/extensions/extension_sync_service.h b/chrome/browser/extensions/extension_sync_service.h
index 9efb52d..0b359d7 100644
--- a/chrome/browser/extensions/extension_sync_service.h
+++ b/chrome/browser/extensions/extension_sync_service.h
@@ -45,8 +45,8 @@ class ExtensionSyncService : public syncer::SyncableService,
~ExtensionSyncService() override;
- // Convenience function to get the ExtensionSyncService for a BrowserContext.
- static ExtensionSyncService* Get(content::BrowserContext* context);
+ // Convenience function to get the ExtensionSyncService for a Profile.
+ static ExtensionSyncService* Get(Profile* profile);
const extensions::ExtensionPrefs& extension_prefs() const {
return *extension_prefs_;
diff --git a/chrome/browser/extensions/extension_sync_service_factory.cc b/chrome/browser/extensions/extension_sync_service_factory.cc
index ea97ca3..23b0c132 100644
--- a/chrome/browser/extensions/extension_sync_service_factory.cc
+++ b/chrome/browser/extensions/extension_sync_service_factory.cc
@@ -14,10 +14,10 @@
#include "extensions/browser/extensions_browser_client.h"
// static
-ExtensionSyncService* ExtensionSyncServiceFactory::GetForBrowserContext(
- content::BrowserContext* context) {
+ExtensionSyncService* ExtensionSyncServiceFactory::GetForProfile(
+ Profile* profile) {
return static_cast<ExtensionSyncService*>(
- GetInstance()->GetServiceForBrowserContext(context, true));
+ GetInstance()->GetServiceForBrowserContext(profile, true));
}
// static
diff --git a/chrome/browser/extensions/extension_sync_service_factory.h b/chrome/browser/extensions/extension_sync_service_factory.h
index 82a36d2..2edba18 100644
--- a/chrome/browser/extensions/extension_sync_service_factory.h
+++ b/chrome/browser/extensions/extension_sync_service_factory.h
@@ -10,11 +10,11 @@
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
class ExtensionSyncService;
+class Profile;
class ExtensionSyncServiceFactory : public BrowserContextKeyedServiceFactory {
public:
- static ExtensionSyncService* GetForBrowserContext(
- content::BrowserContext* context);
+ static ExtensionSyncService* GetForProfile(Profile* profile);
static ExtensionSyncServiceFactory* GetInstance();
@@ -25,7 +25,7 @@ class ExtensionSyncServiceFactory : public BrowserContextKeyedServiceFactory {
~ExtensionSyncServiceFactory() override;
KeyedService* BuildServiceInstanceFor(
- content::BrowserContext* context) const override;
+ content::BrowserContext* profile) const override;
content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const override;
};
diff --git a/chrome/browser/extensions/launch_util.cc b/chrome/browser/extensions/launch_util.cc
index 2f30d67..82b75dc 100644
--- a/chrome/browser/extensions/launch_util.cc
+++ b/chrome/browser/extensions/launch_util.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/extensions/launch_util.h"
#include "base/values.h"
+#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_sync_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/host_desktop.h"
@@ -12,7 +13,6 @@
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "extensions/browser/extension_prefs.h"
-#include "extensions/browser/extension_registry.h"
#include "extensions/browser/pref_names.h"
#include "extensions/common/extension.h"
@@ -59,21 +59,22 @@ LaunchType GetLaunchTypePrefValue(const ExtensionPrefs* prefs,
? static_cast<LaunchType>(value) : LAUNCH_TYPE_INVALID;
}
-void SetLaunchType(content::BrowserContext* context,
+void SetLaunchType(ExtensionService* service,
const std::string& extension_id,
LaunchType launch_type) {
DCHECK(launch_type >= LAUNCH_TYPE_FIRST && launch_type < NUM_LAUNCH_TYPES);
- ExtensionPrefs::Get(context)->UpdateExtensionPref(
- extension_id, kPrefLaunchType,
+ ExtensionPrefs::Get(service->profile())->UpdateExtensionPref(
+ extension_id,
+ kPrefLaunchType,
new base::FundamentalValue(static_cast<int>(launch_type)));
// Sync the launch type.
- const Extension* extension =
- ExtensionRegistry::Get(context)
- ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING);
- if (extension)
- ExtensionSyncService::Get(context)->SyncExtensionChangeIfNeeded(*extension);
+ const Extension* extension = service->GetInstalledExtension(extension_id);
+ if (extension) {
+ ExtensionSyncService::Get(service->profile())->
+ SyncExtensionChangeIfNeeded(*extension);
+ }
}
LaunchContainer GetLaunchContainer(const ExtensionPrefs* prefs,
diff --git a/chrome/browser/extensions/launch_util.h b/chrome/browser/extensions/launch_util.h
index 9b0b294..3cf2641 100644
--- a/chrome/browser/extensions/launch_util.h
+++ b/chrome/browser/extensions/launch_util.h
@@ -9,9 +9,7 @@
#include "extensions/common/constants.h"
-namespace content {
-class BrowserContext;
-}
+class ExtensionService;
namespace user_prefs {
class PrefRegistrySyncable;
@@ -40,7 +38,7 @@ LaunchType GetLaunchTypePrefValue(const ExtensionPrefs* prefs,
const std::string& extension_id);
// Sets an extension's launch type preference and syncs the value if necessary.
-void SetLaunchType(content::BrowserContext* context,
+void SetLaunchType(ExtensionService* prefs,
const std::string& extension_id,
LaunchType launch_type);
diff --git a/chrome/browser/sync/test/integration/two_client_apps_sync_test.cc b/chrome/browser/sync/test/integration/two_client_apps_sync_test.cc
index cbdac9c..58d590a 100644
--- a/chrome/browser/sync/test/integration/two_client_apps_sync_test.cc
+++ b/chrome/browser/sync/test/integration/two_client_apps_sync_test.cc
@@ -366,17 +366,21 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateLaunchType) {
ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
// Change the launch type to window.
- extensions::SetLaunchType(GetProfile(1), extensions::kWebStoreAppId,
+ extensions::SetLaunchType(GetExtensionService(GetProfile(1)),
+ extensions::kWebStoreAppId,
extensions::LAUNCH_TYPE_WINDOW);
- extensions::SetLaunchType(verifier(), extensions::kWebStoreAppId,
+ extensions::SetLaunchType(GetExtensionService(verifier()),
+ extensions::kWebStoreAppId,
extensions::LAUNCH_TYPE_WINDOW);
ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier());
// Change the launch type to regular tab.
- extensions::SetLaunchType(GetProfile(1), extensions::kWebStoreAppId,
+ extensions::SetLaunchType(GetExtensionService(GetProfile(1)),
+ extensions::kWebStoreAppId,
extensions::LAUNCH_TYPE_REGULAR);
ASSERT_FALSE(HasSameAppsAsVerifier(1));
- extensions::SetLaunchType(verifier(), extensions::kWebStoreAppId,
+ extensions::SetLaunchType(GetExtensionService(verifier()),
+ extensions::kWebStoreAppId,
extensions::LAUNCH_TYPE_REGULAR);
ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier());
}
@@ -385,9 +389,11 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UnexpectedLaunchType) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
- extensions::SetLaunchType(GetProfile(1), extensions::kWebStoreAppId,
+ extensions::SetLaunchType(GetExtensionService(GetProfile(1)),
+ extensions::kWebStoreAppId,
extensions::LAUNCH_TYPE_REGULAR);
- extensions::SetLaunchType(verifier(), extensions::kWebStoreAppId,
+ extensions::SetLaunchType(GetExtensionService(verifier()),
+ extensions::kWebStoreAppId,
extensions::LAUNCH_TYPE_REGULAR);
ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier());
diff --git a/chrome/browser/ui/app_list/app_list_controller_delegate.cc b/chrome/browser/ui/app_list/app_list_controller_delegate.cc
index e93132b..318ec8a 100644
--- a/chrome/browser/ui/app_list/app_list_controller_delegate.cc
+++ b/chrome/browser/ui/app_list/app_list_controller_delegate.cc
@@ -188,7 +188,10 @@ void AppListControllerDelegate::SetExtensionLaunchType(
Profile* profile,
const std::string& extension_id,
extensions::LaunchType launch_type) {
- extensions::SetLaunchType(profile, extension_id, launch_type);
+ ExtensionService* service =
+ extensions::ExtensionSystem::Get(profile)->extension_service();
+ extensions::SetLaunchType(
+ service, extension_id, launch_type);
}
bool AppListControllerDelegate::IsExtensionInstalled(
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
index b036635..2846cb7c 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
@@ -883,7 +883,10 @@ void ChromeLauncherController::SetLaunchType(
if (!controller)
return;
- extensions::SetLaunchType(profile_, controller->app_id(), launch_type);
+ extensions::SetLaunchType(
+ extensions::ExtensionSystem::Get(profile_)->extension_service(),
+ controller->app_id(),
+ launch_type);
}
void ChromeLauncherController::UnpinAppWithID(const std::string& app_id) {
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
index c03fc97..456a27e 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
@@ -565,7 +565,7 @@ void BrowserWindowCocoa::ShowBookmarkAppBubble(
: extensions::LAUNCH_TYPE_WINDOW;
profile->GetPrefs()->SetInteger(
extensions::pref_names::kBookmarkAppCreationLaunchType, launch_type);
- extensions::SetLaunchType(profile, extension_id, launch_type);
+ extensions::SetLaunchType(service, extension_id, launch_type);
// Update name of app.
NSString* new_title = [app_title stringValue];
diff --git a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
index ea89f45..2aea5d5 100644
--- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
@@ -127,7 +127,9 @@ class StartupBrowserCreatorTest : public ExtensionBrowserTest {
void SetAppLaunchPref(const std::string& app_id,
extensions::LaunchType launch_type) {
- extensions::SetLaunchType(browser()->profile(), app_id, launch_type);
+ ExtensionService* service = extensions::ExtensionSystem::Get(
+ browser()->profile())->extension_service();
+ extensions::SetLaunchType(service, app_id, launch_type);
}
Browser* FindOneOtherBrowserForProfile(Profile* profile,
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 e88693f..44afa03 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
@@ -302,7 +302,9 @@ extensions::LaunchType AppInfoSummaryPanel::GetLaunchType() const {
void AppInfoSummaryPanel::SetLaunchType(
extensions::LaunchType launch_type) const {
DCHECK(CanSetLaunchType());
- extensions::SetLaunchType(profile_, app_->id(), launch_type);
+ ExtensionService* service =
+ extensions::ExtensionSystem::Get(profile_)->extension_service();
+ extensions::SetLaunchType(service, app_->id(), launch_type);
}
bool AppInfoSummaryPanel::CanSetLaunchType() const {
diff --git a/chrome/browser/ui/views/extensions/bookmark_app_bubble_view.cc b/chrome/browser/ui/views/extensions/bookmark_app_bubble_view.cc
index 88fe50f..6f570920 100644
--- a/chrome/browser/ui/views/extensions/bookmark_app_bubble_view.cc
+++ b/chrome/browser/ui/views/extensions/bookmark_app_bubble_view.cc
@@ -266,7 +266,9 @@ void BookmarkAppBubbleView::ApplyEdits() {
: extensions::LAUNCH_TYPE_WINDOW;
profile_->GetPrefs()->SetInteger(
extensions::pref_names::kBookmarkAppCreationLaunchType, launch_type);
- extensions::SetLaunchType(profile_, extension_id_, launch_type);
+ extensions::SetLaunchType(GetExtensionService(profile_),
+ extension_id_,
+ launch_type);
const extensions::Extension* extension =
extensions::ExtensionRegistry::Get(profile_)->GetExtensionById(
diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
index 9f336ec..5e243bf 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -565,7 +565,8 @@ void AppLauncherHandler::HandleSetLaunchType(const base::ListValue* args) {
base::AutoReset<bool> auto_reset(&ignore_changes_, true);
extensions::SetLaunchType(
- Profile::FromWebUI(web_ui()), extension_id,
+ extension_service_,
+ extension_id,
static_cast<extensions::LaunchType>(static_cast<int>(launch_type)));
}