| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include <windows.h> | 5 #include <windows.h> |
| 6 #include <shlobj.h> | 6 #include <shlobj.h> |
| 7 #include <shobjidl.h> | 7 #include <shobjidl.h> |
| 8 | 8 |
| 9 #include "chrome/browser/shell_integration.h" | 9 #include "chrome/browser/shell_integration.h" |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // type handlers and icons as having changed the default browser status, | 62 // type handlers and icons as having changed the default browser status, |
| 63 // since the user may have changed their shell settings to cause HTML files | 63 // since the user may have changed their shell settings to cause HTML files |
| 64 // to open with a text editor for example. We also don't want to aggressively | 64 // to open with a text editor for example. We also don't want to aggressively |
| 65 // claim FTP, since the user may have a separate FTP client. It is an open | 65 // claim FTP, since the user may have a separate FTP client. It is an open |
| 66 // question as to how to "heal" these settings. Perhaps the user should just | 66 // question as to how to "heal" these settings. Perhaps the user should just |
| 67 // re-run the installer or run with the --set-default-browser command line | 67 // re-run the installer or run with the --set-default-browser command line |
| 68 // flag. There is doubtless some other key we can hook into to cause "Repair" | 68 // flag. There is doubtless some other key we can hook into to cause "Repair" |
| 69 // to show up in Add/Remove programs for us. | 69 // to show up in Add/Remove programs for us. |
| 70 const std::wstring kChromeProtocols[] = {L"http", L"https"}; | 70 const std::wstring kChromeProtocols[] = {L"http", L"https"}; |
| 71 | 71 |
| 72 if (win_util::GetWinVersion() == win_util::WINVERSION_VISTA) { | 72 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { |
| 73 IApplicationAssociationRegistration* pAAR; | 73 IApplicationAssociationRegistration* pAAR; |
| 74 HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration, | 74 HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration, |
| 75 NULL, CLSCTX_INPROC, __uuidof(IApplicationAssociationRegistration), | 75 NULL, CLSCTX_INPROC, __uuidof(IApplicationAssociationRegistration), |
| 76 (void**)&pAAR); | 76 (void**)&pAAR); |
| 77 if (!SUCCEEDED(hr)) | 77 if (!SUCCEEDED(hr)) |
| 78 return false; | 78 return false; |
| 79 | 79 |
| 80 for (int i = 0; i < _countof(kChromeProtocols); i++) { | 80 for (int i = 0; i < _countof(kChromeProtocols); i++) { |
| 81 BOOL result = TRUE; | 81 BOOL result = TRUE; |
| 82 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 82 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // registry on XP and Vista: | 123 // registry on XP and Vista: |
| 124 // - HKCR\http\shell\open\command (XP) | 124 // - HKCR\http\shell\open\command (XP) |
| 125 // - HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ | 125 // - HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ |
| 126 // http\UserChoice (Vista) | 126 // http\UserChoice (Vista) |
| 127 // This method checks if Firefox is defualt browser by checking these | 127 // This method checks if Firefox is defualt browser by checking these |
| 128 // locations and returns true if Firefox traces are found there. In case of | 128 // locations and returns true if Firefox traces are found there. In case of |
| 129 // error (or if Firefox is not found)it returns the default value which | 129 // error (or if Firefox is not found)it returns the default value which |
| 130 // is false. | 130 // is false. |
| 131 bool ShellIntegration::IsFirefoxDefaultBrowser() { | 131 bool ShellIntegration::IsFirefoxDefaultBrowser() { |
| 132 bool ff_default = false; | 132 bool ff_default = false; |
| 133 if (win_util::GetWinVersion() == win_util::WINVERSION_VISTA) { | 133 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { |
| 134 std::wstring app_cmd; | 134 std::wstring app_cmd; |
| 135 RegKey key(HKEY_CURRENT_USER, ShellUtil::kRegVistaUrlPrefs, KEY_READ); | 135 RegKey key(HKEY_CURRENT_USER, ShellUtil::kRegVistaUrlPrefs, KEY_READ); |
| 136 if (key.Valid() && key.ReadValue(L"Progid", &app_cmd) && | 136 if (key.Valid() && key.ReadValue(L"Progid", &app_cmd) && |
| 137 app_cmd == L"FirefoxURL") | 137 app_cmd == L"FirefoxURL") |
| 138 ff_default = true; | 138 ff_default = true; |
| 139 } else { | 139 } else { |
| 140 std::wstring key_path(L"http"); | 140 std::wstring key_path(L"http"); |
| 141 key_path.append(ShellUtil::kRegShellOpen); | 141 key_path.append(ShellUtil::kRegShellOpen); |
| 142 RegKey key(HKEY_CLASSES_ROOT, key_path.c_str(), KEY_READ); | 142 RegKey key(HKEY_CLASSES_ROOT, key_path.c_str(), KEY_READ); |
| 143 std::wstring app_cmd; | 143 std::wstring app_cmd; |
| 144 if (key.Valid() && key.ReadValue(L"", &app_cmd) && | 144 if (key.Valid() && key.ReadValue(L"", &app_cmd) && |
| 145 std::wstring::npos != StringToLowerASCII(app_cmd).find(L"firefox")) | 145 std::wstring::npos != StringToLowerASCII(app_cmd).find(L"firefox")) |
| 146 ff_default = true; | 146 ff_default = true; |
| 147 } | 147 } |
| 148 return ff_default; | 148 return ff_default; |
| 149 } | 149 } |
| 150 | 150 |
| OLD | NEW |