Add support for IsPerUserInstall in the Configurator interface.
This is a mechanical change. The code will be use in the next CL to
refactor how the UpdaterState is being sent in the
component updater update checks.
BUG=615187
Review-Url: https://codereview.chromium.org/2399533004
Cr-Commit-Position: refs/heads/master@{#423579}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index d25dcef..fb42245b 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -228,6 +228,8 @@
"component_updater/component_updater_prefs.h",
"component_updater/component_updater_resource_throttle.cc",
"component_updater/component_updater_resource_throttle.h",
+ "component_updater/component_updater_utils.cc",
+ "component_updater/component_updater_utils.h",
"component_updater/ev_whitelist_component_installer.cc",
"component_updater/ev_whitelist_component_installer.h",
"component_updater/file_type_policies_component_installer.cc",
diff --git a/chrome/browser/component_updater/chrome_component_updater_configurator.cc b/chrome/browser/component_updater/chrome_component_updater_configurator.cc
index dbdccf3f..ea83a735 100644
--- a/chrome/browser/component_updater/chrome_component_updater_configurator.cc
+++ b/chrome/browser/component_updater/chrome_component_updater_configurator.cc
@@ -15,13 +15,14 @@
#endif
#include "chrome/browser/browser_process.h"
#include "chrome/browser/component_updater/component_patcher_operation_out_of_process.h"
+#include "chrome/browser/component_updater/component_updater_utils.h"
#include "chrome/browser/google/google_brand.h"
#include "chrome/browser/update_client/chrome_update_query_params_delegate.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/pref_names.h"
#if defined(OS_WIN)
#include "chrome/installer/util/google_update_settings.h"
-#endif
+#endif // OS_WIN
#include "components/component_updater/configurator_impl.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
@@ -64,6 +65,7 @@
scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner()
const override;
PrefService* GetPrefService() const override;
+ bool IsPerUserInstall() const override;
private:
friend class base::RefCountedThreadSafe<ChromeConfigurator>;
@@ -200,6 +202,10 @@
return pref_service_;
}
+bool ChromeConfigurator::IsPerUserInstall() const {
+ return component_updater::IsPerUserInstall();
+}
+
} // namespace
void RegisterPrefsForChromeComponentUpdaterConfigurator(
diff --git a/chrome/browser/component_updater/component_updater_utils.cc b/chrome/browser/component_updater/component_updater_utils.cc
new file mode 100644
index 0000000..efd113a
--- /dev/null
+++ b/chrome/browser/component_updater/component_updater_utils.cc
@@ -0,0 +1,23 @@
+// Copyright 2016 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 "chrome/browser/component_updater/component_updater_utils.h"
+
+#if defined(OS_WIN)
+#include "chrome/installer/util/install_util.h"
+#endif // OS_WIN
+
+namespace component_updater {
+
+bool IsPerUserInstall() {
+#if defined(OS_WIN)
+ base::FilePath exe_path;
+ PathService::Get(base::FILE_EXE, &exe_path);
+ return InstallUtil::IsPerUserInstall(exe_path);
+#else
+ return true;
+#endif
+}
+
+} // namespace component_updater
diff --git a/chrome/browser/component_updater/component_updater_utils.h b/chrome/browser/component_updater/component_updater_utils.h
new file mode 100644
index 0000000..3b552845
--- /dev/null
+++ b/chrome/browser/component_updater/component_updater_utils.h
@@ -0,0 +1,18 @@
+// Copyright 2016 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_COMPONENT_UPDATER_COMPONENT_UPDATER_UTILS_H_
+#define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_UTILS_H_
+
+namespace component_updater {
+
+// Returns true if Chrome is installed for the current user, or false
+// if Chrome is installed for all users on the machine. Some platforms
+// don't support this type of install. In this case, assume it is a user
+// install and return true.
+bool IsPerUserInstall();
+
+} // namespace component_updater
+
+#endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_UTILS_H_
diff --git a/chrome/browser/extensions/updater/chrome_update_client_config.cc b/chrome/browser/extensions/updater/chrome_update_client_config.cc
index 11690a8..b6e5a97 100644
--- a/chrome/browser/extensions/updater/chrome_update_client_config.cc
+++ b/chrome/browser/extensions/updater/chrome_update_client_config.cc
@@ -5,6 +5,7 @@
#include "base/command_line.h"
#include "base/version.h"
#include "chrome/browser/component_updater/component_patcher_operation_out_of_process.h"
+#include "chrome/browser/component_updater/component_updater_utils.h"
#include "chrome/browser/extensions/updater/chrome_update_client_config.h"
#include "chrome/browser/google/google_brand.h"
#include "chrome/browser/update_client/chrome_update_query_params_delegate.h"
@@ -117,6 +118,10 @@
return nullptr;
}
+bool ChromeUpdateClientConfig::IsPerUserInstall() const {
+ return component_updater::IsPerUserInstall();
+}
+
ChromeUpdateClientConfig::~ChromeUpdateClientConfig() {}
} // namespace extensions
diff --git a/chrome/browser/extensions/updater/chrome_update_client_config.h b/chrome/browser/extensions/updater/chrome_update_client_config.h
index 1b142574..0b051c4 100644
--- a/chrome/browser/extensions/updater/chrome_update_client_config.h
+++ b/chrome/browser/extensions/updater/chrome_update_client_config.h
@@ -46,6 +46,7 @@
bool EnabledBackgroundDownloader() const override;
bool EnabledCupSigning() const override;
PrefService* GetPrefService() const override;
+ bool IsPerUserInstall() const override;
protected:
friend class base::RefCountedThreadSafe<ChromeUpdateClientConfig>;
diff --git a/components/update_client/configurator.h b/components/update_client/configurator.h
index 6034ad89..384b23de6 100644
--- a/components/update_client/configurator.h
+++ b/components/update_client/configurator.h
@@ -131,6 +131,10 @@
// persistent storage.
virtual PrefService* GetPrefService() const = 0;
+ // Returns true if the Chrome is installed for the current user only, or false
+ // if Chrome is installed for all users on the machine.
+ virtual bool IsPerUserInstall() const = 0;
+
protected:
friend class base::RefCountedThreadSafe<Configurator>;
diff --git a/components/update_client/test_configurator.cc b/components/update_client/test_configurator.cc
index d206086..edf5ddf 100644
--- a/components/update_client/test_configurator.cc
+++ b/components/update_client/test_configurator.cc
@@ -175,4 +175,8 @@
return nullptr;
}
+bool TestConfigurator::IsPerUserInstall() const {
+ return true;
+}
+
} // namespace update_client
diff --git a/components/update_client/test_configurator.h b/components/update_client/test_configurator.h
index 74ecad8..89132f5 100644
--- a/components/update_client/test_configurator.h
+++ b/components/update_client/test_configurator.h
@@ -86,6 +86,7 @@
scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner()
const override;
PrefService* GetPrefService() const override;
+ bool IsPerUserInstall() const override;
void SetBrand(const std::string& brand);
void SetOnDemandTime(int seconds);
diff --git a/ios/chrome/browser/component_updater/ios_component_updater_configurator.cc b/ios/chrome/browser/component_updater/ios_component_updater_configurator.cc
index b36979a..9213e9b 100644
--- a/ios/chrome/browser/component_updater/ios_component_updater_configurator.cc
+++ b/ios/chrome/browser/component_updater/ios_component_updater_configurator.cc
@@ -52,6 +52,7 @@
scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner()
const override;
PrefService* GetPrefService() const override;
+ bool IsPerUserInstall() const override;
private:
friend class base::RefCountedThreadSafe<IOSConfigurator>;
@@ -169,6 +170,10 @@
return GetApplicationContext()->GetLocalState();
}
+bool IOSConfigurator::IsPerUserInstall() const {
+ return true;
+}
+
} // namespace
scoped_refptr<update_client::Configurator> MakeIOSComponentUpdaterConfigurator(