diff options
author | Torne (Richard Coles) <torne@google.com> | 2013-08-23 16:39:15 +0100 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2013-08-23 16:39:15 +0100 |
commit | 3551c9c881056c480085172ff9840cab31610854 (patch) | |
tree | 23660320f5f4c279966609cf9da7491b96d10ca8 /chrome/installer | |
parent | 4e9d9adbbb6cf287125ca44a0823791a570472f5 (diff) | |
download | chromium_org-3551c9c881056c480085172ff9840cab31610854.tar.gz |
Merge from Chromium at DEPS revision r219274
This commit was generated by merge_to_master.py.
Change-Id: Ibb7f41396cadf4071e89153e1913c986d126f65d
Diffstat (limited to 'chrome/installer')
44 files changed, 611 insertions, 286 deletions
diff --git a/chrome/installer/gcapi/gcapi.cc b/chrome/installer/gcapi/gcapi.cc index c4a2d6e457..17974981c0 100644 --- a/chrome/installer/gcapi/gcapi.cc +++ b/chrome/installer/gcapi/gcapi.cc @@ -38,6 +38,7 @@ #include "chrome/installer/gcapi/gcapi_reactivation.h" #include "chrome/installer/launcher_support/chrome_launcher_support.h" #include "chrome/installer/util/google_update_constants.h" +#include "chrome/installer/util/google_update_settings.h" #include "chrome/installer/util/util_constants.h" #include "chrome/installer/util/wmi.h" #include "google_update/google_update_idl.h" @@ -69,6 +70,15 @@ const wchar_t kChromeRegVersion[] = L"pv"; const wchar_t kNoChromeOfferUntil[] = L"SOFTWARE\\Google\\No Chrome Offer Until"; +const wchar_t kC1FPendingKey[] = + L"Software\\Google\\Common\\Rlz\\Events\\C"; +const wchar_t kC1FSentKey[] = + L"Software\\Google\\Common\\Rlz\\StatefulEvents\\C"; +const wchar_t kC1FKey[] = L"C1F"; + +const wchar_t kRelaunchBrandcodeValue[] = L"RelaunchBrandcode"; +const wchar_t kRelaunchAllowedAfterValue[] = L"RelaunchAllowedAfter"; + // Prefix used to match the window class for Chrome windows. const wchar_t kChromeWindowClassPrefix[] = L"Chrome_WidgetWin_"; @@ -123,6 +133,22 @@ bool GetCompanyName(const wchar_t* filename, wchar_t* buffer, DWORD out_len) { return true; } +// Offsets the current date by |months|. |months| must be between 0 and 12. +// The returned date is in the YYYYMMDD format. +DWORD FormatDateOffsetByMonths(int months) { + DCHECK(months >= 0 && months <= 12); + + SYSTEMTIME now; + GetLocalTime(&now); + now.wMonth += months; + if (now.wMonth > 12) { + now.wMonth -= 12; + now.wYear += 1; + } + + return now.wYear * 10000 + now.wMonth * 100 + now.wDay; +} + // Return true if we can re-offer Chrome; false, otherwise. // Each partner can only offer Chrome once every six months. bool CanReOfferChrome(BOOL set_flag) { @@ -144,9 +170,7 @@ bool CanReOfferChrome(BOOL set_flag) { 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL, &key, &disposition) == ERROR_SUCCESS) { // Get today's date, and format it as YYYYMMDD numeric value. - SYSTEMTIME now; - GetLocalTime(&now); - DWORD today = now.wYear * 10000 + now.wMonth * 100 + now.wDay; + DWORD today = FormatDateOffsetByMonths(0); // Cannot re-offer, if the timer already exists and is not expired yet. DWORD value_type = REG_DWORD; @@ -165,13 +189,7 @@ bool CanReOfferChrome(BOOL set_flag) { if (set_flag) { // Set expiration date for offer as six months from today, // represented as a YYYYMMDD numeric value. - SYSTEMTIME timer = now; - timer.wMonth = timer.wMonth + 6; - if (timer.wMonth > 12) { - timer.wMonth = timer.wMonth - 12; - timer.wYear = timer.wYear + 1; - } - DWORD value = timer.wYear * 10000 + timer.wMonth * 100 + timer.wDay; + DWORD value = FormatDateOffsetByMonths(6); ::RegSetValueEx(key, company, 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD)); } @@ -183,28 +201,30 @@ bool CanReOfferChrome(BOOL set_flag) { return can_re_offer; } -// Helper function to read a value from registry. Returns true if value -// is read successfully and stored in parameter value. Returns false otherwise. -bool ReadValueFromRegistry(HKEY root_key, const wchar_t* sub_key, - const wchar_t* value_name, wchar_t* value, - size_t* size) { - HKEY key; - if ((::RegOpenKeyEx(root_key, sub_key, NULL, - KEY_READ, &key) == ERROR_SUCCESS) && - (::RegQueryValueEx(key, value_name, NULL, NULL, - reinterpret_cast<LPBYTE>(value), - reinterpret_cast<LPDWORD>(size)) == ERROR_SUCCESS)) { - ::RegCloseKey(key); - return true; - } - return false; +bool IsChromeInstalled(HKEY root_key) { + RegKey key; + return key.Open(root_key, kChromeRegClientsKey, KEY_READ) == ERROR_SUCCESS && + key.HasValue(kChromeRegVersion); } -bool IsChromeInstalled(HKEY root_key) { - wchar_t version[64]; - size_t size = _countof(version); - return ReadValueFromRegistry(root_key, kChromeRegClientsKey, - kChromeRegVersion, version, &size); +// Returns true if the |subkey| in |root| has the kC1FKey entry set to 1. +bool RegKeyHasC1F(HKEY root, const wchar_t* subkey) { + RegKey key; + DWORD value; + return key.Open(root, subkey, KEY_READ) == ERROR_SUCCESS && + key.ReadValueDW(kC1FKey, &value) == ERROR_SUCCESS && + value == static_cast<DWORD>(1); +} + +bool IsC1FSent() { + // The C1F RLZ key can either be in HKCU or in HKLM (the HKLM RLZ key is made + // readable to all-users via rlz_lib::CreateMachineState()) and can either be + // in sent or pending state. Return true if there is a match for any of these + // 4 states. + return RegKeyHasC1F(HKEY_CURRENT_USER, kC1FSentKey) || + RegKeyHasC1F(HKEY_CURRENT_USER, kC1FPendingKey) || + RegKeyHasC1F(HKEY_LOCAL_MACHINE, kC1FSentKey) || + RegKeyHasC1F(HKEY_LOCAL_MACHINE, kC1FPendingKey); } enum WindowsVersion { @@ -666,3 +686,104 @@ BOOL __stdcall ReactivateChrome(wchar_t* brand_code, return result; } + +BOOL __stdcall CanOfferRelaunch(const wchar_t** partner_brandcode_list, + int partner_brandcode_list_length, + int shell_mode, + DWORD* error_code) { + DCHECK(error_code); + + if (!partner_brandcode_list || partner_brandcode_list_length <= 0) { + if (error_code) + *error_code = RELAUNCH_ERROR_INVALID_INPUT; + return FALSE; + } + + // These conditions need to be satisfied for relaunch: + // a) Chrome should be installed; + if (!IsChromeInstalled(HKEY_LOCAL_MACHINE) && + (shell_mode != GCAPI_INVOKED_STANDARD_SHELL || + !IsChromeInstalled(HKEY_CURRENT_USER))) { + if (error_code) + *error_code = RELAUNCH_ERROR_NOTINSTALLED; + return FALSE; + } + + // b) the installed brandcode should belong to that partner (in + // brandcode_list); + std::wstring installed_brandcode; + bool valid_brandcode = false; + if (GoogleUpdateSettings::GetBrand(&installed_brandcode)) { + for (int i = 0; i < partner_brandcode_list_length; ++i) { + if (!_wcsicmp(installed_brandcode.c_str(), partner_brandcode_list[i])) { + valid_brandcode = true; + break; + } + } + } + + if (!valid_brandcode) { + if (error_code) + *error_code = RELAUNCH_ERROR_INVALID_PARTNER; + return FALSE; + } + + // c) C1F ping should not have been sent; + if (IsC1FSent()) { + if (error_code) + *error_code = RELAUNCH_ERROR_PINGS_SENT; + return FALSE; + } + + // d) a minimum period (30 days) must have passed since Chrome was last used; + int days_since_last_run = GoogleChromeDaysSinceLastRun(); + if (days_since_last_run >= 0 && + days_since_last_run < kRelaunchMinDaysDormant) { + if (error_code) + *error_code = RELAUNCH_ERROR_NOTDORMANT; + return FALSE; + } + + // e) a minimum period (6 months) must have passed since the previous + // relaunch offer for the current user; + RegKey key; + DWORD min_relaunch_date; + if (key.Open(HKEY_CURRENT_USER, kChromeRegClientStateKey, + KEY_QUERY_VALUE) == ERROR_SUCCESS && + key.ReadValueDW(kRelaunchAllowedAfterValue, + &min_relaunch_date) == ERROR_SUCCESS && + FormatDateOffsetByMonths(0) < min_relaunch_date) { + if (error_code) + *error_code = RELAUNCH_ERROR_ALREADY_RELAUNCHED; + return FALSE; + } + + return TRUE; +} + +BOOL __stdcall SetRelaunchOffered(const wchar_t** partner_brandcode_list, + int partner_brandcode_list_length, + const wchar_t* relaunch_brandcode, + int shell_mode, + DWORD* error_code) { + if (!CanOfferRelaunch(partner_brandcode_list, partner_brandcode_list_length, + shell_mode, error_code)) + return FALSE; + + // Store the relaunched brand code and the minimum date for relaunch (6 months + // from now), and set the Omaha experiment label. + RegKey key; + if (key.Create(HKEY_CURRENT_USER, kChromeRegClientStateKey, + KEY_SET_VALUE) != ERROR_SUCCESS || + key.WriteValue(kRelaunchBrandcodeValue, + relaunch_brandcode) != ERROR_SUCCESS || + key.WriteValue(kRelaunchAllowedAfterValue, + FormatDateOffsetByMonths(6)) != ERROR_SUCCESS || + !SetRelaunchExperimentLabels(relaunch_brandcode, shell_mode)) { + if (error_code) + *error_code = RELAUNCH_ERROR_RELAUNCH_FAILED; + return FALSE; + } + + return TRUE; +} diff --git a/chrome/installer/gcapi/gcapi.def b/chrome/installer/gcapi/gcapi.def index e6abeaec52..2270c86a83 100644 --- a/chrome/installer/gcapi/gcapi.def +++ b/chrome/installer/gcapi/gcapi.def @@ -8,3 +8,5 @@ EXPORTS GoogleChromeDaysSinceLastRun CanOfferReactivation ReactivateChrome + CanOfferRelaunch + SetRelaunchOffered diff --git a/chrome/installer/gcapi/gcapi.h b/chrome/installer/gcapi/gcapi.h index 1951c5b3ed..a35293e3d5 100644 --- a/chrome/installer/gcapi/gcapi.h +++ b/chrome/installer/gcapi/gcapi.h @@ -22,6 +22,15 @@ #define REACTIVATE_ERROR_INVALID_INPUT (1 << 3) #define REACTIVATE_ERROR_REACTIVATION_FAILED (1 << 4) +// Error conditions for CanOfferRelaunch(). +#define RELAUNCH_ERROR_NOTINSTALLED (1 << 0) +#define RELAUNCH_ERROR_INVALID_PARTNER (1 << 1) +#define RELAUNCH_ERROR_PINGS_SENT (1 << 2) +#define RELAUNCH_ERROR_NOTDORMANT (1 << 3) +#define RELAUNCH_ERROR_ALREADY_RELAUNCHED (1 << 4) +#define RELAUNCH_ERROR_INVALID_INPUT (1 << 5) +#define RELAUNCH_ERROR_RELAUNCH_FAILED (1 << 6) + // Flags to indicate how GCAPI is invoked #define GCAPI_INVOKED_STANDARD_SHELL (1 << 0) #define GCAPI_INVOKED_UAC_ELEVATION (1 << 1) @@ -34,6 +43,10 @@ extern "C" { // may be offered. const int kReactivationMinDaysDormant = 50; +// The minimum number of days an installation can be dormant before a relaunch +// may be offered. +const int kRelaunchMinDaysDormant = 30; + // This function returns TRUE if Google Chrome should be offered. // If the return is FALSE, the |reasons| DWORD explains why. If you don't care // for the reason, you can pass NULL for |reasons|. @@ -104,6 +117,33 @@ BOOL __stdcall ReactivateChrome(wchar_t* brand_code, int shell_mode, DWORD* error_code); +// Returns true if a vendor may offer relaunch at this time. Returns false if +// the vendor may not offer relaunching at this time, and places one of the +// RELAUNCH_ERROR_XXX values in |error_code| if |error_code| is non-null. The +// installed brandcode must be in |partner_brandcode_list|. |shell_mode| should +// be set to one of GCAPI_INVOKED_STANDARD_SHELL or GCAPI_INVOKED_UAC_ELEVATION +// depending on whether this method is invoked from an elevated or non-elevated +// process. +BOOL __stdcall CanOfferRelaunch(const wchar_t** partner_brandcode_list, + int partner_brandcode_list_length, + int shell_mode, + DWORD* error_code); + +// Returns true if a vendor may relaunch at this time (and stores that a +// relaunch was offered). Returns false if the vendor may not relaunch +// at this time, and places one of the RELAUNCH_ERROR_XXX values in |error_code| +// if |error_code| is non-null. As for |CanOfferRelaunch|, the installed +// brandcode must be in |partner_brandcode_list|. |shell_mode| should be set to +// one of GCAPI_INVOKED_STANDARD_SHELL or GCAPI_INVOKED_UAC_ELEVATION depending +// on whether this method is invoked from an elevated or non-elevated process. +// The |relaunch_brandcode| will be stored as the brandcode that was used for +// offering this relaunch. +BOOL __stdcall SetRelaunchOffered(const wchar_t** partner_brandcode_list, + int partner_brandcode_list_length, + const wchar_t* relaunch_brandcode, + int shell_mode, + DWORD* error_code); + // Function pointer type declarations to use with GetProcAddress. typedef BOOL (__stdcall *GCCC_CompatibilityCheck)(BOOL, int, DWORD *); typedef BOOL (__stdcall *GCCC_LaunchGC)(); @@ -116,6 +156,15 @@ typedef BOOL (__stdcall *GCCC_CanOfferReactivation)(const wchar_t*, typedef BOOL (__stdcall *GCCC_ReactivateChrome)(const wchar_t*, int, DWORD*); +typedef BOOL (__stdcall *GCCC_CanOfferRelaunch)(const wchar_t**, + int, + int, + DWORD*); +typedef BOOL (__stdcall *GCCC_SetRelaunchOffered)(const wchar_t**, + int, + const wchar_t*, + int, + DWORD*); #ifdef __cplusplus } // extern "C" diff --git a/chrome/installer/gcapi/gcapi_omaha_experiment.cc b/chrome/installer/gcapi/gcapi_omaha_experiment.cc index 5314922f2f..ac5899fe67 100644 --- a/chrome/installer/gcapi/gcapi_omaha_experiment.cc +++ b/chrome/installer/gcapi/gcapi_omaha_experiment.cc @@ -24,10 +24,7 @@ int GetCurrentRlzWeek() { return delta.InDays() / 7; } -} // namespace - -bool SetReactivationExperimentLabels(const wchar_t* brand_code, - int shell_mode) { +bool SetLabel(const wchar_t* brand_code, const wchar_t* label, int shell_mode) { if (!brand_code) { return false; } @@ -38,7 +35,8 @@ bool SetReactivationExperimentLabels(const wchar_t* brand_code, string16 experiment_labels; base::SStringPrintf(&experiment_labels, - L"reacbrand=%ls_%d|%ls", + L"%ls=%ls_%d|%ls", + label, brand_code, week_number, installer::BuildExperimentDateString().c_str()); @@ -47,3 +45,14 @@ bool SetReactivationExperimentLabels(const wchar_t* brand_code, shell_mode == GCAPI_INVOKED_UAC_ELEVATION, experiment_labels); } + +} // namespace + +bool SetReactivationExperimentLabels(const wchar_t* brand_code, + int shell_mode) { + return SetLabel(brand_code, L"reacbrand", shell_mode); +} + +bool SetRelaunchExperimentLabels(const wchar_t* brand_code, int shell_mode) { + return SetLabel(brand_code, L"relaunchbrand", shell_mode); +} diff --git a/chrome/installer/gcapi/gcapi_omaha_experiment.h b/chrome/installer/gcapi/gcapi_omaha_experiment.h index 4d4be8a345..babe41e3a9 100644 --- a/chrome/installer/gcapi/gcapi_omaha_experiment.h +++ b/chrome/installer/gcapi/gcapi_omaha_experiment.h @@ -9,7 +9,16 @@ // binaries registry keys for |brand_code|. This experiment label will have a // expiration date of now plus one year. If |shell_mode| is set to // GCAPI_INVOKED_UAC_ELEVATION, the value will be written to HKLM, otherwise -// HKCU. +// HKCU. A user cannot have both a reactivation label and a relaunch label set +// at the same time (they are mutually exclusive). bool SetReactivationExperimentLabels(const wchar_t* brand_code, int shell_mode); +// Writes a relaunch brand code experiment label in the Chrome product and +// binaries registry keys for |brand_code|. This experiment label will have a +// expiration date of now plus one year. If |shell_mode| is set to +// GCAPI_INVOKED_UAC_ELEVATION, the value will be written to HKLM, otherwise +// HKCU. A user cannot have both a reactivation label and a relaunch label set +// at the same time (they are mutually exclusive). +bool SetRelaunchExperimentLabels(const wchar_t* brand_code, int shell_mode); + #endif // CHROME_INSTALLER_GCAPI_GCAPI_OMAHA_EXPERIMENT_H_ diff --git a/chrome/installer/gcapi/gcapi_reactivation_test.cc b/chrome/installer/gcapi/gcapi_reactivation_test.cc index cc552df2cd..92987a2027 100644 --- a/chrome/installer/gcapi/gcapi_reactivation_test.cc +++ b/chrome/installer/gcapi/gcapi_reactivation_test.cc @@ -22,17 +22,6 @@ using base::Time; using base::TimeDelta; using base::win::RegKey; -namespace { - -const wchar_t kExperimentLabels[] = L"experiment_labels"; - -const wchar_t* kExperimentAppGuids[] = { - L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}", - L"{8A69D345-D564-463C-AFF1-A69D9E530F96}", -}; - -} - class GCAPIReactivationTest : public ::testing::Test { protected: void SetUp() { @@ -79,21 +68,15 @@ class GCAPIReactivationTest : public ::testing::Test { } bool HasExperimentLabels(HKEY hive) { - int label_count = 0; - for (int i = 0; i < arraysize(kExperimentAppGuids); ++i) { - string16 client_state_path(google_update::kRegPathClientState); - client_state_path += L"\\"; - client_state_path += kExperimentAppGuids[i]; - - RegKey client_state_key(hive, - client_state_path.c_str(), - KEY_QUERY_VALUE); - if (client_state_key.Valid() && - client_state_key.HasValue(kExperimentLabels)) { - label_count++; - } - } - return label_count == arraysize(kExperimentAppGuids); + string16 client_state_path(google_update::kRegPathClientState); + client_state_path.push_back(L'\\'); + client_state_path.append(google_update::kChromeUpgradeCode); + + RegKey client_state_key(hive, + client_state_path.c_str(), + KEY_QUERY_VALUE); + return client_state_key.Valid() && + client_state_key.HasValue(google_update::kExperimentLabels); } std::wstring GetReactivationString(HKEY hive) { diff --git a/chrome/installer/linux/common/installer.include b/chrome/installer/linux/common/installer.include index c5ec0f66fc..561b42af10 100644 --- a/chrome/installer/linux/common/installer.include +++ b/chrome/installer/linux/common/installer.include @@ -118,7 +118,6 @@ stage_install_common() { rm "${DEBUGFILE}" "${STRIPPEDFILE}" # resources - install -m 644 "${BUILDDIR}/${PROGNAME}.pak" "${STAGEDIR}/${INSTALLDIR}/" install -m 644 "${BUILDDIR}/resources.pak" "${STAGEDIR}/${INSTALLDIR}/" # TODO(mmoss): This has broken a couple times on adding new .pak files. Maybe # we should flag all installer files in FILES.cfg and get them from there, so diff --git a/chrome/installer/linux/debian/expected_deps b/chrome/installer/linux/debian/expected_deps index 0e16912f42..f545951d47 100644 --- a/chrome/installer/linux/debian/expected_deps +++ b/chrome/installer/linux/debian/expected_deps @@ -26,3 +26,4 @@ libxext6 libxfixes3 libxrender1 libxss1 +libxtst6 diff --git a/chrome/installer/linux/rpm/expected_deps_i386 b/chrome/installer/linux/rpm/expected_deps_i386 index a2434cfd94..b2d7944390 100644 --- a/chrome/installer/linux/rpm/expected_deps_i386 +++ b/chrome/installer/linux/rpm/expected_deps_i386 @@ -70,3 +70,4 @@ libXext.so.6 libXfixes.so.3 libXrender.so.1 libXss.so.1 +libXtst.so.6 diff --git a/chrome/installer/linux/rpm/expected_deps_x86_64 b/chrome/installer/linux/rpm/expected_deps_x86_64 index e1cc80cb93..0d0fac3e4d 100644 --- a/chrome/installer/linux/rpm/expected_deps_x86_64 +++ b/chrome/installer/linux/rpm/expected_deps_x86_64 @@ -60,3 +60,4 @@ libXext.so.6()(64bit) libXfixes.so.3()(64bit) libXrender.so.1()(64bit) libXss.so.1()(64bit) +libXtst.so.6()(64bit) diff --git a/chrome/installer/mini_installer.gyp b/chrome/installer/mini_installer.gyp index 05d54d2875..5f84d34f1e 100644 --- a/chrome/installer/mini_installer.gyp +++ b/chrome/installer/mini_installer.gyp @@ -61,7 +61,6 @@ ], 'DelayLoadDLLs': [], 'EntryPointSymbol': 'MainEntryPoint', - 'GenerateMapFile': 'true', 'IgnoreAllDefaultLibraries': 'true', 'OptimizeForWindows98': '1', 'SubSystem': '2', # Set /SUBSYSTEM:WINDOWS @@ -177,7 +176,13 @@ # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. 'msvs_disabled_warnings': [ 4267, ], - + + 'variables': { + # Opt out the common compatibility manifest to work around + # crbug.com/272660. + # TODO(yukawa): Enable the common compatibility manifest again. + 'win_exe_compatibility_manifest': '', + }, 'sources': [ 'mini_installer/chrome.release', 'mini_installer/chrome_appid.cc', diff --git a/chrome/installer/mini_installer.gypi b/chrome/installer/mini_installer.gypi index ee9403cab1..78d90ff7cc 100644 --- a/chrome/installer/mini_installer.gypi +++ b/chrome/installer/mini_installer.gypi @@ -48,7 +48,6 @@ }, 'VCLinkerTool': { 'OutputFile': '<(output_dir)/mini_installer.exe', - 'MapFileName': '<(output_dir)/mini_installer.map', 'RandomizedBaseAddress': '1', 'DataExecutionPrevention': '0', 'AdditionalLibraryDirectories': [ @@ -56,7 +55,6 @@ ], 'DelayLoadDLLs': [], 'EntryPointSymbol': 'MainEntryPoint', - 'GenerateMapFile': 'true', 'IgnoreAllDefaultLibraries': 'true', 'OptimizeForWindows98': '1', 'SubSystem': '2', # Set /SUBSYSTEM:WINDOWS diff --git a/chrome/installer/mini_installer/mini_installer.exe.manifest b/chrome/installer/mini_installer/mini_installer.exe.manifest index afb780f37b..8ff4c454c6 100644 --- a/chrome/installer/mini_installer/mini_installer.exe.manifest +++ b/chrome/installer/mini_installer/mini_installer.exe.manifest @@ -1,6 +1,23 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> - <!--The compatibility section will be merged from build/win/compatibility.manifest --> + <!-- + Have compatibility section here instead of using + build/win/compatibility.manifest + to work around crbug.com/272660. + TODO(yukawa): Use build/win/compatibility.manifest again. + --> + <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> + <application> + <!--The ID below indicates application support for Windows Vista --> + <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> + <!--The ID below indicates application support for Windows 7 --> + <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> + <!--The ID below indicates application support for Windows 8 --> + <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> + <!--The ID below indicates application support for Windows 8.1 --> + <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> + </application> + </compatibility> <ms_asmv2:trustInfo xmlns:ms_asmv2="urn:schemas-microsoft-com:asm.v2"> <ms_asmv2:security> <ms_asmv2:requestedPrivileges> diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc index 15e2062617..688df1c786 100644 --- a/chrome/installer/setup/install.cc +++ b/chrome/installer/setup/install.cc @@ -87,7 +87,7 @@ void LogShortcutOperation(ShellUtil::ShortcutLocation location, if (properties.has_shortcut_name()) message.append(UTF16ToUTF8(properties.shortcut_name)); else - message.append(UTF16ToUTF8(dist->GetAppShortCutName())); + message.append(UTF16ToUTF8(dist->GetDisplayName())); message.push_back('"'); message.append(" shortcut to "); @@ -330,7 +330,7 @@ bool CreateVisualElementsManifest(const base::FilePath& src_path, BrowserDistribution::CHROME_BROWSER); // TODO(grt): http://crbug.com/75152 Write a reference to a localized // resource for |display_name|. - string16 display_name(dist->GetAppShortCutName()); + string16 display_name(dist->GetDisplayName()); EscapeXmlAttributeValueInSingleQuotes(&display_name); // Fill the manifest with the desired values. @@ -411,8 +411,11 @@ void CreateOrUpdateShortcuts( if (!do_not_create_desktop_shortcut || shortcut_operation == ShellUtil::SHELL_SHORTCUT_REPLACE_EXISTING) { ShellUtil::ShortcutProperties desktop_properties(base_properties); - if (alternate_desktop_shortcut) - desktop_properties.set_shortcut_name(dist->GetAlternateApplicationName()); + if (alternate_desktop_shortcut) { + desktop_properties.set_shortcut_name( + dist->GetShortcutName( + BrowserDistribution::SHORTCUT_CHROME_ALTERNATE)); + } ExecuteAndLogShortcutOperation( ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, desktop_properties, shortcut_operation); @@ -421,7 +424,9 @@ void CreateOrUpdateShortcuts( // Desktop shortcut. if (!alternate_desktop_shortcut && shortcut_operation == ShellUtil::SHELL_SHORTCUT_REPLACE_EXISTING) { - desktop_properties.set_shortcut_name(dist->GetAlternateApplicationName()); + desktop_properties.set_shortcut_name( + dist->GetShortcutName( + BrowserDistribution::SHORTCUT_CHROME_ALTERNATE)); ExecuteAndLogShortcutOperation( ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, desktop_properties, shortcut_operation); diff --git a/chrome/installer/setup/install_unittest.cc b/chrome/installer/setup/install_unittest.cc index e992aa95e2..40f6ab1c79 100644 --- a/chrome/installer/setup/install_unittest.cc +++ b/chrome/installer/setup/install_unittest.cc @@ -117,23 +117,30 @@ class InstallShortcutTest : public testing::Test { new base::ScopedPathOverride(base::DIR_COMMON_START_MENU, fake_common_start_menu_.path())); - string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); + string16 shortcut_name( + dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + + installer::kLnkExt); string16 alternate_shortcut_name( - dist_->GetAlternateApplicationName() + installer::kLnkExt); + dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME_ALTERNATE) + + installer::kLnkExt); user_desktop_shortcut_ = fake_user_desktop_.path().Append(shortcut_name); user_quick_launch_shortcut_ = fake_user_quick_launch_.path().Append(shortcut_name); user_start_menu_shortcut_ = - fake_start_menu_.path().Append(dist_->GetAppShortCutName()) + fake_start_menu_.path().Append( + dist_->GetStartMenuShortcutSubfolder( + BrowserDistribution::SUBFOLDER_CHROME)) .Append(shortcut_name); system_desktop_shortcut_ = fake_common_desktop_.path().Append(shortcut_name); system_quick_launch_shortcut_ = fake_default_user_quick_launch_.path().Append(shortcut_name); system_start_menu_shortcut_ = - fake_common_start_menu_.path().Append(dist_->GetAppShortCutName()) + fake_common_start_menu_.path().Append( + dist_->GetStartMenuShortcutSubfolder( + BrowserDistribution::SUBFOLDER_CHROME)) .Append(shortcut_name); user_alternate_desktop_shortcut_ = fake_user_desktop_.path().Append(alternate_shortcut_name); diff --git a/chrome/installer/setup/install_worker.cc b/chrome/installer/setup/install_worker.cc index b6259540fc..d98767055d 100644 --- a/chrome/installer/setup/install_worker.cc +++ b/chrome/installer/setup/install_worker.cc @@ -438,7 +438,8 @@ void AddDeleteUninstallShortcutsForMSIWorkItems( LOG(ERROR) << "Failed to get location for shortcut."; } else { uninstall_link = uninstall_link.Append( - product.distribution()->GetAppShortCutName()); + product.distribution()->GetStartMenuShortcutSubfolder( + BrowserDistribution::SUBFOLDER_CHROME)); uninstall_link = uninstall_link.Append( product.distribution()->GetUninstallLinkName() + installer::kLnkExt); VLOG(1) << "Deleting old uninstall shortcut (if present): " @@ -722,8 +723,8 @@ void AddUninstallShortcutWorkItems(const InstallerState& installer_state, string16 uninstall_reg = browser_dist->GetUninstallRegPath(); install_list->AddCreateRegKeyWorkItem(reg_root, uninstall_reg); install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, - installer::kUninstallDisplayNameField, - browser_dist->GetAppShortCutName(), true); + installer::kUninstallDisplayNameField, browser_dist->GetDisplayName(), + true); install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, installer::kUninstallStringField, quoted_uninstall_cmd.GetCommandLineString(), true); @@ -736,7 +737,7 @@ void AddUninstallShortcutWorkItems(const InstallerState& installer_state, BrowserDistribution* dist = product.distribution(); string16 chrome_icon = ShellUtil::FormatIconLocation( install_path.Append(dist->GetIconFilename()).value(), - dist->GetIconIndex()); + dist->GetIconIndex(BrowserDistribution::SHORTCUT_CHROME)); install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, L"DisplayIcon", chrome_icon, true); install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, @@ -786,7 +787,7 @@ void AddVersionKeyWorkItems(HKEY root, string16 version_key(dist->GetVersionKey()); list->AddCreateRegKeyWorkItem(root, version_key); - string16 product_name(dist->GetAppShortCutName()); + string16 product_name(dist->GetDisplayName()); list->AddSetRegValueWorkItem(root, version_key, google_update::kRegNameField, product_name, true); // overwrite name also list->AddSetRegValueWorkItem(root, version_key, @@ -845,7 +846,7 @@ void AddOemInstallWorkItems(const InstallationState& original_state, if (source_product->GetOemInstall(&oem_install)) { VLOG(1) << "Mirroring oeminstall=\"" << oem_install << "\" from " << BrowserDistribution::GetSpecificDistribution(source_type)-> - GetAppShortCutName(); + GetDisplayName(); install_list->AddCreateRegKeyWorkItem(root_key, multi_key); // Always overwrite an old value. install_list->AddSetRegValueWorkItem(root_key, multi_key, @@ -900,7 +901,7 @@ void AddEulaAcceptedWorkItems(const InstallationState& original_state, if (have_eula_accepted) { VLOG(1) << "Mirroring eulaaccepted=" << eula_accepted << " from " << BrowserDistribution::GetSpecificDistribution(product_type)-> - GetAppShortCutName(); + GetDisplayName(); install_list->AddCreateRegKeyWorkItem(root_key, multi_key); install_list->AddSetRegValueWorkItem( root_key, multi_key, google_update::kRegEULAAceptedField, @@ -1433,13 +1434,13 @@ void AddDelegateExecuteWorkItems(const InstallerState& installer_state, const Product& product, WorkItemList* list) { string16 handler_class_uuid; - BrowserDistribution* distribution = product.distribution(); - if (!distribution->GetCommandExecuteImplClsid(&handler_class_uuid)) { + BrowserDistribution* dist = product.distribution(); + if (!dist->GetCommandExecuteImplClsid(&handler_class_uuid)) { if (InstallUtil::IsChromeSxSProcess()) { CleanupBadCanaryDelegateExecuteRegistration(target_path, list); } else { VLOG(1) << "No DelegateExecute verb handler processing to do for " - << distribution->GetAppShortCutName(); + << dist->GetDisplayName(); } return; } @@ -1495,25 +1496,24 @@ void AddActiveSetupWorkItems(const InstallerState& installer_state, const Product& product, WorkItemList* list) { DCHECK(installer_state.operation() != InstallerState::UNINSTALL); - BrowserDistribution* distribution = product.distribution(); + BrowserDistribution* dist = product.distribution(); if (!product.is_chrome() || !installer_state.system_install()) { const char* install_level = installer_state.system_install() ? "system" : "user"; VLOG(1) << "No Active Setup processing to do for " << install_level - << "-level " << distribution->GetAppShortCutName(); + << "-level " << dist->GetDisplayName(); return; } DCHECK(installer_state.RequiresActiveSetup()); const HKEY root = HKEY_LOCAL_MACHINE; - const string16 active_setup_path( - InstallUtil::GetActiveSetupPath(distribution)); + const string16 active_setup_path(InstallUtil::GetActiveSetupPath(dist)); VLOG(1) << "Adding registration items for Active Setup."; list->AddCreateRegKeyWorkItem(root, active_setup_path); list->AddSetRegValueWorkItem(root, active_setup_path, L"", - distribution->GetAppShortCutName(), true); + dist->GetDisplayName(), true); base::FilePath active_setup_exe(installer_state.GetInstallerDirectory( new_version).Append(kActiveSetupExe)); @@ -1528,7 +1528,7 @@ void AddActiveSetupWorkItems(const InstallerState& installer_state, // TODO(grt): http://crbug.com/75152 Write a reference to a localized // resource. list->AddSetRegValueWorkItem(root, active_setup_path, L"Localized Name", - distribution->GetAppShortCutName(), true); + dist->GetDisplayName(), true); list->AddSetRegValueWorkItem(root, active_setup_path, L"IsInstalled", static_cast<DWORD>(1U), true); diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc index b02fb4e016..171ac7c7c4 100644 --- a/chrome/installer/setup/setup_main.cc +++ b/chrome/installer/setup/setup_main.cc @@ -204,7 +204,7 @@ void AddExistingMultiInstalls(const InstallationState& original_state, installer_state->AddProductFromState(type, *state); VLOG(1) << "Product already installed and must be included: " << BrowserDistribution::GetSpecificDistribution(type)-> - GetAppShortCutName(); + GetDisplayName(); } } } @@ -338,9 +338,9 @@ bool CheckGroupPolicySettings(const InstallationState& original_state, &is_overridden); if (is_overridden && app_policy != binaries_policy) { LOG(ERROR) << "Found legacy Group Policy setting for " - << dist->GetAppShortCutName() << " (value: " << app_policy + << dist->GetDisplayName() << " (value: " << app_policy << ") that does not match the setting for " - << binaries_dist->GetAppShortCutName() + << binaries_dist->GetDisplayName() << " (value: " << binaries_policy << ")."; settings_are_valid = false; } @@ -355,7 +355,7 @@ bool CheckGroupPolicySettings(const InstallationState& original_state, LOG(ERROR) << "Cannot apply update on account of inconsistent " "Google Update Group Policy settings. Use the Group Policy " "Editor to set the update policy override for the " - << binaries_dist->GetAppShortCutName() + << binaries_dist->GetDisplayName() << " application and try again."; *status = installer::INCONSISTENT_UPDATE_POLICY; installer_state.WriteInstallerResult( @@ -505,7 +505,7 @@ bool CheckMultiInstallConditions(const InstallationState& original_state, // Block downgrades from multi-install to single-install. if (product_state->is_multi_install()) { LOG(ERROR) << "Multi-install " - << products[0]->distribution()->GetAppShortCutName() + << products[0]->distribution()->GetDisplayName() << " exists; aborting single install."; *status = installer::MULTI_INSTALLATION_EXISTS; installer_state->WriteInstallerResult(*status, @@ -757,7 +757,7 @@ installer::InstallStatus UninstallProduct( VLOG(1) << "version on the system: " << product_state->version().GetString(); } else if (!force_uninstall) { - LOG(ERROR) << product.distribution()->GetAppShortCutName() + LOG(ERROR) << product.distribution()->GetDisplayName() << " not found for uninstall."; return installer::CHROME_NOT_INSTALLED; } @@ -929,7 +929,7 @@ installer::InstallStatus RegisterDevChrome( static const wchar_t kPleaseUninstallYourChromeMessage[] = L"You already have a full-installation (non-dev) of %1ls, please " L"uninstall it first using Add/Remove Programs in the control panel."; - string16 name(chrome_dist->GetAppShortCutName()); + string16 name(chrome_dist->GetDisplayName()); string16 message(base::StringPrintf(kPleaseUninstallYourChromeMessage, name.c_str())); @@ -1241,7 +1241,7 @@ bool HandleNonInstallCmdLineOptions(const InstallationState& original_state, InstallUtil::GetChromeVersion(browser_dist, true, &installed_version); if (!installed_version.IsValid()) { LOG(ERROR) << "No installation of " - << browser_dist->GetAppShortCutName() + << browser_dist->GetDisplayName() << " found for system-level toast."; } else { product.LaunchUserExperiment( @@ -1531,7 +1531,7 @@ installer::InstallStatus InstallProductsHelper( if (product_state != NULL && (product_state->version().CompareTo(*installer_version) > 0)) { LOG(ERROR) << "Higher version of " - << product.distribution()->GetAppShortCutName() + << product.distribution()->GetDisplayName() << " is already installed."; higher_products |= (1 << product.distribution()->GetType()); } @@ -1839,7 +1839,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, ::MessageBoxW(NULL, installer::GetLocalizedString( IDS_UNINSTALL_COMPLETE_BASE).c_str(), - cf_install->distribution()->GetAppShortCutName().c_str(), + cf_install->distribution()->GetDisplayName().c_str(), MB_OK); } } diff --git a/chrome/installer/setup/setup_util.cc b/chrome/installer/setup/setup_util.cc index 3de04fbce5..8ecdcb6d67 100644 --- a/chrome/installer/setup/setup_util.cc +++ b/chrome/installer/setup/setup_util.cc @@ -394,7 +394,7 @@ void MigrateGoogleUpdateStateMultiToSingle( KEY_SET_VALUE); if (result != ERROR_SUCCESS) { LOG(ERROR) << "Failed opening ClientState key for " - << dist->GetAppShortCutName() << " to migrate usagestats."; + << dist->GetDisplayName() << " to migrate usagestats."; } else { state_key.WriteValue(google_update::kRegUsageStatsField, usagestats); } @@ -416,7 +416,7 @@ void MigrateGoogleUpdateStateMultiToSingle( if (result == ERROR_SUCCESS && channel_info.Initialize(state_key) && product_to_migrate.SetChannelFlags(false, &channel_info)) { - VLOG(1) << "Moving " << dist->GetAppShortCutName() + VLOG(1) << "Moving " << dist->GetDisplayName() << " to channel: " << channel_info.value(); channel_info.Write(&state_key); } @@ -431,10 +431,10 @@ void MigrateGoogleUpdateStateMultiToSingle( if (result == ERROR_SUCCESS) { installer::ChannelInfo channel_info; if (!channel_info.Initialize(state_key)) { - LOG(ERROR) << "Failed reading " << dist->GetAppShortCutName() + LOG(ERROR) << "Failed reading " << dist->GetDisplayName() << " channel info."; } else if (channel_info.RemoveAllModifiersAndSuffixes()) { - VLOG(1) << "Moving " << dist->GetAppShortCutName() + VLOG(1) << "Moving " << dist->GetDisplayName() << " to channel: " << channel_info.value(); channel_info.Write(&state_key); } diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc index 30af416846..7f8e7cebb3 100644 --- a/chrome/installer/setup/uninstall.cc +++ b/chrome/installer/setup/uninstall.cc @@ -103,7 +103,7 @@ void AddChannelValueUpdateWorkItems( product_state != NULL && product_state->is_multi_install()) << "Channel value for " << BrowserDistribution::GetSpecificDistribution( - dist_type)->GetAppShortCutName() + dist_type)->GetDisplayName() << " is somehow already set to the desired new value of " << channel_info.value(); } @@ -940,7 +940,7 @@ void UninstallActiveSetupEntries(const InstallerState& installer_state, const char* install_level = installer_state.system_install() ? "system" : "user"; VLOG(1) << "No Active Setup processing to do for " << install_level - << "-level " << distribution->GetAppShortCutName(); + << "-level " << distribution->GetDisplayName(); return; } @@ -1079,7 +1079,7 @@ InstallStatus UninstallProduct(const InstallationState& original_state, bool is_chrome = product.is_chrome(); - VLOG(1) << "UninstallProduct: " << browser_dist->GetAppShortCutName(); + VLOG(1) << "UninstallProduct: " << browser_dist->GetDisplayName(); 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 4f711419db..8a249272c8 100644 --- a/chrome/installer/util/browser_distribution.cc +++ b/chrome/installer/util/browser_distribution.cc @@ -39,6 +39,9 @@ const wchar_t kChromiumActiveSetupGuid[] = const wchar_t kCommandExecuteImplUuid[] = L"{A2DF06F9-A21A-44A8-8A99-8B9C84F29160}"; +// The Chromium App Launcher icon is index 1; see chrome_exe.rc. +const int kAppLauncherIconIndex = 1; + // The BrowserDistribution objects are never freed. BrowserDistribution* g_browser_distribution = NULL; BrowserDistribution* g_chrome_frame_distribution = NULL; @@ -154,12 +157,42 @@ string16 BrowserDistribution::GetBaseAppName() { return L"Chromium"; } -string16 BrowserDistribution::GetAppShortCutName() { - return GetBaseAppName(); +string16 BrowserDistribution::GetDisplayName() { + return GetShortcutName(SHORTCUT_CHROME); +} + +string16 BrowserDistribution::GetShortcutName(ShortcutType shortcut_type) { + switch (shortcut_type) { + case SHORTCUT_CHROME_ALTERNATE: + // TODO(calamity): Change IDS_OEM_MAIN_SHORTCUT_NAME in + // chromium_strings.grd to "The Internet" (so that it doesn't collide with + // the value in google_chrome_strings.grd) then change this to + // installer::GetLocalizedString(IDS_OEM_MAIN_SHORTCUT_NAME_BASE) + return L"The Internet"; + case SHORTCUT_APP_LAUNCHER: + return installer::GetLocalizedString(IDS_APP_LIST_SHORTCUT_NAME_BASE); + default: + DCHECK_EQ(shortcut_type, SHORTCUT_CHROME); + return GetBaseAppName(); + } } -string16 BrowserDistribution::GetAlternateApplicationName() { - return L"The Internet"; +int BrowserDistribution::GetIconIndex(ShortcutType shortcut_type) { + if (shortcut_type == SHORTCUT_APP_LAUNCHER) + return kAppLauncherIconIndex; + DCHECK(shortcut_type == SHORTCUT_CHROME || + shortcut_type == SHORTCUT_CHROME_ALTERNATE) << shortcut_type; + return 0; +} + +string16 BrowserDistribution::GetIconFilename() { + return installer::kChromeExe; +} + +string16 BrowserDistribution::GetStartMenuShortcutSubfolder( + Subfolder subfolder_type) { + DCHECK_EQ(subfolder_type, SUBFOLDER_CHROME); + return GetShortcutName(SHORTCUT_CHROME); } string16 BrowserDistribution::GetBaseAppId() { @@ -228,16 +261,6 @@ bool BrowserDistribution::CanCreateDesktopShortcuts() { return true; } -string16 BrowserDistribution::GetIconFilename() { - return string16(); -} - -int BrowserDistribution::GetIconIndex() { - // Assuming that main icon appears first alphabetically in the resource file - // for GetIconFilename(). - return 0; -} - bool BrowserDistribution::GetChromeChannel(string16* channel) { return false; } diff --git a/chrome/installer/util/browser_distribution.h b/chrome/installer/util/browser_distribution.h index ca67c0bc1b..b308c04fec 100644 --- a/chrome/installer/util/browser_distribution.h +++ b/chrome/installer/util/browser_distribution.h @@ -29,6 +29,17 @@ class BrowserDistribution { NUM_TYPES }; + enum ShortcutType { + SHORTCUT_CHROME, + SHORTCUT_CHROME_ALTERNATE, + SHORTCUT_APP_LAUNCHER + }; + + enum Subfolder { + SUBFOLDER_CHROME, + // TODO(calamity): add SUBFOLDER_APPS when refactoring chrome app dir code. + }; + virtual ~BrowserDistribution() {} static BrowserDistribution* GetDistribution(); @@ -53,10 +64,24 @@ class BrowserDistribution { // at run-time. virtual string16 GetBaseAppName(); - // Returns the localized name of the program. - virtual string16 GetAppShortCutName(); + // Returns the localized display name of this distribution. + virtual string16 GetDisplayName(); - virtual string16 GetAlternateApplicationName(); + // Returns the localized name of the shortcut identified by |shortcut_type| + // for this distribution. + virtual string16 GetShortcutName(ShortcutType shortcut_type); + + // Returns the index of the icon for the product identified by + // |shortcut_type|, inside the file specified by GetIconFilename(). + virtual int GetIconIndex(ShortcutType shortcut_type); + + // Returns the executable filename (not path) that contains the product icon. + virtual string16 GetIconFilename(); + + // Returns the localized name of the subfolder in the Start Menu identified by + // |subfolder_type| that this distribution should create shortcuts in. For + // SUBFOLDER_CHROME this returns GetShortcutName(SHORTCUT_CHROME). + virtual string16 GetStartMenuShortcutSubfolder(Subfolder subfolder_type); // Returns the unsuffixed appid of this program. // The AppUserModelId is a property of Windows programs. @@ -96,13 +121,6 @@ class BrowserDistribution { virtual bool CanCreateDesktopShortcuts(); - // Returns the executable filename (not path) that contains the product icon. - virtual string16 GetIconFilename(); - - // Returns the index of the icon for the product, inside the file specified by - // GetIconFilename(). - virtual int GetIconIndex(); - virtual bool GetChromeChannel(string16* channel); // Returns true if this distribution includes a DelegateExecute verb handler, diff --git a/chrome/installer/util/chrome_app_host_distribution.cc b/chrome/installer/util/chrome_app_host_distribution.cc index 7c40326e1d..1c4c0e13fc 100644 --- a/chrome/installer/util/chrome_app_host_distribution.cc +++ b/chrome/installer/util/chrome_app_host_distribution.cc @@ -38,16 +38,14 @@ string16 ChromeAppHostDistribution::GetBaseAppName() { return L"Google Chrome App Launcher"; } -string16 ChromeAppHostDistribution::GetAppShortCutName() { - const string16& product_name = - installer::GetLocalizedString(IDS_PRODUCT_APP_LAUNCHER_NAME_BASE); - return product_name; +string16 ChromeAppHostDistribution::GetDisplayName() { + return GetShortcutName(SHORTCUT_APP_LAUNCHER); } -string16 ChromeAppHostDistribution::GetAlternateApplicationName() { - const string16& product_name = - installer::GetLocalizedString(IDS_PRODUCT_APP_LAUNCHER_NAME_BASE); - return product_name; +string16 ChromeAppHostDistribution::GetShortcutName( + ShortcutType shortcut_type) { + DCHECK_EQ(shortcut_type, SHORTCUT_APP_LAUNCHER); + return installer::GetLocalizedString(IDS_PRODUCT_APP_LAUNCHER_NAME_BASE); } string16 ChromeAppHostDistribution::GetBaseAppId() { diff --git a/chrome/installer/util/chrome_app_host_distribution.h b/chrome/installer/util/chrome_app_host_distribution.h index 5648abde7f..24e007a32e 100644 --- a/chrome/installer/util/chrome_app_host_distribution.h +++ b/chrome/installer/util/chrome_app_host_distribution.h @@ -15,11 +15,14 @@ class ChromeAppHostDistribution : public BrowserDistribution { public: virtual string16 GetAppGuid() OVERRIDE; - virtual string16 GetBaseAppName() OVERRIDE; + virtual string16 GetDisplayName() OVERRIDE; + + // This can only be called with SHORTCUT_APP_LAUNCHER for |shortcut_type|. + virtual string16 GetShortcutName(ShortcutType shortcut_type) OVERRIDE; - virtual string16 GetAppShortCutName() OVERRIDE; + virtual string16 GetIconFilename() OVERRIDE; - virtual string16 GetAlternateApplicationName() OVERRIDE; + virtual string16 GetBaseAppName() OVERRIDE; virtual string16 GetBaseAppId() OVERRIDE; @@ -51,8 +54,6 @@ class ChromeAppHostDistribution : public BrowserDistribution { virtual bool CanCreateDesktopShortcuts() OVERRIDE; - virtual string16 GetIconFilename() OVERRIDE; - virtual bool GetCommandExecuteImplClsid( string16* handler_class_uuid) OVERRIDE; diff --git a/chrome/installer/util/chrome_app_host_operations.cc b/chrome/installer/util/chrome_app_host_operations.cc index 361f952ef1..cfd9570f86 100644 --- a/chrome/installer/util/chrome_app_host_operations.cc +++ b/chrome/installer/util/chrome_app_host_operations.cc @@ -108,7 +108,8 @@ void ChromeAppHostOperations::AddDefaultShortcutProperties( } if (!properties->has_icon()) - properties->set_icon(target_exe, dist->GetIconIndex()); + properties->set_icon(target_exe, + dist->GetIconIndex(BrowserDistribution::SHORTCUT_APP_LAUNCHER)); if (!properties->has_app_id()) { std::vector<string16> components; diff --git a/chrome/installer/util/chrome_browser_operations.cc b/chrome/installer/util/chrome_browser_operations.cc index 59757e4031..c376261268 100644 --- a/chrome/installer/util/chrome_browser_operations.cc +++ b/chrome/installer/util/chrome_browser_operations.cc @@ -112,7 +112,8 @@ void ChromeBrowserOperations::AddDefaultShortcutProperties( properties->set_target(target_exe); if (!properties->has_icon()) { - int icon_index = dist->GetIconIndex(); + int icon_index = + dist->GetIconIndex(BrowserDistribution::SHORTCUT_CHROME); base::FilePath prefs_path(target_exe.DirName().AppendASCII( installer::kDefaultMasterPrefs)); if (base::PathExists(prefs_path)) { diff --git a/chrome/installer/util/chrome_frame_distribution.cc b/chrome/installer/util/chrome_frame_distribution.cc index 68379d0c78..f968178886 100644 --- a/chrome/installer/util/chrome_frame_distribution.cc +++ b/chrome/installer/util/chrome_frame_distribution.cc @@ -36,16 +36,15 @@ string16 ChromeFrameDistribution::GetBaseAppName() { return L"Google Chrome Frame"; } -string16 ChromeFrameDistribution::GetAppShortCutName() { - const string16& product_name = - installer::GetLocalizedString(IDS_PRODUCT_FRAME_NAME_BASE); - return product_name; -} - -string16 ChromeFrameDistribution::GetAlternateApplicationName() { - const string16& product_name = - installer::GetLocalizedString(IDS_PRODUCT_FRAME_NAME_BASE); - return product_name; +string16 ChromeFrameDistribution::GetShortcutName(ShortcutType shortcut_type) { + switch (shortcut_type) { + case SHORTCUT_CHROME: + case SHORTCUT_CHROME_ALTERNATE: + return installer::GetLocalizedString(IDS_PRODUCT_FRAME_NAME_BASE); + default: + NOTREACHED(); + return string16(); + } } string16 ChromeFrameDistribution::GetInstallSubDir() { @@ -112,8 +111,14 @@ string16 ChromeFrameDistribution::GetIconFilename() { return installer::kChromeExe; } -int ChromeFrameDistribution::GetIconIndex() { - return 0; +int ChromeFrameDistribution::GetIconIndex(ShortcutType shortcut_type) { + switch (shortcut_type) { + case SHORTCUT_CHROME: + return 0; + default: + NOTREACHED(); + return 0; + } } bool ChromeFrameDistribution::CanSetAsDefault() { diff --git a/chrome/installer/util/chrome_frame_distribution.h b/chrome/installer/util/chrome_frame_distribution.h index ff49036b03..fa891d6173 100644 --- a/chrome/installer/util/chrome_frame_distribution.h +++ b/chrome/installer/util/chrome_frame_distribution.h @@ -15,11 +15,11 @@ class ChromeFrameDistribution : public BrowserDistribution { public: virtual string16 GetAppGuid() OVERRIDE; - virtual string16 GetBaseAppName() OVERRIDE; + virtual string16 GetShortcutName(ShortcutType shortcut_type) OVERRIDE; - virtual string16 GetAppShortCutName() OVERRIDE; + virtual int GetIconIndex(ShortcutType shortcut_type) OVERRIDE; - virtual string16 GetAlternateApplicationName() OVERRIDE; + virtual string16 GetBaseAppName() OVERRIDE; virtual string16 GetInstallSubDir() OVERRIDE; @@ -47,8 +47,6 @@ class ChromeFrameDistribution : public BrowserDistribution { virtual string16 GetIconFilename() OVERRIDE; - virtual int GetIconIndex() OVERRIDE; - virtual bool CanSetAsDefault() OVERRIDE; virtual bool CanCreateDesktopShortcuts() OVERRIDE; diff --git a/chrome/installer/util/chromium_binaries_distribution.cc b/chrome/installer/util/chromium_binaries_distribution.cc index 514dfa7dcc..004e6176a6 100644 --- a/chrome/installer/util/chromium_binaries_distribution.cc +++ b/chrome/installer/util/chromium_binaries_distribution.cc @@ -29,11 +29,12 @@ string16 ChromiumBinariesDistribution::GetBaseAppName() { return string16(); } -string16 ChromiumBinariesDistribution::GetAppShortCutName() { +string16 ChromiumBinariesDistribution::GetDisplayName() { return kChromiumBinariesName; } -string16 ChromiumBinariesDistribution::GetAlternateApplicationName() { +string16 ChromiumBinariesDistribution::GetShortcutName( + ShortcutType shortcut_type) { NOTREACHED(); return string16(); } @@ -93,7 +94,7 @@ bool ChromiumBinariesDistribution::CanSetAsDefault() { return false; } -int ChromiumBinariesDistribution::GetIconIndex() { +int ChromiumBinariesDistribution::GetIconIndex(ShortcutType shortcut_type) { NOTREACHED(); return 0; } diff --git a/chrome/installer/util/chromium_binaries_distribution.h b/chrome/installer/util/chromium_binaries_distribution.h index e78bf8654e..43c87ccde9 100644 --- a/chrome/installer/util/chromium_binaries_distribution.h +++ b/chrome/installer/util/chromium_binaries_distribution.h @@ -15,11 +15,13 @@ class ChromiumBinariesDistribution : public BrowserDistribution { public: virtual string16 GetAppGuid() OVERRIDE; - virtual string16 GetBaseAppName() OVERRIDE; + virtual string16 GetDisplayName() OVERRIDE; + + virtual string16 GetShortcutName(ShortcutType shortcut_type) OVERRIDE; - virtual string16 GetAppShortCutName() OVERRIDE; + virtual int GetIconIndex(ShortcutType shortcut_type) OVERRIDE; - virtual string16 GetAlternateApplicationName() OVERRIDE; + virtual string16 GetBaseAppName() OVERRIDE; virtual string16 GetBaseAppId() OVERRIDE; @@ -45,8 +47,6 @@ class ChromiumBinariesDistribution : public BrowserDistribution { virtual bool CanSetAsDefault() OVERRIDE; - virtual int GetIconIndex() OVERRIDE; - virtual bool GetChromeChannel(string16* channel) OVERRIDE; virtual bool GetCommandExecuteImplClsid( diff --git a/chrome/installer/util/google_chrome_binaries_distribution.cc b/chrome/installer/util/google_chrome_binaries_distribution.cc index 16c177d02d..e5ad75121b 100644 --- a/chrome/installer/util/google_chrome_binaries_distribution.cc +++ b/chrome/installer/util/google_chrome_binaries_distribution.cc @@ -25,10 +25,16 @@ string16 GoogleChromeBinariesDistribution::GetAppGuid() { return kChromeBinariesGuid; } -string16 GoogleChromeBinariesDistribution::GetAppShortCutName() { +string16 GoogleChromeBinariesDistribution::GetDisplayName() { return kChromeBinariesName; } +string16 GoogleChromeBinariesDistribution::GetShortcutName( + ShortcutType shortcut_type) { + NOTREACHED(); + return string16(); +} + string16 GoogleChromeBinariesDistribution::GetStateKey() { return string16(google_update::kRegPathClientState) .append(1, L'\\') diff --git a/chrome/installer/util/google_chrome_binaries_distribution.h b/chrome/installer/util/google_chrome_binaries_distribution.h index ded49b8c1d..aa0a1ee508 100644 --- a/chrome/installer/util/google_chrome_binaries_distribution.h +++ b/chrome/installer/util/google_chrome_binaries_distribution.h @@ -13,7 +13,9 @@ class GoogleChromeBinariesDistribution : public ChromiumBinariesDistribution { public: virtual string16 GetAppGuid(); - virtual string16 GetAppShortCutName(); + virtual string16 GetDisplayName(); + + virtual string16 GetShortcutName(ShortcutType shortcut_type); virtual string16 GetStateKey(); diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc index c7a7c3e410..2ae5338f23 100644 --- a/chrome/installer/util/google_chrome_distribution.cc +++ b/chrome/installer/util/google_chrome_distribution.cc @@ -38,6 +38,9 @@ const wchar_t kBrowserAppId[] = L"Chrome"; const wchar_t kCommandExecuteImplUuid[] = L"{5C65F4B0-3651-4514-B207-D10CB699B14B}"; +// The Google Chrome App Launcher icon is index 5; see chrome_exe.rc. +const int kAppLauncherIconIndex = 5; + // Substitute the locale parameter in uninstall URL with whatever // Google Update tells us is the locale. In case we fail to find // the locale, we use US English. @@ -125,16 +128,28 @@ string16 GoogleChromeDistribution::GetBaseAppName() { return L"Google Chrome"; } -string16 GoogleChromeDistribution::GetAppShortCutName() { - const string16& app_shortcut_name = - installer::GetLocalizedString(IDS_PRODUCT_NAME_BASE); - return app_shortcut_name; +string16 GoogleChromeDistribution::GetShortcutName(ShortcutType shortcut_type) { + int string_id = IDS_PRODUCT_NAME_BASE; + switch (shortcut_type) { + case SHORTCUT_CHROME_ALTERNATE: + string_id = IDS_OEM_MAIN_SHORTCUT_NAME_BASE; + break; + case SHORTCUT_APP_LAUNCHER: + string_id = IDS_APP_LIST_SHORTCUT_NAME_BASE; + break; + default: + DCHECK_EQ(shortcut_type, SHORTCUT_CHROME); + break; + } + return installer::GetLocalizedString(string_id); } -string16 GoogleChromeDistribution::GetAlternateApplicationName() { - const string16& alt_product_name = - installer::GetLocalizedString(IDS_OEM_MAIN_SHORTCUT_NAME_BASE); - return alt_product_name; +int GoogleChromeDistribution::GetIconIndex(ShortcutType shortcut_type) { + if (shortcut_type == SHORTCUT_APP_LAUNCHER) + return kAppLauncherIconIndex; + DCHECK(shortcut_type == SHORTCUT_CHROME || + shortcut_type == SHORTCUT_CHROME_ALTERNATE) << shortcut_type; + return 0; } string16 GoogleChromeDistribution::GetBaseAppId() { diff --git a/chrome/installer/util/google_chrome_distribution.h b/chrome/installer/util/google_chrome_distribution.h index d3f148fc76..a00a31e514 100644 --- a/chrome/installer/util/google_chrome_distribution.h +++ b/chrome/installer/util/google_chrome_distribution.h @@ -36,11 +36,13 @@ class GoogleChromeDistribution : public BrowserDistribution { virtual string16 GetAppGuid() OVERRIDE; - virtual string16 GetBaseAppName() OVERRIDE; + virtual string16 GetShortcutName(ShortcutType shortcut_type) OVERRIDE; + + virtual string16 GetIconFilename() OVERRIDE; - virtual string16 GetAppShortCutName() OVERRIDE; + virtual int GetIconIndex(ShortcutType shortcut_type) OVERRIDE; - virtual string16 GetAlternateApplicationName() OVERRIDE; + virtual string16 GetBaseAppName() OVERRIDE; virtual string16 GetBaseAppId() OVERRIDE; @@ -71,8 +73,6 @@ class GoogleChromeDistribution : public BrowserDistribution { virtual string16 GetVersionKey() OVERRIDE; - virtual string16 GetIconFilename() OVERRIDE; - virtual bool GetCommandExecuteImplClsid( string16* handler_class_uuid) OVERRIDE; diff --git a/chrome/installer/util/google_chrome_distribution_dummy.cc b/chrome/installer/util/google_chrome_distribution_dummy.cc index 623870c7ea..ff7638a3bb 100644 --- a/chrome/installer/util/google_chrome_distribution_dummy.cc +++ b/chrome/installer/util/google_chrome_distribution_dummy.cc @@ -41,14 +41,14 @@ string16 GoogleChromeDistribution::GetBaseAppName() { return string16(); } -string16 GoogleChromeDistribution::GetAppShortCutName() { +string16 GoogleChromeDistribution::GetShortcutName(ShortcutType shortcut_type) { NOTREACHED(); return string16(); } -string16 GoogleChromeDistribution::GetAlternateApplicationName() { +int GoogleChromeDistribution::GetIconIndex(ShortcutType shortcut_type) { NOTREACHED(); - return string16(); + return 0; } string16 GoogleChromeDistribution::GetBaseAppId() { diff --git a/chrome/installer/util/google_chrome_sxs_distribution.cc b/chrome/installer/util/google_chrome_sxs_distribution.cc index 5224a8cfef..1e623d995e 100644 --- a/chrome/installer/util/google_chrome_sxs_distribution.cc +++ b/chrome/installer/util/google_chrome_sxs_distribution.cc @@ -18,6 +18,9 @@ const wchar_t kChannelName[] = L"canary"; const wchar_t kBrowserAppId[] = L"ChromeCanary"; const int kSxSIconIndex = 4; +// The Chrome App Launcher Canary icon is index 6; see chrome_exe.rc. +const int kSxSAppLauncherIconIndex = 6; + } // namespace GoogleChromeSxSDistribution::GoogleChromeSxSDistribution() @@ -29,10 +32,21 @@ string16 GoogleChromeSxSDistribution::GetBaseAppName() { return L"Google Chrome Canary"; } -string16 GoogleChromeSxSDistribution::GetAppShortCutName() { - const string16& shortcut_name = - installer::GetLocalizedString(IDS_SXS_SHORTCUT_NAME_BASE); - return shortcut_name; +string16 GoogleChromeSxSDistribution::GetShortcutName( + ShortcutType shortcut_type) { + switch (shortcut_type) { + case SHORTCUT_CHROME_ALTERNATE: + // This should never be called. Returning the same string as Google Chrome + // preserves behavior, but it will result in a naming collision. + NOTREACHED(); + return GoogleChromeDistribution::GetShortcutName(shortcut_type); + case SHORTCUT_APP_LAUNCHER: + return installer::GetLocalizedString( + IDS_APP_LIST_SHORTCUT_NAME_CANARY_BASE); + default: + DCHECK_EQ(shortcut_type, SHORTCUT_CHROME); + return installer::GetLocalizedString(IDS_SXS_SHORTCUT_NAME_BASE); + } } string16 GoogleChromeSxSDistribution::GetBaseAppId() { @@ -53,7 +67,11 @@ bool GoogleChromeSxSDistribution::CanSetAsDefault() { return false; } -int GoogleChromeSxSDistribution::GetIconIndex() { +int GoogleChromeSxSDistribution::GetIconIndex(ShortcutType shortcut_type) { + if (shortcut_type == SHORTCUT_APP_LAUNCHER) + return kSxSAppLauncherIconIndex; + DCHECK(shortcut_type == SHORTCUT_CHROME || + shortcut_type == SHORTCUT_CHROME_ALTERNATE) << shortcut_type; return kSxSIconIndex; } diff --git a/chrome/installer/util/google_chrome_sxs_distribution.h b/chrome/installer/util/google_chrome_sxs_distribution.h index 74a0cc3618..5261a7accd 100644 --- a/chrome/installer/util/google_chrome_sxs_distribution.h +++ b/chrome/installer/util/google_chrome_sxs_distribution.h @@ -20,12 +20,12 @@ class GoogleChromeSxSDistribution : public GoogleChromeDistribution { public: virtual string16 GetBaseAppName() OVERRIDE; - virtual string16 GetAppShortCutName() OVERRIDE; + virtual string16 GetShortcutName(ShortcutType shortcut_type) OVERRIDE; + virtual int GetIconIndex(ShortcutType shortcut_type) OVERRIDE; virtual string16 GetBaseAppId() OVERRIDE; virtual string16 GetInstallSubDir() OVERRIDE; virtual string16 GetUninstallRegPath() OVERRIDE; virtual bool CanSetAsDefault() OVERRIDE; - virtual int GetIconIndex() OVERRIDE; virtual bool GetChromeChannel(string16* channel) OVERRIDE; virtual bool GetCommandExecuteImplClsid( string16* handler_class_uuid) OVERRIDE; diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc index fd1ad19847..c8c037df82 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc @@ -223,12 +223,12 @@ void InstallUtil::GetChromeVersion(BrowserDistribution* dist, *version = Version(); if (result == ERROR_SUCCESS && !version_str.empty()) { - VLOG(1) << "Existing " << dist->GetAppShortCutName() << " version found " + VLOG(1) << "Existing " << dist->GetDisplayName() << " version found " << version_str; *version = Version(WideToASCII(version_str)); } else { DCHECK_EQ(ERROR_FILE_NOT_FOUND, result); - VLOG(1) << "No existing " << dist->GetAppShortCutName() + VLOG(1) << "No existing " << dist->GetDisplayName() << " install found."; } } @@ -249,12 +249,12 @@ void InstallUtil::GetCriticalUpdateVersion(BrowserDistribution* dist, *version = Version(); if (result == ERROR_SUCCESS && !version_str.empty()) { - VLOG(1) << "Critical Update version for " << dist->GetAppShortCutName() + VLOG(1) << "Critical Update version for " << dist->GetDisplayName() << " found " << version_str; *version = Version(WideToASCII(version_str)); } else { DCHECK_EQ(ERROR_FILE_NOT_FOUND, result); - VLOG(1) << "No existing " << dist->GetAppShortCutName() + VLOG(1) << "No existing " << dist->GetDisplayName() << " install found."; } } diff --git a/chrome/installer/util/installation_validator.cc b/chrome/installer/util/installation_validator.cc index f5fb140cba..649d792258 100644 --- a/chrome/installer/util/installation_validator.cc +++ b/chrome/installer/util/installation_validator.cc @@ -211,7 +211,7 @@ void InstallationValidator::ValidateAppCommandFlags( bool expected = flags_exp.find(check_list[i].exp_key) != flags_exp.end(); if (check_list[i].val != expected) { *is_valid = false; - LOG(ERROR) << ctx.dist->GetAppShortCutName() << ": " + LOG(ERROR) << ctx.dist->GetDisplayName() << ": " << name << " command should " << (expected ? "" : "not ") << check_list[i].msg << "."; } @@ -415,7 +415,7 @@ void InstallationValidator::ValidateAppCommandExpectations( the_expectations.erase(expectation); } else { *is_valid = false; - LOG(ERROR) << ctx.dist->GetAppShortCutName() + LOG(ERROR) << ctx.dist->GetDisplayName() << " has an unexpected Google Update product command named \"" << cmd_id << "\"."; } @@ -426,7 +426,7 @@ void InstallationValidator::ValidateAppCommandExpectations( CommandExpectations::const_iterator end(the_expectations.end()); for (; scan != end; ++scan) { *is_valid = false; - LOG(ERROR) << ctx.dist->GetAppShortCutName() + LOG(ERROR) << ctx.dist->GetDisplayName() << " is missing the Google Update product command named \"" << scan->first << "\"."; } @@ -595,7 +595,7 @@ void InstallationValidator::ValidateSetupPath(const ProductContext& ctx, if (!base::FilePath::CompareEqualIgnoreCase(expected_path.value(), setup_exe.value())) { *is_valid = false; - LOG(ERROR) << ctx.dist->GetAppShortCutName() << " path to " << purpose + LOG(ERROR) << ctx.dist->GetDisplayName() << " path to " << purpose << " is not " << expected_path.value() << ": " << setup_exe.value(); } @@ -613,7 +613,7 @@ void InstallationValidator::ValidateCommandExpectations( const SwitchExpectations::value_type& expectation = expected[i]; if (command.HasSwitch(expectation.first) != expectation.second) { *is_valid = false; - LOG(ERROR) << ctx.dist->GetAppShortCutName() << " " << source + LOG(ERROR) << ctx.dist->GetDisplayName() << " " << source << (expectation.second ? " is missing" : " has") << " \"" << expectation.first << "\"" << (expectation.second ? "" : " but shouldn't") << ": " @@ -680,14 +680,14 @@ void InstallationValidator::ValidateOldVersionValues( if (ctx.state.old_version() == NULL) { if (!ctx.state.rename_cmd().empty()) { *is_valid = false; - LOG(ERROR) << ctx.dist->GetAppShortCutName() + LOG(ERROR) << ctx.dist->GetDisplayName() << " has a rename command but no opv: " << ctx.state.rename_cmd(); } } else { if (ctx.state.rename_cmd().empty()) { *is_valid = false; - LOG(ERROR) << ctx.dist->GetAppShortCutName() + LOG(ERROR) << ctx.dist->GetDisplayName() << " has an opv but no rename command: " << ctx.state.old_version()->GetString(); } else { @@ -714,14 +714,14 @@ void InstallationValidator::ValidateMultiInstallProduct( true, // system-level BrowserDistribution::CHROME_BROWSER)) { *is_valid = false; - LOG(ERROR) << ctx.dist->GetAppShortCutName() + LOG(ERROR) << ctx.dist->GetDisplayName() << " (" << ctx.state.version().GetString() << ") is " << "installed without Chrome Binaries or a system-level " << "Chrome."; } } else { *is_valid = false; - LOG(ERROR) << ctx.dist->GetAppShortCutName() + LOG(ERROR) << ctx.dist->GetDisplayName() << " (" << ctx.state.version().GetString() << ") is installed " << "without Chrome Binaries."; } @@ -729,7 +729,7 @@ void InstallationValidator::ValidateMultiInstallProduct( // Version must match that of binaries. if (ctx.state.version().CompareTo(binaries->version()) != 0) { *is_valid = false; - LOG(ERROR) << "Version of " << ctx.dist->GetAppShortCutName() + LOG(ERROR) << "Version of " << ctx.dist->GetDisplayName() << " (" << ctx.state.version().GetString() << ") does not " "match that of Chrome Binaries (" << binaries->version().GetString() << ")."; @@ -738,7 +738,7 @@ void InstallationValidator::ValidateMultiInstallProduct( // Channel value must match that of binaries. if (!ctx.state.channel().Equals(binaries->channel())) { *is_valid = false; - LOG(ERROR) << "Channel name of " << ctx.dist->GetAppShortCutName() + LOG(ERROR) << "Channel name of " << ctx.dist->GetDisplayName() << " (" << ctx.state.channel().value() << ") does not match that of Chrome Binaries (" << binaries->channel().value() << ")."; @@ -772,12 +772,12 @@ void InstallationValidator::ValidateUsageStats(const ProductContext& ctx, if (ctx.state.GetUsageStats(&usagestats)) { if (!ctx.rules.UsageStatsAllowed(ctx)) { *is_valid = false; - LOG(ERROR) << ctx.dist->GetAppShortCutName() + LOG(ERROR) << ctx.dist->GetDisplayName() << " has a usagestats value (" << usagestats << "), yet should not."; } else if (usagestats != 0 && usagestats != 1) { *is_valid = false; - LOG(ERROR) << ctx.dist->GetAppShortCutName() + LOG(ERROR) << ctx.dist->GetDisplayName() << " has an unsupported usagestats value (" << usagestats << ")."; } diff --git a/chrome/installer/util/installer_state.cc b/chrome/installer/util/installer_state.cc index 07b75b31c0..bba1e3bca6 100644 --- a/chrome/installer/util/installer_state.cc +++ b/chrome/installer/util/installer_state.cc @@ -123,20 +123,20 @@ void InstallerState::Initialize(const CommandLine& command_line, Product* p = AddProductFromPreferences( BrowserDistribution::CHROME_BROWSER, prefs, machine_state); VLOG(1) << (is_uninstall ? "Uninstall" : "Install") - << " distribution: " << p->distribution()->GetAppShortCutName(); + << " distribution: " << p->distribution()->GetDisplayName(); } if (prefs.install_chrome_frame()) { Product* p = AddProductFromPreferences( BrowserDistribution::CHROME_FRAME, prefs, machine_state); VLOG(1) << (is_uninstall ? "Uninstall" : "Install") - << " distribution: " << p->distribution()->GetAppShortCutName(); + << " distribution: " << p->distribution()->GetDisplayName(); } if (prefs.install_chrome_app_launcher()) { Product* p = AddProductFromPreferences( BrowserDistribution::CHROME_APP_HOST, prefs, machine_state); VLOG(1) << (is_uninstall ? "Uninstall" : "Install") - << " distribution: " << p->distribution()->GetAppShortCutName(); + << " distribution: " << p->distribution()->GetDisplayName(); } if (!is_uninstall && is_multi_install()) { @@ -169,7 +169,7 @@ void InstallerState::Initialize(const CommandLine& command_line, Product* p = AddProductFromPreferences( BrowserDistribution::CHROME_BINARIES, prefs, machine_state); VLOG(1) << "Install distribution: " - << p->distribution()->GetAppShortCutName(); + << p->distribution()->GetDisplayName(); } } @@ -208,7 +208,7 @@ void InstallerState::Initialize(const CommandLine& command_line, Product* p = AddProductFromPreferences( conditional_additions[i].type, prefs, machine_state); VLOG(1) << "Uninstall distribution: " - << p->distribution()->GetAppShortCutName(); + << p->distribution()->GetDisplayName(); } } } @@ -271,7 +271,7 @@ void InstallerState::Initialize(const CommandLine& command_line, Product* p = AddProductFromPreferences( BrowserDistribution::CHROME_BINARIES, prefs, machine_state); VLOG(1) << (is_uninstall ? "Uninstall" : "Install") - << " distribution: " << p->distribution()->GetAppShortCutName(); + << " distribution: " << p->distribution()->GetDisplayName(); } } diff --git a/chrome/installer/util/prebuild/create_string_rc.py b/chrome/installer/util/prebuild/create_string_rc.py index 12e68ce1be..03c17a025d 100755 --- a/chrome/installer/util/prebuild/create_string_rc.py +++ b/chrome/installer/util/prebuild/create_string_rc.py @@ -78,6 +78,8 @@ kStringIds = [ 'IDS_APP_LAUNCHER_PRODUCT_DESCRIPTION', 'IDS_APP_LAUNCHER_SHORTCUT_TOOLTIP', 'IDS_UNINSTALL_APP_LAUNCHER', + 'IDS_APP_LIST_SHORTCUT_NAME', + 'IDS_APP_LIST_SHORTCUT_NAME_CANARY', ] # The ID of the first resource string. diff --git a/chrome/installer/util/product.cc b/chrome/installer/util/product.cc index dc70b1626b..44e7cefc12 100644 --- a/chrome/installer/util/product.cc +++ b/chrome/installer/util/product.cc @@ -168,7 +168,7 @@ void Product::LaunchUserExperiment(const base::FilePath& setup_path, bool system_level) const { if (distribution_->HasUserExperiments()) { VLOG(1) << "LaunchUserExperiment status: " << status << " product: " - << distribution_->GetAppShortCutName() + << distribution_->GetDisplayName() << " system_level: " << system_level; operations_->LaunchUserExperiment( setup_path, options_, status, system_level); diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index 57521e814d..a5122d50ad 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -219,7 +219,9 @@ class RegistryEntry { const string16& suffix, ScopedVector<RegistryEntry>* entries) { string16 icon_path( - ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex())); + ShellUtil::FormatIconLocation( + chrome_exe, + dist->GetIconIndex(BrowserDistribution::SHORTCUT_CHROME))); string16 open_cmd(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); string16 delegate_command(ShellUtil::GetChromeDelegateCommand(chrome_exe)); // For user-level installs: entries for the app id and DelegateExecute verb @@ -317,7 +319,7 @@ class RegistryEntry { // resource for name, description, and company. entries->push_back(new RegistryEntry( chrome_application, ShellUtil::kRegApplicationName, - dist->GetAppShortCutName())); + dist->GetDisplayName())); entries->push_back(new RegistryEntry( chrome_application, ShellUtil::kRegApplicationDescription, dist->GetAppDescription())); @@ -350,7 +352,9 @@ class RegistryEntry { const string16& suffix, ScopedVector<RegistryEntry>* entries) { const string16 icon_path( - ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex())); + ShellUtil::FormatIconLocation( + chrome_exe, + dist->GetIconIndex(BrowserDistribution::SHORTCUT_CHROME))); const string16 quoted_exe_path(L"\"" + chrome_exe + L"\""); // Register for the Start Menu "Internet" link (pre-Win7). @@ -359,7 +363,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_back(new RegistryEntry( - start_menu_entry, dist->GetAppShortCutName())); + start_menu_entry, dist->GetDisplayName())); // Register the "open" verb for launching Chrome via the "Internet" link. entries->push_back(new RegistryEntry( start_menu_entry + ShellUtil::kRegShellOpen, quoted_exe_path)); @@ -395,7 +399,7 @@ class RegistryEntry { capabilities, ShellUtil::kRegApplicationIcon, icon_path)); entries->push_back(new RegistryEntry( capabilities, ShellUtil::kRegApplicationName, - dist->GetAppShortCutName())); + dist->GetDisplayName())); entries->push_back(new RegistryEntry(capabilities + L"\\Startmenu", L"StartMenuInternet", reg_app_name)); @@ -501,7 +505,9 @@ class RegistryEntry { // Protocols associations. string16 chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe); string16 chrome_icon = - ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex()); + ShellUtil::FormatIconLocation( + chrome_exe, + dist->GetIconIndex(BrowserDistribution::SHORTCUT_CHROME)); for (int i = 0; ShellUtil::kBrowserProtocolAssociations[i] != NULL; i++) { GetXPStyleUserProtocolEntries(ShellUtil::kBrowserProtocolAssociations[i], chrome_icon, chrome_open, entries); @@ -906,7 +912,9 @@ bool RegisterChromeAsDefaultProtocolClientXPStyle(BrowserDistribution* dist, ScopedVector<RegistryEntry> entries; const string16 chrome_open(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); const string16 chrome_icon( - ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex())); + ShellUtil::FormatIconLocation( + chrome_exe, + dist->GetIconIndex(BrowserDistribution::SHORTCUT_CHROME))); RegistryEntry::GetXPStyleUserProtocolEntries(protocol, chrome_icon, chrome_open, &entries); // Change the default protocol handler for current user. @@ -919,17 +927,19 @@ bool RegisterChromeAsDefaultProtocolClientXPStyle(BrowserDistribution* dist, } // Returns |properties.shortcut_name| if the property is set, otherwise it -// returns dist->GetAppShortcutName(). In any case, it makes sure the -// return value is suffixed with ".lnk". +// returns dist->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME). In any +// case, it makes sure the return value is suffixed with ".lnk". string16 ExtractShortcutNameFromProperties( BrowserDistribution* dist, const ShellUtil::ShortcutProperties& properties) { DCHECK(dist); string16 shortcut_name; - if (properties.has_shortcut_name()) + if (properties.has_shortcut_name()) { shortcut_name = properties.shortcut_name; - else - shortcut_name = dist->GetAppShortCutName(); + } else { + shortcut_name = + dist->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME); + } if (!EndsWith(shortcut_name, installer::kLnkExt, false)) shortcut_name.append(installer::kLnkExt); @@ -1289,11 +1299,13 @@ bool BatchShortcutAction(const ShortcutFilterCallback& shortcut_filter, return success; } -// Removes folder spsecified by {|location|, |dist|, |level|}. -bool RemoveShortcutFolder(ShellUtil::ShortcutLocation location, - BrowserDistribution* dist, - ShellUtil::ShellChange level) { +// If the folder specified by {|location|, |dist|, |level|} is empty, remove it. +// Otherwise do nothing. Returns true on success, including the vacuous case +// where no deletion occurred because directory is non-empty. +bool RemoveShortcutFolderIfEmpty(ShellUtil::ShortcutLocation location, + BrowserDistribution* dist, + ShellUtil::ShellChange level) { // Explicitly whitelist locations, since accidental calls can be very harmful. if (location != ShellUtil::SHORTCUT_LOCATION_START_MENU && location != ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS) { @@ -1306,7 +1318,8 @@ bool RemoveShortcutFolder(ShellUtil::ShortcutLocation location, LOG(WARNING) << "Cannot find path at location " << location; return false; } - if (!base::DeleteFile(shortcut_folder, true)) { + if (file_util::IsDirectoryEmpty(shortcut_folder) && + !base::DeleteFile(shortcut_folder, true)) { LOG(ERROR) << "Cannot remove folder " << shortcut_folder.value(); return false; } @@ -1434,8 +1447,10 @@ bool ShellUtil::GetShortcutPath(ShellUtil::ShortcutLocation location, return false; } - if (add_folder_for_dist) - *path = path->Append(dist->GetAppShortCutName()); + if (add_folder_for_dist) { + *path = path->Append(dist->GetStartMenuShortcutSubfolder( + BrowserDistribution::SUBFOLDER_CHROME)); + } return true; } @@ -2027,27 +2042,20 @@ bool ShellUtil::RemoveShortcuts(ShellUtil::ShortcutLocation location, if (!ShellUtil::ShortcutLocationIsSupported(location)) return true; // Vacuous success. - switch (location) { - case SHORTCUT_LOCATION_START_MENU: // Falls through. - case SHORTCUT_LOCATION_APP_SHORTCUTS: - return RemoveShortcutFolder(location, dist, level); - - case SHORTCUT_LOCATION_TASKBAR_PINS: - return BatchShortcutAction(FilterTargetEq(target_exe). - AsShortcutFilterCallback(), - base::Bind(&ShortcutOpUnpin), - location, - dist, - level); - - default: - return BatchShortcutAction(FilterTargetEq(target_exe). - AsShortcutFilterCallback(), - base::Bind(&ShortcutOpDelete), - location, - dist, - level); + FilterTargetEq shortcut_filter(target_exe); + // Main operation to apply to each shortcut in the directory specified. + ShortcutOperationCallback shortcut_operation( + location == SHORTCUT_LOCATION_TASKBAR_PINS ? + base::Bind(&ShortcutOpUnpin) : base::Bind(&ShortcutOpDelete)); + bool success = BatchShortcutAction(shortcut_filter.AsShortcutFilterCallback(), + shortcut_operation, location, dist, level); + // Remove chrome-specific shortcut folders if they are now empty. + if (success && + (location == SHORTCUT_LOCATION_START_MENU || + location == SHORTCUT_LOCATION_APP_SHORTCUTS)) { + success = RemoveShortcutFolderIfEmpty(location, dist, level); } + return success; } // static @@ -2060,14 +2068,11 @@ bool ShellUtil::UpdateShortcuts( if (!ShellUtil::ShortcutLocationIsSupported(location)) return true; // Vacuous success. - base::win::ShortcutProperties shortcut_properties( - TranslateShortcutProperties(properties)); - return BatchShortcutAction(FilterTargetEq(target_exe). - AsShortcutFilterCallback(), - base::Bind(&ShortcutOpUpdate, shortcut_properties), - location, - dist, - level); + FilterTargetEq shortcut_filter(target_exe); + ShortcutOperationCallback shortcut_operation( + base::Bind(&ShortcutOpUpdate, TranslateShortcutProperties(properties))); + return BatchShortcutAction(shortcut_filter.AsShortcutFilterCallback(), + shortcut_operation, location, dist, level); } bool ShellUtil::GetUserSpecificRegistrySuffix(string16* suffix) { diff --git a/chrome/installer/util/shell_util.h b/chrome/installer/util/shell_util.h index c1d0c32163..7d42c3c839 100644 --- a/chrome/installer/util/shell_util.h +++ b/chrome/installer/util/shell_util.h @@ -127,7 +127,7 @@ class ShellUtil { } // Forces the shortcut's name to |shortcut_name_in|. - // Default: the current distribution's GetAppShortcutName(). + // Default: the current distribution's GetShortcutName(SHORTCUT_CHROME). // The ".lnk" extension will automatically be added to this name. void set_shortcut_name(const string16& shortcut_name_in) { shortcut_name = shortcut_name_in; diff --git a/chrome/installer/util/shell_util_unittest.cc b/chrome/installer/util/shell_util_unittest.cc index 647ec28ba0..4000813127 100644 --- a/chrome/installer/util/shell_util_unittest.cc +++ b/chrome/installer/util/shell_util_unittest.cc @@ -104,7 +104,9 @@ class ShellUtilShortcutTest : public testing::Test { case ShellUtil::SHORTCUT_LOCATION_START_MENU: expected_path = (properties.level == ShellUtil::CURRENT_USER) ? fake_start_menu_.path() : fake_common_start_menu_.path(); - expected_path = expected_path.Append(dist_->GetAppShortCutName()); + expected_path = expected_path.Append( + dist_->GetStartMenuShortcutSubfolder( + BrowserDistribution::SUBFOLDER_CHROME)); break; default: ADD_FAILURE() << "Unknown location"; @@ -112,10 +114,12 @@ class ShellUtilShortcutTest : public testing::Test { } string16 shortcut_name; - if (properties.has_shortcut_name()) + if (properties.has_shortcut_name()) { shortcut_name = properties.shortcut_name; - else - shortcut_name = dist_->GetAppShortCutName(); + } else { + shortcut_name = + dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME); + } shortcut_name.append(installer::kLnkExt); expected_path = expected_path.Append(shortcut_name); @@ -141,7 +145,7 @@ class ShellUtilShortcutTest : public testing::Test { if (properties.has_icon()) { expected_properties.set_icon(properties.icon, 0); } else { - int icon_index = dist->GetIconIndex(); + int icon_index = dist->GetIconIndex(BrowserDistribution::SHORTCUT_CHROME); expected_properties.set_icon(chrome_exe_, icon_index); } @@ -200,12 +204,16 @@ TEST_F(ShellUtilShortcutTest, GetShortcutPath) { ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist_, ShellUtil::SYSTEM_LEVEL, &path); EXPECT_EQ(fake_default_user_quick_launch_.path(), path); + string16 start_menu_subfolder = + dist_->GetStartMenuShortcutSubfolder( + BrowserDistribution::SUBFOLDER_CHROME); ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist_, ShellUtil::CURRENT_USER, &path); - EXPECT_EQ(fake_start_menu_.path().Append(dist_->GetAppShortCutName()), path); + EXPECT_EQ(fake_start_menu_.path().Append(start_menu_subfolder), + path); ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist_, ShellUtil::SYSTEM_LEVEL, &path); - EXPECT_EQ(fake_common_start_menu_.path().Append(dist_->GetAppShortCutName()), + EXPECT_EQ(fake_common_start_menu_.path().Append(start_menu_subfolder), path); } @@ -308,7 +316,9 @@ TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevel) { } TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevelWithSystemLevelPresent) { - string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); + string16 shortcut_name( + dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + + installer::kLnkExt); test_properties_.level = ShellUtil::SYSTEM_LEVEL; ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( @@ -335,7 +345,9 @@ TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevelStartMenu) { } TEST_F(ShellUtilShortcutTest, CreateAlwaysUserWithSystemLevelPresent) { - string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); + string16 shortcut_name( + dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + + installer::kLnkExt); test_properties_.level = ShellUtil::SYSTEM_LEVEL; ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( @@ -357,7 +369,9 @@ TEST_F(ShellUtilShortcutTest, RemoveChromeShortcut) { ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); - string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); + string16 shortcut_name( + dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + + installer::kLnkExt); base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); ASSERT_TRUE(base::PathExists(shortcut_path)); @@ -374,7 +388,9 @@ TEST_F(ShellUtilShortcutTest, RemoveSystemLevelChromeShortcut) { ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); - string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); + string16 shortcut_name( + dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + + installer::kLnkExt); base::FilePath shortcut_path( fake_common_desktop_.path().Append(shortcut_name)); ASSERT_TRUE(base::PathExists(shortcut_path)); @@ -423,7 +439,9 @@ TEST_F(ShellUtilShortcutTest, UpdateChromeShortcut) { ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); - string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); + string16 shortcut_name( + dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + + installer::kLnkExt); base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); ASSERT_TRUE(base::PathExists(shortcut_path)); @@ -447,7 +465,9 @@ TEST_F(ShellUtilShortcutTest, UpdateSystemLevelChromeShortcut) { ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); - string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); + string16 shortcut_name( + dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + + installer::kLnkExt); base::FilePath shortcut_path( fake_common_desktop_.path().Append(shortcut_name)); ASSERT_TRUE(base::PathExists(shortcut_path)); @@ -525,7 +545,9 @@ TEST_F(ShellUtilShortcutTest, CreateMultipleStartMenuShortcutsAndRemoveFolder) { ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); base::FilePath shortcut_folder( - fake_start_menu_.path().Append(dist_->GetAppShortCutName())); + fake_start_menu_.path().Append( + dist_->GetStartMenuShortcutSubfolder( + BrowserDistribution::SUBFOLDER_CHROME))); base::FileEnumerator file_counter(shortcut_folder, false, base::FileEnumerator::FILES); int count = 0; @@ -552,7 +574,9 @@ TEST_F(ShellUtilShortcutTest, DontRemoveChromeShortcutIfPointsToAnotherChrome) { ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); - string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); + string16 shortcut_name( + dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + + installer::kLnkExt); base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); ASSERT_TRUE(base::PathExists(shortcut_path)); |