summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormacourteau <macourteau@chromium.org>2015-01-23 05:24:45 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-23 13:25:34 +0000
commit86b29d845dbb28a0bbd7dcd114447234ce641e0a (patch)
tree7c086a2a5bedcec3c5201eb1574b22cde53abcf9
parenta2afdec49795431c735f668ed8d93129b155d995 (diff)
downloadchromium_src-86b29d845dbb28a0bbd7dcd114447234ce641e0a.zip
chromium_src-86b29d845dbb28a0bbd7dcd114447234ce641e0a.tar.gz
chromium_src-86b29d845dbb28a0bbd7dcd114447234ce641e0a.tar.bz2
Revert of Revert of Use ExtensionRegistry on SetLaunchType instead of ExtensionService (patchset #1 id:1 of https://codereview.chromium.org/860423002/)
Reason for revert: Looks like this CL wasn't the one causing trouble after all. Attempting to re-land. Original issue's description: > 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 > > Committed: https://crrev.com/3f7a8d0427d48dddd9cbdd11d22c602182f9b6b5 > Cr-Commit-Position: refs/heads/master@{#312397} 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/867223002 Cr-Commit-Position: refs/heads/master@{#312828}
-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, 45 insertions, 65 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 5ea5e69..59c61d6 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,7 +34,6 @@
#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"
@@ -375,9 +374,8 @@ 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(
- extensions::ExtensionSystem::Get(profile())->extension_service(),
- app->id(), extensions::LAUNCH_TYPE_WINDOW);
+ extensions::SetLaunchType(profile(), 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 ad32f10..23a0df4 100644
--- a/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc
+++ b/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc
@@ -301,9 +301,7 @@ void ChromeManagementAPIDelegate::SetLaunchType(
content::BrowserContext* context,
const std::string& extension_id,
extensions::LaunchType launch_type) const {
- extensions::SetLaunchType(
- extensions::ExtensionSystem::Get(context)->extension_service(),
- extension_id, launch_type);
+ extensions::SetLaunchType(context, 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 9b0f132..f0ba11c 100644
--- a/chrome/browser/extensions/api/management/management_apitest.cc
+++ b/chrome/browser/extensions/api/management/management_apitest.cc
@@ -240,7 +240,8 @@ 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(service, app_id, extensions::LAUNCH_TYPE_REGULAR);
+ extensions::SetLaunchType(browser()->profile(), app_id,
+ extensions::LAUNCH_TYPE_REGULAR);
// Load the extension again.
std::string app_id_new;
@@ -299,7 +300,8 @@ 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(service, app_id, extensions::LAUNCH_TYPE_WINDOW);
+ extensions::SetLaunchType(browser()->profile(), 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 cd8d3aa..ccb04ec 100644
--- a/chrome/browser/extensions/extension_sync_service.cc
+++ b/chrome/browser/extensions/extension_sync_service.cc
@@ -88,8 +88,9 @@ ExtensionSyncService::ExtensionSyncService(Profile* profile,
ExtensionSyncService::~ExtensionSyncService() {}
// static
-ExtensionSyncService* ExtensionSyncService::Get(Profile* profile) {
- return ExtensionSyncServiceFactory::GetForProfile(profile);
+ExtensionSyncService* ExtensionSyncService::Get(
+ content::BrowserContext* context) {
+ return ExtensionSyncServiceFactory::GetForBrowserContext(context);
}
syncer::SyncChange ExtensionSyncService::PrepareToSyncUninstallExtension(
@@ -346,8 +347,7 @@ 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(extension_service_, id,
- app_sync_data.launch_type());
+ extensions::SetLaunchType(profile_, 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 0b359d7..9efb52d 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 Profile.
- static ExtensionSyncService* Get(Profile* profile);
+ // Convenience function to get the ExtensionSyncService for a BrowserContext.
+ static ExtensionSyncService* Get(content::BrowserContext* context);
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 23b0c132..ea97ca3 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::GetForProfile(
- Profile* profile) {
+ExtensionSyncService* ExtensionSyncServiceFactory::GetForBrowserContext(
+ content::BrowserContext* context) {
return static_cast<ExtensionSyncService*>(
- GetInstance()->GetServiceForBrowserContext(profile, true));
+ GetInstance()->GetServiceForBrowserContext(context, true));
}
// static
diff --git a/chrome/browser/extensions/extension_sync_service_factory.h b/chrome/browser/extensions/extension_sync_service_factory.h
index 2edba18..82a36d2 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* GetForProfile(Profile* profile);
+ static ExtensionSyncService* GetForBrowserContext(
+ content::BrowserContext* context);
static ExtensionSyncServiceFactory* GetInstance();
@@ -25,7 +25,7 @@ class ExtensionSyncServiceFactory : public BrowserContextKeyedServiceFactory {
~ExtensionSyncServiceFactory() override;
KeyedService* BuildServiceInstanceFor(
- content::BrowserContext* profile) const override;
+ content::BrowserContext* context) 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 82b75dc..2f30d67 100644
--- a/chrome/browser/extensions/launch_util.cc
+++ b/chrome/browser/extensions/launch_util.cc
@@ -5,7 +5,6 @@
#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"
@@ -13,6 +12,7 @@
#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,22 +59,21 @@ LaunchType GetLaunchTypePrefValue(const ExtensionPrefs* prefs,
? static_cast<LaunchType>(value) : LAUNCH_TYPE_INVALID;
}
-void SetLaunchType(ExtensionService* service,
+void SetLaunchType(content::BrowserContext* context,
const std::string& extension_id,
LaunchType launch_type) {
DCHECK(launch_type >= LAUNCH_TYPE_FIRST && launch_type < NUM_LAUNCH_TYPES);
- ExtensionPrefs::Get(service->profile())->UpdateExtensionPref(
- extension_id,
- kPrefLaunchType,
+ ExtensionPrefs::Get(context)->UpdateExtensionPref(
+ extension_id, kPrefLaunchType,
new base::FundamentalValue(static_cast<int>(launch_type)));
// Sync the launch type.
- const Extension* extension = service->GetInstalledExtension(extension_id);
- if (extension) {
- ExtensionSyncService::Get(service->profile())->
- SyncExtensionChangeIfNeeded(*extension);
- }
+ const Extension* extension =
+ ExtensionRegistry::Get(context)
+ ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING);
+ if (extension)
+ ExtensionSyncService::Get(context)->SyncExtensionChangeIfNeeded(*extension);
}
LaunchContainer GetLaunchContainer(const ExtensionPrefs* prefs,
diff --git a/chrome/browser/extensions/launch_util.h b/chrome/browser/extensions/launch_util.h
index 3cf2641..9b0b294 100644
--- a/chrome/browser/extensions/launch_util.h
+++ b/chrome/browser/extensions/launch_util.h
@@ -9,7 +9,9 @@
#include "extensions/common/constants.h"
-class ExtensionService;
+namespace content {
+class BrowserContext;
+}
namespace user_prefs {
class PrefRegistrySyncable;
@@ -38,7 +40,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(ExtensionService* prefs,
+void SetLaunchType(content::BrowserContext* context,
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 58d590a..cbdac9c 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,21 +366,17 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateLaunchType) {
ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
// Change the launch type to window.
- extensions::SetLaunchType(GetExtensionService(GetProfile(1)),
- extensions::kWebStoreAppId,
+ extensions::SetLaunchType(GetProfile(1), extensions::kWebStoreAppId,
extensions::LAUNCH_TYPE_WINDOW);
- extensions::SetLaunchType(GetExtensionService(verifier()),
- extensions::kWebStoreAppId,
+ extensions::SetLaunchType(verifier(), extensions::kWebStoreAppId,
extensions::LAUNCH_TYPE_WINDOW);
ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier());
// Change the launch type to regular tab.
- extensions::SetLaunchType(GetExtensionService(GetProfile(1)),
- extensions::kWebStoreAppId,
+ extensions::SetLaunchType(GetProfile(1), extensions::kWebStoreAppId,
extensions::LAUNCH_TYPE_REGULAR);
ASSERT_FALSE(HasSameAppsAsVerifier(1));
- extensions::SetLaunchType(GetExtensionService(verifier()),
- extensions::kWebStoreAppId,
+ extensions::SetLaunchType(verifier(), extensions::kWebStoreAppId,
extensions::LAUNCH_TYPE_REGULAR);
ASSERT_TRUE(AwaitAllProfilesHaveSameAppsAsVerifier());
}
@@ -389,11 +385,9 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UnexpectedLaunchType) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
- extensions::SetLaunchType(GetExtensionService(GetProfile(1)),
- extensions::kWebStoreAppId,
+ extensions::SetLaunchType(GetProfile(1), extensions::kWebStoreAppId,
extensions::LAUNCH_TYPE_REGULAR);
- extensions::SetLaunchType(GetExtensionService(verifier()),
- extensions::kWebStoreAppId,
+ extensions::SetLaunchType(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 318ec8a..e93132b 100644
--- a/chrome/browser/ui/app_list/app_list_controller_delegate.cc
+++ b/chrome/browser/ui/app_list/app_list_controller_delegate.cc
@@ -188,10 +188,7 @@ void AppListControllerDelegate::SetExtensionLaunchType(
Profile* profile,
const std::string& extension_id,
extensions::LaunchType launch_type) {
- ExtensionService* service =
- extensions::ExtensionSystem::Get(profile)->extension_service();
- extensions::SetLaunchType(
- service, extension_id, launch_type);
+ extensions::SetLaunchType(profile, 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 2846cb7c..b036635 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
@@ -883,10 +883,7 @@ void ChromeLauncherController::SetLaunchType(
if (!controller)
return;
- extensions::SetLaunchType(
- extensions::ExtensionSystem::Get(profile_)->extension_service(),
- controller->app_id(),
- launch_type);
+ extensions::SetLaunchType(profile_, 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 456a27e..c03fc97 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(service, extension_id, launch_type);
+ extensions::SetLaunchType(profile, 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 2aea5d5..ea89f45 100644
--- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
@@ -127,9 +127,7 @@ class StartupBrowserCreatorTest : public ExtensionBrowserTest {
void SetAppLaunchPref(const std::string& app_id,
extensions::LaunchType launch_type) {
- ExtensionService* service = extensions::ExtensionSystem::Get(
- browser()->profile())->extension_service();
- extensions::SetLaunchType(service, app_id, launch_type);
+ extensions::SetLaunchType(browser()->profile(), 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 44afa03..e88693f 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,9 +302,7 @@ extensions::LaunchType AppInfoSummaryPanel::GetLaunchType() const {
void AppInfoSummaryPanel::SetLaunchType(
extensions::LaunchType launch_type) const {
DCHECK(CanSetLaunchType());
- ExtensionService* service =
- extensions::ExtensionSystem::Get(profile_)->extension_service();
- extensions::SetLaunchType(service, app_->id(), launch_type);
+ extensions::SetLaunchType(profile_, 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 6f570920..88fe50f 100644
--- a/chrome/browser/ui/views/extensions/bookmark_app_bubble_view.cc
+++ b/chrome/browser/ui/views/extensions/bookmark_app_bubble_view.cc
@@ -266,9 +266,7 @@ void BookmarkAppBubbleView::ApplyEdits() {
: extensions::LAUNCH_TYPE_WINDOW;
profile_->GetPrefs()->SetInteger(
extensions::pref_names::kBookmarkAppCreationLaunchType, launch_type);
- extensions::SetLaunchType(GetExtensionService(profile_),
- extension_id_,
- launch_type);
+ extensions::SetLaunchType(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 5e243bf..9f336ec 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -565,8 +565,7 @@ void AppLauncherHandler::HandleSetLaunchType(const base::ListValue* args) {
base::AutoReset<bool> auto_reset(&ignore_changes_, true);
extensions::SetLaunchType(
- extension_service_,
- extension_id,
+ Profile::FromWebUI(web_ui()), extension_id,
static_cast<extensions::LaunchType>(static_cast<int>(launch_type)));
}