| Index: chrome/browser/extensions/webstore_installer.cc
|
| diff --git a/chrome/browser/extensions/webstore_installer.cc b/chrome/browser/extensions/webstore_installer.cc
|
| index 5ef853c25f2366f8bdb027dc77f7aafa3a7ad644..40b977685948cd2de8dc727e0b406eff77ced810 100644
|
| --- a/chrome/browser/extensions/webstore_installer.cc
|
| +++ b/chrome/browser/extensions/webstore_installer.cc
|
| @@ -10,6 +10,8 @@
|
| #include "base/bind.h"
|
| #include "base/command_line.h"
|
| #include "base/file_util.h"
|
| +#include "base/metrics/field_trial.h"
|
| +#include "base/path_service.h"
|
| #include "base/rand_util.h"
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/strings/string_util.h"
|
| @@ -27,6 +29,7 @@
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/ui/browser_list.h"
|
| #include "chrome/browser/ui/tabs/tab_strip_model.h"
|
| +#include "chrome/common/chrome_paths.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/extensions/extension.h"
|
| #include "chrome/common/extensions/extension_constants.h"
|
| @@ -79,6 +82,11 @@ const char kInlineInstallSource[] = "inline";
|
| const char kDefaultInstallSource[] = "ondemand";
|
| const char kAppLauncherInstallSource[] = "applauncher";
|
|
|
| +// Folder for downloading crx files from the webstore. This is used so that the
|
| +// crx files don't go via the usual downloads folder.
|
| +const base::FilePath::CharType kWebstoreDownloadFolder[] =
|
| + FILE_PATH_LITERAL("Webstore Downloads");
|
| +
|
| base::FilePath* g_download_directory_for_tests = NULL;
|
|
|
| // Must be executed on the FILE thread.
|
| @@ -125,6 +133,16 @@ void GetDownloadFilePath(
|
| base::Bind(callback, file));
|
| }
|
|
|
| +bool UseSeparateWebstoreDownloadDirectory() {
|
| + const char kWebstoreDownloadDirectoryFieldTrialName[] =
|
| + "WebstoreDownloadDirectory";
|
| + const char kSeparateDirectoryUnderUDD[] = "SeparateDirectoryUnderUDD";
|
| +
|
| + std::string field_trial_group = base::FieldTrialList::FindFullName(
|
| + kWebstoreDownloadDirectoryFieldTrialName);
|
| + return field_trial_group == kSeparateDirectoryUnderUDD;
|
| +}
|
| +
|
| } // namespace
|
|
|
| namespace extensions {
|
| @@ -487,8 +505,17 @@ void WebstoreInstaller::DownloadNextPendingModule() {
|
| void WebstoreInstaller::DownloadCrx(
|
| const std::string& extension_id, InstallSource source) {
|
| download_url_ = GetWebstoreInstallURL(extension_id, source);
|
| - base::FilePath download_path = DownloadPrefs::FromDownloadManager(
|
| - BrowserContext::GetDownloadManager(profile_))->DownloadPath();
|
| +
|
| + base::FilePath download_path;
|
| + if (UseSeparateWebstoreDownloadDirectory()) {
|
| + base::FilePath user_data_dir;
|
| + PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
|
| + download_path = user_data_dir.Append(kWebstoreDownloadFolder);
|
| + } else {
|
| + download_path = DownloadPrefs::FromDownloadManager(
|
| + BrowserContext::GetDownloadManager(profile_))->DownloadPath();
|
| + }
|
| +
|
| BrowserThread::PostTask(
|
| BrowserThread::FILE, FROM_HERE,
|
| base::Bind(&GetDownloadFilePath, download_path, id_,
|
|
|