| 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 // 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 <windows.h> | 10 #include <windows.h> |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol"; | 392 const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol"; |
| 393 | 393 |
| 394 const wchar_t* ShellUtil::kChromeExtProgId = L"ChromeExt"; | 394 const wchar_t* ShellUtil::kChromeExtProgId = L"ChromeExt"; |
| 395 const wchar_t* ShellUtil::kChromeExtProgIdDesc = L"Chrome Extension Installer"; | 395 const wchar_t* ShellUtil::kChromeExtProgIdDesc = L"Chrome Extension Installer"; |
| 396 | 396 |
| 397 ShellUtil::RegisterStatus ShellUtil::AddChromeToSetAccessDefaults( | 397 ShellUtil::RegisterStatus ShellUtil::AddChromeToSetAccessDefaults( |
| 398 const std::wstring& chrome_exe, bool skip_if_not_admin) { | 398 const std::wstring& chrome_exe, bool skip_if_not_admin) { |
| 399 if (IsChromeRegistered(chrome_exe)) | 399 if (IsChromeRegistered(chrome_exe)) |
| 400 return ShellUtil::SUCCESS; | 400 return ShellUtil::SUCCESS; |
| 401 | 401 |
| 402 if (win_util::GetWinVersion() == win_util::WINVERSION_VISTA) | 402 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) |
| 403 return RegisterOnVista(chrome_exe, skip_if_not_admin); | 403 return RegisterOnVista(chrome_exe, skip_if_not_admin); |
| 404 | 404 |
| 405 // Try adding these entries to HKLM first and if that fails try adding | 405 // Try adding these entries to HKLM first and if that fails try adding |
| 406 // to HKCU. | 406 // to HKCU. |
| 407 if (SetAccessDefaultRegEntries(HKEY_LOCAL_MACHINE, chrome_exe)) | 407 if (SetAccessDefaultRegEntries(HKEY_LOCAL_MACHINE, chrome_exe)) |
| 408 return ShellUtil::SUCCESS; | 408 return ShellUtil::SUCCESS; |
| 409 | 409 |
| 410 if (!skip_if_not_admin && | 410 if (!skip_if_not_admin && |
| 411 SetAccessDefaultRegEntries(HKEY_CURRENT_USER, chrome_exe)) | 411 SetAccessDefaultRegEntries(HKEY_CURRENT_USER, chrome_exe)) |
| 412 return ShellUtil::REGISTERED_PER_USER; | 412 return ShellUtil::REGISTERED_PER_USER; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 // We are accessing GetDefaultUserProfileDirectory this way so that we do | 455 // We are accessing GetDefaultUserProfileDirectory this way so that we do |
| 456 // not have to declare dependency to Userenv.lib for chrome.exe | 456 // not have to declare dependency to Userenv.lib for chrome.exe |
| 457 typedef BOOL (WINAPI *PROFILE_FUNC)(LPWSTR, LPDWORD); | 457 typedef BOOL (WINAPI *PROFILE_FUNC)(LPWSTR, LPDWORD); |
| 458 HMODULE module = LoadLibrary(L"Userenv.dll"); | 458 HMODULE module = LoadLibrary(L"Userenv.dll"); |
| 459 PROFILE_FUNC p = reinterpret_cast<PROFILE_FUNC>(GetProcAddress(module, | 459 PROFILE_FUNC p = reinterpret_cast<PROFILE_FUNC>(GetProcAddress(module, |
| 460 "GetDefaultUserProfileDirectoryW")); | 460 "GetDefaultUserProfileDirectoryW")); |
| 461 DWORD size = _countof(qlaunch); | 461 DWORD size = _countof(qlaunch); |
| 462 if ((p == NULL) || ((p)(qlaunch, &size) != TRUE)) | 462 if ((p == NULL) || ((p)(qlaunch, &size) != TRUE)) |
| 463 return false; | 463 return false; |
| 464 *path = qlaunch; | 464 *path = qlaunch; |
| 465 if (win_util::GetWinVersion() == win_util::WINVERSION_VISTA) { | 465 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { |
| 466 file_util::AppendToPath(path, L"AppData\\Roaming"); | 466 file_util::AppendToPath(path, L"AppData\\Roaming"); |
| 467 } else { | 467 } else { |
| 468 file_util::AppendToPath(path, L"Application Data"); | 468 file_util::AppendToPath(path, L"Application Data"); |
| 469 } | 469 } |
| 470 } else { | 470 } else { |
| 471 if (FAILED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, | 471 if (FAILED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, |
| 472 SHGFP_TYPE_CURRENT, qlaunch))) | 472 SHGFP_TYPE_CURRENT, qlaunch))) |
| 473 return false; | 473 return false; |
| 474 *path = qlaunch; | 474 *path = qlaunch; |
| 475 } | 475 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 } | 544 } |
| 545 | 545 |
| 546 return ret; | 546 return ret; |
| 547 } | 547 } |
| 548 | 548 |
| 549 bool ShellUtil::MakeChromeDefault(int shell_change, | 549 bool ShellUtil::MakeChromeDefault(int shell_change, |
| 550 const std::wstring chrome_exe) { | 550 const std::wstring chrome_exe) { |
| 551 bool ret = true; | 551 bool ret = true; |
| 552 // First use the new "recommended" way on Vista to make Chrome default | 552 // First use the new "recommended" way on Vista to make Chrome default |
| 553 // browser. | 553 // browser. |
| 554 if (win_util::GetWinVersion() == win_util::WINVERSION_VISTA) { | 554 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { |
| 555 LOG(INFO) << "Registering Chrome as default browser on Vista."; | 555 LOG(INFO) << "Registering Chrome as default browser on Vista."; |
| 556 IApplicationAssociationRegistration* pAAR; | 556 IApplicationAssociationRegistration* pAAR; |
| 557 HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration, | 557 HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration, |
| 558 NULL, CLSCTX_INPROC, __uuidof(IApplicationAssociationRegistration), | 558 NULL, CLSCTX_INPROC, __uuidof(IApplicationAssociationRegistration), |
| 559 (void**)&pAAR); | 559 (void**)&pAAR); |
| 560 if (SUCCEEDED(hr)) { | 560 if (SUCCEEDED(hr)) { |
| 561 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 561 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 562 hr = pAAR->SetAppAsDefaultAll(dist->GetApplicationName().c_str()); | 562 hr = pAAR->SetAppAsDefaultAll(dist->GetApplicationName().c_str()); |
| 563 pAAR->Release(); | 563 pAAR->Release(); |
| 564 } | 564 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 return file_util::UpdateShortcutLink(chrome_exe.c_str(), // target | 663 return file_util::UpdateShortcutLink(chrome_exe.c_str(), // target |
| 664 shortcut.c_str(), // shortcut | 664 shortcut.c_str(), // shortcut |
| 665 chrome_path.c_str(), // working dir | 665 chrome_path.c_str(), // working dir |
| 666 NULL, // arguments | 666 NULL, // arguments |
| 667 NULL, // description | 667 NULL, // description |
| 668 chrome_exe.c_str(), // icon file | 668 chrome_exe.c_str(), // icon file |
| 669 0); // icon index | 669 0); // icon index |
| 670 } | 670 } |
| 671 } | 671 } |
| 672 | 672 |
| OLD | NEW |