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

Unified Diff: chrome/browser/extensions/extension_system_factory.cc

Issue 9369013: Take extensions out of Profile into a profile-keyed service, ExtensionSystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_system_factory.cc
diff --git a/chrome/browser/extensions/extension_system_factory.cc b/chrome/browser/extensions/extension_system_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5c5cc70eccd92893e419072f9363b33d80aae497
--- /dev/null
+++ b/chrome/browser/extensions/extension_system_factory.cc
@@ -0,0 +1,88 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/extension_system_factory.h"
+
+#include "chrome/browser/extensions/extension_message_service.h"
+#include "chrome/browser/extensions/extension_prefs.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_dependency_manager.h"
+
+// ExtensionSystemDelegateFactory
+
+// static
+ExtensionSystemImpl::Delegate* ExtensionSystemDelegateFactory::GetForProfile(
+ Profile* profile) {
+ return static_cast<ExtensionSystemImpl::Delegate*>(
+ GetInstance()->GetServiceForProfile(profile, true));
+}
+
+// static
+ExtensionSystemDelegateFactory* ExtensionSystemDelegateFactory::GetInstance() {
+ return Singleton<ExtensionSystemDelegateFactory>::get();
+}
+
+ProfileKeyedService* ExtensionSystemDelegateFactory::BuildServiceInstanceFor(
+ Profile* profile) const {
+ return new ExtensionSystemImpl::Delegate(profile->GetOriginalProfile());
Elliot Glaysher 2012/02/09 20:10:24 Since this is redirected in incognito, I'm pretty
Yoyo Zhou 2012/02/16 21:49:20 Done.
+}
+
+bool ExtensionSystemDelegateFactory::ServiceRedirectedInIncognito() {
+ return true;
+}
+
+void ExtensionSystemDelegateFactory::ProfileShutdown(Profile* profile) {
+ if (GetForProfile(profile)->message_service())
+ GetForProfile(profile)->message_service()->DestroyingProfile();
Elliot Glaysher 2012/02/09 20:10:24 You probably want this in you ExtensionService::Sh
Yoyo Zhou 2012/02/16 21:49:20 Ah... I didn't read profile_keyed_service.h. This
+ ProfileKeyedServiceFactory::ProfileShutdown(profile);
+}
+
+ExtensionSystemDelegateFactory::ExtensionSystemDelegateFactory()
+ : ProfileKeyedServiceFactory(
+ "ExtensionSystemDelegate",
+ ProfileDependencyManager::GetInstance()) {
Elliot Glaysher 2012/02/09 20:10:24 I assume that either ExtensionSystemDelegateFactor
Yoyo Zhou 2012/02/16 21:49:20 I only found reference to 3 factories, all from Ex
+}
+
+ExtensionSystemDelegateFactory::~ExtensionSystemDelegateFactory() {
+}
+
+// ExtensionSystemFactory
+
+// static
+ExtensionSystem* ExtensionSystemFactory::GetForProfile(
+ Profile* profile) {
+ return static_cast<ExtensionSystem*>(
+ GetInstance()->GetServiceForProfile(profile, true));
+}
+
+// static
+ExtensionSystemFactory* ExtensionSystemFactory::GetInstance() {
+ return Singleton<ExtensionSystemFactory>::get();
+}
+
+ProfileKeyedService* ExtensionSystemFactory::BuildServiceInstanceFor(
+ Profile* profile) const {
+ return new ExtensionSystemImpl(profile);
+}
+
+bool ExtensionSystemFactory::ServiceHasOwnInstanceInIncognito() {
+ return true;
+}
+
+void ExtensionSystemFactory::ProfileShutdown(Profile* profile) {
+ GetForProfile(profile)->DestroyProcessManager();
Elliot Glaysher 2012/02/09 20:10:24 Same as above.
Yoyo Zhou 2012/02/16 21:49:20 Done.
+ ProfileKeyedServiceFactory::ProfileShutdown(profile);
+}
+
+ExtensionSystemFactory::ExtensionSystemFactory()
+ : ProfileKeyedServiceFactory(
+ "ExtensionSystem",
+ ProfileDependencyManager::GetInstance()) {
+ DependsOn(ExtensionSystemDelegateFactory::GetInstance());
+}
+
+ExtensionSystemFactory::~ExtensionSystemFactory() {
+}

Powered by Google App Engine
This is Rietveld 408576698