summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/installer/util')
-rw-r--r--chrome/installer/util/browser_distribution.cc84
-rw-r--r--chrome/installer/util/browser_distribution.h72
-rw-r--r--chrome/installer/util/google_chrome_distribution.cc218
-rw-r--r--chrome/installer/util/google_chrome_distribution.h82
-rw-r--r--chrome/installer/util/google_chrome_distribution_unittest.cc (renamed from chrome/installer/util/install_util_unittest.cc)68
-rw-r--r--chrome/installer/util/helper.cc7
-rw-r--r--chrome/installer/util/install_util.cc48
-rw-r--r--chrome/installer/util/install_util.h22
-rw-r--r--chrome/installer/util/installer_unittests.vcproj6
-rw-r--r--chrome/installer/util/prebuild/create_string_rc.py6
-rw-r--r--chrome/installer/util/shell_util.cc13
-rw-r--r--chrome/installer/util/using_util.vsprops11
-rw-r--r--chrome/installer/util/util.vcproj16
-rw-r--r--chrome/installer/util/util_constants.cc6
-rw-r--r--chrome/installer/util/util_constants.h8
15 files changed, 525 insertions, 142 deletions
diff --git a/chrome/installer/util/browser_distribution.cc b/chrome/installer/util/browser_distribution.cc
new file mode 100644
index 0000000..3c02cb0
--- /dev/null
+++ b/chrome/installer/util/browser_distribution.cc
@@ -0,0 +1,84 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// This file defines a class that contains various method related to branding.
+// It provides only default implementations of these methods. Usually to add
+// specific branding, we will need to extend this class with a custom
+// implementation.
+
+#include "chrome/installer/util/browser_distribution.h"
+#include "chrome/installer/util/google_chrome_distribution.h"
+
+BrowserDistribution* BrowserDistribution::GetDistribution() {
+ static BrowserDistribution* dist = NULL;
+ if (dist == NULL) {
+#if defined(GOOGLE_CHROME_BUILD)
+ dist = new GoogleChromeDistribution();
+#else
+ dist = new BrowserDistribution();
+#endif
+ }
+ return dist;
+}
+
+void BrowserDistribution::DoPostUninstallOperations(
+ const installer::Version& version) {
+}
+
+void BrowserDistribution::DoPreUninstallOperations() {
+}
+
+std::wstring BrowserDistribution::GetApplicationName() {
+ return L"Chromium";
+}
+
+std::wstring BrowserDistribution::GetInstallSubDir() {
+ return L"Chromium";
+}
+
+std::wstring BrowserDistribution::GetPublisherName() {
+ return L"Chromium";
+}
+
+int BrowserDistribution::GetInstallReturnCode(
+ installer_util::InstallStatus install_status) {
+ return install_status;
+}
+
+std::wstring BrowserDistribution::GetUninstallRegPath() {
+ return L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Chromium";
+}
+
+std::wstring BrowserDistribution::GetVersionKey() {
+ return L"Software\\Chromium";
+}
+
+void BrowserDistribution::UpdateDiffInstallStatus(bool system_install,
+ bool incremental_install, installer_util::InstallStatus install_status) {
+}
diff --git a/chrome/installer/util/browser_distribution.h b/chrome/installer/util/browser_distribution.h
new file mode 100644
index 0000000..3ede388
--- /dev/null
+++ b/chrome/installer/util/browser_distribution.h
@@ -0,0 +1,72 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// This file declares a class that contains various method related to branding.
+
+#ifndef CHROME_INSTALLER_UTIL_BROWSER_DISTRIBUTION_H_
+#define CHROME_INSTALLER_UTIL_BROWSER_DISTRIBUTION_H_
+
+#include "base/basictypes.h"
+#include "chrome/installer/util/util_constants.h"
+#include "chrome/installer/util/version.h"
+
+class BrowserDistribution {
+ public:
+ virtual ~BrowserDistribution() {}
+
+ static BrowserDistribution* GetDistribution();
+
+ virtual void DoPostUninstallOperations(const installer::Version& version);
+
+ virtual void DoPreUninstallOperations();
+
+ virtual std::wstring GetApplicationName();
+
+ virtual std::wstring GetInstallSubDir();
+
+ virtual std::wstring GetPublisherName();
+
+ virtual int GetInstallReturnCode(
+ installer_util::InstallStatus install_status);
+
+ virtual std::wstring GetUninstallRegPath();
+
+ virtual std::wstring GetVersionKey();
+
+ virtual void UpdateDiffInstallStatus(bool system_install,
+ bool incremental_install, installer_util::InstallStatus install_status);
+
+ protected:
+ BrowserDistribution() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BrowserDistribution);
+};
+
+#endif // CHROME_INSTALLER_UTIL_BROWSER_DISTRIBUTION_H_
diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc
new file mode 100644
index 0000000..2623b36
--- /dev/null
+++ b/chrome/installer/util/google_chrome_distribution.cc
@@ -0,0 +1,218 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// This file defines specific implementation of BrowserDistribution class for
+// Google Chrome.
+
+#include "chrome/installer/util/google_chrome_distribution.h"
+
+#include <atlbase.h>
+#include <windows.h>
+#include <msi.h>
+
+#include "base/file_util.h"
+#include "base/path_service.h"
+#include "base/registry.h"
+#include "base/string_util.h"
+#include "base/wmi_util.h"
+#include "chrome/installer/util/install_util.h"
+#include "chrome/installer/util/google_update_constants.h"
+#include "chrome/installer/util/logging_installer.h"
+
+namespace {
+std::wstring GetUninstallSurveyUrl() {
+ /* TODO(rahulk): Make this work (requires some serious refactoring of
+ resources and GoogleUpdateSettings class) and get rid of #ifdef from
+ uninstall.cc.
+ const ATLSTRINGRESOURCEIMAGE* image = AtlGetStringResourceImage(
+ _AtlBaseModule.GetModuleInstance(), IDS_UNINSTALL_SURVEY_URL);
+ DCHECK(image);
+ std::wstring url = std::wstring(image->achString, image->nLength);
+ DCHECK(!url.empty());
+
+ std::wstring language;
+ if (!GoogleUpdateSettings::GetLanguage(&language))
+ language = L"en-US"; // Default to US English.
+
+ return ReplaceStringPlaceholders(url.c_str(), language.c_str(), NULL);
+ */
+ return L"";
+
+}
+}
+
+void GoogleChromeDistribution::DoPostUninstallOperations(
+ const installer::Version& version) {
+ // Send the Chrome version and OS version as params to the form.
+ // It would be nice to send the locale, too, but I don't see an
+ // easy way to get that in the existing code. It's something we
+ // can add later, if needed.
+ // We depend on installed_version.GetString() not having spaces or other
+ // characters that need escaping: 0.2.13.4. Should that change, we will
+ // need to escape the string before using it in a URL.
+ const std::wstring kVersionParam = L"crversion";
+ const std::wstring kVersion = version.GetString();
+ const std::wstring kOSParam = L"os";
+ std::wstring os_version = L"na";
+ OSVERSIONINFO version_info;
+ version_info.dwOSVersionInfoSize = sizeof(version_info);
+ if (GetVersionEx(&version_info)) {
+ os_version = StringPrintf(L"%d.%d.%d", version_info.dwMajorVersion,
+ version_info.dwMinorVersion,
+ version_info.dwBuildNumber);
+ }
+
+ std::wstring iexplore;
+ if (!PathService::Get(base::DIR_PROGRAM_FILES, &iexplore))
+ return;
+
+ file_util::AppendToPath(&iexplore, L"Internet Explorer");
+ file_util::AppendToPath(&iexplore, L"iexplore.exe");
+
+ std::wstring command = iexplore + L" " + GetUninstallSurveyUrl() + L"&" +
+ kVersionParam + L"=" + kVersion + L"&" + kOSParam + L"=" + os_version;
+ int pid = 0;
+ WMIProcessUtil::Launch(command, &pid);
+}
+
+// Uninstall Chrome specific Gears. First we find Gears MSI ProductId (that
+// changes with every new version of Gears) using Gears MSI UpgradeCode (that
+// does not change) and then uninstall Gears using API.
+void GoogleChromeDistribution::DoPreUninstallOperations() {
+ /* TODO(rahulk) this comment is commented for now because it is causing extra
+ dependencies for the renderer. Need to remove ifdef from uninstall.cc and
+ uncomment this function.
+ wchar_t product[39]; // GUID + '\0'
+ MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); // Don't show any UI to user.
+ for (int i = 0; MsiEnumRelatedProducts(google_update::kGearsUpgradeCode, 0, i,
+ product) != ERROR_NO_MORE_ITEMS; ++i) {
+ LOG(INFO) << "Uninstalling Gears - " << product;
+ unsigned int ret = MsiConfigureProduct(product, INSTALLLEVEL_MAXIMUM,
+ INSTALLSTATE_ABSENT);
+ if (ret != ERROR_SUCCESS)
+ LOG(ERROR) << "Failed to uninstall Gears " << product << ": " << ret;
+ }*/
+}
+
+std::wstring GoogleChromeDistribution::GetApplicationName() {
+ return L"Google Chrome";
+}
+
+std::wstring GoogleChromeDistribution::GetInstallSubDir() {
+ return L"Google\\Chrome";
+}
+
+std::wstring GoogleChromeDistribution::GetNewGoogleUpdateApKey(bool diff_install,
+ installer_util::InstallStatus status, const std::wstring& value) {
+ // Magic suffix that we need to add or remove to "ap" key value.
+ const std::wstring kMagicSuffix = L"-full";
+
+ bool has_magic_string = false;
+ if ((value.length() >= kMagicSuffix.length()) &&
+ (value.rfind(kMagicSuffix) == (value.length() - kMagicSuffix.length()))) {
+ LOG(INFO) << "Incremental installer failure key already set.";
+ has_magic_string = true;
+ }
+
+ std::wstring new_value(value);
+ if ((!diff_install || !GetInstallReturnCode(status)) && has_magic_string) {
+ LOG(INFO) << "Removing failure key from value " << value;
+ new_value = value.substr(0, value.length() - kMagicSuffix.length());
+ } else if ((diff_install && GetInstallReturnCode(status)) &&
+ !has_magic_string) {
+ LOG(INFO) << "Incremental installer failed, setting failure key.";
+ new_value.append(kMagicSuffix);
+ }
+
+ return new_value;
+}
+
+std::wstring GoogleChromeDistribution::GetPublisherName() {
+ return L"Google";
+}
+
+int GoogleChromeDistribution::GetInstallReturnCode(
+ installer_util::InstallStatus status) {
+ switch (status) {
+ case installer_util::FIRST_INSTALL_SUCCESS:
+ case installer_util::INSTALL_REPAIRED:
+ case installer_util::NEW_VERSION_UPDATED:
+ case installer_util::HIGHER_VERSION_EXISTS:
+ return 0; // For Google Update's benefit we need to return 0 for success
+ default:
+ return status;
+ }
+}
+
+std::wstring GoogleChromeDistribution::GetUninstallRegPath() {
+ return L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome";
+}
+
+std::wstring GoogleChromeDistribution::GetVersionKey() {
+ std::wstring key(google_update::kRegPathClients);
+ key.append(L"\\");
+ key.append(google_update::kChromeGuid);
+ return key;
+}
+
+// This method checks if we need to change "ap" key in Google Update to try
+// full installer as fall back method in case incremental installer fails.
+// - If incremental installer fails we append a magic string ("-full"), if
+// it is not present already, so that Google Update server next time will send
+// full installer to update Chrome on the local machine
+// - If we are currently running full installer, we remove this magic
+// string (if it is present) regardless of whether installer failed or not.
+// There is no fall-back for full installer :)
+void GoogleChromeDistribution::UpdateDiffInstallStatus(bool system_install,
+ bool incremental_install, installer_util::InstallStatus install_status) {
+ HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
+
+ RegKey key;
+ std::wstring ap_key_value;
+ std::wstring chrome_google_update_state_key(
+ google_update::kRegPathClientState);
+ chrome_google_update_state_key.append(L"\\");
+ chrome_google_update_state_key.append(google_update::kChromeGuid);
+ if (!key.Open(reg_root, chrome_google_update_state_key.c_str(),
+ KEY_ALL_ACCESS) || !key.ReadValue(google_update::kRegApFieldName,
+ &ap_key_value)) {
+ LOG(INFO) << "Application key not found. Returning without changing it.";
+ key.Close();
+ return;
+ }
+
+ std::wstring new_value = GoogleChromeDistribution::GetNewGoogleUpdateApKey(
+ incremental_install, install_status, ap_key_value);
+ if ((new_value.compare(ap_key_value) != 0) &&
+ !key.WriteValue(google_update::kRegApFieldName, new_value.c_str())) {
+ LOG(ERROR) << "Failed to write value " << new_value
+ << " to the registry field " << google_update::kRegApFieldName;
+ }
+ key.Close();
+}
diff --git a/chrome/installer/util/google_chrome_distribution.h b/chrome/installer/util/google_chrome_distribution.h
new file mode 100644
index 0000000..f1d6af9
--- /dev/null
+++ b/chrome/installer/util/google_chrome_distribution.h
@@ -0,0 +1,82 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// This file extends generic BrowserDistribution class to declare Google Chrome
+// specific implementation.
+
+#ifndef CHROME_INSTALLER_UTIL_GOOGLE_CHROME_DISTRIBUTION_H_
+#define CHROME_INSTALLER_UTIL_GOOGLE_CHROME_DISTRIBUTION_H_
+
+#include "chrome/installer/util/browser_distribution.h"
+#include "chrome/installer/util/util_constants.h"
+
+class GoogleChromeDistribution : public BrowserDistribution {
+ public:
+ virtual void DoPostUninstallOperations(const installer::Version& version);
+
+ virtual void DoPreUninstallOperations();
+
+ virtual std::wstring GetApplicationName();
+
+ virtual std::wstring GetInstallSubDir();
+
+ // This method generates the new value for Google Update "ap" key for Chrome
+ // based on whether we are doing incremental install (or not) and whether
+ // the install succeeded.
+ // - If install worked, remove the magic string (if present).
+ // - If incremental installer failed, append a magic string (if
+ // not present already).
+ // - If full installer failed, still remove this magic
+ // string (if it is present already).
+ //
+ // diff_install: tells whether this is incremental install or not.
+ // install_status: if 0, means installation was successful.
+ // value: current value of Google Update "ap" key.
+ std::wstring GetNewGoogleUpdateApKey(bool diff_install,
+ installer_util::InstallStatus status, const std::wstring& value);
+
+ virtual std::wstring GetPublisherName();
+
+ virtual int GetInstallReturnCode(
+ installer_util::InstallStatus install_status);
+
+ virtual std::wstring GetUninstallRegPath();
+
+ virtual std::wstring GetVersionKey();
+
+ virtual void UpdateDiffInstallStatus(bool system_install,
+ bool incremental_install, installer_util::InstallStatus install_status);
+
+ private:
+ friend class BrowserDistribution;
+
+ GoogleChromeDistribution() {}
+};
+
+#endif // CHROME_INSTALLER_UTIL_GOOGLE_CHROME_DISTRIBUTION_H_
diff --git a/chrome/installer/util/install_util_unittest.cc b/chrome/installer/util/google_chrome_distribution_unittest.cc
index b0a816a..30f971a 100644
--- a/chrome/installer/util/install_util_unittest.cc
+++ b/chrome/installer/util/google_chrome_distribution_unittest.cc
@@ -27,15 +27,16 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
-// Unit tests for InstallUtil class.
+// Unit tests for GoogleChromeDistribution class.
#include <windows.h>
-#include "chrome/installer/util/install_util.h"
+#include "chrome/installer/util/browser_distribution.h"
+#include "chrome/installer/util/google_chrome_distribution.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
-class InstallUtilTest : public testing::Test {
+class GoogleChromeDistributionTest : public testing::Test {
protected:
virtual void SetUp() {
// Currently no setup required.
@@ -47,51 +48,48 @@ class InstallUtilTest : public testing::Test {
};
} // namespace
-TEST_F(InstallUtilTest, GetNewGoogleUpdateApKeyTest) {
+#if defined(GOOGLE_CHROME_BUILD)
+TEST_F(GoogleChromeDistributionTest, GetNewGoogleUpdateApKeyTest) {
+ GoogleChromeDistribution* dist = static_cast<GoogleChromeDistribution*>(
+ BrowserDistribution::GetDistribution());
installer_util::InstallStatus s = installer_util::FIRST_INSTALL_SUCCESS;
installer_util::InstallStatus f = installer_util::INSTALL_FAILED;
// Incremental Installer that worked.
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, s, L""), L"");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, s, L"1.1"), L"1.1");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, s, L"1.1-dev"),
- L"1.1-dev");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, s, L"-full"), L"");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, s, L"1.1-full"),
- L"1.1");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, s, L"1.1-dev-full"),
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, s, L""), L"");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, s, L"1.1"), L"1.1");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, s, L"1.1-dev"), L"1.1-dev");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, s, L"-full"), L"");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, s, L"1.1-full"), L"1.1");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, s, L"1.1-dev-full"),
L"1.1-dev");
// Incremental Installer that failed.
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, f, L""), L"-full");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, f, L"1.1"), L"1.1-full");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, f, L"1.1-dev"),
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, f, L""), L"-full");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, f, L"1.1"), L"1.1-full");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, f, L"1.1-dev"),
L"1.1-dev-full");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, f, L"-full"), L"-full");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, f, L"1.1-full"),
- L"1.1-full");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, f, L"1.1-dev-full"),
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, f, L"-full"), L"-full");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, f, L"1.1-full"), L"1.1-full");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, f, L"1.1-dev-full"),
L"1.1-dev-full");
// Full Installer that worked.
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, s, L""), L"");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, s, L"1.1"), L"1.1");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, s, L"1.1-dev"),
- L"1.1-dev");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, s, L"-full"), L"");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, s, L"1.1-full"),
- L"1.1");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, s, L"1.1-dev-full"),
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, s, L""), L"");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, s, L"1.1"), L"1.1");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, s, L"1.1-dev"), L"1.1-dev");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, s, L"-full"), L"");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, s, L"1.1-full"), L"1.1");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, s, L"1.1-dev-full"),
L"1.1-dev");
// Full Installer that failed.
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, f, L""), L"");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, f, L"1.1"), L"1.1");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, f, L"1.1-dev"),
- L"1.1-dev");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, f, L"-full"), L"");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, f, L"1.1-full"),
- L"1.1");
- EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, f, L"1.1-dev-full"),
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, f, L""), L"");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, f, L"1.1"), L"1.1");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, f, L"1.1-dev"), L"1.1-dev");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, f, L"-full"), L"");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, f, L"1.1-full"), L"1.1");
+ EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, f, L"1.1-dev-full"),
L"1.1-dev");
}
+#endif
diff --git a/chrome/installer/util/helper.cc b/chrome/installer/util/helper.cc
index 271fdb2..2546f76 100644
--- a/chrome/installer/util/helper.cc
+++ b/chrome/installer/util/helper.cc
@@ -33,6 +33,7 @@
#include "base/path_service.h"
#include "base/process_util.h"
#include "base/scoped_ptr.h"
+#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/delete_tree_work_item.h"
#include "chrome/installer/util/helper.h"
#include "chrome/installer/util/logging_installer.h"
@@ -49,10 +50,8 @@ std::wstring installer::GetChromeInstallPath(bool system_install) {
}
if (!install_path.empty()) {
- file_util::AppendToPath(&install_path,
- std::wstring(installer_util::kInstallGoogleDir));
- file_util::AppendToPath(&install_path,
- std::wstring(installer_util::kChrome));
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
+ file_util::AppendToPath(&install_path, dist->GetInstallSubDir());
file_util::AppendToPath(&install_path,
std::wstring(installer_util::kInstallBinaryDir));
}
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc
index 087589b..8a1dfcc 100644
--- a/chrome/installer/util/install_util.cc
+++ b/chrome/installer/util/install_util.cc
@@ -37,22 +37,17 @@
#include "base/logging.h"
#include "base/registry.h"
#include "base/string_util.h"
+#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/google_update_constants.h"
-std::wstring InstallUtil::GetChromeGoogleUpdateKey() {
- std::wstring chrome_google_update_key(google_update::kRegPathClients);
- chrome_google_update_key.append(L"\\");
- chrome_google_update_key.append(google_update::kChromeGuid);
- return chrome_google_update_key;
-}
-
installer::Version* InstallUtil::GetChromeVersion(bool system_install) {
RegKey key;
std::wstring version_str;
HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
- if (!key.Open(reg_root, GetChromeGoogleUpdateKey().c_str(), KEY_READ) ||
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
+ if (!key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_READ) ||
!key.ReadValue(google_update::kRegVersionField, &version_str)) {
LOG(INFO) << "No existing Chrome install found.";
key.Close();
@@ -62,40 +57,3 @@ installer::Version* InstallUtil::GetChromeVersion(bool system_install) {
LOG(INFO) << "Existing Chrome version found " << version_str;
return installer::Version::GetVersionFromString(version_str);
}
-
-std::wstring InstallUtil::GetNewGoogleUpdateApKey(bool diff_install,
- installer_util::InstallStatus status, const std::wstring& value) {
- // Magic suffix that we need to add or remove to "ap" key value.
- const std::wstring kMagicSuffix = L"-full";
-
- bool has_magic_string = false;
- if ((value.length() >= kMagicSuffix.length()) &&
- (value.rfind(kMagicSuffix) == (value.length() - kMagicSuffix.length()))) {
- LOG(INFO) << "Incremental installer failure key already set.";
- has_magic_string = true;
- }
-
- std::wstring new_value(value);
- if ((!diff_install || InstallSuccessful(status)) && has_magic_string) {
- LOG(INFO) << "Removing failure key from value " << value;
- new_value = value.substr(0, value.length() - kMagicSuffix.length());
- } else if ((diff_install && !InstallSuccessful(status)) &&
- !has_magic_string) {
- LOG(INFO) << "Incremental installer failed, setting failure key.";
- new_value.append(kMagicSuffix);
- }
-
- return new_value;
-}
-
-bool InstallUtil::InstallSuccessful(installer_util::InstallStatus status) {
- switch (status) {
- case installer_util::FIRST_INSTALL_SUCCESS:
- case installer_util::INSTALL_REPAIRED:
- case installer_util::NEW_VERSION_UPDATED:
- case installer_util::HIGHER_VERSION_EXISTS:
- return true;
- default:
- return false;
- }
-}
diff --git a/chrome/installer/util/install_util.h b/chrome/installer/util/install_util.h
index 69884e9..3c35a3f 100644
--- a/chrome/installer/util/install_util.h
+++ b/chrome/installer/util/install_util.h
@@ -45,34 +45,12 @@
// independently.
class InstallUtil {
public:
- // This method gets the Google Update registry key path for Chrome.
- // i.e. - Software\Google\Update\Clients\<chrome-guid>";
- static std::wstring GetChromeGoogleUpdateKey();
-
// Find the version of Chrome installed on the system by checking the
// Google Update registry key. Returns the version or NULL if no version is
// found.
// system_install: if true, looks for version number under the HKLM root,
// otherwise looks under the HKCU.
static installer::Version * GetChromeVersion(bool system_install);
-
- // This method generates the new value for Oamaha "ap" key for Chrome
- // based on whether we are doing incremental install (or not) and whether
- // the install succeeded.
- // - If install worked, remove the magic string (if present).
- // - If incremental installer failed, append a magic string (if
- // not present already).
- // - If full installer failed, still remove this magic
- // string (if it is present already).
- //
- // diff_install: tells whether this is incremental install or not.
- // install_status: if 0, means installation was successful.
- // value: current value of Google Update "ap" key.
- static std::wstring GetNewGoogleUpdateApKey(bool diff_install,
- installer_util::InstallStatus status, const std::wstring& value);
-
- // Given an InstallStatus it tells whether the install was sucessful or not.
- static bool InstallSuccessful(installer_util::InstallStatus status);
private:
DISALLOW_EVIL_CONSTRUCTORS(InstallUtil);
};
diff --git a/chrome/installer/util/installer_unittests.vcproj b/chrome/installer/util/installer_unittests.vcproj
index b7e3eef..4f710ac 100644
--- a/chrome/installer/util/installer_unittests.vcproj
+++ b/chrome/installer/util/installer_unittests.vcproj
@@ -17,7 +17,7 @@
<Configuration
Name="Debug|Win32"
ConfigurationType="1"
- InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\debug.vsprops;$(SolutionDir)\tools\build\win\unit_test.vsprops;$(SolutionDir)\installer\util\using_util.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops"
+ InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\debug.vsprops;$(SolutionDir)\tools\build\win\unit_test.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops"
>
<Tool
Name="VCPreBuildEventTool"
@@ -78,7 +78,7 @@
<Configuration
Name="Release|Win32"
ConfigurationType="1"
- InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\release.vsprops;$(SolutionDir)\tools\build\win\unit_test.vsprops;$(SolutionDir)\installer\util\using_util.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops"
+ InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\release.vsprops;$(SolutionDir)\tools\build\win\unit_test.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops"
>
<Tool
Name="VCPreBuildEventTool"
@@ -172,7 +172,7 @@
>
</File>
<File
- RelativePath="install_util_unittest.cc"
+ RelativePath="google_chrome_distribution_unittest.cc"
>
</File>
<File
diff --git a/chrome/installer/util/prebuild/create_string_rc.py b/chrome/installer/util/prebuild/create_string_rc.py
index a617646..ca4fd09 100644
--- a/chrome/installer/util/prebuild/create_string_rc.py
+++ b/chrome/installer/util/prebuild/create_string_rc.py
@@ -56,9 +56,9 @@ class TranslationStruct:
def CollectTranslatedStrings():
- """Collects all the translations for "Google Chrome" from the XTB files.
- Returns a list of tuples of (language, translated string). The list is
- sorted by language codes."""
+ """Collects all the translations for all the strings specified by kStringIds.
+ Returns a list of tuples of (string_id, language, translated string). The
+ list is sorted by language codes."""
kGeneratedResourcesPath = os.path.join(path_utils.ScriptDir(), '..', '..',
'..', 'app/generated_resources.grd')
kTranslationDirectory = os.path.join(path_utils.ScriptDir(), '..', '..',
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index c8ebfc8..bc8b882 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -47,6 +47,7 @@
#include "base/win_util.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/create_reg_key_work_item.h"
#include "chrome/installer/util/l10n_string_util.h"
#include "chrome/installer/util/set_reg_value_work_item.h"
@@ -80,9 +81,10 @@ class RegistryEntry {
entries.push_front(new RegistryEntry(
L"Software\\Classes\\ChromeHTML\\shell\\open\\command", open_cmd));
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
entries.push_front(new RegistryEntry(
L"Software\\Clients\\StartMenuInternet\\chrome.exe",
- installer_util::kApplicationName));
+ dist->GetApplicationName()));
entries.push_front(new RegistryEntry(
L"Software\\Clients\\StartMenuInternet\\chrome.exe\\shell\\open\\command",
quoted_exe_path));
@@ -107,17 +109,17 @@ class RegistryEntry {
entries.push_front(new RegistryEntry(
ShellUtil::kRegRegisteredApplications,
- installer_util::kApplicationName,
+ dist->GetApplicationName(),
L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities"));
entries.push_front(new RegistryEntry(
L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities",
- L"ApplicationDescription", installer_util::kApplicationName));
+ L"ApplicationDescription", dist->GetApplicationName()));
entries.push_front(new RegistryEntry(
L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities",
L"ApplicationIcon", icon_path));
entries.push_front(new RegistryEntry(
L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities",
- L"ApplicationName", installer_util::kApplicationName));
+ L"ApplicationName", dist->GetApplicationName()));
entries.push_front(new RegistryEntry(
L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities\\StartMenu",
@@ -251,7 +253,8 @@ ShellUtil::RegisterStatus RegisterOnVista(const std::wstring& chrome_exe,
std::wstring exe_path(file_util::GetDirectoryFromPath(chrome_exe));
file_util::AppendToPath(&exe_path, installer_util::kSetupExe);
if (!file_util::PathExists(exe_path)) {
- RegKey key(HKEY_CURRENT_USER, installer_util::kUninstallRegPath);
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
+ RegKey key(HKEY_CURRENT_USER, dist->GetUninstallRegPath().c_str());
key.ReadValue(installer_util::kUninstallStringField, &exe_path);
exe_path = exe_path.substr(0, exe_path.find_first_of(L" --"));
TrimString(exe_path, L" \"", &exe_path);
diff --git a/chrome/installer/util/using_util.vsprops b/chrome/installer/util/using_util.vsprops
deleted file mode 100644
index fe84cd9..0000000
--- a/chrome/installer/util/using_util.vsprops
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioPropertySheet
- ProjectType="Visual C++"
- Version="8.00"
- Name="using_util"
- >
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="shlwapi.lib"
- />
-</VisualStudioPropertySheet>
diff --git a/chrome/installer/util/util.vcproj b/chrome/installer/util/util.vcproj
index 0eac40b..8fcb759 100644
--- a/chrome/installer/util/util.vcproj
+++ b/chrome/installer/util/util.vcproj
@@ -41,6 +41,14 @@
</Configurations>
<Files>
<File
+ RelativePath="browser_distribution.cc"
+ >
+ </File>
+ <File
+ RelativePath="browser_distribution.h"
+ >
+ </File>
+ <File
RelativePath="copy_tree_work_item.cc"
>
</File>
@@ -73,6 +81,14 @@
>
</File>
<File
+ RelativePath="google_chrome_distribution.cc"
+ >
+ </File>
+ <File
+ RelativePath="google_chrome_distribution.h"
+ >
+ </File>
+ <File
RelativePath="google_update_settings.cc"
>
</File>
diff --git a/chrome/installer/util/util_constants.cc b/chrome/installer/util/util_constants.cc
index d008647..32fd6d3 100644
--- a/chrome/installer/util/util_constants.cc
+++ b/chrome/installer/util/util_constants.cc
@@ -67,16 +67,10 @@ const wchar_t kVerboseLogging[] = L"verbose-logging";
} // namespace switches
const wchar_t kInstallBinaryDir[] = L"Application";
-const wchar_t kInstallGoogleDir[] = L"Google";
-const wchar_t kChrome[] = L"Chrome";
const wchar_t kChromeExe[] = L"chrome.exe";
const wchar_t kChromeDll[] = L"chrome.dll";
-
-const wchar_t kPublisherName[] = L"Google";
-const wchar_t kApplicationName[] = L"Google Chrome";
const wchar_t kSetupExe[] = L"setup.exe";
-const wchar_t kUninstallRegPath[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome";
const wchar_t kUninstallStringField[] = L"UninstallString";
const wchar_t kUninstallDisplayNameField[] = L"DisplayName";
} // namespace installer_util
diff --git a/chrome/installer/util/util_constants.h b/chrome/installer/util/util_constants.h
index af9596f..449148c 100644
--- a/chrome/installer/util/util_constants.h
+++ b/chrome/installer/util/util_constants.h
@@ -69,18 +69,10 @@ extern const wchar_t kVerboseLogging[];
} // namespace switches
extern const wchar_t kInstallBinaryDir[];
-extern const wchar_t kInstallGoogleDir[];
-extern const wchar_t kChrome[];
extern const wchar_t kChromeExe[];
extern const wchar_t kChromeDll[];
-
-// Bug 1214772 - these should be removed for public beta and replaced with
-// a localized string.
-extern const wchar_t kPublisherName[];
-extern const wchar_t kApplicationName[];
extern const wchar_t kSetupExe[];
-extern const wchar_t kUninstallRegPath[];
extern const wchar_t kUninstallStringField[];
extern const wchar_t kUninstallDisplayNameField[];
} // namespace installer_util