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 #include "chrome/browser/shell_integration.h" | 5 #include "chrome/browser/shell_integration.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 #include <shobjidl.h> | 9 #include <shobjidl.h> |
10 | 10 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 std::wstring key_path(kChromeProtocols[i] + ShellUtil::kRegShellOpen); | 108 std::wstring key_path(kChromeProtocols[i] + ShellUtil::kRegShellOpen); |
109 RegKey key(root_key, key_path.c_str(), KEY_READ); | 109 RegKey key(root_key, key_path.c_str(), KEY_READ); |
110 std::wstring value; | 110 std::wstring value; |
111 if (!key.Valid() || !key.ReadValue(L"", &value)) | 111 if (!key.Valid() || !key.ReadValue(L"", &value)) |
112 return UNKNOWN_DEFAULT_BROWSER; | 112 return UNKNOWN_DEFAULT_BROWSER; |
113 // Need to normalize path in case it's been munged. | 113 // Need to normalize path in case it's been munged. |
114 CommandLine command_line = CommandLine::FromString(value); | 114 CommandLine command_line = CommandLine::FromString(value); |
115 std::wstring short_path; | 115 std::wstring short_path; |
116 GetShortPathName(command_line.program().c_str(), | 116 GetShortPathName(command_line.program().c_str(), |
117 WriteInto(&short_path, MAX_PATH), MAX_PATH); | 117 WriteInto(&short_path, MAX_PATH), MAX_PATH); |
118 if ((short_path.size() != short_app_path.size()) || | 118 if (!FilePath::CompareEqualIgnoreCase(short_path, short_app_path)) |
119 (!std::equal(short_path.begin(), | |
120 short_path.end(), | |
121 short_app_path.begin(), | |
122 CaseInsensitiveCompare<wchar_t>()))) | |
123 return NOT_DEFAULT_BROWSER; | 119 return NOT_DEFAULT_BROWSER; |
124 } | 120 } |
125 } | 121 } |
126 return IS_DEFAULT_BROWSER; | 122 return IS_DEFAULT_BROWSER; |
127 } | 123 } |
128 | 124 |
129 // There is no reliable way to say which browser is default on a machine (each | 125 // There is no reliable way to say which browser is default on a machine (each |
130 // browser can have some of the protocols/shortcuts). So we look for only HTTP | 126 // browser can have some of the protocols/shortcuts). So we look for only HTTP |
131 // protocol handler. Even this handler is located at different places in | 127 // protocol handler. Even this handler is located at different places in |
132 // registry on XP and Vista: | 128 // registry on XP and Vista: |
(...skipping 16 matching lines...) Expand all Loading... |
149 std::wstring key_path(L"http"); | 145 std::wstring key_path(L"http"); |
150 key_path.append(ShellUtil::kRegShellOpen); | 146 key_path.append(ShellUtil::kRegShellOpen); |
151 RegKey key(HKEY_CLASSES_ROOT, key_path.c_str(), KEY_READ); | 147 RegKey key(HKEY_CLASSES_ROOT, key_path.c_str(), KEY_READ); |
152 std::wstring app_cmd; | 148 std::wstring app_cmd; |
153 if (key.Valid() && key.ReadValue(L"", &app_cmd) && | 149 if (key.Valid() && key.ReadValue(L"", &app_cmd) && |
154 std::wstring::npos != StringToLowerASCII(app_cmd).find(L"firefox")) | 150 std::wstring::npos != StringToLowerASCII(app_cmd).find(L"firefox")) |
155 ff_default = true; | 151 ff_default = true; |
156 } | 152 } |
157 return ff_default; | 153 return ff_default; |
158 } | 154 } |
OLD | NEW |