| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 std::wstring start_menu_entry(ShellUtil::kRegStartMenuInternet); | 593 std::wstring start_menu_entry(ShellUtil::kRegStartMenuInternet); |
| 594 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 594 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 595 start_menu_entry.append(L"\\" + dist->GetApplicationName() + *entry); | 595 start_menu_entry.append(L"\\" + dist->GetApplicationName() + *entry); |
| 596 RegKey key(HKEY_LOCAL_MACHINE, start_menu_entry.c_str()); | 596 RegKey key(HKEY_LOCAL_MACHINE, start_menu_entry.c_str()); |
| 597 return key.Valid(); | 597 return key.Valid(); |
| 598 } | 598 } |
| 599 | 599 |
| 600 bool ShellUtil::MakeChromeDefault(int shell_change, | 600 bool ShellUtil::MakeChromeDefault(int shell_change, |
| 601 const std::wstring& chrome_exe, | 601 const std::wstring& chrome_exe, |
| 602 bool elevate_if_not_admin) { | 602 bool elevate_if_not_admin) { |
| 603 if (!BrowserDistribution::GetDistribution()->CanSetAsDefault()) |
| 604 return false; |
| 605 |
| 603 ShellUtil::RegisterChromeBrowser(chrome_exe, L"", elevate_if_not_admin); | 606 ShellUtil::RegisterChromeBrowser(chrome_exe, L"", elevate_if_not_admin); |
| 604 | 607 |
| 605 bool ret = true; | 608 bool ret = true; |
| 606 // First use the new "recommended" way on Vista to make Chrome default | 609 // First use the new "recommended" way on Vista to make Chrome default |
| 607 // browser. | 610 // browser. |
| 608 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { | 611 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { |
| 609 LOG(INFO) << "Registering Chrome as default browser on Vista."; | 612 LOG(INFO) << "Registering Chrome as default browser on Vista."; |
| 610 IApplicationAssociationRegistration* pAAR; | 613 IApplicationAssociationRegistration* pAAR; |
| 611 HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration, | 614 HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration, |
| 612 NULL, CLSCTX_INPROC, __uuidof(IApplicationAssociationRegistration), | 615 NULL, CLSCTX_INPROC, __uuidof(IApplicationAssociationRegistration), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 | 653 |
| 651 // Send Windows notification event so that it can update icons for | 654 // Send Windows notification event so that it can update icons for |
| 652 // file associations. | 655 // file associations. |
| 653 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); | 656 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); |
| 654 return ret; | 657 return ret; |
| 655 } | 658 } |
| 656 | 659 |
| 657 bool ShellUtil::RegisterChromeBrowser(const std::wstring& chrome_exe, | 660 bool ShellUtil::RegisterChromeBrowser(const std::wstring& chrome_exe, |
| 658 const std::wstring& unique_suffix, | 661 const std::wstring& unique_suffix, |
| 659 bool elevate_if_not_admin) { | 662 bool elevate_if_not_admin) { |
| 663 if (!BrowserDistribution::GetDistribution()->CanSetAsDefault()) |
| 664 return false; |
| 665 |
| 660 // First figure out we need to append a suffix to the registry entries to | 666 // First figure out we need to append a suffix to the registry entries to |
| 661 // make them unique. | 667 // make them unique. |
| 662 std::wstring suffix; | 668 std::wstring suffix; |
| 663 if (!unique_suffix.empty()) { | 669 if (!unique_suffix.empty()) { |
| 664 suffix = unique_suffix; | 670 suffix = unique_suffix; |
| 665 } else if (InstallUtil::IsPerUserInstall(chrome_exe.c_str()) && | 671 } else if (InstallUtil::IsPerUserInstall(chrome_exe.c_str()) && |
| 666 !GetUserSpecificDefaultBrowserSuffix(&suffix) && | 672 !GetUserSpecificDefaultBrowserSuffix(&suffix) && |
| 667 !AnotherUserHasDefaultBrowser(chrome_exe)) { | 673 !AnotherUserHasDefaultBrowser(chrome_exe)) { |
| 668 suffix = L""; | 674 suffix = L""; |
| 669 } | 675 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 return file_util::UpdateShortcutLink(chrome_exe.c_str(), // target | 787 return file_util::UpdateShortcutLink(chrome_exe.c_str(), // target |
| 782 shortcut.c_str(), // shortcut | 788 shortcut.c_str(), // shortcut |
| 783 chrome_path.c_str(), // working dir | 789 chrome_path.c_str(), // working dir |
| 784 NULL, // arguments | 790 NULL, // arguments |
| 785 description.c_str(), // description | 791 description.c_str(), // description |
| 786 chrome_exe.c_str(), // icon file | 792 chrome_exe.c_str(), // icon file |
| 787 icon_index, // icon index | 793 icon_index, // icon index |
| 788 chrome::kBrowserAppID); // app id | 794 chrome::kBrowserAppID); // app id |
| 789 } | 795 } |
| 790 } | 796 } |
| OLD | NEW |