| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/safe_browsing/srt_global_error_win.h" | 5 #include "chrome/browser/safe_browsing/srt_global_error_win.h" |
| 6 | 6 |
| 7 #include "base/base_paths.h" |
| 7 #include "base/bind.h" | 8 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 10 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 13 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 14 #include "base/process/launch.h" | 15 #include "base/process/launch.h" |
| 15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 45 // downloaded or run. | 46 // downloaded or run. |
| 46 const char kSRTDownloadURL[] = | 47 const char kSRTDownloadURL[] = |
| 47 "https://www.google.com/chrome/srt/?chrome-prompt=1"; | 48 "https://www.google.com/chrome/srt/?chrome-prompt=1"; |
| 48 | 49 |
| 49 // The extension to use to replace the temporary one created when the SRT was | 50 // The extension to use to replace the temporary one created when the SRT was |
| 50 // downloaded. | 51 // downloaded. |
| 51 const base::FilePath::CharType kExecutableExtension[] = L"exe"; | 52 const base::FilePath::CharType kExecutableExtension[] = L"exe"; |
| 52 | 53 |
| 53 // A switch to add to the command line when executing the SRT. | 54 // A switch to add to the command line when executing the SRT. |
| 54 const char kChromePromptSwitch[] = "chrome-prompt"; | 55 const char kChromePromptSwitch[] = "chrome-prompt"; |
| 56 const char kChromeExePathSwitch[] = "chrome-exe-path"; |
| 55 const char kChromeSystemInstallSwitch[] = "chrome-system-install"; | 57 const char kChromeSystemInstallSwitch[] = "chrome-system-install"; |
| 56 const char kUmaUserSwitch[] = "uma-user"; | 58 const char kUmaUserSwitch[] = "uma-user"; |
| 57 | 59 |
| 58 void MaybeExecuteSRTFromBlockingPool( | 60 void MaybeExecuteSRTFromBlockingPool( |
| 59 const base::FilePath& downloaded_path, | 61 const base::FilePath& downloaded_path, |
| 60 bool metrics_enabled, | 62 bool metrics_enabled, |
| 61 const scoped_refptr<SingleThreadTaskRunner>& task_runner, | 63 const scoped_refptr<SingleThreadTaskRunner>& task_runner, |
| 62 const base::Closure& success_callback, | 64 const base::Closure& success_callback, |
| 63 const base::Closure& failure_callback) { | 65 const base::Closure& failure_callback) { |
| 64 DCHECK(!downloaded_path.empty()); | 66 DCHECK(!downloaded_path.empty()); |
| 65 | 67 |
| 66 if (base::PathExists(downloaded_path)) { | 68 if (base::PathExists(downloaded_path)) { |
| 67 base::FilePath executable_path( | 69 base::FilePath executable_path( |
| 68 downloaded_path.ReplaceExtension(kExecutableExtension)); | 70 downloaded_path.ReplaceExtension(kExecutableExtension)); |
| 69 if (base::ReplaceFile(downloaded_path, executable_path, nullptr)) { | 71 if (base::ReplaceFile(downloaded_path, executable_path, nullptr)) { |
| 70 base::CommandLine srt_command_line(executable_path); | 72 base::CommandLine srt_command_line(executable_path); |
| 71 srt_command_line.AppendSwitch(kChromePromptSwitch); | 73 srt_command_line.AppendSwitch(kChromePromptSwitch); |
| 72 srt_command_line.AppendSwitchASCII(kChromeVersionSwitch, | 74 srt_command_line.AppendSwitchASCII(kChromeVersionSwitch, |
| 73 version_info::GetVersionNumber()); | 75 version_info::GetVersionNumber()); |
| 74 srt_command_line.AppendSwitchASCII(kChromeChannelSwitch, | 76 srt_command_line.AppendSwitchASCII(kChromeChannelSwitch, |
| 75 base::IntToString(ChannelAsInt())); | 77 base::IntToString(ChannelAsInt())); |
| 76 | 78 |
| 77 base::FilePath chrome_exe_path; | 79 base::FilePath chrome_exe_path; |
| 78 PathService::Get(base::FILE_EXE, &chrome_exe_path); | 80 PathService::Get(base::FILE_EXE, &chrome_exe_path); |
| 81 srt_command_line.AppendSwitchPath(kChromeExePathSwitch, chrome_exe_path); |
| 79 if (!InstallUtil::IsPerUserInstall(chrome_exe_path)) | 82 if (!InstallUtil::IsPerUserInstall(chrome_exe_path)) |
| 80 srt_command_line.AppendSwitch(kChromeSystemInstallSwitch); | 83 srt_command_line.AppendSwitch(kChromeSystemInstallSwitch); |
| 81 | 84 |
| 82 if (metrics_enabled) { | 85 if (metrics_enabled) { |
| 83 srt_command_line.AppendSwitch(kUmaUserSwitch); | 86 srt_command_line.AppendSwitch(kUmaUserSwitch); |
| 84 srt_command_line.AppendSwitch(kEnableCrashReporting); | 87 srt_command_line.AppendSwitch(kEnableCrashReporting); |
| 85 } | 88 } |
| 86 | 89 |
| 87 base::Process srt_process( | 90 base::Process srt_process( |
| 88 base::LaunchProcess(srt_command_line, base::LaunchOptions())); | 91 base::LaunchProcess(srt_command_line, base::LaunchOptions())); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 void SRTGlobalError::OnUserinteractionDone() { | 255 void SRTGlobalError::OnUserinteractionDone() { |
| 253 DCHECK(interacted_); | 256 DCHECK(interacted_); |
| 254 // Once the user interacted with the bubble, we can forget about any pending | 257 // Once the user interacted with the bubble, we can forget about any pending |
| 255 // prompt. | 258 // prompt. |
| 256 g_browser_process->local_state()->SetBoolean(prefs::kSwReporterPendingPrompt, | 259 g_browser_process->local_state()->SetBoolean(prefs::kSwReporterPendingPrompt, |
| 257 false); | 260 false); |
| 258 delete this; | 261 delete this; |
| 259 } | 262 } |
| 260 | 263 |
| 261 } // namespace safe_browsing | 264 } // namespace safe_browsing |
| OLD | NEW |