Chromium Code Reviews| 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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 606 OPENASINFO open_as_info = {}; | 606 OPENASINFO open_as_info = {}; |
| 607 open_as_info.pcszFile = protocol; | 607 open_as_info.pcszFile = protocol; |
| 608 open_as_info.oaifInFlags = | 608 open_as_info.oaifInFlags = |
| 609 OAIF_URL_PROTOCOL | OAIF_FORCE_REGISTRATION | OAIF_REGISTER_EXT; | 609 OAIF_URL_PROTOCOL | OAIF_FORCE_REGISTRATION | OAIF_REGISTER_EXT; |
| 610 HRESULT hr = SHOpenWithDialog(NULL, &open_as_info); | 610 HRESULT hr = SHOpenWithDialog(NULL, &open_as_info); |
| 611 DLOG_IF(WARNING, FAILED(hr)) << "Failed to set as default " << protocol | 611 DLOG_IF(WARNING, FAILED(hr)) << "Failed to set as default " << protocol |
| 612 << " handler; hr=0x" << std::hex << hr; | 612 << " handler; hr=0x" << std::hex << hr; |
| 613 if (FAILED(hr)) | 613 if (FAILED(hr)) |
| 614 return false; | 614 return false; |
| 615 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); | 615 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); |
| 616 return true; | 616 return SUCCEEDED(hr); |
|
grt (UTC plus 2)
2012/06/21 15:18:43
SUCCEEDED(hr) -> true
motek.
2012/06/21 18:28:10
Done.
| |
| 617 } | 617 } |
| 618 | 618 |
| 619 // Launches the Windows 7 and Windows 8 application association dialog, which | 619 // Launches the Windows 7 and Windows 8 application association dialog, which |
| 620 // is the only documented way to make a browser the default browser on | 620 // is the only documented way to make a browser the default browser on |
| 621 // Windows 8. | 621 // Windows 8. |
| 622 bool LaunchApplicationAssociationDialog(const string16& app_id) { | 622 bool LaunchApplicationAssociationDialog(const string16& app_id) { |
| 623 base::win::ScopedComPtr<IApplicationAssociationRegistrationUI> aarui; | 623 base::win::ScopedComPtr<IApplicationAssociationRegistrationUI> aarui; |
| 624 HRESULT hr = aarui.CreateInstance(CLSID_ApplicationAssociationRegistrationUI); | 624 HRESULT hr = aarui.CreateInstance(CLSID_ApplicationAssociationRegistrationUI); |
| 625 if (FAILED(hr)) | 625 if (FAILED(hr)) |
| 626 return false; | 626 return false; |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1234 | 1234 |
| 1235 if (!RegisterChromeBrowser(dist, chrome_exe, string16(), true)) | 1235 if (!RegisterChromeBrowser(dist, chrome_exe, string16(), true)) |
| 1236 return false; | 1236 return false; |
| 1237 | 1237 |
| 1238 // On Windows 8, you can't set yourself as the default handler | 1238 // On Windows 8, you can't set yourself as the default handler |
| 1239 // programatically. In other words IApplicationAssociationRegistration | 1239 // programatically. In other words IApplicationAssociationRegistration |
| 1240 // has been rendered useless. What you can do is to launch | 1240 // has been rendered useless. What you can do is to launch |
| 1241 // "Set Program Associations" section of the "Default Programs" | 1241 // "Set Program Associations" section of the "Default Programs" |
| 1242 // control panel, which is a mess, or pop the concise "How you want to open | 1242 // control panel, which is a mess, or pop the concise "How you want to open |
| 1243 // webpages?" dialog. We choose the latter. | 1243 // webpages?" dialog. We choose the latter. |
| 1244 // Return true only when the user took an action and there was no error. | |
| 1244 return LaunchSelectDefaultProtocolHandlerDialog(L"http"); | 1245 return LaunchSelectDefaultProtocolHandlerDialog(L"http"); |
| 1245 } | 1246 } |
| 1246 | 1247 |
| 1247 bool ShellUtil::MakeChromeDefaultProtocolClient(BrowserDistribution* dist, | 1248 bool ShellUtil::MakeChromeDefaultProtocolClient(BrowserDistribution* dist, |
| 1248 const string16& chrome_exe, | 1249 const string16& chrome_exe, |
| 1249 const string16& protocol) { | 1250 const string16& protocol) { |
| 1250 if (!dist->CanSetAsDefault()) | 1251 if (!dist->CanSetAsDefault()) |
| 1251 return false; | 1252 return false; |
| 1252 | 1253 |
| 1253 ShellUtil::RegisterChromeForProtocol(dist, chrome_exe, L"", protocol, true); | 1254 ShellUtil::RegisterChromeForProtocol(dist, chrome_exe, L"", protocol, true); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1511 chrome_exe.c_str(), | 1512 chrome_exe.c_str(), |
| 1512 shortcut.c_str(), | 1513 shortcut.c_str(), |
| 1513 chrome_path.value().c_str(), | 1514 chrome_path.value().c_str(), |
| 1514 arguments.c_str(), | 1515 arguments.c_str(), |
| 1515 description.c_str(), | 1516 description.c_str(), |
| 1516 icon_path.c_str(), | 1517 icon_path.c_str(), |
| 1517 icon_index, | 1518 icon_index, |
| 1518 app_id.c_str(), | 1519 app_id.c_str(), |
| 1519 ConvertShellUtilShortcutOptionsToFileUtil(options)); | 1520 ConvertShellUtilShortcutOptionsToFileUtil(options)); |
| 1520 } | 1521 } |
| OLD | NEW |