OLD | NEW |
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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 } | 211 } |
212 | 212 |
213 // This method returns a list of all the registry entries that | 213 // This method returns a list of all the registry entries that |
214 // are needed to register this installation's ProgId and AppId. | 214 // are needed to register this installation's ProgId and AppId. |
215 // These entries need to be registered in HKLM prior to Win8. | 215 // These entries need to be registered in HKLM prior to Win8. |
216 static void GetProgIdEntries(BrowserDistribution* dist, | 216 static void GetProgIdEntries(BrowserDistribution* dist, |
217 const string16& chrome_exe, | 217 const string16& chrome_exe, |
218 const string16& suffix, | 218 const string16& suffix, |
219 ScopedVector<RegistryEntry>* entries) { | 219 ScopedVector<RegistryEntry>* entries) { |
220 string16 icon_path( | 220 string16 icon_path( |
221 ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex())); | 221 ShellUtil::FormatIconLocation( |
| 222 chrome_exe, |
| 223 dist->GetShortcutInfo( |
| 224 BrowserDistribution::SHORTCUT_CHROME).icon_index)); |
222 string16 open_cmd(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); | 225 string16 open_cmd(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); |
223 string16 delegate_command(ShellUtil::GetChromeDelegateCommand(chrome_exe)); | 226 string16 delegate_command(ShellUtil::GetChromeDelegateCommand(chrome_exe)); |
224 // For user-level installs: entries for the app id and DelegateExecute verb | 227 // For user-level installs: entries for the app id and DelegateExecute verb |
225 // handler will be in HKCU; thus we do not need a suffix on those entries. | 228 // handler will be in HKCU; thus we do not need a suffix on those entries. |
226 string16 app_id( | 229 string16 app_id( |
227 ShellUtil::GetBrowserModelId( | 230 ShellUtil::GetBrowserModelId( |
228 dist, InstallUtil::IsPerUserInstall(chrome_exe.c_str()))); | 231 dist, InstallUtil::IsPerUserInstall(chrome_exe.c_str()))); |
229 string16 delegate_guid; | 232 string16 delegate_guid; |
230 bool set_delegate_execute = | 233 bool set_delegate_execute = |
231 IsChromeMetroSupported() && | 234 IsChromeMetroSupported() && |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 string16 chrome_application(chrome_html_prog_id + | 312 string16 chrome_application(chrome_html_prog_id + |
310 ShellUtil::kRegApplication); | 313 ShellUtil::kRegApplication); |
311 entries->push_back(new RegistryEntry( | 314 entries->push_back(new RegistryEntry( |
312 chrome_application, ShellUtil::kRegAppUserModelId, app_id)); | 315 chrome_application, ShellUtil::kRegAppUserModelId, app_id)); |
313 entries->push_back(new RegistryEntry( | 316 entries->push_back(new RegistryEntry( |
314 chrome_application, ShellUtil::kRegApplicationIcon, icon_path)); | 317 chrome_application, ShellUtil::kRegApplicationIcon, icon_path)); |
315 // TODO(grt): http://crbug.com/75152 Write a reference to a localized | 318 // TODO(grt): http://crbug.com/75152 Write a reference to a localized |
316 // resource for name, description, and company. | 319 // resource for name, description, and company. |
317 entries->push_back(new RegistryEntry( | 320 entries->push_back(new RegistryEntry( |
318 chrome_application, ShellUtil::kRegApplicationName, | 321 chrome_application, ShellUtil::kRegApplicationName, |
319 dist->GetAppShortCutName())); | 322 dist->GetDisplayName())); |
320 entries->push_back(new RegistryEntry( | 323 entries->push_back(new RegistryEntry( |
321 chrome_application, ShellUtil::kRegApplicationDescription, | 324 chrome_application, ShellUtil::kRegApplicationDescription, |
322 dist->GetAppDescription())); | 325 dist->GetAppDescription())); |
323 entries->push_back(new RegistryEntry( | 326 entries->push_back(new RegistryEntry( |
324 chrome_application, ShellUtil::kRegApplicationCompany, | 327 chrome_application, ShellUtil::kRegApplicationCompany, |
325 dist->GetPublisherName())); | 328 dist->GetPublisherName())); |
326 } | 329 } |
327 } | 330 } |
328 | 331 |
329 // This method returns a list of the registry entries needed to declare a | 332 // This method returns a list of the registry entries needed to declare a |
(...skipping 12 matching lines...) Expand all Loading... |
342 // this installation in "RegisteredApplications" on Windows (to appear in | 345 // this installation in "RegisteredApplications" on Windows (to appear in |
343 // Default Programs, StartMenuInternet, etc.). | 346 // Default Programs, StartMenuInternet, etc.). |
344 // These entries need to be registered in HKLM prior to Win8. | 347 // These entries need to be registered in HKLM prior to Win8. |
345 // If |suffix| is not empty, these entries are guaranteed to be unique on this | 348 // If |suffix| is not empty, these entries are guaranteed to be unique on this |
346 // machine. | 349 // machine. |
347 static void GetShellIntegrationEntries(BrowserDistribution* dist, | 350 static void GetShellIntegrationEntries(BrowserDistribution* dist, |
348 const string16& chrome_exe, | 351 const string16& chrome_exe, |
349 const string16& suffix, | 352 const string16& suffix, |
350 ScopedVector<RegistryEntry>* entries) { | 353 ScopedVector<RegistryEntry>* entries) { |
351 const string16 icon_path( | 354 const string16 icon_path( |
352 ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex())); | 355 ShellUtil::FormatIconLocation(chrome_exe, dist-> |
| 356 GetShortcutInfo(BrowserDistribution::SHORTCUT_CHROME).icon_index)); |
353 const string16 quoted_exe_path(L"\"" + chrome_exe + L"\""); | 357 const string16 quoted_exe_path(L"\"" + chrome_exe + L"\""); |
354 | 358 |
355 // Register for the Start Menu "Internet" link (pre-Win7). | 359 // Register for the Start Menu "Internet" link (pre-Win7). |
356 const string16 start_menu_entry(GetBrowserClientKey(dist, suffix)); | 360 const string16 start_menu_entry(GetBrowserClientKey(dist, suffix)); |
357 // Register Chrome's display name. | 361 // Register Chrome's display name. |
358 // TODO(grt): http://crbug.com/75152 Also set LocalizedString; see | 362 // TODO(grt): http://crbug.com/75152 Also set LocalizedString; see |
359 // http://msdn.microsoft.com/en-us/library/windows/desktop/cc144109(v=VS.85)
.aspx#registering_the_display_name | 363 // http://msdn.microsoft.com/en-us/library/windows/desktop/cc144109(v=VS.85)
.aspx#registering_the_display_name |
360 entries->push_back(new RegistryEntry( | 364 entries->push_back(new RegistryEntry( |
361 start_menu_entry, dist->GetAppShortCutName())); | 365 start_menu_entry, |
| 366 dist->GetDisplayName())); |
362 // Register the "open" verb for launching Chrome via the "Internet" link. | 367 // Register the "open" verb for launching Chrome via the "Internet" link. |
363 entries->push_back(new RegistryEntry( | 368 entries->push_back(new RegistryEntry( |
364 start_menu_entry + ShellUtil::kRegShellOpen, quoted_exe_path)); | 369 start_menu_entry + ShellUtil::kRegShellOpen, quoted_exe_path)); |
365 // Register Chrome's icon for the Start Menu "Internet" link. | 370 // Register Chrome's icon for the Start Menu "Internet" link. |
366 entries->push_back(new RegistryEntry( | 371 entries->push_back(new RegistryEntry( |
367 start_menu_entry + ShellUtil::kRegDefaultIcon, icon_path)); | 372 start_menu_entry + ShellUtil::kRegDefaultIcon, icon_path)); |
368 | 373 |
369 // Register installation information. | 374 // Register installation information. |
370 string16 install_info(start_menu_entry + L"\\InstallInfo"); | 375 string16 install_info(start_menu_entry + L"\\InstallInfo"); |
371 // Note: not using CommandLine since it has ambiguous rules for quoting | 376 // Note: not using CommandLine since it has ambiguous rules for quoting |
(...skipping 15 matching lines...) Expand all Loading... |
387 // Write out Chrome's Default Programs info. | 392 // Write out Chrome's Default Programs info. |
388 // TODO(grt): http://crbug.com/75152 Write a reference to a localized | 393 // TODO(grt): http://crbug.com/75152 Write a reference to a localized |
389 // resource rather than this. | 394 // resource rather than this. |
390 entries->push_back(new RegistryEntry( | 395 entries->push_back(new RegistryEntry( |
391 capabilities, ShellUtil::kRegApplicationDescription, | 396 capabilities, ShellUtil::kRegApplicationDescription, |
392 dist->GetLongAppDescription())); | 397 dist->GetLongAppDescription())); |
393 entries->push_back(new RegistryEntry( | 398 entries->push_back(new RegistryEntry( |
394 capabilities, ShellUtil::kRegApplicationIcon, icon_path)); | 399 capabilities, ShellUtil::kRegApplicationIcon, icon_path)); |
395 entries->push_back(new RegistryEntry( | 400 entries->push_back(new RegistryEntry( |
396 capabilities, ShellUtil::kRegApplicationName, | 401 capabilities, ShellUtil::kRegApplicationName, |
397 dist->GetAppShortCutName())); | 402 dist->GetDisplayName())); |
398 | 403 |
399 entries->push_back(new RegistryEntry(capabilities + L"\\Startmenu", | 404 entries->push_back(new RegistryEntry(capabilities + L"\\Startmenu", |
400 L"StartMenuInternet", reg_app_name)); | 405 L"StartMenuInternet", reg_app_name)); |
401 | 406 |
402 const string16 html_prog_id(GetBrowserProgId(suffix)); | 407 const string16 html_prog_id(GetBrowserProgId(suffix)); |
403 for (int i = 0; ShellUtil::kPotentialFileAssociations[i] != NULL; i++) { | 408 for (int i = 0; ShellUtil::kPotentialFileAssociations[i] != NULL; i++) { |
404 entries->push_back(new RegistryEntry( | 409 entries->push_back(new RegistryEntry( |
405 capabilities + L"\\FileAssociations", | 410 capabilities + L"\\FileAssociations", |
406 ShellUtil::kPotentialFileAssociations[i], html_prog_id)); | 411 ShellUtil::kPotentialFileAssociations[i], html_prog_id)); |
407 } | 412 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 for (int i = 0; ShellUtil::kDefaultFileAssociations[i] != NULL; i++) { | 498 for (int i = 0; ShellUtil::kDefaultFileAssociations[i] != NULL; i++) { |
494 string16 ext_key(ShellUtil::kRegClasses); | 499 string16 ext_key(ShellUtil::kRegClasses); |
495 ext_key.push_back(base::FilePath::kSeparators[0]); | 500 ext_key.push_back(base::FilePath::kSeparators[0]); |
496 ext_key.append(ShellUtil::kDefaultFileAssociations[i]); | 501 ext_key.append(ShellUtil::kDefaultFileAssociations[i]); |
497 entries->push_back(new RegistryEntry(ext_key, html_prog_id)); | 502 entries->push_back(new RegistryEntry(ext_key, html_prog_id)); |
498 } | 503 } |
499 | 504 |
500 // Protocols associations. | 505 // Protocols associations. |
501 string16 chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe); | 506 string16 chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe); |
502 string16 chrome_icon = | 507 string16 chrome_icon = |
503 ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex()); | 508 ShellUtil::FormatIconLocation(chrome_exe, dist-> |
| 509 GetShortcutInfo(BrowserDistribution::SHORTCUT_CHROME).icon_index); |
504 for (int i = 0; ShellUtil::kBrowserProtocolAssociations[i] != NULL; i++) { | 510 for (int i = 0; ShellUtil::kBrowserProtocolAssociations[i] != NULL; i++) { |
505 GetXPStyleUserProtocolEntries(ShellUtil::kBrowserProtocolAssociations[i], | 511 GetXPStyleUserProtocolEntries(ShellUtil::kBrowserProtocolAssociations[i], |
506 chrome_icon, chrome_open, entries); | 512 chrome_icon, chrome_open, entries); |
507 } | 513 } |
508 | 514 |
509 // start->Internet shortcut. | 515 // start->Internet shortcut. |
510 string16 start_menu(ShellUtil::kRegStartMenuInternet); | 516 string16 start_menu(ShellUtil::kRegStartMenuInternet); |
511 string16 app_name = dist->GetBaseAppName() + suffix; | 517 string16 app_name = dist->GetBaseAppName() + suffix; |
512 entries->push_back(new RegistryEntry(start_menu, app_name)); | 518 entries->push_back(new RegistryEntry(start_menu, app_name)); |
513 } | 519 } |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 // Associates Chrome with |protocol| in the registry. This should not be | 904 // Associates Chrome with |protocol| in the registry. This should not be |
899 // required on Vista+ but since some applications still read these registry | 905 // required on Vista+ but since some applications still read these registry |
900 // keys directly, we have to do this on Vista+ as well. | 906 // keys directly, we have to do this on Vista+ as well. |
901 // See http://msdn.microsoft.com/library/aa767914.aspx for more details. | 907 // See http://msdn.microsoft.com/library/aa767914.aspx for more details. |
902 bool RegisterChromeAsDefaultProtocolClientXPStyle(BrowserDistribution* dist, | 908 bool RegisterChromeAsDefaultProtocolClientXPStyle(BrowserDistribution* dist, |
903 const string16& chrome_exe, | 909 const string16& chrome_exe, |
904 const string16& protocol) { | 910 const string16& protocol) { |
905 ScopedVector<RegistryEntry> entries; | 911 ScopedVector<RegistryEntry> entries; |
906 const string16 chrome_open(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); | 912 const string16 chrome_open(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); |
907 const string16 chrome_icon( | 913 const string16 chrome_icon( |
908 ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex())); | 914 ShellUtil::FormatIconLocation(chrome_exe, |
| 915 dist-> |
| 916 GetShortcutInfo(BrowserDistribution::SHORTCUT_CHROME).icon_index)); |
909 RegistryEntry::GetXPStyleUserProtocolEntries(protocol, chrome_icon, | 917 RegistryEntry::GetXPStyleUserProtocolEntries(protocol, chrome_icon, |
910 chrome_open, &entries); | 918 chrome_open, &entries); |
911 // Change the default protocol handler for current user. | 919 // Change the default protocol handler for current user. |
912 if (!AddRegistryEntries(HKEY_CURRENT_USER, entries)) { | 920 if (!AddRegistryEntries(HKEY_CURRENT_USER, entries)) { |
913 LOG(ERROR) << "Could not make Chrome default protocol client (XP)."; | 921 LOG(ERROR) << "Could not make Chrome default protocol client (XP)."; |
914 return false; | 922 return false; |
915 } | 923 } |
916 | 924 |
917 return true; | 925 return true; |
918 } | 926 } |
919 | 927 |
920 // Returns |properties.shortcut_name| if the property is set, otherwise it | 928 // Returns |properties.shortcut_name| if the property is set, otherwise it |
921 // returns dist->GetAppShortcutName(). In any case, it makes sure the | 929 // returns dist->GetShortcutInfo(BrowserDistribution::SHORTCUT_CHROME).name. In |
922 // return value is suffixed with ".lnk". | 930 // any case, it makes sure the return value is suffixed with ".lnk". |
923 string16 ExtractShortcutNameFromProperties( | 931 string16 ExtractShortcutNameFromProperties( |
924 BrowserDistribution* dist, | 932 BrowserDistribution* dist, |
925 const ShellUtil::ShortcutProperties& properties) { | 933 const ShellUtil::ShortcutProperties& properties) { |
926 DCHECK(dist); | 934 DCHECK(dist); |
927 string16 shortcut_name; | 935 string16 shortcut_name( |
928 if (properties.has_shortcut_name()) | 936 properties.has_shortcut_name() ? properties.shortcut_name : |
929 shortcut_name = properties.shortcut_name; | 937 dist->GetShortcutInfo(BrowserDistribution::SHORTCUT_CHROME).name); |
930 else | |
931 shortcut_name = dist->GetAppShortCutName(); | |
932 | 938 |
933 if (!EndsWith(shortcut_name, installer::kLnkExt, false)) | 939 if (!EndsWith(shortcut_name, installer::kLnkExt, false)) |
934 shortcut_name.append(installer::kLnkExt); | 940 shortcut_name.append(installer::kLnkExt); |
935 | 941 |
936 return shortcut_name; | 942 return shortcut_name; |
937 } | 943 } |
938 | 944 |
939 // Converts ShellUtil::ShortcutOperation to the best-matching value in | 945 // Converts ShellUtil::ShortcutOperation to the best-matching value in |
940 // base::win::ShortcutOperation. | 946 // base::win::ShortcutOperation. |
941 base::win::ShortcutOperation TranslateShortcutOperation( | 947 base::win::ShortcutOperation TranslateShortcutOperation( |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 default: | 1395 default: |
1390 NOTREACHED(); | 1396 NOTREACHED(); |
1391 return false; | 1397 return false; |
1392 } | 1398 } |
1393 | 1399 |
1394 if (!PathService::Get(dir_key, path) || path->empty()) { | 1400 if (!PathService::Get(dir_key, path) || path->empty()) { |
1395 NOTREACHED() << dir_key; | 1401 NOTREACHED() << dir_key; |
1396 return false; | 1402 return false; |
1397 } | 1403 } |
1398 | 1404 |
1399 if (add_folder_for_dist) | 1405 if (add_folder_for_dist) { |
1400 *path = path->Append(dist->GetAppShortCutName()); | 1406 // TODO(calamity): Change to GetStartMenuShortcutSubfolder() once it is |
| 1407 // implemented across all distributions. |
| 1408 *path = path->Append( |
| 1409 dist->GetShortcutInfo(BrowserDistribution::SHORTCUT_CHROME).name); |
| 1410 } |
1401 | 1411 |
1402 return true; | 1412 return true; |
1403 } | 1413 } |
1404 | 1414 |
1405 bool ShellUtil::CreateOrUpdateShortcut( | 1415 bool ShellUtil::CreateOrUpdateShortcut( |
1406 ShellUtil::ShortcutLocation location, | 1416 ShellUtil::ShortcutLocation location, |
1407 BrowserDistribution* dist, | 1417 BrowserDistribution* dist, |
1408 const ShellUtil::ShortcutProperties& properties, | 1418 const ShellUtil::ShortcutProperties& properties, |
1409 ShellUtil::ShortcutOperation operation) { | 1419 ShellUtil::ShortcutOperation operation) { |
1410 // Explicitly whitelist locations to which this is applicable. | 1420 // Explicitly whitelist locations to which this is applicable. |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2080 // are any left...). | 2090 // are any left...). |
2081 if (free_bits >= 8 && next_byte_index < size) { | 2091 if (free_bits >= 8 && next_byte_index < size) { |
2082 free_bits -= 8; | 2092 free_bits -= 8; |
2083 bit_stream += bytes[next_byte_index++] << free_bits; | 2093 bit_stream += bytes[next_byte_index++] << free_bits; |
2084 } | 2094 } |
2085 } | 2095 } |
2086 | 2096 |
2087 DCHECK_EQ(ret.length(), encoded_length); | 2097 DCHECK_EQ(ret.length(), encoded_length); |
2088 return ret; | 2098 return ret; |
2089 } | 2099 } |
OLD | NEW |