| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <shlwapi.h> | 8 #include <shlwapi.h> |
| 9 #include <shobjidl.h> | 9 #include <shobjidl.h> |
| 10 #include <propkey.h> // Needs to come after shobjidl.h. | 10 #include <propkey.h> // Needs to come after shobjidl.h. |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 void ResetDefaultBrowser() { | 254 void ResetDefaultBrowser() { |
| 255 static const wchar_t* const kUrlAssociationKeyFormats[] = { | 255 static const wchar_t* const kUrlAssociationKeyFormats[] = { |
| 256 L"SOFTWARE\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\" | 256 L"SOFTWARE\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\" |
| 257 L"%ls\\UserChoice", | 257 L"%ls\\UserChoice", |
| 258 L"SOFTWARE\\Microsoft\\Windows\\Roaming\\OpenWith\\UrlAssociations\\" | 258 L"SOFTWARE\\Microsoft\\Windows\\Roaming\\OpenWith\\UrlAssociations\\" |
| 259 L"%ls\\UserChoice"}; | 259 L"%ls\\UserChoice"}; |
| 260 static const wchar_t* const kProtocols[] = {L"http", L"https"}; | 260 static const wchar_t* const kProtocols[] = {L"http", L"https"}; |
| 261 | 261 |
| 262 for (const wchar_t* format : kUrlAssociationKeyFormats) { | 262 for (const wchar_t* format : kUrlAssociationKeyFormats) { |
| 263 for (const wchar_t* protocol : kProtocols) { | 263 for (const wchar_t* protocol : kProtocols) { |
| 264 base::win::RegKey registry_key( | 264 (void)format; |
| 265 (void)protocol; |
| 266 /*base::win::RegKey registry_key( |
| 265 HKEY_CURRENT_USER, base::StringPrintf(format, protocol).c_str(), | 267 HKEY_CURRENT_USER, base::StringPrintf(format, protocol).c_str(), |
| 266 KEY_SET_VALUE); | 268 KEY_SET_VALUE); |
| 267 registry_key.DeleteValue(L"Hash"); | 269 registry_key.DeleteValue(L"Hash");*/ |
| 268 } | 270 } |
| 269 } | 271 } |
| 270 } | 272 } |
| 271 | 273 |
| 272 // Returns true if the AsyncSetAsDefault field trial is activated. | 274 // Returns true if the AsyncSetAsDefault field trial is activated. |
| 273 bool IsAsyncSetAsDefaultEnabled() { | 275 bool IsAsyncSetAsDefaultEnabled() { |
| 274 using base::CommandLine; | 276 using base::CommandLine; |
| 275 | 277 |
| 276 // Note: It's important to query the field trial state first, to ensure that | 278 // Note: It's important to query the field trial state first, to ensure that |
| 277 // UMA reports the correct group. | 279 // UMA reports the correct group. |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 base::win::ScopedPropVariant propvariant; | 508 base::win::ScopedPropVariant propvariant; |
| 507 for (base::FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty(); | 509 for (base::FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty(); |
| 508 shortcut = shortcuts_enum.Next()) { | 510 shortcut = shortcuts_enum.Next()) { |
| 509 // TODO(gab): Use ProgramCompare instead of comparing FilePaths below once | 511 // TODO(gab): Use ProgramCompare instead of comparing FilePaths below once |
| 510 // it is fixed to work with FilePaths with spaces. | 512 // it is fixed to work with FilePaths with spaces. |
| 511 if (!base::win::ResolveShortcut(shortcut, &target_path, &arguments) || | 513 if (!base::win::ResolveShortcut(shortcut, &target_path, &arguments) || |
| 512 chrome_exe != target_path) { | 514 chrome_exe != target_path) { |
| 513 continue; | 515 continue; |
| 514 } | 516 } |
| 515 base::CommandLine command_line( | 517 base::CommandLine command_line( |
| 516 base::CommandLine::FromString(base::StringPrintf( | 518 base::CommandLine::FromString(L""/*base::StringPrintf( |
| 517 L"\"%ls\" %ls", target_path.value().c_str(), arguments.c_str()))); | 519 L"\"%ls\" %ls", target_path.value().c_str(), arguments.c_str())*/)); |
| 518 | 520 |
| 519 // Get the expected AppId for this Chrome shortcut. | 521 // Get the expected AppId for this Chrome shortcut. |
| 520 base::string16 expected_app_id( | 522 base::string16 expected_app_id( |
| 521 GetExpectedAppId(command_line, is_per_user_install)); | 523 GetExpectedAppId(command_line, is_per_user_install)); |
| 522 if (expected_app_id.empty()) | 524 if (expected_app_id.empty()) |
| 523 continue; | 525 continue; |
| 524 | 526 |
| 525 // Load the shortcut. | 527 // Load the shortcut. |
| 526 base::win::ScopedComPtr<IShellLink> shell_link; | 528 base::win::ScopedComPtr<IShellLink> shell_link; |
| 527 base::win::ScopedComPtr<IPersistFile> persist_file; | 529 base::win::ScopedComPtr<IPersistFile> persist_file; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 // static | 706 // static |
| 705 bool ShellIntegration::DefaultBrowserWorker::SetAsDefaultBrowserAsynchronous() { | 707 bool ShellIntegration::DefaultBrowserWorker::SetAsDefaultBrowserAsynchronous() { |
| 706 DCHECK(IsSetAsDefaultAsynchronous()); | 708 DCHECK(IsSetAsDefaultAsynchronous()); |
| 707 | 709 |
| 708 ResetDefaultBrowser(); | 710 ResetDefaultBrowser(); |
| 709 | 711 |
| 710 base::CommandLine cmdline(base::FilePath(L"openwith.exe")); | 712 base::CommandLine cmdline(base::FilePath(L"openwith.exe")); |
| 711 cmdline.AppendArgNative(StartupBrowserCreator::GetDefaultBrowserUrl()); | 713 cmdline.AppendArgNative(StartupBrowserCreator::GetDefaultBrowserUrl()); |
| 712 return base::LaunchProcess(cmdline, base::LaunchOptions()).IsValid(); | 714 return base::LaunchProcess(cmdline, base::LaunchOptions()).IsValid(); |
| 713 } | 715 } |
| OLD | NEW |