OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <shobjidl.h> | 8 #include <shobjidl.h> |
9 #include <propkey.h> | 9 #include <propkey.h> |
10 #include <propvarutil.h> | 10 #include <propvarutil.h> |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 336 |
337 // open command for protocol associations | 337 // open command for protocol associations |
338 for (int i = 0; i < _countof(kChromeProtocols); i++) { | 338 for (int i = 0; i < _countof(kChromeProtocols); i++) { |
339 // Check in HKEY_CLASSES_ROOT that is the result of merge between | 339 // Check in HKEY_CLASSES_ROOT that is the result of merge between |
340 // HKLM and HKCU | 340 // HKLM and HKCU |
341 HKEY root_key = HKEY_CLASSES_ROOT; | 341 HKEY root_key = HKEY_CLASSES_ROOT; |
342 // Check <protocol>\shell\open\command | 342 // Check <protocol>\shell\open\command |
343 std::wstring key_path(kChromeProtocols[i] + ShellUtil::kRegShellOpen); | 343 std::wstring key_path(kChromeProtocols[i] + ShellUtil::kRegShellOpen); |
344 base::win::RegKey key(root_key, key_path.c_str(), KEY_READ); | 344 base::win::RegKey key(root_key, key_path.c_str(), KEY_READ); |
345 std::wstring value; | 345 std::wstring value; |
346 if (!key.Valid() || !key.ReadValue(L"", &value)) | 346 if (!key.Valid() || (key.ReadValue(L"", &value) != ERROR_SUCCESS)) |
347 return NOT_DEFAULT_BROWSER; | 347 return NOT_DEFAULT_BROWSER; |
348 // Need to normalize path in case it's been munged. | 348 // Need to normalize path in case it's been munged. |
349 CommandLine command_line = CommandLine::FromString(value); | 349 CommandLine command_line = CommandLine::FromString(value); |
350 std::wstring short_path; | 350 std::wstring short_path; |
351 GetShortPathName(command_line.GetProgram().value().c_str(), | 351 GetShortPathName(command_line.GetProgram().value().c_str(), |
352 WriteInto(&short_path, MAX_PATH), MAX_PATH); | 352 WriteInto(&short_path, MAX_PATH), MAX_PATH); |
353 if (!FilePath::CompareEqualIgnoreCase(short_path, short_app_path)) | 353 if (!FilePath::CompareEqualIgnoreCase(short_path, short_app_path)) |
354 return NOT_DEFAULT_BROWSER; | 354 return NOT_DEFAULT_BROWSER; |
355 } | 355 } |
356 } | 356 } |
(...skipping 10 matching lines...) Expand all Loading... |
367 // This method checks if Firefox is defualt browser by checking these | 367 // This method checks if Firefox is defualt browser by checking these |
368 // locations and returns true if Firefox traces are found there. In case of | 368 // locations and returns true if Firefox traces are found there. In case of |
369 // error (or if Firefox is not found)it returns the default value which | 369 // error (or if Firefox is not found)it returns the default value which |
370 // is false. | 370 // is false. |
371 bool ShellIntegration::IsFirefoxDefaultBrowser() { | 371 bool ShellIntegration::IsFirefoxDefaultBrowser() { |
372 bool ff_default = false; | 372 bool ff_default = false; |
373 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | 373 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
374 std::wstring app_cmd; | 374 std::wstring app_cmd; |
375 base::win::RegKey key(HKEY_CURRENT_USER, | 375 base::win::RegKey key(HKEY_CURRENT_USER, |
376 ShellUtil::kRegVistaUrlPrefs, KEY_READ); | 376 ShellUtil::kRegVistaUrlPrefs, KEY_READ); |
377 if (key.Valid() && key.ReadValue(L"Progid", &app_cmd) && | 377 if (key.Valid() && (key.ReadValue(L"Progid", &app_cmd) == ERROR_SUCCESS) && |
378 app_cmd == L"FirefoxURL") | 378 app_cmd == L"FirefoxURL") |
379 ff_default = true; | 379 ff_default = true; |
380 } else { | 380 } else { |
381 std::wstring key_path(L"http"); | 381 std::wstring key_path(L"http"); |
382 key_path.append(ShellUtil::kRegShellOpen); | 382 key_path.append(ShellUtil::kRegShellOpen); |
383 base::win::RegKey key(HKEY_CLASSES_ROOT, key_path.c_str(), KEY_READ); | 383 base::win::RegKey key(HKEY_CLASSES_ROOT, key_path.c_str(), KEY_READ); |
384 std::wstring app_cmd; | 384 std::wstring app_cmd; |
385 if (key.Valid() && key.ReadValue(L"", &app_cmd) && | 385 if (key.Valid() && (key.ReadValue(L"", &app_cmd) == ERROR_SUCCESS) && |
386 std::wstring::npos != StringToLowerASCII(app_cmd).find(L"firefox")) | 386 std::wstring::npos != StringToLowerASCII(app_cmd).find(L"firefox")) |
387 ff_default = true; | 387 ff_default = true; |
388 } | 388 } |
389 return ff_default; | 389 return ff_default; |
390 } | 390 } |
391 | 391 |
392 std::wstring ShellIntegration::GetAppId(const std::wstring& app_name, | 392 std::wstring ShellIntegration::GetAppId(const std::wstring& app_name, |
393 const FilePath& profile_path) { | 393 const FilePath& profile_path) { |
394 std::wstring app_id(app_name); | 394 std::wstring app_id(app_name); |
395 | 395 |
(...skipping 13 matching lines...) Expand all Loading... |
409 profile_path); | 409 profile_path); |
410 } | 410 } |
411 | 411 |
412 void ShellIntegration::MigrateChromiumShortcuts() { | 412 void ShellIntegration::MigrateChromiumShortcuts() { |
413 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 413 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
414 return; | 414 return; |
415 | 415 |
416 BrowserThread::PostTask( | 416 BrowserThread::PostTask( |
417 BrowserThread::FILE, FROM_HERE, new MigrateChromiumShortcutsTask()); | 417 BrowserThread::FILE, FROM_HERE, new MigrateChromiumShortcutsTask()); |
418 } | 418 } |
OLD | NEW |