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

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

Issue 46583007: Download webstore CRXs into separate directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove field trial block Created 7 years, 1 month 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/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[] =
jar (doing other things) 2013/11/18 23:49:44 nit: these super long names reduce readability IMO
jackhou1 2013/11/19 06:56:48 Done.
+ "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) {
jar (doing other things) 2013/11/18 23:49:44 nit: one arg per line.
jackhou1 2013/11/19 06:56:48 Done.
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_,

Powered by Google App Engine
This is Rietveld 408576698