diff options
19 files changed, 65 insertions, 52 deletions
diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc index 9e0c42e..93f1f2f 100644 --- a/chrome/browser/shell_integration_win.cc +++ b/chrome/browser/shell_integration_win.cc @@ -112,8 +112,7 @@ ShellIntegration::DefaultWebClientState ProbeAppIsDefaultHandlers( NOTREACHED(); return ShellIntegration::UNKNOWN_DEFAULT_WEB_CLIENT; } - string16 app_name(dist->GetApplicationName()); - app_name += ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe.value()); + string16 app_name(ShellUtil::GetApplicationName(dist, chrome_exe.value())); BOOL result; for (size_t i = 0; i < num_protocols; ++i) { diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc index 4e709f6..48fbe54 100644 --- a/chrome/installer/setup/setup_main.cc +++ b/chrome/installer/setup/setup_main.cc @@ -158,7 +158,7 @@ void AddExistingMultiInstalls(const InstallationState& original_state, installer_state->AddProductFromState(type, *state); VLOG(1) << "Product already installed and must be included: " << BrowserDistribution::GetSpecificDistribution( - type)->GetApplicationName(); + type)->GetAppShortCutName(); } } } @@ -398,7 +398,7 @@ bool CheckMultiInstallConditions(const InstallationState& original_state, multi_chrome->SetOption(installer::kOptionMultiInstall, true); chrome = installer_state->AddProduct(&multi_chrome); VLOG(1) << "Upgrading existing multi-install Chrome browser along with " - << chrome_frame->distribution()->GetApplicationName(); + << chrome_frame->distribution()->GetAppShortCutName(); } else if (chrome_frame->HasOption(installer::kOptionReadyMode)) { // Chrome Frame with ready-mode is to be installed, yet Chrome is // neither installed nor being installed. Fail. @@ -479,7 +479,7 @@ bool CheckPreInstallConditions(const InstallationState& original_state, // Block downgrades from multi-install to single-install. if (!installer_state->is_multi_install() && product_state->is_multi_install()) { - LOG(ERROR) << "Multi-install " << browser_dist->GetApplicationName() + LOG(ERROR) << "Multi-install " << browser_dist->GetAppShortCutName() << " exists; aborting single install."; *status = installer::MULTI_INSTALLATION_EXISTS; installer_state->WriteInstallerResult(*status, diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc index 33cc700..36242f7 100644 --- a/chrome/installer/setup/uninstall.cc +++ b/chrome/installer/setup/uninstall.cc @@ -572,7 +572,7 @@ bool DeleteChromeRegistrationKeys(BrowserDistribution* dist, HKEY root, // Delete Software\RegisteredApplications\Chromium InstallUtil::DeleteRegistryValue(root, ShellUtil::kRegRegisteredApplications, - dist->GetApplicationName() + browser_entry_suffix); + dist->GetBaseAppName() + browser_entry_suffix); // Delete Software\Classes\Applications\chrome.exe string16 app_key(ShellUtil::kRegClasses); @@ -609,8 +609,7 @@ bool DeleteChromeRegistrationKeys(BrowserDistribution* dist, HKEY root, // lives in HKLM. InstallUtil::DeleteRegistryValueIf( root, ShellUtil::kRegStartMenuInternet, L"", - InstallUtil::ValueEquals(dist->GetApplicationName() + - browser_entry_suffix)); + InstallUtil::ValueEquals(dist->GetBaseAppName() + browser_entry_suffix)); // Delete each protocol association if it references this Chrome. InstallUtil::ProgramCompare open_command_pred(chrome_exe); @@ -712,7 +711,7 @@ InstallStatus UninstallProduct(const InstallationState& original_state, bool is_chrome = product.is_chrome(); - VLOG(1) << "UninstallProduct: " << browser_dist->GetApplicationName(); + VLOG(1) << "UninstallProduct: " << browser_dist->GetAppShortCutName(); if (force_uninstall) { // Since --force-uninstall command line option is used, we are going to diff --git a/chrome/installer/util/browser_distribution.cc b/chrome/installer/util/browser_distribution.cc index 6ca1b42..d3579b0 100644 --- a/chrome/installer/util/browser_distribution.cc +++ b/chrome/installer/util/browser_distribution.cc @@ -149,12 +149,12 @@ string16 BrowserDistribution::GetAppGuid() { return L""; } -string16 BrowserDistribution::GetApplicationName() { +string16 BrowserDistribution::GetBaseAppName() { return L"Chromium"; } string16 BrowserDistribution::GetAppShortCutName() { - return GetApplicationName(); + return GetBaseAppName(); } string16 BrowserDistribution::GetAlternateApplicationName() { diff --git a/chrome/installer/util/browser_distribution.h b/chrome/installer/util/browser_distribution.h index 8944db9..7d02b63 100644 --- a/chrome/installer/util/browser_distribution.h +++ b/chrome/installer/util/browser_distribution.h @@ -67,9 +67,12 @@ class BrowserDistribution { virtual string16 GetAppGuid(); - // Returns the name by which the program is registered with Default Programs. - // This is not a localized string suitable for presenting to a user. - virtual string16 GetApplicationName(); + // Returns the unsuffixed application name of this program. + // This is the base of the name registered with Default Programs on Windows. + // IMPORTANT: This should only be called by the installer which needs to make + // decisions on the suffixing of the upcoming install, not by external callers + // at run-time. + virtual string16 GetBaseAppName(); // Returns the localized name of the program. virtual string16 GetAppShortCutName(); diff --git a/chrome/installer/util/browser_distribution_unittest.cc b/chrome/installer/util/browser_distribution_unittest.cc index 3913201..d0e1059 100644 --- a/chrome/installer/util/browser_distribution_unittest.cc +++ b/chrome/installer/util/browser_distribution_unittest.cc @@ -16,11 +16,11 @@ TEST(BrowserDistributionTest, StringsTest) { BrowserDistribution::GetSpecificDistribution( BrowserDistribution::kProductTypes[i]); ASSERT_TRUE(dist != NULL); - std::wstring name = dist->GetApplicationName(); + string16 name = dist->GetBaseAppName(); EXPECT_FALSE(name.empty()); - std::wstring desc = dist->GetAppDescription(); + string16 desc = dist->GetAppDescription(); EXPECT_FALSE(desc.empty()); - std::wstring alt_name = dist->GetAlternateApplicationName(); + string16 alt_name = dist->GetAlternateApplicationName(); EXPECT_FALSE(alt_name.empty()); } } @@ -28,10 +28,10 @@ TEST(BrowserDistributionTest, StringsTest) { // The shortcut strings obtained by the shell utility functions should not // be empty or be the same. TEST(BrowserDistributionTest, AlternateAndNormalShortcutName) { - std::wstring normal_name; - std::wstring alternate_name; - std::wstring appended_name_one; - std::wstring appended_name_two; + string16 normal_name; + string16 alternate_name; + string16 appended_name_one; + string16 appended_name_two; BrowserDistribution* dist = BrowserDistribution::GetDistribution(); EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, false, L"", &normal_name)); diff --git a/chrome/installer/util/chrome_frame_distribution.cc b/chrome/installer/util/chrome_frame_distribution.cc index 8be7d49..049825a 100644 --- a/chrome/installer/util/chrome_frame_distribution.cc +++ b/chrome/installer/util/chrome_frame_distribution.cc @@ -32,7 +32,7 @@ string16 ChromeFrameDistribution::GetAppGuid() { return kChromeFrameGuid; } -string16 ChromeFrameDistribution::GetApplicationName() { +string16 ChromeFrameDistribution::GetBaseAppName() { return L"Google Chrome Frame"; } diff --git a/chrome/installer/util/chrome_frame_distribution.h b/chrome/installer/util/chrome_frame_distribution.h index 1596db4..a5007e8 100644 --- a/chrome/installer/util/chrome_frame_distribution.h +++ b/chrome/installer/util/chrome_frame_distribution.h @@ -16,7 +16,7 @@ class ChromeFrameDistribution : public BrowserDistribution { public: virtual string16 GetAppGuid() OVERRIDE; - virtual string16 GetApplicationName() OVERRIDE; + virtual string16 GetBaseAppName() OVERRIDE; virtual string16 GetAppShortCutName() OVERRIDE; diff --git a/chrome/installer/util/chromium_binaries_distribution.cc b/chrome/installer/util/chromium_binaries_distribution.cc index 0e073be..179e891 100644 --- a/chrome/installer/util/chromium_binaries_distribution.cc +++ b/chrome/installer/util/chromium_binaries_distribution.cc @@ -24,7 +24,7 @@ string16 ChromiumBinariesDistribution::GetAppGuid() { return string16(); } -string16 ChromiumBinariesDistribution::GetApplicationName() { +string16 ChromiumBinariesDistribution::GetBaseAppName() { NOTREACHED(); return string16(); } diff --git a/chrome/installer/util/chromium_binaries_distribution.h b/chrome/installer/util/chromium_binaries_distribution.h index 599cdc0..a40bf85 100644 --- a/chrome/installer/util/chromium_binaries_distribution.h +++ b/chrome/installer/util/chromium_binaries_distribution.h @@ -16,7 +16,7 @@ class ChromiumBinariesDistribution : public BrowserDistribution { public: virtual string16 GetAppGuid() OVERRIDE; - virtual string16 GetApplicationName() OVERRIDE; + virtual string16 GetBaseAppName() OVERRIDE; virtual string16 GetAppShortCutName() OVERRIDE; diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc index 84aa4be..4b41b44 100644 --- a/chrome/installer/util/google_chrome_distribution.cc +++ b/chrome/installer/util/google_chrome_distribution.cc @@ -415,7 +415,7 @@ string16 GoogleChromeDistribution::GetAppGuid() { return product_guid(); } -string16 GoogleChromeDistribution::GetApplicationName() { +string16 GoogleChromeDistribution::GetBaseAppName() { // I'd really like to return L ## PRODUCT_FULLNAME_STRING; but that's no good // since it'd be "Chromium" in a non-Chrome build, which isn't at all what I // want. Sigh. diff --git a/chrome/installer/util/google_chrome_distribution.h b/chrome/installer/util/google_chrome_distribution.h index 4bc4381..6c4d87d 100644 --- a/chrome/installer/util/google_chrome_distribution.h +++ b/chrome/installer/util/google_chrome_distribution.h @@ -38,7 +38,7 @@ class GoogleChromeDistribution : public BrowserDistribution { virtual string16 GetAppGuid() OVERRIDE; - virtual string16 GetApplicationName() OVERRIDE; + virtual string16 GetBaseAppName() OVERRIDE; virtual string16 GetAppShortCutName() OVERRIDE; diff --git a/chrome/installer/util/google_chrome_distribution_dummy.cc b/chrome/installer/util/google_chrome_distribution_dummy.cc index 8cc9dac..ac7c9b5 100644 --- a/chrome/installer/util/google_chrome_distribution_dummy.cc +++ b/chrome/installer/util/google_chrome_distribution_dummy.cc @@ -31,7 +31,7 @@ string16 GoogleChromeDistribution::GetAppGuid() { return string16(); } -string16 GoogleChromeDistribution::GetApplicationName() { +string16 GoogleChromeDistribution::GetBaseAppName() { NOTREACHED(); return string16(); } diff --git a/chrome/installer/util/google_chrome_sxs_distribution.cc b/chrome/installer/util/google_chrome_sxs_distribution.cc index 5e3a8ff..8798295 100644 --- a/chrome/installer/util/google_chrome_sxs_distribution.cc +++ b/chrome/installer/util/google_chrome_sxs_distribution.cc @@ -25,7 +25,7 @@ GoogleChromeSxSDistribution::GoogleChromeSxSDistribution() GoogleChromeDistribution::set_product_guid(kChromeSxSGuid); } -string16 GoogleChromeSxSDistribution::GetApplicationName() { +string16 GoogleChromeSxSDistribution::GetBaseAppName() { return L"Google Chrome Canary"; } diff --git a/chrome/installer/util/google_chrome_sxs_distribution.h b/chrome/installer/util/google_chrome_sxs_distribution.h index 93867ff..8e3e769 100644 --- a/chrome/installer/util/google_chrome_sxs_distribution.h +++ b/chrome/installer/util/google_chrome_sxs_distribution.h @@ -20,7 +20,7 @@ // system level install and setting as default browser. class GoogleChromeSxSDistribution : public GoogleChromeDistribution { public: - virtual string16 GetApplicationName() OVERRIDE; + virtual string16 GetBaseAppName() OVERRIDE; virtual string16 GetAppShortCutName() OVERRIDE; virtual string16 GetBrowserAppId() OVERRIDE; virtual string16 GetInstallSubDir() OVERRIDE; diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc index 4b096ef..bb10265 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc @@ -185,12 +185,12 @@ Version* InstallUtil::GetChromeVersion(BrowserDistribution* dist, Version* ret = NULL; if (result == ERROR_SUCCESS && !version_str.empty()) { - VLOG(1) << "Existing " << dist->GetApplicationName() - << " version found " << version_str; + VLOG(1) << "Existing " << dist->GetAppShortCutName() << " version found " + << version_str; ret = Version::GetVersionFromString(WideToASCII(version_str)); } else { DCHECK_EQ(ERROR_FILE_NOT_FOUND, result); - VLOG(1) << "No existing " << dist->GetApplicationName() + VLOG(1) << "No existing " << dist->GetAppShortCutName() << " install found."; } @@ -212,12 +212,12 @@ Version* InstallUtil::GetCriticalUpdateVersion(BrowserDistribution* dist, Version* ret = NULL; if (result == ERROR_SUCCESS && !version_str.empty()) { - VLOG(1) << "Critical Update version for " << dist->GetApplicationName() + VLOG(1) << "Critical Update version for " << dist->GetAppShortCutName() << " found " << version_str; ret = Version::GetVersionFromString(WideToASCII(version_str)); } else { DCHECK_EQ(ERROR_FILE_NOT_FOUND, result); - VLOG(1) << "No existing " << dist->GetApplicationName() + VLOG(1) << "No existing " << dist->GetAppShortCutName() << " install found."; } diff --git a/chrome/installer/util/installer_state.cc b/chrome/installer/util/installer_state.cc index 5e88ad5..bbf3a33 100644 --- a/chrome/installer/util/installer_state.cc +++ b/chrome/installer/util/installer_state.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -117,14 +117,14 @@ void InstallerState::Initialize(const CommandLine& command_line, AddProductFromPreferences(BrowserDistribution::CHROME_BROWSER, prefs, machine_state); VLOG(1) << (is_uninstall ? "Uninstall" : "Install") - << " distribution: " << p->distribution()->GetApplicationName(); + << " distribution: " << p->distribution()->GetAppShortCutName(); } if (prefs.install_chrome_frame()) { Product* p = AddProductFromPreferences(BrowserDistribution::CHROME_FRAME, prefs, machine_state); VLOG(1) << (is_uninstall ? "Uninstall" : "Install") - << " distribution: " << p->distribution()->GetApplicationName(); + << " distribution: " << p->distribution()->GetAppShortCutName(); } BrowserDistribution* operand = NULL; diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index ba52f96..201f588 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -109,7 +109,7 @@ class RegistryEntry { DCHECK(suffix.empty() || suffix[0] == L'.'); return string16(ShellUtil::kRegStartMenuInternet) .append(1, L'\\') - .append(dist->GetApplicationName()) + .append(dist->GetBaseAppName()) .append(suffix); } @@ -213,7 +213,7 @@ class RegistryEntry { // resource for name, description, and company. entries->push_front(new RegistryEntry( chrome_application, ShellUtil::kRegApplicationName, - dist->GetApplicationName().append(suffix))); + dist->GetAppShortCutName().append(suffix))); entries->push_front(new RegistryEntry( chrome_application, ShellUtil::kRegApplicationDescription, dist->GetAppDescription())); @@ -252,7 +252,7 @@ class RegistryEntry { // TODO(grt): http://crbug.com/75152 Also set LocalizedString; see // http://msdn.microsoft.com/en-us/library/windows/desktop/cc144109(v=VS.85).aspx#registering_the_display_name entries->push_front(new RegistryEntry( - start_menu_entry, dist->GetApplicationName())); + start_menu_entry, dist->GetAppShortCutName())); // Register the "open" verb for launching Chrome via the "Internet" link. entries->push_front(new RegistryEntry( start_menu_entry + ShellUtil::kRegShellOpen, quoted_exe_path)); @@ -273,7 +273,7 @@ class RegistryEntry { entries->push_front(new RegistryEntry(install_info, L"IconsVisible", 1)); // Register with Default Programs. - string16 reg_app_name(dist->GetApplicationName().append(suffix)); + string16 reg_app_name(dist->GetBaseAppName().append(suffix)); // Tell Windows where to find Chrome's Default Programs info. string16 capabilities(GetCapabilitiesKey(dist, suffix)); entries->push_front(new RegistryEntry(ShellUtil::kRegRegisteredApplications, @@ -382,7 +382,7 @@ class RegistryEntry { // start->Internet shortcut. string16 start_menu(ShellUtil::kRegStartMenuInternet); - string16 app_name = dist->GetApplicationName() + suffix; + string16 app_name = dist->GetBaseAppName() + suffix; entries->push_front(new RegistryEntry(start_menu, app_name)); return true; } @@ -1026,7 +1026,7 @@ void ShellUtil::GetRegisteredBrowsers( KEY_QUERY_VALUE) != ERROR_SUCCESS || key.ReadValue(NULL, &name) != ERROR_SUCCESS || name.empty() || - name.find(dist->GetApplicationName()) != string16::npos) { + name.find(dist->GetBaseAppName()) != string16::npos) { continue; } // Read the browser's reinstall command. @@ -1052,6 +1052,13 @@ string16 ShellUtil::GetCurrentInstallationSuffix(BrowserDistribution* dist, return tested_suffix; } +string16 ShellUtil::GetApplicationName(BrowserDistribution* dist, + const string16& chrome_exe) { + string16 app_name = dist->GetBaseAppName(); + app_name += GetCurrentInstallationSuffix(dist, chrome_exe); + return app_name; +} + bool ShellUtil::MakeChromeDefault(BrowserDistribution* dist, int shell_change, const string16& chrome_exe, @@ -1075,10 +1082,7 @@ bool ShellUtil::MakeChromeDefault(BrowserDistribution* dist, bool ret = true; // First use the new "recommended" way on Vista to make Chrome default // browser. - string16 app_name = dist->GetApplicationName(); - const string16 app_suffix( - ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe)); - app_name += app_suffix; + string16 app_name = GetApplicationName(dist, chrome_exe); if (base::win::GetVersion() >= base::win::VERSION_VISTA) { // On Windows Vista and Win7 we still can set ourselves via the @@ -1118,7 +1122,9 @@ bool ShellUtil::MakeChromeDefault(BrowserDistribution* dist, std::list<RegistryEntry*> entries; STLElementDeleter<std::list<RegistryEntry*> > entries_deleter(&entries); - RegistryEntry::GetUserEntries(dist, chrome_exe, app_suffix, &entries); + RegistryEntry::GetUserEntries( + dist, chrome_exe, GetCurrentInstallationSuffix(dist, chrome_exe), + &entries); // Change the default browser for current user. if ((shell_change & ShellUtil::CURRENT_USER) && !AddRegistryEntries(HKEY_CURRENT_USER, entries)) { @@ -1175,9 +1181,7 @@ bool ShellUtil::MakeChromeDefaultProtocolClient(BrowserDistribution* dist, HRESULT hr = pAAR.CreateInstance(CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC); if (SUCCEEDED(hr)) { - string16 app_name = dist->GetApplicationName(); - app_name += ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe); - + string16 app_name = GetApplicationName(dist, chrome_exe); hr = pAAR->SetAppAsDefault(app_name.c_str(), protocol.c_str(), AT_URLPROTOCOL); } diff --git a/chrome/installer/util/shell_util.h b/chrome/installer/util/shell_util.h index b711d5a..7179eea 100644 --- a/chrome/installer/util/shell_util.h +++ b/chrome/installer/util/shell_util.h @@ -234,6 +234,14 @@ class ShellUtil { static string16 GetCurrentInstallationSuffix(BrowserDistribution* dist, const string16& chrome_exe); + // Returns the application name of the program under |dist|. + // This application name will be suffixed as is appropriate for the current + // install. + // This is the name that is registered with Default Programs on Windows and + // that should thus be used to "make chrome default" and such. + static string16 GetApplicationName(BrowserDistribution* dist, + const string16& chrome_exe); + // Make Chrome the default browser. This function works by going through // the url protocols and file associations that are related to general // browsing, e.g. http, https, .html etc., and requesting to become the |