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> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/registry.h" | |
17 #include "base/scoped_comptr_win.h" | 16 #include "base/scoped_comptr_win.h" |
18 #include "base/string_util.h" | 17 #include "base/string_util.h" |
19 #include "base/task.h" | 18 #include "base/task.h" |
20 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
21 #include "base/win_util.h" | 20 #include "base/win_util.h" |
| 21 #include "base/win/registry.h" |
22 #include "base/win/windows_version.h" | 22 #include "base/win/windows_version.h" |
23 #include "chrome/browser/browser_thread.h" | 23 #include "chrome/browser/browser_thread.h" |
24 #include "chrome/browser/web_applications/web_app.h" | 24 #include "chrome/browser/web_applications/web_app.h" |
25 #include "chrome/common/chrome_constants.h" | 25 #include "chrome/common/chrome_constants.h" |
26 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
27 #include "chrome/common/chrome_paths_internal.h" | 27 #include "chrome/common/chrome_paths_internal.h" |
28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
29 #include "chrome/installer/util/browser_distribution.h" | 29 #include "chrome/installer/util/browser_distribution.h" |
30 #include "chrome/installer/util/create_reg_key_work_item.h" | 30 #include "chrome/installer/util/create_reg_key_work_item.h" |
31 #include "chrome/installer/util/set_reg_value_work_item.h" | 31 #include "chrome/installer/util/set_reg_value_work_item.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 GetShortPathName(app_path.c_str(), WriteInto(&short_app_path, MAX_PATH), | 333 GetShortPathName(app_path.c_str(), WriteInto(&short_app_path, MAX_PATH), |
334 MAX_PATH); | 334 MAX_PATH); |
335 | 335 |
336 // open command for protocol associations | 336 // open command for protocol associations |
337 for (int i = 0; i < _countof(kChromeProtocols); i++) { | 337 for (int i = 0; i < _countof(kChromeProtocols); i++) { |
338 // Check in HKEY_CLASSES_ROOT that is the result of merge between | 338 // Check in HKEY_CLASSES_ROOT that is the result of merge between |
339 // HKLM and HKCU | 339 // HKLM and HKCU |
340 HKEY root_key = HKEY_CLASSES_ROOT; | 340 HKEY root_key = HKEY_CLASSES_ROOT; |
341 // Check <protocol>\shell\open\command | 341 // Check <protocol>\shell\open\command |
342 std::wstring key_path(kChromeProtocols[i] + ShellUtil::kRegShellOpen); | 342 std::wstring key_path(kChromeProtocols[i] + ShellUtil::kRegShellOpen); |
343 RegKey key(root_key, key_path.c_str(), KEY_READ); | 343 base::win::RegKey key(root_key, key_path.c_str(), KEY_READ); |
344 std::wstring value; | 344 std::wstring value; |
345 if (!key.Valid() || !key.ReadValue(L"", &value)) | 345 if (!key.Valid() || !key.ReadValue(L"", &value)) |
346 return NOT_DEFAULT_BROWSER; | 346 return NOT_DEFAULT_BROWSER; |
347 // Need to normalize path in case it's been munged. | 347 // Need to normalize path in case it's been munged. |
348 CommandLine command_line = CommandLine::FromString(value); | 348 CommandLine command_line = CommandLine::FromString(value); |
349 std::wstring short_path; | 349 std::wstring short_path; |
350 GetShortPathName(command_line.GetProgram().value().c_str(), | 350 GetShortPathName(command_line.GetProgram().value().c_str(), |
351 WriteInto(&short_path, MAX_PATH), MAX_PATH); | 351 WriteInto(&short_path, MAX_PATH), MAX_PATH); |
352 if (!FilePath::CompareEqualIgnoreCase(short_path, short_app_path)) | 352 if (!FilePath::CompareEqualIgnoreCase(short_path, short_app_path)) |
353 return NOT_DEFAULT_BROWSER; | 353 return NOT_DEFAULT_BROWSER; |
(...skipping 10 matching lines...) Expand all Loading... |
364 // - HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ | 364 // - HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ |
365 // http\UserChoice (Vista) | 365 // http\UserChoice (Vista) |
366 // This method checks if Firefox is defualt browser by checking these | 366 // This method checks if Firefox is defualt browser by checking these |
367 // locations and returns true if Firefox traces are found there. In case of | 367 // locations and returns true if Firefox traces are found there. In case of |
368 // error (or if Firefox is not found)it returns the default value which | 368 // error (or if Firefox is not found)it returns the default value which |
369 // is false. | 369 // is false. |
370 bool ShellIntegration::IsFirefoxDefaultBrowser() { | 370 bool ShellIntegration::IsFirefoxDefaultBrowser() { |
371 bool ff_default = false; | 371 bool ff_default = false; |
372 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | 372 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
373 std::wstring app_cmd; | 373 std::wstring app_cmd; |
374 RegKey key(HKEY_CURRENT_USER, ShellUtil::kRegVistaUrlPrefs, KEY_READ); | 374 base::win::RegKey key(HKEY_CURRENT_USER, |
| 375 ShellUtil::kRegVistaUrlPrefs, KEY_READ); |
375 if (key.Valid() && key.ReadValue(L"Progid", &app_cmd) && | 376 if (key.Valid() && key.ReadValue(L"Progid", &app_cmd) && |
376 app_cmd == L"FirefoxURL") | 377 app_cmd == L"FirefoxURL") |
377 ff_default = true; | 378 ff_default = true; |
378 } else { | 379 } else { |
379 std::wstring key_path(L"http"); | 380 std::wstring key_path(L"http"); |
380 key_path.append(ShellUtil::kRegShellOpen); | 381 key_path.append(ShellUtil::kRegShellOpen); |
381 RegKey key(HKEY_CLASSES_ROOT, key_path.c_str(), KEY_READ); | 382 base::win::RegKey key(HKEY_CLASSES_ROOT, key_path.c_str(), KEY_READ); |
382 std::wstring app_cmd; | 383 std::wstring app_cmd; |
383 if (key.Valid() && key.ReadValue(L"", &app_cmd) && | 384 if (key.Valid() && key.ReadValue(L"", &app_cmd) && |
384 std::wstring::npos != StringToLowerASCII(app_cmd).find(L"firefox")) | 385 std::wstring::npos != StringToLowerASCII(app_cmd).find(L"firefox")) |
385 ff_default = true; | 386 ff_default = true; |
386 } | 387 } |
387 return ff_default; | 388 return ff_default; |
388 } | 389 } |
389 | 390 |
390 std::wstring ShellIntegration::GetAppId(const std::wstring& app_name, | 391 std::wstring ShellIntegration::GetAppId(const std::wstring& app_name, |
391 const FilePath& profile_path) { | 392 const FilePath& profile_path) { |
(...skipping 15 matching lines...) Expand all Loading... |
407 profile_path); | 408 profile_path); |
408 } | 409 } |
409 | 410 |
410 void ShellIntegration::MigrateChromiumShortcuts() { | 411 void ShellIntegration::MigrateChromiumShortcuts() { |
411 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 412 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
412 return; | 413 return; |
413 | 414 |
414 BrowserThread::PostTask( | 415 BrowserThread::PostTask( |
415 BrowserThread::FILE, FROM_HERE, new MigrateChromiumShortcutsTask()); | 416 BrowserThread::FILE, FROM_HERE, new MigrateChromiumShortcutsTask()); |
416 } | 417 } |
OLD | NEW |