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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/process/launch.h" | 14 #include "base/process/launch.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
18 #include "chrome/app/chrome_command_ids.h" | 18 #include "chrome/app/chrome_command_ids.h" |
19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 20 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 21 #include "chrome/browser/safe_browsing/srt_client_info_win.h" |
21 #include "chrome/browser/safe_browsing/srt_field_trial_win.h" | 22 #include "chrome/browser/safe_browsing/srt_field_trial_win.h" |
22 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
23 #include "chrome/browser/ui/browser_finder.h" | 24 #include "chrome/browser/ui/browser_finder.h" |
24 #include "chrome/browser/ui/global_error/global_error_service.h" | 25 #include "chrome/browser/ui/global_error/global_error_service.h" |
25 #include "chrome/common/channel_info.h" | 26 #include "chrome/common/channel_info.h" |
26 #include "chrome/grit/chromium_strings.h" | 27 #include "chrome/grit/chromium_strings.h" |
27 #include "chrome/grit/generated_resources.h" | 28 #include "chrome/grit/generated_resources.h" |
28 #include "chrome/installer/util/install_util.h" | 29 #include "chrome/installer/util/install_util.h" |
29 #include "components/component_updater/pref_names.h" | 30 #include "components/component_updater/pref_names.h" |
30 #include "components/prefs/pref_service.h" | 31 #include "components/prefs/pref_service.h" |
(...skipping 13 matching lines...) Expand all Loading... |
44 // downloaded or run. | 45 // downloaded or run. |
45 const char kSRTDownloadURL[] = | 46 const char kSRTDownloadURL[] = |
46 "https://www.google.com/chrome/srt/?chrome-prompt=1"; | 47 "https://www.google.com/chrome/srt/?chrome-prompt=1"; |
47 | 48 |
48 // The extension to use to replace the temporary one created when the SRT was | 49 // The extension to use to replace the temporary one created when the SRT was |
49 // downloaded. | 50 // downloaded. |
50 const base::FilePath::CharType kExecutableExtension[] = L"exe"; | 51 const base::FilePath::CharType kExecutableExtension[] = L"exe"; |
51 | 52 |
52 // A switch to add to the command line when executing the SRT. | 53 // A switch to add to the command line when executing the SRT. |
53 const char kChromePromptSwitch[] = "chrome-prompt"; | 54 const char kChromePromptSwitch[] = "chrome-prompt"; |
54 const char kChromeVersionSwitch[] = "chrome-version"; | |
55 const char kChromeSystemInstallSwitch[] = "chrome-system-install"; | 55 const char kChromeSystemInstallSwitch[] = "chrome-system-install"; |
56 const char kChromeChannelSwitch[] = "chrome-channel"; | |
57 const char kEnableCrashReporting[] = "enable-crash-reporting"; | 56 const char kEnableCrashReporting[] = "enable-crash-reporting"; |
58 const char kUmaUserSwitch[] = "uma-user"; | 57 const char kUmaUserSwitch[] = "uma-user"; |
59 | 58 |
60 // Encodes Chrome's channel as an integer to be passed to the SRT on the command | |
61 // line. The SRT binary expects to recieve Chrome's channel encoded as: | |
62 // 0: unknown; 1: canary; 2: dev; 3: beta; 4: stable. | |
63 int ChannelAsInt() { | |
64 switch (chrome::GetChannel()) { | |
65 case version_info::Channel::UNKNOWN: | |
66 return 0; | |
67 case version_info::Channel::CANARY: | |
68 return 1; | |
69 case version_info::Channel::DEV: | |
70 return 2; | |
71 case version_info::Channel::BETA: | |
72 return 3; | |
73 case version_info::Channel::STABLE: | |
74 return 4; | |
75 default: | |
76 return 0; | |
77 } | |
78 } | |
79 | |
80 void MaybeExecuteSRTFromBlockingPool( | 59 void MaybeExecuteSRTFromBlockingPool( |
81 const base::FilePath& downloaded_path, | 60 const base::FilePath& downloaded_path, |
82 bool metrics_enabled, | 61 bool metrics_enabled, |
83 const scoped_refptr<SingleThreadTaskRunner>& task_runner, | 62 const scoped_refptr<SingleThreadTaskRunner>& task_runner, |
84 const base::Closure& success_callback, | 63 const base::Closure& success_callback, |
85 const base::Closure& failure_callback) { | 64 const base::Closure& failure_callback) { |
86 DCHECK(!downloaded_path.empty()); | 65 DCHECK(!downloaded_path.empty()); |
87 | 66 |
88 if (base::PathExists(downloaded_path)) { | 67 if (base::PathExists(downloaded_path)) { |
89 base::FilePath executable_path( | 68 base::FilePath executable_path( |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 void SRTGlobalError::OnUserinteractionDone() { | 253 void SRTGlobalError::OnUserinteractionDone() { |
275 DCHECK(interacted_); | 254 DCHECK(interacted_); |
276 // Once the user interacted with the bubble, we can forget about any pending | 255 // Once the user interacted with the bubble, we can forget about any pending |
277 // prompt. | 256 // prompt. |
278 g_browser_process->local_state()->SetBoolean(prefs::kSwReporterPendingPrompt, | 257 g_browser_process->local_state()->SetBoolean(prefs::kSwReporterPendingPrompt, |
279 false); | 258 false); |
280 delete this; | 259 delete this; |
281 } | 260 } |
282 | 261 |
283 } // namespace safe_browsing | 262 } // namespace safe_browsing |
OLD | NEW |