summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-15 09:21:12 +0000
committeryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-15 09:21:12 +0000
commit2d30d04ecb2e82011ce317f855967cf7f4cc5213 (patch)
tree9c1a640683e27200139fe15f04a90dd0f52fc919
parent08d7b2796ca0ee39154410a76fb298e1bda23fea (diff)
downloadchromium_src-2d30d04ecb2e82011ce317f855967cf7f4cc5213.zip
chromium_src-2d30d04ecb2e82011ce317f855967cf7f4cc5213.tar.gz
chromium_src-2d30d04ecb2e82011ce317f855967cf7f4cc5213.tar.bz2
Make ExtensionPrefs a ProfileKeyedService.
BUG=178218 TBR=asargent@chromium.org Review URL: https://chromiumcodereview.appspot.com/14999009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200220 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--apps/app_restore_service_browsertest.cc10
-rw-r--r--chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc4
-rw-r--r--chrome/browser/extensions/api/permissions/permissions_api.cc29
-rw-r--r--chrome/browser/extensions/event_router.cc14
-rw-r--r--chrome/browser/extensions/extension_prefs.cc41
-rw-r--r--chrome/browser/extensions/extension_prefs.h30
-rw-r--r--chrome/browser/extensions/extension_prefs_factory.cc63
-rw-r--r--chrome/browser/extensions/extension_prefs_factory.h39
-rw-r--r--chrome/browser/extensions/extension_process_manager.cc3
-rw-r--r--chrome/browser/extensions/extension_service.cc3
-rw-r--r--chrome/browser/extensions/extension_service.h4
-rw-r--r--chrome/browser/extensions/extension_service_unittest.cc2
-rw-r--r--chrome/browser/extensions/extension_system.cc38
-rw-r--r--chrome/browser/extensions/extension_system.h13
-rw-r--r--chrome/browser/extensions/extension_system_factory.cc4
-rw-r--r--chrome/browser/extensions/extension_toolbar_model_browsertest.cc4
-rw-r--r--chrome/browser/extensions/permissions_updater.cc12
-rw-r--r--chrome/browser/extensions/platform_app_launcher.cc2
-rw-r--r--chrome/browser/extensions/test_extension_prefs.cc4
-rw-r--r--chrome/browser/extensions/test_extension_system.cc26
-rw-r--r--chrome/browser/extensions/test_extension_system.h5
-rw-r--r--chrome/browser/media_galleries/media_galleries_test_util.cc12
-rw-r--r--chrome/browser/profiles/profile_dependency_manager.cc2
-rw-r--r--chrome/browser/ui/panels/base_panel_browser_test.cc10
-rw-r--r--chrome/browser/ui/panels/panel_browsertest.cc4
-rw-r--r--chrome/browser/ui/panels/stacked_panel_browsertest.cc4
-rw-r--r--chrome/chrome_browser_extensions.gypi2
-rw-r--r--extensions/common/constants.cc2
-rw-r--r--extensions/common/constants.h4
29 files changed, 238 insertions, 152 deletions
diff --git a/apps/app_restore_service_browsertest.cc b/apps/app_restore_service_browsertest.cc
index a335617e..ce800a4 100644
--- a/apps/app_restore_service_browsertest.cc
+++ b/apps/app_restore_service_browsertest.cc
@@ -7,8 +7,6 @@
#include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
#include "chrome/browser/extensions/api/file_system/file_system_api.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/extensions/extension_test_message_listener.h"
#include "chrome/browser/extensions/platform_app_browsertest_util.h"
#include "chrome/common/extensions/extension.h"
@@ -35,9 +33,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) {
const Extension* extension = LoadExtension(
test_data_dir_.AppendASCII("platform_apps/restart_test"));
ASSERT_TRUE(extension);
- ExtensionService* extension_service =
- ExtensionSystem::Get(browser()->profile())->extension_service();
- ExtensionPrefs* extension_prefs = extension_service->extension_prefs();
+ ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(browser()->profile());
// App is running.
ASSERT_TRUE(extension_prefs->IsExtensionRunning(extension->id()));
@@ -83,7 +79,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, FileAccessIsSavedToPrefs) {
file_written_listener.WaitUntilSatisfied();
ExtensionPrefs* extension_prefs =
- ExtensionSystem::Get(browser()->profile())->extension_prefs();
+ ExtensionPrefs::Get(browser()->profile());
// Record the file entries in prefs because when the app gets suspended it
// will have them all cleared.
@@ -127,7 +123,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, FileAccessIsRestored) {
file_written_listener.WaitUntilSatisfied();
ExtensionPrefs* extension_prefs =
- ExtensionSystem::Get(browser()->profile())->extension_prefs();
+ ExtensionPrefs::Get(browser()->profile());
// Record the file entries in prefs because when the app gets suspended it
// will have them all cleared.
std::vector<SavedFileEntry> file_entries;
diff --git a/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc b/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc
index 771ad7c..7ad6d02 100644
--- a/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc
+++ b/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc
@@ -5,8 +5,6 @@
#include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
#include "chrome/browser/extensions/extension_prefs.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/extension_system.h"
#include "content/public/browser/child_process_security_policy.h"
#include "net/base/mime_util.h"
#include "webkit/fileapi/file_system_types.h"
@@ -163,7 +161,7 @@ GrantedFileEntry CreateFileEntry(
policy->GrantReadFile(renderer_id, path);
// Save this file entry in the prefs.
- AddSavedFileEntry(ExtensionSystem::Get(profile)->extension_prefs(),
+ AddSavedFileEntry(ExtensionPrefs::Get(profile),
extension_id,
result.id,
path,
diff --git a/chrome/browser/extensions/api/permissions/permissions_api.cc b/chrome/browser/extensions/api/permissions/permissions_api.cc
index ab523a5..cbaf1d9 100644
--- a/chrome/browser/extensions/api/permissions/permissions_api.cc
+++ b/chrome/browser/extensions/api/permissions/permissions_api.cc
@@ -7,7 +7,6 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h"
#include "chrome/browser/extensions/extension_prefs.h"
-#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/permissions_updater.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_notification_types.h"
@@ -54,11 +53,11 @@ bool PermissionsContainsFunction::RunImpl() {
scoped_ptr<Contains::Params> params(Contains::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
- ExtensionPrefs* prefs = ExtensionSystem::Get(profile_)->extension_prefs();
scoped_refptr<PermissionSet> permissions =
- helpers::UnpackPermissionSet(params->permissions,
- prefs->AllowFileAccess(extension_->id()),
- &error_);
+ helpers::UnpackPermissionSet(
+ params->permissions,
+ ExtensionPrefs::Get(profile_)->AllowFileAccess(extension_->id()),
+ &error_);
if (!permissions.get())
return false;
@@ -78,11 +77,11 @@ bool PermissionsRemoveFunction::RunImpl() {
scoped_ptr<Remove::Params> params(Remove::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
- ExtensionPrefs* prefs = ExtensionSystem::Get(profile_)->extension_prefs();
scoped_refptr<PermissionSet> permissions =
- helpers::UnpackPermissionSet(params->permissions,
- prefs->AllowFileAccess(extension_->id()),
- &error_);
+ helpers::UnpackPermissionSet(
+ params->permissions,
+ ExtensionPrefs::Get(profile_)->AllowFileAccess(extension_->id()),
+ &error_);
if (!permissions.get())
return false;
@@ -156,12 +155,11 @@ bool PermissionsRequestFunction::RunImpl() {
scoped_ptr<Request::Params> params(Request::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
- ExtensionPrefs* prefs = ExtensionSystem::Get(profile_)->extension_prefs();
-
requested_permissions_ =
- helpers::UnpackPermissionSet(params->permissions,
- prefs->AllowFileAccess(extension_->id()),
- &error_);
+ helpers::UnpackPermissionSet(
+ params->permissions,
+ ExtensionPrefs::Get(profile_)->AllowFileAccess(extension_->id()),
+ &error_);
if (!requested_permissions_.get())
return false;
@@ -192,7 +190,8 @@ bool PermissionsRequestFunction::RunImpl() {
// We don't need to prompt the user if the requested permissions are a subset
// of the granted permissions set.
scoped_refptr<const PermissionSet> granted =
- prefs->GetGrantedPermissions(GetExtension()->id());
+ ExtensionPrefs::Get(profile_)->
+ GetGrantedPermissions(GetExtension()->id());
if (granted && granted->Contains(*requested_permissions_)) {
PermissionsUpdater perms_updater(profile());
perms_updater.AddPermissions(GetExtension(), requested_permissions_.get());
diff --git a/chrome/browser/extensions/event_router.cc b/chrome/browser/extensions/event_router.cc
index 130ff58..7ae00db 100644
--- a/chrome/browser/extensions/event_router.cc
+++ b/chrome/browser/extensions/event_router.cc
@@ -289,7 +289,7 @@ void EventRouter::AddLazyEventListener(const std::string& event_name,
bool is_new = listeners_.AddListener(listener.Pass());
if (is_new) {
- ExtensionPrefs* prefs = ExtensionSystem::Get(profile_)->extension_prefs();
+ ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_);
std::set<std::string> events = prefs->GetRegisteredEvents(extension_id);
bool prefs_is_new = events.insert(event_name).second;
if (prefs_is_new)
@@ -304,7 +304,7 @@ void EventRouter::RemoveLazyEventListener(const std::string& event_name,
bool did_exist = listeners_.RemoveListener(&listener);
if (did_exist) {
- ExtensionPrefs* prefs = ExtensionSystem::Get(profile_)->extension_prefs();
+ ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_);
std::set<std::string> events = prefs->GetRegisteredEvents(extension_id);
bool prefs_did_exist = events.erase(event_name) > 0;
DCHECK(prefs_did_exist);
@@ -327,8 +327,8 @@ void EventRouter::AddFilteredEventListener(const std::string& event_name,
scoped_ptr<DictionaryValue>(filter.DeepCopy()))));
if (added) {
- ExtensionPrefs* prefs = ExtensionSystem::Get(profile_)->extension_prefs();
- prefs->AddFilterToEvent(event_name, extension_id, &filter);
+ ExtensionPrefs::Get(profile_)->AddFilterToEvent(
+ event_name, extension_id, &filter);
}
}
}
@@ -349,8 +349,8 @@ void EventRouter::RemoveFilteredEventListener(
bool removed = listeners_.RemoveListener(&listener);
if (removed) {
- ExtensionPrefs* prefs = ExtensionSystem::Get(profile_)->extension_prefs();
- prefs->RemoveFilterFromEvent(event_name, extension_id, &filter);
+ ExtensionPrefs::Get(profile_)->RemoveFilterFromEvent(
+ event_name, extension_id, &filter);
}
}
}
@@ -625,7 +625,7 @@ void EventRouter::Observe(int type,
// Add all registered lazy listeners to our cache.
const Extension* extension =
content::Details<const Extension>(details).ptr();
- ExtensionPrefs* prefs = ExtensionSystem::Get(profile_)->extension_prefs();
+ ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_);
std::set<std::string> registered_events =
prefs->GetRegisteredEvents(extension->id());
listeners_.LoadUnfilteredLazyListeners(extension->id(),
diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc
index a200bfc..64ef63c 100644
--- a/chrome/browser/extensions/extension_prefs.cc
+++ b/chrome/browser/extensions/extension_prefs.cc
@@ -14,7 +14,9 @@
#include "base/version.h"
#include "chrome/browser/extensions/admin_policy.h"
#include "chrome/browser/extensions/extension_pref_store.h"
+#include "chrome/browser/extensions/extension_prefs_factory.h"
#include "chrome/browser/extensions/extension_sorting.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
@@ -379,7 +381,7 @@ template class ExtensionPrefs::ScopedUpdate<ListValue, Value::TYPE_LIST>;
//
// static
-scoped_ptr<ExtensionPrefs> ExtensionPrefs::Create(
+ExtensionPrefs* ExtensionPrefs::Create(
PrefService* prefs,
const base::FilePath& root_dir,
ExtensionPrefValueMap* extension_pref_value_map,
@@ -392,7 +394,7 @@ scoped_ptr<ExtensionPrefs> ExtensionPrefs::Create(
}
// static
-scoped_ptr<ExtensionPrefs> ExtensionPrefs::Create(
+ExtensionPrefs* ExtensionPrefs::Create(
PrefService* pref_service,
const base::FilePath& root_dir,
ExtensionPrefValueMap* extension_pref_value_map,
@@ -402,14 +404,26 @@ scoped_ptr<ExtensionPrefs> ExtensionPrefs::Create(
new ExtensionPrefs(pref_service,
root_dir,
extension_pref_value_map,
- time_provider.Pass()));
- prefs->Init(extensions_disabled);
- return prefs.Pass();
+ time_provider.Pass(),
+ extensions_disabled));
+ return prefs.release();
}
ExtensionPrefs::~ExtensionPrefs() {
}
+void ExtensionPrefs::Shutdown() {
+ // It's safe to do this for any profile because the regular profile going away
+ // implies its incognito profile going away.
+ if (!extensions_disabled_)
+ ClearIncognitoSessionOnlyContentSettings();
+}
+
+// static
+ExtensionPrefs* ExtensionPrefs::Get(Profile* profile) {
+ return ExtensionPrefsFactory::GetInstance()->GetForProfile(profile);
+}
+
// static
const char ExtensionPrefs::kExtensionsPref[] = "extensions.settings";
@@ -1756,8 +1770,8 @@ void ExtensionPrefs::LoadExtensionControlledPrefs(
}
}
-void ExtensionPrefs::InitPrefStore(bool extensions_disabled) {
- if (extensions_disabled) {
+void ExtensionPrefs::InitPrefStore() {
+ if (extensions_disabled_) {
extension_pref_value_map_->NotifyInitializationCompleted();
return;
}
@@ -1978,20 +1992,17 @@ ExtensionPrefs::ExtensionPrefs(
PrefService* prefs,
const base::FilePath& root_dir,
ExtensionPrefValueMap* extension_pref_value_map,
- scoped_ptr<TimeProvider> time_provider)
+ scoped_ptr<TimeProvider> time_provider,
+ bool extensions_disabled)
: prefs_(prefs),
install_directory_(root_dir),
extension_pref_value_map_(extension_pref_value_map),
extension_sorting_(new ExtensionSorting(this, prefs)),
content_settings_store_(new ContentSettingsStore()),
- time_provider_(time_provider.Pass()) {
-}
-
-void ExtensionPrefs::Init(bool extensions_disabled) {
+ time_provider_(time_provider.Pass()),
+ extensions_disabled_(extensions_disabled) {
MakePathsRelative();
-
- InitPrefStore(extensions_disabled);
-
+ InitPrefStore();
content_settings_store_->AddObserver(this);
}
diff --git a/chrome/browser/extensions/extension_prefs.h b/chrome/browser/extensions/extension_prefs.h
index 68870da..462fe6f 100644
--- a/chrome/browser/extensions/extension_prefs.h
+++ b/chrome/browser/extensions/extension_prefs.h
@@ -17,6 +17,7 @@
#include "chrome/browser/extensions/extension_prefs_scope.h"
#include "chrome/browser/extensions/extension_scoped_prefs.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
+#include "chrome/browser/profiles/profile_keyed_service.h"
#include "chrome/common/extensions/extension.h"
#include "extensions/common/url_pattern_set.h"
#include "sync/api/string_ordinal.h"
@@ -24,6 +25,7 @@
class ExtensionPrefValueMap;
class ExtensionSorting;
class PrefService;
+class Profile;
namespace user_prefs {
class PrefRegistrySyncable;
@@ -49,7 +51,8 @@ class URLPatternSet;
// PrefValueStore::extension_prefs(), which this class populates and
// maintains as the underlying extensions change.
class ExtensionPrefs : public ContentSettingsStore::Observer,
- public ExtensionScopedPrefs {
+ public ExtensionScopedPrefs,
+ public ProfileKeyedService {
public:
// Key name for a preference that keeps track of per-extension settings. This
// is a dictionary object read from the Preferences file, keyed off of
@@ -127,7 +130,9 @@ class ExtensionPrefs : public ContentSettingsStore::Observer,
// Creates and initializes an ExtensionPrefs object.
// Does not take ownership of |prefs| and |extension_pref_value_map|.
- static scoped_ptr<ExtensionPrefs> Create(
+ // If |extensions_disabled| is true, extension controlled preferences and
+ // content settings do not become effective.
+ static ExtensionPrefs* Create(
PrefService* prefs,
const base::FilePath& root_dir,
ExtensionPrefValueMap* extension_pref_value_map,
@@ -135,7 +140,7 @@ class ExtensionPrefs : public ContentSettingsStore::Observer,
// A version of Create which allows injection of a custom base::Time provider.
// Use this as needed for testing.
- static scoped_ptr<ExtensionPrefs> Create(
+ static ExtensionPrefs* Create(
PrefService* prefs,
const base::FilePath& root_dir,
ExtensionPrefValueMap* extension_pref_value_map,
@@ -144,6 +149,12 @@ class ExtensionPrefs : public ContentSettingsStore::Observer,
virtual ~ExtensionPrefs();
+ // ProfileKeyedService implementation.
+ virtual void Shutdown() OVERRIDE;
+
+ // Convenience function to get the ExtensionPrefs for a Profile.
+ static ExtensionPrefs* Get(Profile* profile);
+
// Returns all installed extensions from extension preferences provided by
// |pref_service|. This is exposed for ProtectedPrefsWatcher because it needs
// access to the extension ID list before the ExtensionService is initialized.
@@ -543,11 +554,8 @@ class ExtensionPrefs : public ContentSettingsStore::Observer,
ExtensionPrefs(PrefService* prefs,
const base::FilePath& root_dir,
ExtensionPrefValueMap* extension_pref_value_map,
- scoped_ptr<TimeProvider> time_provider);
-
- // If |extensions_disabled| is true, extension controlled preferences and
- // content settings do not become effective.
- void Init(bool extensions_disabled);
+ scoped_ptr<TimeProvider> time_provider,
+ bool extensions_disabled);
// extensions::ContentSettingsStore::Observer methods:
virtual void OnContentSettingChanged(const std::string& extension_id,
@@ -611,8 +619,8 @@ class ExtensionPrefs : public ContentSettingsStore::Observer,
void FixMissingPrefs(const ExtensionIdList& extension_ids);
// Installs the persistent extension preferences into |prefs_|'s extension
- // pref store. Does nothing if |extensions_disabled| is true.
- void InitPrefStore(bool extensions_disabled);
+ // pref store. Does nothing if extensions_disabled_ is true.
+ void InitPrefStore();
// Migrates the permissions data in the pref store.
void MigratePermissions(const ExtensionIdList& extension_ids);
@@ -666,6 +674,8 @@ class ExtensionPrefs : public ContentSettingsStore::Observer,
scoped_ptr<TimeProvider> time_provider_;
+ bool extensions_disabled_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs);
};
diff --git a/chrome/browser/extensions/extension_prefs_factory.cc b/chrome/browser/extensions/extension_prefs_factory.cc
new file mode 100644
index 0000000..4c0a34f
--- /dev/null
+++ b/chrome/browser/extensions/extension_prefs_factory.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2013 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 "base/command_line.h"
+#include "base/prefs/pref_service.h"
+#include "chrome/browser/extensions/extension_pref_value_map.h"
+#include "chrome/browser/extensions/extension_pref_value_map_factory.h"
+#include "chrome/browser/extensions/extension_prefs.h"
+#include "chrome/browser/extensions/extension_prefs_factory.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/profiles/incognito_helpers.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_dependency_manager.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/pref_names.h"
+#include "extensions/common/constants.h"
+
+namespace extensions {
+
+// static
+ExtensionPrefs* ExtensionPrefsFactory::GetForProfile(Profile* profile) {
+ return static_cast<ExtensionPrefs*>(
+ GetInstance()->GetServiceForProfile(profile, true));
+}
+
+// static
+ExtensionPrefsFactory* ExtensionPrefsFactory::GetInstance() {
+ return Singleton<ExtensionPrefsFactory>::get();
+}
+
+void ExtensionPrefsFactory::SetInstanceForTesting(
+ content::BrowserContext* context, ExtensionPrefs* prefs) {
+ Associate(context, prefs);
+}
+
+ExtensionPrefsFactory::ExtensionPrefsFactory()
+ : ProfileKeyedServiceFactory("ExtensionPrefs",
+ ProfileDependencyManager::GetInstance()) {
+}
+
+ExtensionPrefsFactory::~ExtensionPrefsFactory() {
+}
+
+ProfileKeyedService* ExtensionPrefsFactory::BuildServiceInstanceFor(
+ content::BrowserContext* context) const {
+ Profile* profile = Profile::FromBrowserContext(context);
+ bool extensions_disabled =
+ profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions) ||
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableExtensions);
+ return ExtensionPrefs::Create(
+ profile->GetPrefs(),
+ profile->GetPath().AppendASCII(extensions::kInstallDirectoryName),
+ ExtensionPrefValueMapFactory::GetForProfile(profile),
+ extensions_disabled);
+}
+
+content::BrowserContext* ExtensionPrefsFactory::GetBrowserContextToUse(
+ content::BrowserContext* context) const {
+ return chrome::GetBrowserContextRedirectedInIncognito(context);
+}
+
+} // namespace extensions
diff --git a/chrome/browser/extensions/extension_prefs_factory.h b/chrome/browser/extensions/extension_prefs_factory.h
new file mode 100644
index 0000000..d9edba5
--- /dev/null
+++ b/chrome/browser/extensions/extension_prefs_factory.h
@@ -0,0 +1,39 @@
+// Copyright (c) 2013 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.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_FACTORY_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_FACTORY_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/singleton.h"
+#include "chrome/browser/profiles/profile_keyed_service_factory.h"
+
+namespace extensions {
+
+class ExtensionPrefs;
+
+class ExtensionPrefsFactory : public ProfileKeyedServiceFactory {
+ public:
+ static ExtensionPrefs* GetForProfile(Profile* profile);
+
+ static ExtensionPrefsFactory* GetInstance();
+
+ void SetInstanceForTesting(
+ content::BrowserContext* context, ExtensionPrefs* prefs);
+
+ private:
+ friend struct DefaultSingletonTraits<ExtensionPrefsFactory>;
+
+ ExtensionPrefsFactory();
+ virtual ~ExtensionPrefsFactory();
+
+ virtual ProfileKeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* profile) const OVERRIDE;
+ virtual content::BrowserContext* GetBrowserContextToUse(
+ content::BrowserContext* context) const OVERRIDE;
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_FACTORY_H_
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index da504f0..6a6993c 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -580,7 +580,8 @@ void ExtensionProcessManager::Observe(
case chrome::NOTIFICATION_EXTENSION_LOADED: {
Profile* profile = content::Source<Profile>(source).ptr();
- ExtensionService* service = profile->GetExtensionService();
+ ExtensionService* service =
+ extensions::ExtensionSystem::Get(profile)->extension_service();
if (service->is_ready()) {
const Extension* extension =
content::Details<const Extension>(details).ptr();
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 2cfc144..a7a1652 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -103,6 +103,7 @@
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/common/pepper_plugin_info.h"
+#include "extensions/common/constants.h"
#include "extensions/common/error_utils.h"
#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
@@ -185,8 +186,6 @@ ExtensionService::NaClModuleInfo::~NaClModuleInfo() {
// ExtensionService.
-const char ExtensionService::kInstallDirectoryName[] = "Extensions";
-
const char ExtensionService::kLocalAppSettingsDirectoryName[] =
"Local App Settings";
const char ExtensionService::kLocalExtensionSettingsDirectoryName[] =
diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h
index 70b1a5f..3f0408a2 100644
--- a/chrome/browser/extensions/extension_service.h
+++ b/chrome/browser/extensions/extension_service.h
@@ -144,10 +144,6 @@ class ExtensionService
public content::NotificationObserver,
public extensions::Blacklist::Observer {
public:
- // The name of the directory inside the profile where extensions are
- // installed to.
- static const char kInstallDirectoryName[];
-
// If auto-updates are turned on, default to running every 5 hours.
static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5;
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index fb7ec15..26c3051 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -4654,7 +4654,7 @@ TEST(ExtensionServiceTestSimple, Enabledness) {
#endif
scoped_ptr<CommandLine> command_line;
base::FilePath install_dir = profile->GetPath()
- .AppendASCII(ExtensionService::kInstallDirectoryName);
+ .AppendASCII(extensions::kInstallDirectoryName);
#if defined(ENABLE_PLUGINS)
webkit::npapi::MockPluginList plugin_list;
diff --git a/chrome/browser/extensions/extension_system.cc b/chrome/browser/extensions/extension_system.cc
index 8ad8221..6f56d0e4 100644
--- a/chrome/browser/extensions/extension_system.cc
+++ b/chrome/browser/extensions/extension_system.cc
@@ -8,7 +8,6 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
-#include "base/prefs/pref_service.h"
#include "base/strings/string_tokenizer.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/content_settings/cookie_settings.h"
@@ -21,6 +20,7 @@
#include "chrome/browser/extensions/extension_pref_store.h"
#include "chrome/browser/extensions/extension_pref_value_map.h"
#include "chrome/browser/extensions/extension_pref_value_map_factory.h"
+#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system_factory.h"
@@ -42,9 +42,9 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/features/feature.h"
#include "chrome/common/extensions/manifest.h"
-#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/url_data_source.h"
+#include "extensions/common/constants.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/app_mode/app_mode_utils.h"
@@ -86,16 +86,8 @@ ExtensionSystemImpl::Shared::~Shared() {
}
void ExtensionSystemImpl::Shared::InitPrefs() {
- bool extensions_disabled =
- profile_->GetPrefs()->GetBoolean(prefs::kDisableExtensions) ||
- CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableExtensions);
- extension_prefs_ = ExtensionPrefs::Create(
- profile_->GetPrefs(),
- profile_->GetPath().AppendASCII(ExtensionService::kInstallDirectoryName),
- ExtensionPrefValueMapFactory::GetForProfile(profile_),
- extensions_disabled);
lazy_background_task_queue_.reset(new LazyBackgroundTaskQueue(profile_));
- event_router_.reset(new EventRouter(profile_, extension_prefs_.get()));
+ event_router_.reset(new EventRouter(profile_, ExtensionPrefs::Get(profile_)));
// Two state stores. The latter, which contains declarative rules, must be
// loaded immediately so that the rules are ready before we issue network
@@ -110,12 +102,12 @@ void ExtensionSystemImpl::Shared::InitPrefs() {
false));
shell_window_geometry_cache_.reset(new ShellWindowGeometryCache(
- profile_, extension_prefs_.get()));
+ profile_, ExtensionPrefs::Get(profile_)));
- blacklist_.reset(new Blacklist(extension_prefs_.get()));
+ blacklist_.reset(new Blacklist(ExtensionPrefs::Get(profile_)));
standard_management_policy_provider_.reset(
- new StandardManagementPolicyProvider(extension_prefs_.get()));
+ new StandardManagementPolicyProvider(ExtensionPrefs::Get(profile_)));
}
void ExtensionSystemImpl::Shared::RegisterManagementPolicyProviders() {
@@ -145,8 +137,8 @@ void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) {
extension_service_.reset(new ExtensionService(
profile_,
CommandLine::ForCurrentProcess(),
- profile_->GetPath().AppendASCII(ExtensionService::kInstallDirectoryName),
- extension_prefs_.get(),
+ profile_->GetPath().AppendASCII(extensions::kInstallDirectoryName),
+ ExtensionPrefs::Get(profile_),
blacklist_.get(),
autoupdate_enabled,
extensions_enabled));
@@ -253,10 +245,6 @@ StateStore* ExtensionSystemImpl::Shared::rules_store() {
return rules_store_.get();
}
-ExtensionPrefs* ExtensionSystemImpl::Shared::extension_prefs() {
- return extension_prefs_.get();
-}
-
ShellWindowGeometryCache* ExtensionSystemImpl::Shared::
shell_window_geometry_cache() {
return shell_window_geometry_cache_.get();
@@ -319,10 +307,6 @@ ExtensionSystemImpl::~ExtensionSystemImpl() {
void ExtensionSystemImpl::Shutdown() {
extension_process_manager_.reset();
-
- if (profile_->IsOffTheRecord() && extension_service() &&
- extension_service()->extensions_enabled())
- extension_prefs()->ClearIncognitoSessionOnlyContentSettings();
}
void ExtensionSystemImpl::InitForRegularProfile(bool extensions_enabled) {
@@ -383,10 +367,6 @@ StateStore* ExtensionSystemImpl::rules_store() {
return shared_->rules_store();
}
-ExtensionPrefs* ExtensionSystemImpl::extension_prefs() {
- return shared_->extension_prefs();
-}
-
ShellWindowGeometryCache* ExtensionSystemImpl::shell_window_geometry_cache() {
return shared_->shell_window_geometry_cache();
}
@@ -433,7 +413,7 @@ void ExtensionSystemImpl::RegisterExtensionWithRequestContexts(
const Extension* extension) {
base::Time install_time;
if (extension->location() != Manifest::COMPONENT) {
- install_time = extension_service()->extension_prefs()->
+ install_time = ExtensionPrefs::Get(profile_)->
GetInstallTime(extension->id());
}
bool incognito_enabled =
diff --git a/chrome/browser/extensions/extension_system.h b/chrome/browser/extensions/extension_system.h
index 72c5c0b..f7da8b9 100644
--- a/chrome/browser/extensions/extension_system.h
+++ b/chrome/browser/extensions/extension_system.h
@@ -28,7 +28,6 @@ class AlarmManager;
class Blacklist;
class EventRouter;
class Extension;
-class ExtensionPrefs;
class ExtensionSystemSharedFactory;
class ExtensionWarningBadgeService;
class ExtensionWarningService;
@@ -86,9 +85,6 @@ class ExtensionSystem : public ProfileKeyedService {
// The rules store is created at startup.
virtual StateStore* rules_store() = 0;
- // The extension prefs.
- virtual ExtensionPrefs* extension_prefs() = 0;
-
// The ShellWindowGeometryCache is created at startup.
virtual ShellWindowGeometryCache* shell_window_geometry_cache() = 0;
@@ -160,7 +156,6 @@ class ExtensionSystemImpl : public ExtensionSystem {
virtual ExtensionProcessManager* process_manager() OVERRIDE;
virtual StateStore* state_store() OVERRIDE; // shared
virtual StateStore* rules_store() OVERRIDE; // shared
- virtual ExtensionPrefs* extension_prefs() OVERRIDE; // shared
virtual ShellWindowGeometryCache* shell_window_geometry_cache()
OVERRIDE; // shared
virtual LazyBackgroundTaskQueue* lazy_background_task_queue()
@@ -205,7 +200,6 @@ class ExtensionSystemImpl : public ExtensionSystem {
StateStore* state_store();
StateStore* rules_store();
- ExtensionPrefs* extension_prefs();
ShellWindowGeometryCache* shell_window_geometry_cache();
ExtensionService* extension_service();
ManagementPolicy* management_policy();
@@ -223,8 +217,6 @@ class ExtensionSystemImpl : public ExtensionSystem {
scoped_ptr<StateStore> state_store_;
scoped_ptr<StateStore> rules_store_;
- scoped_ptr<ExtensionPrefs> extension_prefs_;
- // ShellWindowGeometryCache depends on ExtensionPrefs.
scoped_ptr<ShellWindowGeometryCache> shell_window_geometry_cache_;
// LazyBackgroundTaskQueue is a dependency of
// MessageService and EventRouter.
@@ -232,12 +224,11 @@ class ExtensionSystemImpl : public ExtensionSystem {
scoped_ptr<EventRouter> event_router_;
scoped_ptr<NavigationObserver> navigation_observer_;
scoped_refptr<UserScriptMaster> user_script_master_;
- // Blacklist depends on ExtensionPrefs.
scoped_ptr<Blacklist> blacklist_;
- // StandardManagementPolicyProvider depends on ExtensionPrefs and Blacklist.
+ // StandardManagementPolicyProvider depends on Blacklist.
scoped_ptr<StandardManagementPolicyProvider>
standard_management_policy_provider_;
- // ExtensionService depends on ExtensionPrefs, StateStore, and Blacklist.
+ // ExtensionService depends on StateStore and Blacklist.
scoped_ptr<ExtensionService> extension_service_;
scoped_ptr<ManagementPolicy> management_policy_;
// extension_info_map_ needs to outlive extension_process_manager_.
diff --git a/chrome/browser/extensions/extension_system_factory.cc b/chrome/browser/extensions/extension_system_factory.cc
index 49f5370..444ba62 100644
--- a/chrome/browser/extensions/extension_system_factory.cc
+++ b/chrome/browser/extensions/extension_system_factory.cc
@@ -4,8 +4,7 @@
#include "chrome/browser/extensions/extension_system_factory.h"
-#include "chrome/browser/extensions/extension_prefs.h"
-#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_prefs_factory.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/profiles/incognito_helpers.h"
@@ -34,6 +33,7 @@ ExtensionSystemSharedFactory::ExtensionSystemSharedFactory()
: ProfileKeyedServiceFactory(
"ExtensionSystemShared",
ProfileDependencyManager::GetInstance()) {
+ DependsOn(ExtensionPrefsFactory::GetInstance());
DependsOn(GlobalErrorServiceFactory::GetInstance());
#if defined(ENABLE_THEMES)
DependsOn(ThemeServiceFactory::GetInstance());
diff --git a/chrome/browser/extensions/extension_toolbar_model_browsertest.cc b/chrome/browser/extensions/extension_toolbar_model_browsertest.cc
index 9a46a8b..4daed93 100644
--- a/chrome/browser/extensions/extension_toolbar_model_browsertest.cc
+++ b/chrome/browser/extensions/extension_toolbar_model_browsertest.cc
@@ -370,8 +370,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionToolbarModelTest, ReorderOnPrefChange) {
extensions::ExtensionIdList new_order;
new_order.push_back(id_c);
new_order.push_back(id_b);
- extensions::ExtensionSystem::Get(browser()->profile())
- ->extension_prefs()->SetToolbarOrder(new_order);
+ extensions::ExtensionPrefs::Get(browser()->profile())->SetToolbarOrder(
+ new_order);
// Verify order is changed.
EXPECT_EQ(id_c, ExtensionAt(0)->id());
diff --git a/chrome/browser/extensions/permissions_updater.cc b/chrome/browser/extensions/permissions_updater.cc
index f98d702..9c0ced5f 100644
--- a/chrome/browser/extensions/permissions_updater.cc
+++ b/chrome/browser/extensions/permissions_updater.cc
@@ -10,7 +10,6 @@
#include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h"
#include "chrome/browser/extensions/event_router.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/common/chrome_notification_types.h"
@@ -83,13 +82,14 @@ void PermissionsUpdater::GrantActivePermissions(const Extension* extension) {
extension->location() != Manifest::INTERNAL)
return;
- GetExtensionPrefs()->AddGrantedPermissions(extension->id(),
- extension->GetActivePermissions());
+ ExtensionPrefs::Get(profile_)->AddGrantedPermissions(
+ extension->id(), extension->GetActivePermissions());
}
void PermissionsUpdater::UpdateActivePermissions(
const Extension* extension, const PermissionSet* permissions) {
- GetExtensionPrefs()->SetActivePermissions(extension->id(), permissions);
+ ExtensionPrefs::Get(profile_)->SetActivePermissions(
+ extension->id(), permissions);
extension->SetActivePermissions(permissions);
}
@@ -156,8 +156,4 @@ void PermissionsUpdater::NotifyPermissionsUpdated(
DispatchEvent(extension->id(), event_name, changed);
}
-ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() {
- return ExtensionSystem::Get(profile_)->extension_service()->extension_prefs();
-}
-
} // namespace extensions
diff --git a/chrome/browser/extensions/platform_app_launcher.cc b/chrome/browser/extensions/platform_app_launcher.cc
index bffd8c8..8e22447 100644
--- a/chrome/browser/extensions/platform_app_launcher.cc
+++ b/chrome/browser/extensions/platform_app_launcher.cc
@@ -332,7 +332,7 @@ class SavedFileEntryLauncher
// Record that we have granted this file permission.
app_file_handler_util::AddSavedFileEntry(
- ExtensionSystem::Get(profile_)->extension_prefs(),
+ ExtensionPrefs::Get(profile_),
host->extension()->id(),
it->id,
it->path,
diff --git a/chrome/browser/extensions/test_extension_prefs.cc b/chrome/browser/extensions/test_extension_prefs.cc
index 7250cb6..07e4b5a 100644
--- a/chrome/browser/extensions/test_extension_prefs.cc
+++ b/chrome/browser/extensions/test_extension_prefs.cc
@@ -111,7 +111,7 @@ void TestExtensionPrefs::RecreateExtensionPrefs() {
new ExtensionPrefStore(extension_pref_value_map_.get(), false));
pref_service_.reset(builder.CreateSyncable(pref_registry_));
- prefs_ = ExtensionPrefs::Create(
+ prefs_.reset(ExtensionPrefs::Create(
pref_service_.get(),
temp_dir_.path(),
extension_pref_value_map_.get(),
@@ -119,7 +119,7 @@ void TestExtensionPrefs::RecreateExtensionPrefs() {
// Guarantee that no two extensions get the same installation time
// stamp and we can reliably assert the installation order in the tests.
scoped_ptr<ExtensionPrefs::TimeProvider>(
- new IncrementalTimeProvider()));
+ new IncrementalTimeProvider())));
}
scoped_refptr<Extension> TestExtensionPrefs::AddExtension(std::string name) {
diff --git a/chrome/browser/extensions/test_extension_system.cc b/chrome/browser/extensions/test_extension_system.cc
index f1641e0..5cb9046 100644
--- a/chrome/browser/extensions/test_extension_system.cc
+++ b/chrome/browser/extensions/test_extension_system.cc
@@ -11,6 +11,8 @@
#include "chrome/browser/extensions/extension_info_map.h"
#include "chrome/browser/extensions/extension_pref_value_map.h"
#include "chrome/browser/extensions/extension_pref_value_map_factory.h"
+#include "chrome/browser/extensions/extension_prefs.h"
+#include "chrome/browser/extensions/extension_prefs_factory.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
@@ -62,37 +64,39 @@ ExtensionPrefs* TestExtensionSystem::CreateExtensionPrefs(
command_line && command_line->HasSwitch(switches::kDisableExtensions);
// Note that the GetPrefs() creates a TestingPrefService, therefore
- // the extension controlled pref values set in extension_prefs_
+ // the extension controlled pref values set in ExtensionPrefs
// are not reflected in the pref service. One would need to
// inject a new ExtensionPrefStore(extension_pref_value_map, false).
- extension_prefs_ = ExtensionPrefs::Create(
+ return ExtensionPrefs::Create(
profile_->GetPrefs(),
install_directory,
ExtensionPrefValueMapFactory::GetForProfile(profile_),
extensions_disabled);
- return extension_prefs_.get();
}
ExtensionService* TestExtensionSystem::CreateExtensionService(
const CommandLine* command_line,
const base::FilePath& install_directory,
bool autoupdate_enabled) {
- if (!extension_prefs_)
- CreateExtensionPrefs(command_line, install_directory);
+ if (!ExtensionPrefs::Get(profile_)) {
+ ExtensionPrefsFactory::GetInstance()->SetInstanceForTesting(
+ profile_,
+ CreateExtensionPrefs(command_line, install_directory));
+ }
state_store_.reset(new StateStore(profile_, new TestingValueStore()));
shell_window_geometry_cache_.reset(
- new ShellWindowGeometryCache(profile_, extension_prefs_.get()));
- blacklist_.reset(new Blacklist(extension_prefs_.get()));
+ new ShellWindowGeometryCache(profile_, ExtensionPrefs::Get(profile_)));
+ blacklist_.reset(new Blacklist(ExtensionPrefs::Get(profile_)));
standard_management_policy_provider_.reset(
- new StandardManagementPolicyProvider(extension_prefs_.get()));
+ new StandardManagementPolicyProvider(ExtensionPrefs::Get(profile_)));
management_policy_.reset(new ManagementPolicy());
management_policy_->RegisterProvider(
standard_management_policy_provider_.get());
extension_service_.reset(new ExtensionService(profile_,
command_line,
install_directory,
- extension_prefs_.get(),
+ ExtensionPrefs::Get(profile_),
blacklist_.get(),
autoupdate_enabled,
true));
@@ -128,10 +132,6 @@ StateStore* TestExtensionSystem::rules_store() {
return state_store_.get();
}
-ExtensionPrefs* TestExtensionSystem::extension_prefs() {
- return extension_prefs_.get();
-}
-
ShellWindowGeometryCache* TestExtensionSystem::shell_window_geometry_cache() {
return shell_window_geometry_cache_.get();
}
diff --git a/chrome/browser/extensions/test_extension_system.h b/chrome/browser/extensions/test_extension_system.h
index 0ac8082..df02117 100644
--- a/chrome/browser/extensions/test_extension_system.h
+++ b/chrome/browser/extensions/test_extension_system.h
@@ -19,6 +19,7 @@ class BrowserContext;
}
namespace extensions {
+class ExtensionPrefs;
// Test ExtensionSystem, for use with TestingProfile.
class TestExtensionSystem : public ExtensionSystem {
@@ -57,7 +58,6 @@ class TestExtensionSystem : public ExtensionSystem {
virtual ExtensionProcessManager* process_manager() OVERRIDE;
virtual StateStore* state_store() OVERRIDE;
virtual StateStore* rules_store() OVERRIDE;
- virtual ExtensionPrefs* extension_prefs() OVERRIDE;
virtual ShellWindowGeometryCache* shell_window_geometry_cache() OVERRIDE;
virtual ExtensionInfoMap* info_map() OVERRIDE;
virtual LazyBackgroundTaskQueue* lazy_background_task_queue() OVERRIDE;
@@ -78,9 +78,6 @@ class TestExtensionSystem : public ExtensionSystem {
Profile* profile_;
private:
- // The Extension Preferences. Only created if CreateExtensionService is
- // invoked.
- scoped_ptr<ExtensionPrefs> extension_prefs_;
scoped_ptr<StateStore> state_store_;
scoped_ptr<ShellWindowGeometryCache> shell_window_geometry_cache_;
scoped_ptr<Blacklist> blacklist_;
diff --git a/chrome/browser/media_galleries/media_galleries_test_util.cc b/chrome/browser/media_galleries/media_galleries_test_util.cc
index 5669f07..97afbf3 100644
--- a/chrome/browser/media_galleries/media_galleries_test_util.cc
+++ b/chrome/browser/media_galleries/media_galleries_test_util.cc
@@ -8,6 +8,7 @@
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/stringprintf.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"
@@ -41,8 +42,9 @@ scoped_refptr<extensions::Extension> AddMediaGalleriesApp(
permission_list->Append(media_galleries_permission);
manifest->Set(extension_manifest_keys::kPermissions, permission_list);
-
- base::FilePath path = profile->GetPath().AppendASCII(name);
+ extensions::ExtensionPrefs* extension_prefs =
+ extensions::ExtensionPrefs::Get(profile);
+ base::FilePath path = extension_prefs->install_directory().AppendASCII(name);
std::string errors;
scoped_refptr<extensions::Extension> extension =
extensions::Extension::Create(path, extensions::Manifest::INTERNAL,
@@ -53,11 +55,11 @@ scoped_refptr<extensions::Extension> AddMediaGalleriesApp(
if (!extension.get() || !extensions::Extension::IdIsValid(extension->id()))
return NULL;
- ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(profile)->extension_service();
- extension_service->extension_prefs()->OnExtensionInstalled(
+ extension_prefs->OnExtensionInstalled(
extension.get(), extensions::Extension::ENABLED,
syncer::StringOrdinal::CreateInitialOrdinal());
+ ExtensionService* extension_service =
+ extensions::ExtensionSystem::Get(profile)->extension_service();
extension_service->AddExtension(extension);
extension_service->EnableExtension(extension->id());
diff --git a/chrome/browser/profiles/profile_dependency_manager.cc b/chrome/browser/profiles/profile_dependency_manager.cc
index d508c41..c6a13b1 100644
--- a/chrome/browser/profiles/profile_dependency_manager.cc
+++ b/chrome/browser/profiles/profile_dependency_manager.cc
@@ -47,6 +47,7 @@
#include "chrome/browser/extensions/api/tab_capture/tab_capture_registry_factory.h"
#include "chrome/browser/extensions/api/tabs/tabs_windows_api.h"
#include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
+#include "chrome/browser/extensions/extension_prefs_factory.h"
#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/extension_web_ui_override_registrar.h"
#include "chrome/browser/extensions/install_tracker_factory.h"
@@ -278,6 +279,7 @@ void ProfileDependencyManager::AssertFactoriesBuilt() {
extensions::CookiesAPI::GetFactoryInstance();
extensions::DialAPIFactory::GetInstance();
extensions::ExtensionActionAPI::GetFactoryInstance();
+ extensions::ExtensionPrefsFactory::GetInstance();
extensions::ExtensionSystemFactory::GetInstance();
extensions::ExtensionWebUIOverrideRegistrar::GetFactoryInstance();
extensions::FontSettingsAPI::GetFactoryInstance();
diff --git a/chrome/browser/ui/panels/base_panel_browser_test.cc b/chrome/browser/ui/panels/base_panel_browser_test.cc
index 5c4da16..4cce306 100644
--- a/chrome/browser/ui/panels/base_panel_browser_test.cc
+++ b/chrome/browser/ui/panels/base_panel_browser_test.cc
@@ -10,6 +10,7 @@
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
+#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
@@ -456,12 +457,9 @@ scoped_refptr<Extension> BasePanelBrowserTest::CreateExtension(
const base::FilePath::StringType& path,
extensions::Manifest::Location location,
const DictionaryValue& extra_value) {
-#if defined(OS_WIN)
- base::FilePath full_path(FILE_PATH_LITERAL("c:\\"));
-#else
- base::FilePath full_path(FILE_PATH_LITERAL("/"));
-#endif
- full_path = full_path.Append(path);
+ extensions::ExtensionPrefs* extension_prefs =
+ extensions::ExtensionPrefs::Get(browser()->profile());
+ base::FilePath full_path = extension_prefs->install_directory().Append(path);
scoped_ptr<DictionaryValue> input_value(extra_value.DeepCopy());
input_value->SetString(extension_manifest_keys::kVersion, "1.0.0.0");
diff --git a/chrome/browser/ui/panels/panel_browsertest.cc b/chrome/browser/ui/panels/panel_browsertest.cc
index d0ee3db..dd39bf1 100644
--- a/chrome/browser/ui/panels/panel_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_browsertest.cc
@@ -1454,7 +1454,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest,
DictionaryValue empty_value;
scoped_refptr<extensions::Extension> extension =
CreateExtension(FILE_PATH_LITERAL("TestExtension"),
- extensions::Manifest::INVALID_LOCATION, empty_value);
+ extensions::Manifest::INTERNAL, empty_value);
std::string extension_app_name =
web_app::GenerateApplicationNameFromExtensionId(extension->id());
@@ -1480,7 +1480,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest,
// Create another extension and a panel from that extension.
scoped_refptr<extensions::Extension> extension_other =
CreateExtension(FILE_PATH_LITERAL("TestExtensionOther"),
- extensions::Manifest::INVALID_LOCATION, empty_value);
+ extensions::Manifest::INTERNAL, empty_value);
std::string extension_app_name_other =
web_app::GenerateApplicationNameFromExtensionId(extension_other->id());
Panel* panel_other = CreatePanel(extension_app_name_other);
diff --git a/chrome/browser/ui/panels/stacked_panel_browsertest.cc b/chrome/browser/ui/panels/stacked_panel_browsertest.cc
index f1eebe2..e019ee2 100644
--- a/chrome/browser/ui/panels/stacked_panel_browsertest.cc
+++ b/chrome/browser/ui/panels/stacked_panel_browsertest.cc
@@ -988,12 +988,12 @@ IN_PROC_BROWSER_TEST_F(StackedPanelBrowserTest,
DictionaryValue empty_value;
scoped_refptr<extensions::Extension> extension1 =
CreateExtension(FILE_PATH_LITERAL("TestExtension1"),
- extensions::Manifest::INVALID_LOCATION, empty_value);
+ extensions::Manifest::INTERNAL, empty_value);
std::string extension1_app_name =
web_app::GenerateApplicationNameFromExtensionId(extension1->id());
scoped_refptr<extensions::Extension> extension2 =
CreateExtension(FILE_PATH_LITERAL("TestExtension2"),
- extensions::Manifest::INVALID_LOCATION, empty_value);
+ extensions::Manifest::INTERNAL, empty_value);
std::string extension2_app_name =
web_app::GenerateApplicationNameFromExtensionId(extension2->id());
diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi
index 8d8e1a1..c8a7747 100644
--- a/chrome/chrome_browser_extensions.gypi
+++ b/chrome/chrome_browser_extensions.gypi
@@ -585,6 +585,8 @@
'browser/extensions/extension_pref_value_map_factory.h',
'browser/extensions/extension_prefs.cc',
'browser/extensions/extension_prefs.h',
+ 'browser/extensions/extension_prefs_factory.cc',
+ 'browser/extensions/extension_prefs_factory.h',
'browser/extensions/extension_prefs_scope.h',
'browser/extensions/extension_process_manager.cc',
'browser/extensions/extension_process_manager.h',
diff --git a/extensions/common/constants.cc b/extensions/common/constants.cc
index d931137..f84386a 100644
--- a/extensions/common/constants.cc
+++ b/extensions/common/constants.cc
@@ -17,4 +17,6 @@ const base::FilePath::CharType kMessagesFilename[] =
const base::FilePath::CharType kPlatformSpecificFolder[] =
FILE_PATH_LITERAL("_platform_specific");
+const char kInstallDirectoryName[] = "Extensions";
+
} // namespace extensions
diff --git a/extensions/common/constants.h b/extensions/common/constants.h
index 31a4985..aeb9e67 100644
--- a/extensions/common/constants.h
+++ b/extensions/common/constants.h
@@ -24,6 +24,10 @@ extern const base::FilePath::CharType kMessagesFilename[];
// The base directory for subdirectories with platform-specific code.
extern const base::FilePath::CharType kPlatformSpecificFolder[];
+// The name of the directory inside the profile where extensions are
+// installed to.
+extern const char kInstallDirectoryName[];
+
} // namespace extensions
#endif // EXTENSIONS_COMMON_CONSTANTS_H_