Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: chrome/installer/util/shell_util.cc

Issue 11359133: Add default icon to app_host.exe, and use it in shortcuts during installation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: More renames and comments. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // This file defines functions that integrate Chrome in Windows shell. These 5 // This file defines functions that integrate Chrome in Windows shell. These
6 // functions can be used by Chrome as well as Chrome installer. All of the 6 // functions can be used by Chrome as well as Chrome installer. All of the
7 // work is done by the local functions defined in anonymous namespace in 7 // work is done by the local functions defined in anonymous namespace in
8 // this class. 8 // this class.
9 9
10 #include "chrome/installer/util/shell_util.h" 10 #include "chrome/installer/util/shell_util.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 return GetBrowserClientKey(dist, suffix).append(L"\\Capabilities"); 208 return GetBrowserClientKey(dist, suffix).append(L"\\Capabilities");
209 } 209 }
210 210
211 // This method returns a list of all the registry entries that 211 // This method returns a list of all the registry entries that
212 // are needed to register this installation's ProgId and AppId. 212 // are needed to register this installation's ProgId and AppId.
213 // These entries need to be registered in HKLM prior to Win8. 213 // These entries need to be registered in HKLM prior to Win8.
214 static void GetProgIdEntries(BrowserDistribution* dist, 214 static void GetProgIdEntries(BrowserDistribution* dist,
215 const string16& chrome_exe, 215 const string16& chrome_exe,
216 const string16& suffix, 216 const string16& suffix,
217 ScopedVector<RegistryEntry>* entries) { 217 ScopedVector<RegistryEntry>* entries) {
218 string16 icon_path(ShellUtil::GetChromeIcon(dist, chrome_exe)); 218 string16 icon_path(ShellUtil::GetIconString(chrome_exe,
219 dist->GetIconIndex()));
219 string16 open_cmd(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); 220 string16 open_cmd(ShellUtil::GetChromeShellOpenCmd(chrome_exe));
220 string16 delegate_command(ShellUtil::GetChromeDelegateCommand(chrome_exe)); 221 string16 delegate_command(ShellUtil::GetChromeDelegateCommand(chrome_exe));
221 // For user-level installs: entries for the app id and DelegateExecute verb 222 // For user-level installs: entries for the app id and DelegateExecute verb
222 // handler will be in HKCU; thus we do not need a suffix on those entries. 223 // handler will be in HKCU; thus we do not need a suffix on those entries.
223 string16 app_id( 224 string16 app_id(
224 ShellUtil::GetBrowserModelId( 225 ShellUtil::GetBrowserModelId(
225 dist, InstallUtil::IsPerUserInstall(chrome_exe.c_str()))); 226 dist, InstallUtil::IsPerUserInstall(chrome_exe.c_str())));
226 string16 delegate_guid; 227 string16 delegate_guid;
227 bool set_delegate_execute = 228 bool set_delegate_execute =
228 IsChromeMetroSupported() && 229 IsChromeMetroSupported() &&
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 // This method returns a list of the registry entries required to register 339 // This method returns a list of the registry entries required to register
339 // this installation in "RegisteredApplications" on Windows (to appear in 340 // this installation in "RegisteredApplications" on Windows (to appear in
340 // Default Programs, StartMenuInternet, etc.). 341 // Default Programs, StartMenuInternet, etc.).
341 // These entries need to be registered in HKLM prior to Win8. 342 // These entries need to be registered in HKLM prior to Win8.
342 // If |suffix| is not empty, these entries are guaranteed to be unique on this 343 // If |suffix| is not empty, these entries are guaranteed to be unique on this
343 // machine. 344 // machine.
344 static void GetShellIntegrationEntries(BrowserDistribution* dist, 345 static void GetShellIntegrationEntries(BrowserDistribution* dist,
345 const string16& chrome_exe, 346 const string16& chrome_exe,
346 const string16& suffix, 347 const string16& suffix,
347 ScopedVector<RegistryEntry>* entries) { 348 ScopedVector<RegistryEntry>* entries) {
348 const string16 icon_path(ShellUtil::GetChromeIcon(dist, chrome_exe)); 349 const string16 icon_path(
350 ShellUtil::GetIconString(chrome_exe, dist->GetIconIndex()));
349 const string16 quoted_exe_path(L"\"" + chrome_exe + L"\""); 351 const string16 quoted_exe_path(L"\"" + chrome_exe + L"\"");
350 352
351 // Register for the Start Menu "Internet" link (pre-Win7). 353 // Register for the Start Menu "Internet" link (pre-Win7).
352 const string16 start_menu_entry(GetBrowserClientKey(dist, suffix)); 354 const string16 start_menu_entry(GetBrowserClientKey(dist, suffix));
353 // Register Chrome's display name. 355 // Register Chrome's display name.
354 // TODO(grt): http://crbug.com/75152 Also set LocalizedString; see 356 // TODO(grt): http://crbug.com/75152 Also set LocalizedString; see
355 // http://msdn.microsoft.com/en-us/library/windows/desktop/cc144109(v=VS.85) .aspx#registering_the_display_name 357 // http://msdn.microsoft.com/en-us/library/windows/desktop/cc144109(v=VS.85) .aspx#registering_the_display_name
356 entries->push_back(new RegistryEntry( 358 entries->push_back(new RegistryEntry(
357 start_menu_entry, dist->GetAppShortCutName())); 359 start_menu_entry, dist->GetAppShortCutName()));
358 // Register the "open" verb for launching Chrome via the "Internet" link. 360 // Register the "open" verb for launching Chrome via the "Internet" link.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 string16 html_prog_id(GetBrowserProgId(suffix)); 490 string16 html_prog_id(GetBrowserProgId(suffix));
489 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { 491 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) {
490 string16 ext_key(ShellUtil::kRegClasses); 492 string16 ext_key(ShellUtil::kRegClasses);
491 ext_key.push_back(FilePath::kSeparators[0]); 493 ext_key.push_back(FilePath::kSeparators[0]);
492 ext_key.append(ShellUtil::kFileAssociations[i]); 494 ext_key.append(ShellUtil::kFileAssociations[i]);
493 entries->push_back(new RegistryEntry(ext_key, html_prog_id)); 495 entries->push_back(new RegistryEntry(ext_key, html_prog_id));
494 } 496 }
495 497
496 // Protocols associations. 498 // Protocols associations.
497 string16 chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe); 499 string16 chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe);
498 string16 chrome_icon = ShellUtil::GetChromeIcon(dist, chrome_exe); 500 string16 chrome_icon = ShellUtil::GetIconString(chrome_exe,
501 dist->GetIconIndex());
499 for (int i = 0; ShellUtil::kBrowserProtocolAssociations[i] != NULL; i++) { 502 for (int i = 0; ShellUtil::kBrowserProtocolAssociations[i] != NULL; i++) {
500 GetXPStyleUserProtocolEntries(ShellUtil::kBrowserProtocolAssociations[i], 503 GetXPStyleUserProtocolEntries(ShellUtil::kBrowserProtocolAssociations[i],
501 chrome_icon, chrome_open, entries); 504 chrome_icon, chrome_open, entries);
502 } 505 }
503 506
504 // start->Internet shortcut. 507 // start->Internet shortcut.
505 string16 start_menu(ShellUtil::kRegStartMenuInternet); 508 string16 start_menu(ShellUtil::kRegStartMenuInternet);
506 string16 app_name = dist->GetBaseAppName() + suffix; 509 string16 app_name = dist->GetBaseAppName() + suffix;
507 entries->push_back(new RegistryEntry(start_menu, app_name)); 510 entries->push_back(new RegistryEntry(start_menu, app_name));
508 } 511 }
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 891
889 // Associates Chrome with |protocol| in the registry. This should not be 892 // Associates Chrome with |protocol| in the registry. This should not be
890 // required on Vista+ but since some applications still read these registry 893 // required on Vista+ but since some applications still read these registry
891 // keys directly, we have to do this on Vista+ as well. 894 // keys directly, we have to do this on Vista+ as well.
892 // See http://msdn.microsoft.com/library/aa767914.aspx for more details. 895 // See http://msdn.microsoft.com/library/aa767914.aspx for more details.
893 bool RegisterChromeAsDefaultProtocolClientXPStyle(BrowserDistribution* dist, 896 bool RegisterChromeAsDefaultProtocolClientXPStyle(BrowserDistribution* dist,
894 const string16& chrome_exe, 897 const string16& chrome_exe,
895 const string16& protocol) { 898 const string16& protocol) {
896 ScopedVector<RegistryEntry> entries; 899 ScopedVector<RegistryEntry> entries;
897 const string16 chrome_open(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); 900 const string16 chrome_open(ShellUtil::GetChromeShellOpenCmd(chrome_exe));
898 const string16 chrome_icon(ShellUtil::GetChromeIcon(dist, chrome_exe)); 901 const string16 chrome_icon(
902 ShellUtil::GetIconString(chrome_exe, dist->GetIconIndex()));
899 RegistryEntry::GetXPStyleUserProtocolEntries(protocol, chrome_icon, 903 RegistryEntry::GetXPStyleUserProtocolEntries(protocol, chrome_icon,
900 chrome_open, &entries); 904 chrome_open, &entries);
901 // Change the default protocol handler for current user. 905 // Change the default protocol handler for current user.
902 if (!AddRegistryEntries(HKEY_CURRENT_USER, entries)) { 906 if (!AddRegistryEntries(HKEY_CURRENT_USER, entries)) {
903 LOG(ERROR) << "Could not make Chrome default protocol client (XP)."; 907 LOG(ERROR) << "Could not make Chrome default protocol client (XP).";
904 return false; 908 return false;
905 } 909 }
906 910
907 return true; 911 return true;
908 } 912 }
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 ret = base::win::TaskbarPinShortcutLink(chosen_path->value().c_str()); 1317 ret = base::win::TaskbarPinShortcutLink(chosen_path->value().c_str());
1314 if (!ret) { 1318 if (!ret) {
1315 LOG(ERROR) << "The shorcut at " << chosen_path->value() 1319 LOG(ERROR) << "The shorcut at " << chosen_path->value()
1316 << " was created, but the taskbar pin failed."; 1320 << " was created, but the taskbar pin failed.";
1317 } 1321 }
1318 } 1322 }
1319 1323
1320 return ret; 1324 return ret;
1321 } 1325 }
1322 1326
1323 string16 ShellUtil::GetChromeIcon(BrowserDistribution* dist, 1327 string16 ShellUtil::GetIconString(const string16& icon_path,
1324 const string16& chrome_exe) { 1328 int icon_index) {
1325 string16 chrome_icon(chrome_exe); 1329 string16 resource_string(icon_path);
gab 2012/11/14 21:34:34 s/resource_string/icon_string
huangs 2012/11/14 21:57:01 Done.
1326 chrome_icon.append(L","); 1330 resource_string.append(L",");
1327 chrome_icon.append(base::IntToString16(dist->GetIconIndex())); 1331 resource_string.append(base::IntToString16(icon_index));
1328 return chrome_icon; 1332 return resource_string;
1329 } 1333 }
1330 1334
1331 string16 ShellUtil::GetChromeShellOpenCmd(const string16& chrome_exe) { 1335 string16 ShellUtil::GetChromeShellOpenCmd(const string16& chrome_exe) {
1332 return L"\"" + chrome_exe + L"\" -- \"%1\""; 1336 return L"\"" + chrome_exe + L"\" -- \"%1\"";
1333 } 1337 }
1334 1338
1335 string16 ShellUtil::GetChromeDelegateCommand(const string16& chrome_exe) { 1339 string16 ShellUtil::GetChromeDelegateCommand(const string16& chrome_exe) {
1336 return L"\"" + chrome_exe + L"\" -- %*"; 1340 return L"\"" + chrome_exe + L"\" -- %*";
1337 } 1341 }
1338 1342
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 // are any left...). 1958 // are any left...).
1955 if (free_bits >= 8 && next_byte_index < size) { 1959 if (free_bits >= 8 && next_byte_index < size) {
1956 free_bits -= 8; 1960 free_bits -= 8;
1957 bit_stream += bytes[next_byte_index++] << free_bits; 1961 bit_stream += bytes[next_byte_index++] << free_bits;
1958 } 1962 }
1959 } 1963 }
1960 1964
1961 DCHECK_EQ(ret.length(), encoded_length); 1965 DCHECK_EQ(ret.length(), encoded_length);
1962 return ret; 1966 return ret;
1963 } 1967 }
OLDNEW
« chrome/installer/util/browser_distribution.cc ('K') | « chrome/installer/util/shell_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698