diff options
19 files changed, 88 insertions, 53 deletions
diff --git a/chrome/browser/extensions/app_host/app_host.rc b/chrome/browser/extensions/app_host/app_host.rc index ffd5341..ef4d290 100644 --- a/chrome/browser/extensions/app_host/app_host.rc +++ b/chrome/browser/extensions/app_host/app_host.rc @@ -1,5 +1,6 @@ // Microsoft Visual C++ generated resource script. // +#include "app_host_resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// @@ -24,6 +25,15 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US ///////////////////////////////////////////////////////////////////////////// // +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_HOST_MAIN ICON "..\\..\\..\\app\\theme\\app_list.ico" + +///////////////////////////////////////////////////////////////////////////// +// // GOOGLEUPDATEAPPLICATIONCOMMANDS is a "well-known" marker resource defined // by Omaha. Executables must both be signed by Google and contain the marker // in order to expose application commands. diff --git a/chrome/browser/extensions/app_host/app_host_resource.h b/chrome/browser/extensions/app_host/app_host_resource.h new file mode 100644 index 0000000..29d289c --- /dev/null +++ b/chrome/browser/extensions/app_host/app_host_resource.h @@ -0,0 +1,5 @@ +// 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. + +#define IDI_APP_HOST_MAIN 101 diff --git a/chrome/browser/shell_integration.h b/chrome/browser/shell_integration.h index 138c874..c6c1b303 100644 --- a/chrome/browser/shell_integration.h +++ b/chrome/browser/shell_integration.h @@ -146,9 +146,10 @@ class ShellIntegration { // Get the AppUserModelId for the App List, for the profile in |profile_path|. static string16 GetAppListAppModelIdForProfile(const FilePath& profile_path); - // Returns the path to the Chromium icon. This is used to specify the icon - // to use for the taskbar group on Win 7. - static string16 GetChromiumIconPath(); + // Returns the location (path and index) of the Chromium icon, (e.g., + // "C:\path\to\chrome.exe,0"). This is used to specify the icon to use + // for the taskbar group on Win 7. + static string16 GetChromiumIconLocation(); // Migrates existing chrome shortcuts by tagging them with correct app id. // see http://crbug.com/28104 diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc index 3279075..aa45a1c 100644 --- a/chrome/browser/shell_integration_win.cc +++ b/chrome/browser/shell_integration_win.cc @@ -425,20 +425,18 @@ string16 ShellIntegration::GetAppListAppModelIdForProfile( profile_path); } -string16 ShellIntegration::GetChromiumIconPath() { - // Determine the app path. If we can't determine what that is, we have - // bigger fish to fry... - FilePath app_path; - if (!PathService::Get(base::FILE_EXE, &app_path)) { +string16 ShellIntegration::GetChromiumIconLocation() { + // Determine the path to chrome.exe. If we can't determine what that is, + // we have bigger fish to fry... + FilePath chrome_exe; + if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { NOTREACHED(); return string16(); } - string16 icon_path(app_path.value()); - icon_path.push_back(','); - icon_path += base::IntToString16( + return ShellUtil::FormatIconLocation( + chrome_exe.value(), BrowserDistribution::GetDistribution()->GetIconIndex()); - return icon_path; } void ShellIntegration::MigrateChromiumShortcuts() { diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index befe9a2..ffd3bdf 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -441,7 +441,7 @@ Browser::Browser(const CreateParams& params) window()->GetNativeWindow()); if (is_type_panel()) { - ui::win::SetAppIconForWindow(ShellIntegration::GetChromiumIconPath(), + ui::win::SetAppIconForWindow(ShellIntegration::GetChromiumIconLocation(), window()->GetNativeWindow()); } #endif diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi index 8c6d38e..84b10dc 100644 --- a/chrome/chrome_browser_extensions.gypi +++ b/chrome/chrome_browser_extensions.gypi @@ -883,6 +883,7 @@ 'sources': [ 'browser/extensions/app_host/app_host.rc', 'browser/extensions/app_host/app_host_main.cc', + 'browser/extensions/app_host/app_host_resource.h', 'browser/extensions/app_host/binaries_installer.cc', 'browser/extensions/app_host/binaries_installer.h', 'browser/extensions/app_host/update.cc', diff --git a/chrome/installer/setup/install_worker.cc b/chrome/installer/setup/install_worker.cc index 2ef5660..d89a71d 100644 --- a/chrome/installer/setup/install_worker.cc +++ b/chrome/installer/setup/install_worker.cc @@ -621,12 +621,10 @@ void AddUninstallShortcutWorkItems(const InstallerState& installer_state, install_path.value(), true); - // TODO(huangs): Generalize this, so app_host.exe can get its own icon, - // and not rely on chrome.exe's. - // DisplayIcon, NoModify and NoRepair - string16 chrome_icon = ShellUtil::GetChromeIcon( - product.distribution(), - install_path.Append(installer::kChromeExe).value()); + BrowserDistribution* dist = product.distribution(); + string16 chrome_icon = ShellUtil::FormatIconLocation( + install_path.Append(dist->GetIconFilename()).value(), + dist->GetIconIndex()); install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, L"DisplayIcon", chrome_icon, true); install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, diff --git a/chrome/installer/util/browser_distribution.cc b/chrome/installer/util/browser_distribution.cc index 26f5a2f..142509e 100644 --- a/chrome/installer/util/browser_distribution.cc +++ b/chrome/installer/util/browser_distribution.cc @@ -225,7 +225,13 @@ 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; } diff --git a/chrome/installer/util/browser_distribution.h b/chrome/installer/util/browser_distribution.h index 7ec1eac..f6b568d 100644 --- a/chrome/installer/util/browser_distribution.h +++ b/chrome/installer/util/browser_distribution.h @@ -121,6 +121,11 @@ 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); diff --git a/chrome/installer/util/chrome_app_host_distribution.cc b/chrome/installer/util/chrome_app_host_distribution.cc index 69eba10..9e9325e 100644 --- a/chrome/installer/util/chrome_app_host_distribution.cc +++ b/chrome/installer/util/chrome_app_host_distribution.cc @@ -22,11 +22,6 @@ namespace { -#if defined(GOOGLE_CHROME_BUILD) -const int kAppListIconIndex = 5; -#else -const int kAppListIconIndex = 1; -#endif const wchar_t kChromeAppHostGuid[] = L"{FDA71E6F-AC4C-4a00-8B70-9958A68906BF}"; } // namespace @@ -139,8 +134,8 @@ bool ChromeAppHostDistribution::CanCreateDesktopShortcuts() { return true; } -int ChromeAppHostDistribution::GetIconIndex() { - return kAppListIconIndex; +string16 ChromeAppHostDistribution::GetIconFilename() { + return installer::kChromeAppHostExe; } bool ChromeAppHostDistribution::GetCommandExecuteImplClsid( diff --git a/chrome/installer/util/chrome_app_host_distribution.h b/chrome/installer/util/chrome_app_host_distribution.h index 9da219d..1bf744a 100644 --- a/chrome/installer/util/chrome_app_host_distribution.h +++ b/chrome/installer/util/chrome_app_host_distribution.h @@ -53,7 +53,7 @@ class ChromeAppHostDistribution : public BrowserDistribution { virtual bool CanCreateDesktopShortcuts() OVERRIDE; - virtual int GetIconIndex() 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 56ab023..25c0d4b 100644 --- a/chrome/installer/util/chrome_app_host_operations.cc +++ b/chrome/installer/util/chrome_app_host_operations.cc @@ -127,15 +127,8 @@ void ChromeAppHostOperations::AddDefaultShortcutProperties( properties->set_arguments(app_host_args.GetCommandLineString()); } - if (!properties->has_icon()) { - // Currently the App Launcher icon is inside chrome.exe, which we assume - // to be located in the same directory as app_host.exe. - // TODO(huangs): Cause the icon to also be embedded in app_host.exe, - // and then point at this (as chrome.exe is _not_ in the same folder - // for system-level chrome installs, or may even be uninstalled). - FilePath chrome_exe(target_exe.DirName().Append(kChromeExe)); - properties->set_icon(chrome_exe, dist->GetIconIndex()); - } + if (!properties->has_icon()) + properties->set_icon(target_exe, dist->GetIconIndex()); if (!properties->has_app_id()) { std::vector<string16> components; diff --git a/chrome/installer/util/chrome_frame_distribution.cc b/chrome/installer/util/chrome_frame_distribution.cc index 73d4d143..712ef3a 100644 --- a/chrome/installer/util/chrome_frame_distribution.cc +++ b/chrome/installer/util/chrome_frame_distribution.cc @@ -112,6 +112,14 @@ string16 ChromeFrameDistribution::GetVersionKey() { return key; } +string16 ChromeFrameDistribution::GetIconFilename() { + return installer::kChromeExe; +} + +int ChromeFrameDistribution::GetIconIndex() { + return 0; +} + bool ChromeFrameDistribution::CanSetAsDefault() { return false; } diff --git a/chrome/installer/util/chrome_frame_distribution.h b/chrome/installer/util/chrome_frame_distribution.h index e7d0be8..2b76265c 100644 --- a/chrome/installer/util/chrome_frame_distribution.h +++ b/chrome/installer/util/chrome_frame_distribution.h @@ -47,6 +47,10 @@ class ChromeFrameDistribution : public BrowserDistribution { virtual string16 GetVersionKey() OVERRIDE; + virtual string16 GetIconFilename() OVERRIDE; + + virtual int GetIconIndex() OVERRIDE; + virtual bool CanSetAsDefault() OVERRIDE; virtual bool CanCreateDesktopShortcuts() OVERRIDE; diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc index 4232530..106c588 100644 --- a/chrome/installer/util/google_chrome_distribution.cc +++ b/chrome/installer/util/google_chrome_distribution.cc @@ -538,6 +538,10 @@ string16 GoogleChromeDistribution::GetVersionKey() { return key; } +string16 GoogleChromeDistribution::GetIconFilename() { + return installer::kChromeExe; +} + bool GoogleChromeDistribution::GetCommandExecuteImplClsid( string16* handler_class_uuid) { if (handler_class_uuid) diff --git a/chrome/installer/util/google_chrome_distribution.h b/chrome/installer/util/google_chrome_distribution.h index c7a2858..9b57ae8 100644 --- a/chrome/installer/util/google_chrome_distribution.h +++ b/chrome/installer/util/google_chrome_distribution.h @@ -74,6 +74,8 @@ 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 933c631..74d1c35 100644 --- a/chrome/installer/util/google_chrome_distribution_dummy.cc +++ b/chrome/installer/util/google_chrome_distribution_dummy.cc @@ -116,13 +116,17 @@ string16 GoogleChromeDistribution::GetVersionKey() { return string16(); } +string16 GoogleChromeDistribution::GetIconFilename() { + NOTREACHED(); + return string16(); +} + bool GoogleChromeDistribution::GetCommandExecuteImplClsid( string16* handler_class_uuid) { NOTREACHED(); return false; } - void GoogleChromeDistribution::UpdateInstallStatus(bool system_install, installer::ArchiveType archive_type, installer::InstallStatus install_status) { diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index 6cfaf5f..b7240e1 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -215,7 +215,8 @@ class RegistryEntry { const string16& chrome_exe, const string16& suffix, ScopedVector<RegistryEntry>* entries) { - string16 icon_path(ShellUtil::GetChromeIcon(dist, chrome_exe)); + string16 icon_path( + ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex())); 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 @@ -345,7 +346,8 @@ class RegistryEntry { const string16& chrome_exe, const string16& suffix, ScopedVector<RegistryEntry>* entries) { - const string16 icon_path(ShellUtil::GetChromeIcon(dist, chrome_exe)); + const string16 icon_path( + ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex())); const string16 quoted_exe_path(L"\"" + chrome_exe + L"\""); // Register for the Start Menu "Internet" link (pre-Win7). @@ -495,7 +497,8 @@ class RegistryEntry { // Protocols associations. string16 chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe); - string16 chrome_icon = ShellUtil::GetChromeIcon(dist, chrome_exe); + string16 chrome_icon = + ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex()); for (int i = 0; ShellUtil::kBrowserProtocolAssociations[i] != NULL; i++) { GetXPStyleUserProtocolEntries(ShellUtil::kBrowserProtocolAssociations[i], chrome_icon, chrome_open, entries); @@ -895,7 +898,8 @@ bool RegisterChromeAsDefaultProtocolClientXPStyle(BrowserDistribution* dist, const string16& protocol) { ScopedVector<RegistryEntry> entries; const string16 chrome_open(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); - const string16 chrome_icon(ShellUtil::GetChromeIcon(dist, chrome_exe)); + const string16 chrome_icon( + ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex())); RegistryEntry::GetXPStyleUserProtocolEntries(protocol, chrome_icon, chrome_open, &entries); // Change the default protocol handler for current user. @@ -1320,12 +1324,12 @@ bool ShellUtil::CreateOrUpdateShortcut( return ret; } -string16 ShellUtil::GetChromeIcon(BrowserDistribution* dist, - const string16& chrome_exe) { - string16 chrome_icon(chrome_exe); - chrome_icon.append(L","); - chrome_icon.append(base::IntToString16(dist->GetIconIndex())); - return chrome_icon; +string16 ShellUtil::FormatIconLocation(const string16& icon_path, + int icon_index) { + string16 icon_string(icon_path); + icon_string.append(L","); + icon_string.append(base::IntToString16(icon_index)); + return icon_string; } string16 ShellUtil::GetChromeShellOpenCmd(const string16& chrome_exe) { diff --git a/chrome/installer/util/shell_util.h b/chrome/installer/util/shell_util.h index b521527..2f745f5 100644 --- a/chrome/installer/util/shell_util.h +++ b/chrome/installer/util/shell_util.h @@ -312,12 +312,9 @@ class ShellUtil { const ShellUtil::ShortcutProperties& properties, ShellUtil::ShortcutOperation operation); - // This method appends the Chrome icon index inside chrome.exe to the - // chrome.exe path passed in as input, to generate the full path for - // Chrome icon that can be used as value for Windows registry keys. - // |chrome_exe| full path to chrome.exe. - static string16 GetChromeIcon(BrowserDistribution* dist, - const string16& chrome_exe); + // Returns the string "|icon_path|,|icon_index|" (see, for example, + // http://msdn.microsoft.com/library/windows/desktop/dd391573.aspx). + static string16 FormatIconLocation(const string16& icon_path, int icon_index); // This method returns the command to open URLs/files using chrome. Typically // this command is written to the registry under shell\open\command key. |