summaryrefslogtreecommitdiff
path: root/chrome/installer
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2014-05-14 12:12:37 +0100
committerTorne (Richard Coles) <torne@google.com>2014-05-14 12:12:37 +0100
commit010d83a9304c5a91596085d917d248abff47903a (patch)
tree41ef1a01862f352f9653c7a9cfa817abefe2cce2 /chrome/installer
parent08c107de54178bb0990a09adec724924e8bc9486 (diff)
downloadchromium_org-010d83a9304c5a91596085d917d248abff47903a.tar.gz
Merge from Chromium at DEPS revision 269336
This commit was generated by merge_to_master.py. Change-Id: I8b9c77f10eccd2a8b4c7ce373ffda18568af54ff
Diffstat (limited to 'chrome/installer')
-rw-r--r--chrome/installer/setup/DEPS1
-rw-r--r--chrome/installer/setup/setup_main.cc6
-rw-r--r--chrome/installer/setup/uninstall.cc35
-rw-r--r--chrome/installer/util/auto_launch_util.cc22
-rw-r--r--chrome/installer/util/helper.cc36
-rw-r--r--chrome/installer/util/helper.h10
-rw-r--r--chrome/installer/util/installer_state.cc2
-rw-r--r--chrome/installer/util/product.cc4
-rw-r--r--chrome/installer/util/product.h7
-rw-r--r--chrome/installer/util/product_unittest.cc22
-rw-r--r--chrome/installer/util/user_experiment.cc33
-rw-r--r--chrome/installer/util/util_constants.cc1
-rw-r--r--chrome/installer/util/util_constants.h1
13 files changed, 67 insertions, 113 deletions
diff --git a/chrome/installer/setup/DEPS b/chrome/installer/setup/DEPS
index 3a8062cdec..a96cf4b697 100644
--- a/chrome/installer/setup/DEPS
+++ b/chrome/installer/setup/DEPS
@@ -1,5 +1,4 @@
include_rules = [
"+chrome/app",
"+courgette",
- "+extensions/common/constants.h",
]
diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc
index 5b64ab6e77..57fe5e5c25 100644
--- a/chrome/installer/setup/setup_main.cc
+++ b/chrome/installer/setup/setup_main.cc
@@ -1353,8 +1353,10 @@ void UninstallMultiChromeFrameIfPresent(const CommandLine& cmd_line,
MasterPreferences uninstall_prefs(uninstall_cmd);
InstallerState uninstall_state;
uninstall_state.Initialize(uninstall_cmd, uninstall_prefs, *original_state);
- const Product* chrome_frame_product = uninstall_state.FindProduct(
- BrowserDistribution::CHROME_FRAME);
+ // Post M32, uninstall_prefs and uninstall_state won't have Chrome Frame in
+ // them since they've lost the power to do Chrome Frame installs.
+ const Product* chrome_frame_product = uninstall_state.AddProductFromState(
+ BrowserDistribution::CHROME_FRAME, *chrome_frame_state);
if (chrome_frame_product) {
// No shared state should be left behind.
const bool remove_all = true;
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 91502141de..353e390053 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -24,7 +24,7 @@
#include "base/win/shortcut.h"
#include "base/win/windows_version.h"
#include "chrome/common/chrome_constants.h"
-#include "chrome/common/chrome_paths_internal.h"
+#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_result_codes.h"
#include "chrome/installer/launcher_support/chrome_launcher_support.h"
#include "chrome/installer/setup/install.h"
@@ -47,7 +47,6 @@
#include "chrome/installer/util/shell_util.h"
#include "chrome/installer/util/util_constants.h"
#include "content/public/common/result_codes.h"
-#include "extensions/common/constants.h"
#include "rlz/lib/rlz_lib.h"
using base::win::RegKey;
@@ -388,20 +387,25 @@ DeleteResult DeleteEmptyDir(const base::FilePath& path) {
return DELETE_FAILED;
}
+// Get the user data directory, which is *not* DIR_USER_DATA for Chrome Frame.
+// TODO(grt): Remove Chrome Frame uninstall support when usage is low enough.
base::FilePath GetUserDataDir(const Product& product) {
- // Obtain the location of the user profile data.
- base::FilePath user_data_dir = product.GetUserDataPath();
- LOG_IF(ERROR, user_data_dir.empty())
- << "Could not retrieve user's profile directory.";
-
- return user_data_dir;
+ base::FilePath path;
+ bool is_chrome_frame = product.is_chrome_frame();
+ int key = is_chrome_frame ? base::DIR_LOCAL_APP_DATA : chrome::DIR_USER_DATA;
+ if (!PathService::Get(key, &path))
+ return base::FilePath();
+ if (is_chrome_frame) {
+ path = path.Append(product.distribution()->GetInstallSubDir());
+ path = path.Append(chrome::kUserDataDirname);
+ }
+ return path;
}
// Creates a copy of the local state file and returns a path to the copy.
base::FilePath BackupLocalStateFile(const base::FilePath& user_data_dir) {
base::FilePath backup;
- base::FilePath state_file(
- user_data_dir.Append(chrome::kLocalStateFilename));
+ base::FilePath state_file(user_data_dir.Append(chrome::kLocalStateFilename));
if (!base::CreateTemporaryFile(&backup))
LOG(ERROR) << "Failed to create temporary file for Local State.";
else
@@ -1043,7 +1047,7 @@ const wchar_t kChromeExtProgId[] = L"ChromiumExt";
// Delete Software\Classes\.crx,
base::string16 ext_association(ShellUtil::kRegClasses);
ext_association.append(L"\\");
- ext_association.append(extensions::kExtensionFileExtension);
+ ext_association.append(L".crx");
InstallUtil::DeleteRegistryKey(roots[i], ext_association);
}
}
@@ -1327,7 +1331,14 @@ InstallStatus UninstallProduct(const InstallationState& original_state,
// (aka non-multi) installation or we are the Chrome Binaries.
base::FilePath user_data_dir(GetUserDataDir(product));
- base::FilePath backup_state_file(BackupLocalStateFile(user_data_dir));
+ base::FilePath backup_state_file;
+ if (!user_data_dir.empty()) {
+ backup_state_file = BackupLocalStateFile(user_data_dir);
+ } else {
+ LOG(ERROR) << "Could not retrieve the user's profile directory.";
+ ret = installer::UNINSTALL_FAILED;
+ delete_profile = false;
+ }
if (product.is_chrome_app_host()) {
DeleteAppHostFilesAndFolders(installer_state, product_state->version());
diff --git a/chrome/installer/util/auto_launch_util.cc b/chrome/installer/util/auto_launch_util.cc
index 6dd5d35d5e..7ad231536e 100644
--- a/chrome/installer/util/auto_launch_util.cc
+++ b/chrome/installer/util/auto_launch_util.cc
@@ -12,10 +12,9 @@
#include "base/strings/utf_string_conversions.h"
#include "base/win/win_util.h"
#include "chrome/common/chrome_constants.h"
+#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
-#include "chrome/installer/util/browser_distribution.h"
-#include "chrome/installer/util/product.h"
#include "chrome/installer/util/util_constants.h"
#include "crypto/sha2.h"
@@ -36,25 +35,15 @@ enum FlagSetting {
FLAG_PRESERVE, // Preserve the value that the flag has currently.
};
-// A helper function that takes a |profile_path| and builds a registry key
+// A helper function that takes a |profile_directory| and builds a registry key
// name to use when deciding where to read/write the auto-launch value
// to/from. It takes into account the name of the profile (so that different
// installations of Chrome don't conflict, and so the in the future different
// profiles can be auto-launched (or not) separately).
base::string16 ProfileToKeyName(const base::string16& profile_directory) {
base::FilePath path;
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (command_line.HasSwitch(switches::kUserDataDir)) {
- path = command_line.GetSwitchValuePath(switches::kUserDataDir);
- } else {
- // Get the path from the same source as the installer, to make sure there
- // are no differences.
- BrowserDistribution* distribution =
- BrowserDistribution::GetSpecificDistribution(
- BrowserDistribution::CHROME_BROWSER);
- installer::Product product(distribution);
- path = product.GetUserDataPath();
- }
+ const bool success = PathService::Get(chrome::DIR_USER_DATA, &path);
+ DCHECK(success);
path = path.Append(profile_directory);
std::string input(path.AsUTF8Unsafe());
@@ -212,8 +201,7 @@ void SetWillLaunchAtLogin(const base::FilePath& application_path,
cmd_line += ASCIIToUTF16("\"");
}
- base::win::AddCommandToAutoRun(
- HKEY_CURRENT_USER, key_name, cmd_line);
+ base::win::AddCommandToAutoRun(HKEY_CURRENT_USER, key_name, cmd_line);
} else {
base::win::RemoveCommandFromAutoRun(HKEY_CURRENT_USER, key_name);
}
diff --git a/chrome/installer/util/helper.cc b/chrome/installer/util/helper.cc
index df63dc0ed3..f76213ded3 100644
--- a/chrome/installer/util/helper.cc
+++ b/chrome/installer/util/helper.cc
@@ -12,39 +12,17 @@
#include "chrome/installer/util/installation_state.h"
#include "chrome/installer/util/util_constants.h"
-namespace {
-
-base::FilePath GetChromeInstallBasePath(bool system,
- BrowserDistribution* distribution,
- const wchar_t* sub_path) {
- base::FilePath install_path;
- if (system) {
- PathService::Get(base::DIR_PROGRAM_FILES, &install_path);
- } else {
- PathService::Get(base::DIR_LOCAL_APP_DATA, &install_path);
- }
-
- if (!install_path.empty()) {
- install_path = install_path.Append(distribution->GetInstallSubDir());
- install_path = install_path.Append(sub_path);
- }
-
- return install_path;
-}
-
-} // namespace
-
namespace installer {
base::FilePath GetChromeInstallPath(bool system_install,
BrowserDistribution* dist) {
- return GetChromeInstallBasePath(system_install, dist, kInstallBinaryDir);
-}
-
-base::FilePath GetChromeUserDataPath(BrowserDistribution* dist) {
- // TODO(msw): Remove this method and make callers use PathService directly to
- // obtain the right DIR_USER_DATA.
- return GetChromeInstallBasePath(false, dist, kInstallUserDataDir);
+ base::FilePath install_path;
+ int key = system_install ? base::DIR_PROGRAM_FILES : base::DIR_LOCAL_APP_DATA;
+ if (PathService::Get(key, &install_path)) {
+ install_path = install_path.Append(dist->GetInstallSubDir());
+ install_path = install_path.Append(kInstallBinaryDir);
+ }
+ return install_path;
}
BrowserDistribution* GetBinariesDistribution(bool system_install) {
diff --git a/chrome/installer/util/helper.h b/chrome/installer/util/helper.h
index 152a160bc9..940db447f6 100644
--- a/chrome/installer/util/helper.h
+++ b/chrome/installer/util/helper.h
@@ -22,14 +22,8 @@ namespace installer {
// system_install: if true, the function returns system wide location
// (ProgramFiles\Google). Otherwise it returns user specific
// location (Document And Settings\<user>\Local Settings...)
-base::FilePath GetChromeInstallPath(bool system_install, BrowserDistribution* dist);
-
-// Returns the path to the directory that holds the user data. This is always
-// inside a user's local application data folder (e.g., "AppData\Local" or
-// "Local Settings\Application Data" in %USERPROFILE%). Note that this is the
-// default user data directory and does not take into account that it can be
-// overriden with a command line parameter.
-base::FilePath GetChromeUserDataPath(BrowserDistribution* dist);
+base::FilePath GetChromeInstallPath(bool system_install,
+ BrowserDistribution* dist);
// Returns the distribution corresponding to the current process's binaries.
// In the case of a multi-install product, this will be the CHROME_BINARIES
diff --git a/chrome/installer/util/installer_state.cc b/chrome/installer/util/installer_state.cc
index a5ed9d96e8..e6cc475e5e 100644
--- a/chrome/installer/util/installer_state.cc
+++ b/chrome/installer/util/installer_state.cc
@@ -661,7 +661,7 @@ void InstallerState::GetExistingExeVersions(
FileVersionInfo::CreateFileVersionInfo(chrome_exe));
if (file_version_info) {
base::string16 version_string = file_version_info->file_version();
- if (!version_string.empty() && IsStringASCII(version_string))
+ if (!version_string.empty() && base::IsStringASCII(version_string))
existing_versions->insert(base::UTF16ToASCII(version_string));
}
}
diff --git a/chrome/installer/util/product.cc b/chrome/installer/util/product.cc
index 1d11a7ee72..7ade852aa7 100644
--- a/chrome/installer/util/product.cc
+++ b/chrome/installer/util/product.cc
@@ -62,10 +62,6 @@ void Product::InitializeFromUninstallCommand(
operations_->ReadOptions(uninstall_command, &options_);
}
-base::FilePath Product::GetUserDataPath() const {
- return GetChromeUserDataPath(distribution_);
-}
-
bool Product::LaunchChrome(const base::FilePath& application_path) const {
bool success = !application_path.empty();
if (success) {
diff --git a/chrome/installer/util/product.h b/chrome/installer/util/product.h
index c9da9067b5..a815fb2946 100644
--- a/chrome/installer/util/product.h
+++ b/chrome/installer/util/product.h
@@ -81,13 +81,6 @@ class Product {
return options_.erase(option) != 0;
}
- // Returns the path to the directory that holds the user data. This is always
- // inside a user's local application data folder (e.g., "AppData\Local" or
- // "Local Settings\Application Data" in %USERPROFILE%). Note that this is the
- // default user data directory and does not take into account that it can be
- // overriden with a command line parameter.
- base::FilePath GetUserDataPath() const;
-
// Launches Chrome without waiting for it to exit.
bool LaunchChrome(const base::FilePath& application_path) const;
diff --git a/chrome/installer/util/product_unittest.cc b/chrome/installer/util/product_unittest.cc
index fa4c27ea8c..eabade71f3 100644
--- a/chrome/installer/util/product_unittest.cc
+++ b/chrome/installer/util/product_unittest.cc
@@ -5,8 +5,10 @@
#include "chrome/installer/util/product_unittest.h"
#include "base/logging.h"
+#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/test_reg_util_win.h"
+#include "chrome/common/chrome_paths.h"
#include "chrome/installer/util/chrome_frame_distribution.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/installation_state.h"
@@ -45,14 +47,7 @@ class ProductTest : public TestWithTempDirAndDeleteTempOverrideKeys {
protected:
};
-// This test is flaky on Win, see http://crbug.com/100567
-#if defined(OS_WIN)
-#define MAYBE_ProductInstallBasic DISABLED_ProductInstallBasic
-#else
-#define MAYBE_ProductInstallBasic ProductInstallBasic
-#endif
-
-TEST_F(ProductTest, MAYBE_ProductInstallBasic) {
+TEST_F(ProductTest, ProductInstallBasic) {
// TODO(tommi): We should mock this and use our mocked distribution.
const bool multi_install = false;
const bool system_level = true;
@@ -70,17 +65,16 @@ TEST_F(ProductTest, MAYBE_ProductInstallBasic) {
BrowserDistribution* distribution = product->distribution();
EXPECT_EQ(BrowserDistribution::CHROME_BROWSER, distribution->GetType());
- base::FilePath user_data(product->GetUserDataPath());
- EXPECT_FALSE(user_data.empty());
- EXPECT_NE(std::wstring::npos,
- user_data.value().find(installer::kInstallUserDataDir));
+ base::FilePath user_data_dir;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir));
+ EXPECT_FALSE(user_data_dir.empty());
base::FilePath program_files;
- PathService::Get(base::DIR_PROGRAM_FILES, &program_files);
+ ASSERT_TRUE(PathService::Get(base::DIR_PROGRAM_FILES, &program_files));
// The User Data path should never be under program files, even though
// system_level is true.
EXPECT_EQ(std::wstring::npos,
- user_data.value().find(program_files.value()));
+ user_data_dir.value().find(program_files.value()));
// There should be no installed version in the registry.
machine_state.Initialize();
diff --git a/chrome/installer/util/user_experiment.cc b/chrome/installer/util/user_experiment.cc
index 73de5a6413..68e4eace8a 100644
--- a/chrome/installer/util/user_experiment.cc
+++ b/chrome/installer/util/user_experiment.cc
@@ -11,6 +11,7 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
+#include "base/path_service.h"
#include "base/process/launch.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
@@ -20,6 +21,7 @@
#include "base/win/scoped_handle.h"
#include "base/win/windows_version.h"
#include "chrome/common/attrition_experiments.h"
+#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_result_codes.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/installer/util/browser_distribution.h"
@@ -85,11 +87,14 @@ int GetDirectoryWriteTimeInHours(const wchar_t* path) {
return ::GetFileTime(file, NULL, NULL, &time) ? FileTimeToHours(time) : -1;
}
-// Returns the directory last-write time age in hours, relative to current
-// time, so if it returns 14 it means that the directory was last written 14
-// hours ago. Returns -1 if there was an error retrieving the directory.
-int GetDirectoryWriteAgeInHours(const wchar_t* path) {
- int dir_time = GetDirectoryWriteTimeInHours(path);
+// Returns the time in hours since the last write to the user data directory.
+// A return value of 14 means that the directory was last written 14 hours ago.
+// Returns -1 if there was an error retrieving the directory.
+int GetUserDataDirectoryWriteAgeInHours() {
+ base::FilePath user_data_dir;
+ if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir))
+ return -1;
+ int dir_time = GetDirectoryWriteTimeInHours(user_data_dir.value().c_str());
if (dir_time < 0)
return dir_time;
FILETIME time;
@@ -425,21 +430,17 @@ void LaunchBrowserUserExperiment(const CommandLine& base_cmd_line,
return;
}
}
- // Check browser usage inactivity by the age of the last-write time of the
- // most recently-used chrome user data directory.
- BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution(
- BrowserDistribution::CHROME_BROWSER);
- base::FilePath user_data_dir(GetChromeUserDataPath(dist));
-
const bool experiment_enabled = false;
- const int kThirtyDays = 30 * 24;
-
- int dir_age_hours = GetDirectoryWriteAgeInHours(
- user_data_dir.value().c_str());
if (!experiment_enabled) {
VLOG(1) << "Toast experiment is disabled.";
return;
- } else if (dir_age_hours < 0) {
+ }
+
+ // Check browser usage inactivity by the age of the last-write time of the
+ // relevant chrome user data directory.
+ const int kThirtyDays = 30 * 24;
+ const int dir_age_hours = GetUserDataDirectoryWriteAgeInHours();
+ if (dir_age_hours < 0) {
// This means that we failed to find the user data dir. The most likely
// cause is that this user has not ever used chrome at all which can
// happen in a system-level install.
diff --git a/chrome/installer/util/util_constants.cc b/chrome/installer/util/util_constants.cc
index b4639e5557..8800c5c461 100644
--- a/chrome/installer/util/util_constants.cc
+++ b/chrome/installer/util/util_constants.cc
@@ -238,7 +238,6 @@ const wchar_t kGoogleChromeInstallSubDir2[] = L"Chrome";
const wchar_t kInstallBinaryDir[] = L"Application";
const wchar_t kInstallerDir[] = L"Installer";
const wchar_t kInstallTempDir[] = L"Temp";
-const wchar_t kInstallUserDataDir[] = L"User Data";
const wchar_t kLnkExt[] = L".lnk";
const wchar_t kNaClExe[] = L"nacl64.exe";
const wchar_t kSetupExe[] = L"setup.exe";
diff --git a/chrome/installer/util/util_constants.h b/chrome/installer/util/util_constants.h
index d5d6281e99..09416e4a7e 100644
--- a/chrome/installer/util/util_constants.h
+++ b/chrome/installer/util/util_constants.h
@@ -224,7 +224,6 @@ extern const wchar_t kGoogleChromeInstallSubDir2[];
extern const wchar_t kInstallBinaryDir[];
extern const wchar_t kInstallerDir[];
extern const wchar_t kInstallTempDir[];
-extern const wchar_t kInstallUserDataDir[];
extern const wchar_t kLnkExt[];
extern const wchar_t kNaClExe[];
extern const wchar_t kSetupExe[];