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/installer/util/install_util.h" | 26 #include "chrome/installer/util/install_util.h" |
27 #include "components/component_updater/pref_names.h" | 27 #include "components/component_updater/pref_names.h" |
28 #include "components/prefs/pref_service.h" | 28 #include "components/prefs/pref_service.h" |
29 #include "components/version_info/version_info.h" | 29 #include "components/version_info/version_info.h" |
30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
31 #include "grit/chromium_strings.h" | 31 #include "grit/chromium_strings.h" |
32 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
33 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
34 | 34 |
35 using base::SingleThreadTaskRunner; | 35 using base::SingleThreadTaskRunner; |
36 using base::ThreadTaskRunnerHandle; | 36 using base::ThreadTaskRunnerHandle; |
37 using content::BrowserThread; | 37 using content::BrowserThread; |
38 | 38 |
39 namespace safe_browsing { | 39 namespace safe_browsing { |
40 | 40 |
41 namespace { | 41 namespace { |
42 | 42 |
43 // Used as a backup plan in case the SRT executable was not successfully | 43 // Used as a backup plan in case the SRT executable was not successfully |
44 // downloaded or run. | 44 // downloaded or run. |
45 const char kSRTDownloadURL[] = | 45 const char kSRTDownloadURL[] = |
46 "https://www.google.com/chrome/srt/?chrome-prompt=1"; | 46 "https://www.google.com/chrome/srt/?chrome-prompt=1"; |
47 | 47 |
48 // The extension to use to replace the temporary one created when the SRT was | 48 // The extension to use to replace the temporary one created when the SRT was |
49 // downloaded. | 49 // downloaded. |
50 const base::FilePath::CharType kExecutableExtension[] = L"exe"; | 50 const base::FilePath::CharType kExecutableExtension[] = L"exe"; |
51 | 51 |
52 // A switch to add to the command line when executing the SRT. | 52 // A switch to add to the command line when executing the SRT. |
53 const char kChromePromptSwitch[] = "chrome-prompt"; | 53 const char kChromePromptSwitch[] = "chrome-prompt"; |
54 const char kChromeVersionSwitch[] = "chrome-version"; | |
55 const char kChromeSystemInstallSwitch[] = "chrome-system-install"; | 54 const char kChromeSystemInstallSwitch[] = "chrome-system-install"; |
56 const char kChromeChannelSwitch[] = "chrome-channel"; | |
57 const char kEnableCrashReporting[] = "enable-crash-reporting"; | 55 const char kEnableCrashReporting[] = "enable-crash-reporting"; |
58 const char kUmaUserSwitch[] = "uma-user"; | 56 const char kUmaUserSwitch[] = "uma-user"; |
59 | 57 |
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( | 58 void MaybeExecuteSRTFromBlockingPool( |
81 const base::FilePath& downloaded_path, | 59 const base::FilePath& downloaded_path, |
82 bool metrics_enabled, | 60 bool metrics_enabled, |
83 const scoped_refptr<SingleThreadTaskRunner>& task_runner, | 61 const scoped_refptr<SingleThreadTaskRunner>& task_runner, |
84 const base::Closure& success_callback, | 62 const base::Closure& success_callback, |
85 const base::Closure& failure_callback) { | 63 const base::Closure& failure_callback) { |
86 DCHECK(!downloaded_path.empty()); | 64 DCHECK(!downloaded_path.empty()); |
87 | 65 |
88 if (base::PathExists(downloaded_path)) { | 66 if (base::PathExists(downloaded_path)) { |
89 base::FilePath executable_path( | 67 base::FilePath executable_path( |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 void SRTGlobalError::OnUserinteractionDone() { | 251 void SRTGlobalError::OnUserinteractionDone() { |
274 DCHECK(interacted_); | 252 DCHECK(interacted_); |
275 // Once the user interacted with the bubble, we can forget about any pending | 253 // Once the user interacted with the bubble, we can forget about any pending |
276 // prompt. | 254 // prompt. |
277 g_browser_process->local_state()->SetBoolean(prefs::kSwReporterPendingPrompt, | 255 g_browser_process->local_state()->SetBoolean(prefs::kSwReporterPendingPrompt, |
278 false); | 256 false); |
279 delete this; | 257 delete this; |
280 } | 258 } |
281 | 259 |
282 } // namespace safe_browsing | 260 } // namespace safe_browsing |
OLD | NEW |