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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 string16 key(ShellUtil::kRegClasses); | 418 string16 key(ShellUtil::kRegClasses); |
419 key.push_back(FilePath::kSeparators[0]); | 419 key.push_back(FilePath::kSeparators[0]); |
420 key.append(ShellUtil::kFileAssociations[i]); | 420 key.append(ShellUtil::kFileAssociations[i]); |
421 key.push_back(FilePath::kSeparators[0]); | 421 key.push_back(FilePath::kSeparators[0]); |
422 key.append(ShellUtil::kRegOpenWithProgids); | 422 key.append(ShellUtil::kRegOpenWithProgids); |
423 entries->push_back(new RegistryEntry(key, html_prog_id, string16())); | 423 entries->push_back(new RegistryEntry(key, html_prog_id, string16())); |
424 } | 424 } |
425 } | 425 } |
426 | 426 |
427 // This method returns a list of all the user level registry entries that | 427 // This method returns a list of all the user level registry entries that |
428 // are needed to make Chromium the default handler for a protocol. | 428 // are needed to make Chromium the default handler for a protocol on XP. |
429 static void GetUserProtocolEntries(const string16& protocol, | 429 static void GetXPStyleUserProtocolEntries( |
430 const string16& chrome_icon, | 430 const string16& protocol, |
431 const string16& chrome_open, | 431 const string16& chrome_icon, |
432 ScopedVector<RegistryEntry>* entries) { | 432 const string16& chrome_open, |
| 433 ScopedVector<RegistryEntry>* entries) { |
433 // Protocols associations. | 434 // Protocols associations. |
434 string16 url_key(ShellUtil::kRegClasses); | 435 string16 url_key(ShellUtil::kRegClasses); |
435 url_key.push_back(FilePath::kSeparators[0]); | 436 url_key.push_back(FilePath::kSeparators[0]); |
436 url_key.append(protocol); | 437 url_key.append(protocol); |
437 | 438 |
438 // This registry value tells Windows that this 'class' is a URL scheme | 439 // This registry value tells Windows that this 'class' is a URL scheme |
439 // so IE, explorer and other apps will route it to our handler. | 440 // so IE, explorer and other apps will route it to our handler. |
440 // <root hkey>\Software\Classes\<protocol>\URL Protocol | 441 // <root hkey>\Software\Classes\<protocol>\URL Protocol |
441 entries->push_back(new RegistryEntry(url_key, | 442 entries->push_back(new RegistryEntry(url_key, |
442 ShellUtil::kRegUrlProtocol, L"")); | 443 ShellUtil::kRegUrlProtocol, L"")); |
443 | 444 |
444 // <root hkey>\Software\Classes\<protocol>\DefaultIcon | 445 // <root hkey>\Software\Classes\<protocol>\DefaultIcon |
445 string16 icon_key = url_key + ShellUtil::kRegDefaultIcon; | 446 string16 icon_key = url_key + ShellUtil::kRegDefaultIcon; |
446 entries->push_back(new RegistryEntry(icon_key, chrome_icon)); | 447 entries->push_back(new RegistryEntry(icon_key, chrome_icon)); |
447 | 448 |
448 // <root hkey>\Software\Classes\<protocol>\shell\open\command | 449 // <root hkey>\Software\Classes\<protocol>\shell\open\command |
449 string16 shell_key = url_key + ShellUtil::kRegShellOpen; | 450 string16 shell_key = url_key + ShellUtil::kRegShellOpen; |
450 entries->push_back(new RegistryEntry(shell_key, chrome_open)); | 451 entries->push_back(new RegistryEntry(shell_key, chrome_open)); |
451 | 452 |
452 // <root hkey>\Software\Classes\<protocol>\shell\open\ddeexec | 453 // <root hkey>\Software\Classes\<protocol>\shell\open\ddeexec |
453 string16 dde_key = url_key + L"\\shell\\open\\ddeexec"; | 454 string16 dde_key = url_key + L"\\shell\\open\\ddeexec"; |
454 entries->push_back(new RegistryEntry(dde_key, L"")); | 455 entries->push_back(new RegistryEntry(dde_key, L"")); |
455 | 456 |
456 // <root hkey>\Software\Classes\<protocol>\shell\@ | 457 // <root hkey>\Software\Classes\<protocol>\shell\@ |
457 string16 protocol_shell_key = url_key + ShellUtil::kRegShellPath; | 458 string16 protocol_shell_key = url_key + ShellUtil::kRegShellPath; |
458 entries->push_back(new RegistryEntry(protocol_shell_key, L"open")); | 459 entries->push_back(new RegistryEntry(protocol_shell_key, L"open")); |
459 } | 460 } |
460 | 461 |
461 // This method returns a list of all the user level registry entries that | 462 // This method returns a list of all the user level registry entries that |
462 // are needed to make Chromium default browser. | 463 // are needed to make Chromium default browser on XP. |
463 // Some of these entries are irrelevant in recent versions of Windows, but | 464 // Some of these entries are irrelevant in recent versions of Windows, but |
464 // we register them anyways as some legacy apps are hardcoded to lookup those | 465 // we register them anyways as some legacy apps are hardcoded to lookup those |
465 // values. | 466 // values. |
466 static void GetDefaultBrowserUserEntries( | 467 static void GetXPStyleDefaultBrowserUserEntries( |
467 BrowserDistribution* dist, | 468 BrowserDistribution* dist, |
468 const string16& chrome_exe, | 469 const string16& chrome_exe, |
469 const string16& suffix, | 470 const string16& suffix, |
470 ScopedVector<RegistryEntry>* entries) { | 471 ScopedVector<RegistryEntry>* entries) { |
471 // File extension associations. | 472 // File extension associations. |
472 string16 html_prog_id(GetBrowserProgId(suffix)); | 473 string16 html_prog_id(GetBrowserProgId(suffix)); |
473 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { | 474 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { |
474 string16 ext_key(ShellUtil::kRegClasses); | 475 string16 ext_key(ShellUtil::kRegClasses); |
475 ext_key.push_back(FilePath::kSeparators[0]); | 476 ext_key.push_back(FilePath::kSeparators[0]); |
476 ext_key.append(ShellUtil::kFileAssociations[i]); | 477 ext_key.append(ShellUtil::kFileAssociations[i]); |
477 entries->push_back(new RegistryEntry(ext_key, html_prog_id)); | 478 entries->push_back(new RegistryEntry(ext_key, html_prog_id)); |
478 } | 479 } |
479 | 480 |
480 // Protocols associations. | 481 // Protocols associations. |
481 string16 chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe); | 482 string16 chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe); |
482 string16 chrome_icon = ShellUtil::GetChromeIcon(dist, chrome_exe); | 483 string16 chrome_icon = ShellUtil::GetChromeIcon(dist, chrome_exe); |
483 for (int i = 0; ShellUtil::kBrowserProtocolAssociations[i] != NULL; i++) { | 484 for (int i = 0; ShellUtil::kBrowserProtocolAssociations[i] != NULL; i++) { |
484 GetUserProtocolEntries(ShellUtil::kBrowserProtocolAssociations[i], | 485 GetXPStyleUserProtocolEntries(ShellUtil::kBrowserProtocolAssociations[i], |
485 chrome_icon, chrome_open, entries); | 486 chrome_icon, chrome_open, entries); |
486 } | 487 } |
487 | 488 |
488 // start->Internet shortcut. | 489 // start->Internet shortcut. |
489 string16 start_menu(ShellUtil::kRegStartMenuInternet); | 490 string16 start_menu(ShellUtil::kRegStartMenuInternet); |
490 string16 app_name = dist->GetBaseAppName() + suffix; | 491 string16 app_name = dist->GetBaseAppName() + suffix; |
491 entries->push_back(new RegistryEntry(start_menu, app_name)); | 492 entries->push_back(new RegistryEntry(start_menu, app_name)); |
492 } | 493 } |
493 | 494 |
494 // Generate work_item tasks required to create current registry entry and | 495 // Generate work_item tasks required to create current registry entry and |
495 // add them to the given work item list. | 496 // add them to the given work item list. |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 } | 875 } |
875 if (QuickIsChromeRegistered(dist, chrome_exe, *suffix, | 876 if (QuickIsChromeRegistered(dist, chrome_exe, *suffix, |
876 CONFIRM_SHELL_REGISTRATION)) { | 877 CONFIRM_SHELL_REGISTRATION)) { |
877 // Username suffix for installs that are suffixed as per the old-style. | 878 // Username suffix for installs that are suffixed as per the old-style. |
878 return true; | 879 return true; |
879 } | 880 } |
880 | 881 |
881 return ShellUtil::GetUserSpecificRegistrySuffix(suffix); | 882 return ShellUtil::GetUserSpecificRegistrySuffix(suffix); |
882 } | 883 } |
883 | 884 |
884 // Returns the root registry key (HKLM or HKCU) into which shell integration | 885 // Returns the root registry key (HKLM or HKCU) under which registrations must |
885 // registration for default protocols must be placed. As of Windows 8 everything | 886 // be placed for this install. As of Windows 8 everything can go in HKCU for |
886 // can go in HKCU for per-user installs. | 887 // per-user installs. |
887 HKEY DetermineShellIntegrationRoot(bool is_per_user) { | 888 HKEY DetermineRegistrationRoot(bool is_per_user) { |
888 return is_per_user && base::win::GetVersion() >= base::win::VERSION_WIN8 ? | 889 return is_per_user && base::win::GetVersion() >= base::win::VERSION_WIN8 ? |
889 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; | 890 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; |
890 } | 891 } |
891 | 892 |
892 // Associates Chrome with supported protocols and file associations. This should | 893 // Associates Chrome with supported protocols and file associations. This should |
893 // not be required on Vista+ but since some applications still read | 894 // not be required on Vista+ but since some applications still read |
894 // Software\Classes\http key directly, we have to do this on Vista+ as well. | 895 // Software\Classes\http key directly, we have to do this on Vista+ as well. |
895 bool RegisterChromeAsDefaultForXP(BrowserDistribution* dist, | 896 bool RegisterChromeAsDefaultXPStyle(BrowserDistribution* dist, |
896 int shell_change, | 897 int shell_change, |
897 const string16& chrome_exe) { | 898 const string16& chrome_exe) { |
898 bool ret = true; | 899 bool ret = true; |
899 ScopedVector<RegistryEntry> entries; | 900 ScopedVector<RegistryEntry> entries; |
900 RegistryEntry::GetDefaultBrowserUserEntries( | 901 RegistryEntry::GetXPStyleDefaultBrowserUserEntries( |
901 dist, chrome_exe, | 902 dist, chrome_exe, |
902 ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe), &entries); | 903 ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe), &entries); |
903 | 904 |
904 // Change the default browser for current user. | 905 // Change the default browser for current user. |
905 if ((shell_change & ShellUtil::CURRENT_USER) && | 906 if ((shell_change & ShellUtil::CURRENT_USER) && |
906 !AddRegistryEntries(HKEY_CURRENT_USER, entries)) { | 907 !AddRegistryEntries(HKEY_CURRENT_USER, entries)) { |
907 ret = false; | 908 ret = false; |
908 LOG(ERROR) << "Could not make Chrome default browser (XP/current user)."; | 909 LOG(ERROR) << "Could not make Chrome default browser (XP/current user)."; |
909 } | 910 } |
910 | 911 |
911 // Chrome as default browser at system level. | 912 // Chrome as default browser at system level. |
912 if ((shell_change & ShellUtil::SYSTEM_LEVEL) && | 913 if ((shell_change & ShellUtil::SYSTEM_LEVEL) && |
913 !AddRegistryEntries(HKEY_LOCAL_MACHINE, entries)) { | 914 !AddRegistryEntries(HKEY_LOCAL_MACHINE, entries)) { |
914 ret = false; | 915 ret = false; |
915 LOG(ERROR) << "Could not make Chrome default browser (XP/system level)."; | 916 LOG(ERROR) << "Could not make Chrome default browser (XP/system level)."; |
916 } | 917 } |
917 | 918 |
918 return ret; | 919 return ret; |
919 } | 920 } |
920 | 921 |
921 // Associates Chrome with |protocol| in the registry. This should not be | 922 // Associates Chrome with |protocol| in the registry. This should not be |
922 // required on Vista+ but since some applications still read these registry | 923 // required on Vista+ but since some applications still read these registry |
923 // keys directly, we have to do this on Vista+ as well. | 924 // keys directly, we have to do this on Vista+ as well. |
924 // See http://msdn.microsoft.com/library/aa767914.aspx for more details. | 925 // See http://msdn.microsoft.com/library/aa767914.aspx for more details. |
925 bool RegisterChromeAsDefaultProtocolClientForXP(BrowserDistribution* dist, | 926 bool RegisterChromeAsDefaultProtocolClientXPStyle(BrowserDistribution* dist, |
926 const string16& chrome_exe, | 927 const string16& chrome_exe, |
927 const string16& protocol) { | 928 const string16& protocol) { |
928 ScopedVector<RegistryEntry> entries; | 929 ScopedVector<RegistryEntry> entries; |
929 const string16 chrome_open(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); | 930 const string16 chrome_open(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); |
930 const string16 chrome_icon(ShellUtil::GetChromeIcon(dist, chrome_exe)); | 931 const string16 chrome_icon(ShellUtil::GetChromeIcon(dist, chrome_exe)); |
931 RegistryEntry::GetUserProtocolEntries(protocol, chrome_icon, chrome_open, | 932 RegistryEntry::GetXPStyleUserProtocolEntries(protocol, chrome_icon, |
932 &entries); | 933 chrome_open, &entries); |
933 // Change the default protocol handler for current user. | 934 // Change the default protocol handler for current user. |
934 if (!AddRegistryEntries(HKEY_CURRENT_USER, entries)) { | 935 if (!AddRegistryEntries(HKEY_CURRENT_USER, entries)) { |
935 LOG(ERROR) << "Could not make Chrome default protocol client (XP)."; | 936 LOG(ERROR) << "Could not make Chrome default protocol client (XP)."; |
936 return false; | 937 return false; |
937 } | 938 } |
938 | 939 |
939 return true; | 940 return true; |
940 } | 941 } |
941 | 942 |
942 // Returns |properties.shortcut_name| if the property is set, otherwise it | 943 // Returns |properties.shortcut_name| if the property is set, otherwise it |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 | 1018 |
1018 // Cleans up an old verb (run) we used to register in | 1019 // Cleans up an old verb (run) we used to register in |
1019 // <root>\Software\Classes\Chrome<.suffix>\.exe\shell\run on Windows 8. | 1020 // <root>\Software\Classes\Chrome<.suffix>\.exe\shell\run on Windows 8. |
1020 // TODO (gab): This was fixed before the general availability of Windows 8 and | 1021 // TODO (gab): This was fixed before the general availability of Windows 8 and |
1021 // thus can safely be removed in February 2013. | 1022 // thus can safely be removed in February 2013. |
1022 void RemoveRunVerbOnWindows8( | 1023 void RemoveRunVerbOnWindows8( |
1023 BrowserDistribution* dist, | 1024 BrowserDistribution* dist, |
1024 const string16& chrome_exe) { | 1025 const string16& chrome_exe) { |
1025 if (IsChromeMetroSupported()) { | 1026 if (IsChromeMetroSupported()) { |
1026 bool is_per_user_install =InstallUtil::IsPerUserInstall(chrome_exe.c_str()); | 1027 bool is_per_user_install =InstallUtil::IsPerUserInstall(chrome_exe.c_str()); |
1027 HKEY root_key = DetermineShellIntegrationRoot(is_per_user_install); | 1028 HKEY root_key = DetermineRegistrationRoot(is_per_user_install); |
1028 // There's no need to rollback, so forgo the usual work item lists and just | 1029 // There's no need to rollback, so forgo the usual work item lists and just |
1029 // remove the key from the registry. | 1030 // remove the key from the registry. |
1030 string16 run_verb_key(ShellUtil::kRegClasses); | 1031 string16 run_verb_key(ShellUtil::kRegClasses); |
1031 run_verb_key.push_back(FilePath::kSeparators[0]); | 1032 run_verb_key.push_back(FilePath::kSeparators[0]); |
1032 run_verb_key.append(ShellUtil::GetBrowserModelId( | 1033 run_verb_key.append(ShellUtil::GetBrowserModelId( |
1033 dist, is_per_user_install)); | 1034 dist, is_per_user_install)); |
1034 run_verb_key.append(ShellUtil::kRegExePath); | 1035 run_verb_key.append(ShellUtil::kRegExePath); |
1035 run_verb_key.append(ShellUtil::kRegShellPath); | 1036 run_verb_key.append(ShellUtil::kRegShellPath); |
1036 run_verb_key.push_back(FilePath::kSeparators[0]); | 1037 run_verb_key.push_back(FilePath::kSeparators[0]); |
1037 run_verb_key.append(ShellUtil::kRegVerbRun); | 1038 run_verb_key.append(ShellUtil::kRegVerbRun); |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 ShellUtil::kFileAssociations[i], AT_FILEEXTENSION); | 1590 ShellUtil::kFileAssociations[i], AT_FILEEXTENSION); |
1590 if (!SUCCEEDED(hr)) { | 1591 if (!SUCCEEDED(hr)) { |
1591 ret = false; | 1592 ret = false; |
1592 LOG(ERROR) << "Failed to register as default for file extension " | 1593 LOG(ERROR) << "Failed to register as default for file extension " |
1593 << ShellUtil::kFileAssociations[i] << " (" << hr << ")"; | 1594 << ShellUtil::kFileAssociations[i] << " (" << hr << ")"; |
1594 } | 1595 } |
1595 } | 1596 } |
1596 } | 1597 } |
1597 } | 1598 } |
1598 | 1599 |
1599 if (!RegisterChromeAsDefaultForXP(dist, shell_change, chrome_exe)) | 1600 if (!RegisterChromeAsDefaultXPStyle(dist, shell_change, chrome_exe)) |
1600 ret = false; | 1601 ret = false; |
1601 | 1602 |
1602 // Send Windows notification event so that it can update icons for | 1603 // Send Windows notification event so that it can update icons for |
1603 // file associations. | 1604 // file associations. |
1604 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); | 1605 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); |
1605 return ret; | 1606 return ret; |
1606 } | 1607 } |
1607 | 1608 |
1608 bool ShellUtil::ShowMakeChromeDefaultSystemUI(BrowserDistribution* dist, | 1609 bool ShellUtil::ShowMakeChromeDefaultSystemUI(BrowserDistribution* dist, |
1609 const string16& chrome_exe) { | 1610 const string16& chrome_exe) { |
1610 DCHECK_GE(base::win::GetVersion(), base::win::VERSION_WIN8); | 1611 DCHECK_GE(base::win::GetVersion(), base::win::VERSION_WIN8); |
1611 if (!dist->CanSetAsDefault()) | 1612 if (!dist->CanSetAsDefault()) |
1612 return false; | 1613 return false; |
1613 | 1614 |
1614 if (!RegisterChromeBrowser(dist, chrome_exe, string16(), true)) | 1615 if (!RegisterChromeBrowser(dist, chrome_exe, string16(), true)) |
1615 return false; | 1616 return false; |
1616 | 1617 |
1617 // On Windows 8, you can't set yourself as the default handler | 1618 // On Windows 8, you can't set yourself as the default handler |
1618 // programatically. In other words IApplicationAssociationRegistration | 1619 // programatically. In other words IApplicationAssociationRegistration |
1619 // has been rendered useless. What you can do is to launch | 1620 // has been rendered useless. What you can do is to launch |
1620 // "Set Program Associations" section of the "Default Programs" | 1621 // "Set Program Associations" section of the "Default Programs" |
1621 // control panel, which is a mess, or pop the concise "How you want to open | 1622 // control panel, which is a mess, or pop the concise "How you want to open |
1622 // webpages?" dialog. We choose the latter. | 1623 // webpages?" dialog. We choose the latter. |
1623 // Return true only when the user took an action and there was no error. | 1624 // Return true only when the user took an action and there was no error. |
1624 const bool ret = LaunchSelectDefaultProtocolHandlerDialog(L"http"); | 1625 const bool ret = LaunchSelectDefaultProtocolHandlerDialog(L"http"); |
1625 | 1626 |
1626 if (ret && GetChromeDefaultState() == IS_DEFAULT) | 1627 if (ret && GetChromeDefaultState() == IS_DEFAULT) |
1627 RegisterChromeAsDefaultForXP(dist, CURRENT_USER, chrome_exe); | 1628 RegisterChromeAsDefaultXPStyle(dist, CURRENT_USER, chrome_exe); |
1628 | 1629 |
1629 return ret; | 1630 return ret; |
1630 } | 1631 } |
1631 | 1632 |
1632 bool ShellUtil::MakeChromeDefaultProtocolClient(BrowserDistribution* dist, | 1633 bool ShellUtil::MakeChromeDefaultProtocolClient(BrowserDistribution* dist, |
1633 const string16& chrome_exe, | 1634 const string16& chrome_exe, |
1634 const string16& protocol) { | 1635 const string16& protocol) { |
1635 if (!dist->CanSetAsDefault()) | 1636 if (!dist->CanSetAsDefault()) |
1636 return false; | 1637 return false; |
1637 | 1638 |
(...skipping 21 matching lines...) Expand all Loading... |
1659 AT_URLPROTOCOL); | 1660 AT_URLPROTOCOL); |
1660 } | 1661 } |
1661 if (!SUCCEEDED(hr)) { | 1662 if (!SUCCEEDED(hr)) { |
1662 ret = false; | 1663 ret = false; |
1663 LOG(ERROR) << "Could not make Chrome default protocol client (Vista):" | 1664 LOG(ERROR) << "Could not make Chrome default protocol client (Vista):" |
1664 << " HRESULT=" << hr << "."; | 1665 << " HRESULT=" << hr << "."; |
1665 } | 1666 } |
1666 } | 1667 } |
1667 | 1668 |
1668 // Now use the old way to associate Chrome with the desired protocol. This | 1669 // Now use the old way to associate Chrome with the desired protocol. This |
1669 // should not be required on Vista but since some applications still read | 1670 // should not be required on Vista+, but since some applications still read |
1670 // Software\Classes\http key directly, we have to do this on Vista also. | 1671 // Software\Classes\<protocol> key directly, do this on Vista+ also. |
1671 if (!RegisterChromeAsDefaultProtocolClientForXP(dist, chrome_exe, protocol)) | 1672 if (!RegisterChromeAsDefaultProtocolClientXPStyle(dist, chrome_exe, protocol)) |
1672 ret = false; | 1673 ret = false; |
1673 | 1674 |
1674 return ret; | 1675 return ret; |
1675 } | 1676 } |
1676 | 1677 |
1677 bool ShellUtil::ShowMakeChromeDefaultProtocolClientSystemUI( | 1678 bool ShellUtil::ShowMakeChromeDefaultProtocolClientSystemUI( |
1678 BrowserDistribution* dist, | 1679 BrowserDistribution* dist, |
1679 const string16& chrome_exe, | 1680 const string16& chrome_exe, |
1680 const string16& protocol) { | 1681 const string16& protocol) { |
1681 DCHECK_GE(base::win::GetVersion(), base::win::VERSION_WIN8); | 1682 DCHECK_GE(base::win::GetVersion(), base::win::VERSION_WIN8); |
1682 if (!dist->CanSetAsDefault()) | 1683 if (!dist->CanSetAsDefault()) |
1683 return false; | 1684 return false; |
1684 | 1685 |
1685 if (!RegisterChromeForProtocol(dist, chrome_exe, string16(), protocol, true)) | 1686 if (!RegisterChromeForProtocol(dist, chrome_exe, string16(), protocol, true)) |
1686 return false; | 1687 return false; |
1687 | 1688 |
1688 // On Windows 8, you can't set yourself as the default handler | 1689 // On Windows 8, you can't set yourself as the default handler |
1689 // programatically. In other words IApplicationAssociationRegistration | 1690 // programatically. In other words IApplicationAssociationRegistration |
1690 // has been rendered useless. What you can do is to launch | 1691 // has been rendered useless. What you can do is to launch |
1691 // "Set Program Associations" section of the "Default Programs" | 1692 // "Set Program Associations" section of the "Default Programs" |
1692 // control panel, which is a mess, or pop the concise "How you want to open | 1693 // control panel, which is a mess, or pop the concise "How you want to open |
1693 // links of this type (protocol)?" dialog. We choose the latter. | 1694 // links of this type (protocol)?" dialog. We choose the latter. |
1694 // Return true only when the user took an action and there was no error. | 1695 // Return true only when the user took an action and there was no error. |
1695 const bool ret = LaunchSelectDefaultProtocolHandlerDialog(protocol.c_str()); | 1696 const bool ret = LaunchSelectDefaultProtocolHandlerDialog(protocol.c_str()); |
1696 | 1697 |
1697 if (ret && GetChromeDefaultProtocolClientState(protocol) == IS_DEFAULT) | 1698 if (ret && GetChromeDefaultProtocolClientState(protocol) == IS_DEFAULT) |
1698 RegisterChromeAsDefaultProtocolClientForXP(dist, chrome_exe, protocol); | 1699 RegisterChromeAsDefaultProtocolClientXPStyle(dist, chrome_exe, protocol); |
1699 | 1700 |
1700 return ret; | 1701 return ret; |
1701 } | 1702 } |
1702 | 1703 |
1703 bool ShellUtil::RegisterChromeBrowser(BrowserDistribution* dist, | 1704 bool ShellUtil::RegisterChromeBrowser(BrowserDistribution* dist, |
1704 const string16& chrome_exe, | 1705 const string16& chrome_exe, |
1705 const string16& unique_suffix, | 1706 const string16& unique_suffix, |
1706 bool elevate_if_not_admin) { | 1707 bool elevate_if_not_admin) { |
1707 if (!dist->CanSetAsDefault()) | 1708 if (!dist->CanSetAsDefault()) |
1708 return false; | 1709 return false; |
1709 | 1710 |
1710 string16 suffix; | 1711 string16 suffix; |
1711 if (!unique_suffix.empty()) { | 1712 if (!unique_suffix.empty()) { |
1712 suffix = unique_suffix; | 1713 suffix = unique_suffix; |
1713 } else if (!GetInstallationSpecificSuffix(dist, chrome_exe, &suffix)) { | 1714 } else if (!GetInstallationSpecificSuffix(dist, chrome_exe, &suffix)) { |
1714 return false; | 1715 return false; |
1715 } | 1716 } |
1716 | 1717 |
1717 // TODO(grt): remove this on or after 2012-08-01; see impl for details. | 1718 // TODO(grt): remove this on or after 2012-08-01; see impl for details. |
1718 RemoveBadWindows8RegistrationIfNeeded(dist, chrome_exe); | 1719 RemoveBadWindows8RegistrationIfNeeded(dist, chrome_exe); |
1719 | 1720 |
1720 // TODO(gab): remove this on or after 2013-02-01; see impl for details. | 1721 // TODO(gab): remove this on or after 2013-02-01; see impl for details. |
1721 RemoveRunVerbOnWindows8(dist, chrome_exe); | 1722 RemoveRunVerbOnWindows8(dist, chrome_exe); |
1722 | 1723 |
1723 // Check if Chromium is already registered with this suffix. | 1724 // Check if Chromium is already registered with this suffix. |
1724 if (IsChromeRegistered(dist, chrome_exe, suffix)) | 1725 if (IsChromeRegistered(dist, chrome_exe, suffix)) |
1725 return true; | 1726 return true; |
1726 | 1727 |
1727 bool user_level = InstallUtil::IsPerUserInstall(chrome_exe.c_str()); | 1728 bool user_level = InstallUtil::IsPerUserInstall(chrome_exe.c_str()); |
1728 HKEY root = DetermineShellIntegrationRoot(user_level); | 1729 HKEY root = DetermineRegistrationRoot(user_level); |
1729 | 1730 |
1730 // Do the full registration if we can do it at user-level or if the user is an | 1731 // Do the full registration if we can do it at user-level or if the user is an |
1731 // admin. | 1732 // admin. |
1732 if (root == HKEY_CURRENT_USER || IsUserAnAdmin()) { | 1733 if (root == HKEY_CURRENT_USER || IsUserAnAdmin()) { |
1733 ScopedVector<RegistryEntry> progid_and_appreg_entries; | 1734 ScopedVector<RegistryEntry> progid_and_appreg_entries; |
1734 ScopedVector<RegistryEntry> shell_entries; | 1735 ScopedVector<RegistryEntry> shell_entries; |
1735 RegistryEntry::GetProgIdEntries(dist, chrome_exe, suffix, | 1736 RegistryEntry::GetProgIdEntries(dist, chrome_exe, suffix, |
1736 &progid_and_appreg_entries); | 1737 &progid_and_appreg_entries); |
1737 RegistryEntry::GetAppRegistrationEntries(chrome_exe, suffix, | 1738 RegistryEntry::GetAppRegistrationEntries(chrome_exe, suffix, |
1738 &progid_and_appreg_entries); | 1739 &progid_and_appreg_entries); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1790 if (!unique_suffix.empty()) { | 1791 if (!unique_suffix.empty()) { |
1791 suffix = unique_suffix; | 1792 suffix = unique_suffix; |
1792 } else if (!GetInstallationSpecificSuffix(dist, chrome_exe, &suffix)) { | 1793 } else if (!GetInstallationSpecificSuffix(dist, chrome_exe, &suffix)) { |
1793 return false; | 1794 return false; |
1794 } | 1795 } |
1795 | 1796 |
1796 // Check if Chromium is already registered with this suffix. | 1797 // Check if Chromium is already registered with this suffix. |
1797 if (IsChromeRegisteredForProtocol(dist, suffix, protocol)) | 1798 if (IsChromeRegisteredForProtocol(dist, suffix, protocol)) |
1798 return true; | 1799 return true; |
1799 | 1800 |
1800 HKEY root = DetermineShellIntegrationRoot( | 1801 HKEY root = DetermineRegistrationRoot( |
1801 InstallUtil::IsPerUserInstall(chrome_exe.c_str())); | 1802 InstallUtil::IsPerUserInstall(chrome_exe.c_str())); |
1802 | 1803 |
1803 if (root == HKEY_CURRENT_USER || IsUserAnAdmin()) { | 1804 if (root == HKEY_CURRENT_USER || IsUserAnAdmin()) { |
1804 // We can do this operation directly. | 1805 // We can do this operation directly. |
1805 // First, make sure Chrome is fully registered on this machine. | 1806 // First, make sure Chrome is fully registered on this machine. |
1806 if (!RegisterChromeBrowser(dist, chrome_exe, suffix, false)) | 1807 if (!RegisterChromeBrowser(dist, chrome_exe, suffix, false)) |
1807 return false; | 1808 return false; |
1808 | 1809 |
1809 // Write in the capabillity for the protocol. | 1810 // Write in the capabillity for the protocol. |
1810 ScopedVector<RegistryEntry> entries; | 1811 ScopedVector<RegistryEntry> entries; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1939 // are any left...). | 1940 // are any left...). |
1940 if (free_bits >= 8 && next_byte_index < size) { | 1941 if (free_bits >= 8 && next_byte_index < size) { |
1941 free_bits -= 8; | 1942 free_bits -= 8; |
1942 bit_stream += bytes[next_byte_index++] << free_bits; | 1943 bit_stream += bytes[next_byte_index++] << free_bits; |
1943 } | 1944 } |
1944 } | 1945 } |
1945 | 1946 |
1946 DCHECK_EQ(ret.length(), encoded_length); | 1947 DCHECK_EQ(ret.length(), encoded_length); |
1947 return ret; | 1948 return ret; |
1948 } | 1949 } |
OLD | NEW |