Chromium Code Reviews| Index: chrome/browser/extensions/extension_service.cc |
| diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc |
| index 9d6d90f55e8cd6b8f415da72ac43bfcd6bcb59a1..d51cc0c076507f101aecf9fc469775677266989b 100644 |
| --- a/chrome/browser/extensions/extension_service.cc |
| +++ b/chrome/browser/extensions/extension_service.cc |
| @@ -45,6 +45,7 @@ |
| #include "chrome/browser/extensions/extension_host.h" |
| #include "chrome/browser/extensions/extension_input_ime_api.h" |
| #include "chrome/browser/extensions/extension_management_api.h" |
| +#include "chrome/browser/extensions/extension_pref_value_map.h" |
| #include "chrome/browser/extensions/extension_preference_api.h" |
| #include "chrome/browser/extensions/extension_process_manager.h" |
| #include "chrome/browser/extensions/extension_processes_api.h" |
| @@ -78,7 +79,9 @@ |
| #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| #include "chrome/browser/ui/webui/favicon_source.h" |
| #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
| +#include "chrome/browser/web_applications/web_app.h" |
| #include "chrome/common/child_process_logging.h" |
| +#include "chrome/common/chrome_constants.h" |
| #include "chrome/common/chrome_notification_types.h" |
| #include "chrome/common/chrome_paths.h" |
| #include "chrome/common/chrome_switches.h" |
| @@ -2231,19 +2234,11 @@ void ExtensionService::OnExtensionInstalled( |
| from_webstore, |
| page_ordinal); |
| - // Unpacked extensions default to allowing file access, but if that has been |
| - // overridden, don't reset the value. |
| - if (Extension::ShouldAlwaysAllowFileAccess(extension->location()) && |
| - !extension_prefs_->HasAllowFileAccessSetting(id)) { |
| - extension_prefs_->SetAllowFileAccess(id, true); |
| + if (initial_enable && extension->RequiresSeparateUserDataDirectory()) { |
| + SetupExtensionPrefsInSeparateDataDirectory( |
| + extension, from_webstore, page_ordinal); |
| } |
| - // If the extension should automatically block network startup (e.g., it uses |
| - // the webRequest API), set the preference. Otherwise clear it, in case the |
| - // extension stopped using a relevant API. |
| - extension_prefs_->SetDelaysNetworkRequests( |
| - extension->id(), extension->ImplicitlyDelaysNetworkStartup()); |
| - |
| content::NotificationService::current()->Notify( |
| chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| content::Source<Profile>(profile_), |
| @@ -2636,3 +2631,29 @@ extensions::SocketController* ExtensionService::socket_controller() { |
| } |
| return socket_controller_; |
| } |
| + |
| +void ExtensionService::SetupExtensionPrefsInSeparateDataDirectory( |
| + const Extension* extension, |
| + bool from_webstore, |
| + const StringOrdinal& page_ordinal) { |
| + const std::string& id = extension->id(); |
| + FilePath data_dir = |
| + web_app::GetWebAppDataDirectory(profile_->GetPath(), *extension); |
| + FilePath profile_path = data_dir.AppendASCII(chrome::kInitialProfile); |
| + FilePath pref_path = profile_path.Append(chrome::kPreferencesFilename); |
| + scoped_ptr<PrefService> prefs_service(PrefService::CreatePrefService( |
| + pref_path, NULL, false)); |
| + |
| + ExtensionPrefValueMap map; |
| + ExtensionPrefs::RegisterUserPrefs(prefs_service.get()); |
| + ExtensionPrefs extension_prefs(prefs_service.get(), install_directory_, &map); |
| + extension_prefs.Init(false); |
| + extension_prefs.OnExtensionInstalled(extension, |
| + Extension::ENABLED, |
| + from_webstore, |
| + page_ordinal); |
| + extension_prefs.AddGrantedPermissions(id, extension->GetActivePermissions()); |
|
Mihai Parparita -not on Chrome
2012/02/13 23:29:24
Is this a (partial) duplication of what CrxInstall
|
| + extension_prefs.SetExtensionState(id, Extension::ENABLED); |
| + |
| + prefs_service->CommitPendingWrite(); |
| +} |