Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: chrome/browser/safe_browsing/srt_global_error_win.cc

Issue 2812223003: Move shared constants to //components/chrome_cleaner (Closed)
Patch Set: Code review Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/base_paths.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" 22 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
23 #include "chrome/browser/safe_browsing/srt_client_info_win.h" 23 #include "chrome/browser/safe_browsing/srt_client_info_win.h"
24 #include "chrome/browser/safe_browsing/srt_field_trial_win.h" 24 #include "chrome/browser/safe_browsing/srt_field_trial_win.h"
25 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
26 #include "chrome/browser/ui/browser_finder.h" 26 #include "chrome/browser/ui/browser_finder.h"
27 #include "chrome/browser/ui/global_error/global_error_service.h" 27 #include "chrome/browser/ui/global_error/global_error_service.h"
28 #include "chrome/common/channel_info.h" 28 #include "chrome/common/channel_info.h"
29 #include "chrome/grit/chromium_strings.h" 29 #include "chrome/grit/chromium_strings.h"
30 #include "chrome/grit/generated_resources.h" 30 #include "chrome/grit/generated_resources.h"
31 #include "chrome/installer/util/install_util.h" 31 #include "chrome/installer/util/install_util.h"
32 #include "components/chrome_cleaner/public/constants/constants.h"
32 #include "components/component_updater/pref_names.h" 33 #include "components/component_updater/pref_names.h"
33 #include "components/prefs/pref_service.h" 34 #include "components/prefs/pref_service.h"
34 #include "components/version_info/version_info.h" 35 #include "components/version_info/version_info.h"
35 #include "content/public/browser/browser_thread.h" 36 #include "content/public/browser/browser_thread.h"
36 #include "ui/base/l10n/l10n_util.h" 37 #include "ui/base/l10n/l10n_util.h"
37 38
38 using base::SingleThreadTaskRunner; 39 using base::SingleThreadTaskRunner;
39 using base::ThreadTaskRunnerHandle; 40 using base::ThreadTaskRunnerHandle;
40 using content::BrowserThread; 41 using content::BrowserThread;
41 42
42 namespace safe_browsing { 43 namespace safe_browsing {
43 44
44 namespace { 45 namespace {
45 46
46 // Used as a backup plan in case the SRT executable was not successfully 47 // Used as a backup plan in case the SRT executable was not successfully
47 // downloaded or run. 48 // downloaded or run.
48 const char kSRTDownloadURL[] = 49 const char kSRTDownloadURL[] =
49 "https://www.google.com/chrome/srt/?chrome-prompt=1"; 50 "https://www.google.com/chrome/srt/?chrome-prompt=1";
50 51
51 // The extension to use to replace the temporary one created when the SRT was 52 // The extension to use to replace the temporary one created when the SRT was
52 // downloaded. 53 // downloaded.
53 const base::FilePath::CharType kExecutableExtension[] = L"exe"; 54 const base::FilePath::CharType kExecutableExtension[] = L"exe";
54 55
55 // Switches to add to the command line when executing the SRT. 56 // Values to be passed to the chrome_cleaner::kChromePromptSwitch of the Chrome
56 const char kChromePromptSwitch[] = "chrome-prompt"; 57 // Cleanup Tool to indicate how the user interacted with the accept button.
Joe Mason 2017/04/13 17:54:01 Does it make sense to put these in public/constant
ftirelo 2017/04/18 15:26:49 Done.
57 const char kChromeExePathSwitch[] = "chrome-exe-path";
58 const char kChromeSystemInstallSwitch[] = "chrome-system-install";
59 const char kUmaUserSwitch[] = "uma-user";
60
61 // Values to be passed to the kChromePromptSwitch of the Chrome Cleanup Tool to
62 // indicate how the user interacted with the accept button.
63 enum class ChromePromptValue { 58 enum class ChromePromptValue {
64 // The user accepted the prompt when the prompt was first shown. 59 // The user accepted the prompt when the prompt was first shown.
65 kPrompted = 3, 60 kPrompted = 3,
66 // The user accepted the prompt after navigating to it from the menu. 61 // The user accepted the prompt after navigating to it from the menu.
67 kShownFromMenu = 4 62 kShownFromMenu = 4
68 }; 63 };
69 64
70 void MaybeExecuteSRTFromBlockingPool( 65 void MaybeExecuteSRTFromBlockingPool(
71 const base::FilePath& downloaded_path, 66 const base::FilePath& downloaded_path,
72 bool metrics_enabled, 67 bool metrics_enabled,
73 bool sber_enabled, 68 bool sber_enabled,
74 ChromePromptValue prompt_value, 69 ChromePromptValue prompt_value,
75 const scoped_refptr<SingleThreadTaskRunner>& task_runner, 70 const scoped_refptr<SingleThreadTaskRunner>& task_runner,
76 const base::Closure& success_callback, 71 const base::Closure& success_callback,
77 const base::Closure& failure_callback) { 72 const base::Closure& failure_callback) {
78 DCHECK(!downloaded_path.empty()); 73 DCHECK(!downloaded_path.empty());
79 74
80 if (base::PathExists(downloaded_path)) { 75 if (base::PathExists(downloaded_path)) {
81 base::FilePath executable_path( 76 base::FilePath executable_path(
82 downloaded_path.ReplaceExtension(kExecutableExtension)); 77 downloaded_path.ReplaceExtension(kExecutableExtension));
83 if (base::ReplaceFile(downloaded_path, executable_path, nullptr)) { 78 if (base::ReplaceFile(downloaded_path, executable_path, nullptr)) {
84 base::CommandLine srt_command_line(executable_path); 79 base::CommandLine srt_command_line(executable_path);
85 srt_command_line.AppendSwitchASCII( 80 srt_command_line.AppendSwitchASCII(
86 kChromePromptSwitch, 81 chrome_cleaner::kChromePromptSwitch,
87 base::IntToString(static_cast<int>(prompt_value))); 82 base::IntToString(static_cast<int>(prompt_value)));
88 srt_command_line.AppendSwitchASCII(kChromeVersionSwitch, 83 srt_command_line.AppendSwitchASCII(chrome_cleaner::kChromeVersionSwitch,
89 version_info::GetVersionNumber()); 84 version_info::GetVersionNumber());
90 srt_command_line.AppendSwitchASCII(kChromeChannelSwitch, 85 srt_command_line.AppendSwitchASCII(chrome_cleaner::kChromeChannelSwitch,
91 base::IntToString(ChannelAsInt())); 86 base::IntToString(ChannelAsInt()));
92 87
93 base::FilePath chrome_exe_path; 88 base::FilePath chrome_exe_path;
94 PathService::Get(base::FILE_EXE, &chrome_exe_path); 89 PathService::Get(base::FILE_EXE, &chrome_exe_path);
95 srt_command_line.AppendSwitchPath(kChromeExePathSwitch, chrome_exe_path); 90 srt_command_line.AppendSwitchPath(chrome_cleaner::kChromeExePathSwitch,
91 chrome_exe_path);
96 if (!InstallUtil::IsPerUserInstall()) 92 if (!InstallUtil::IsPerUserInstall())
97 srt_command_line.AppendSwitch(kChromeSystemInstallSwitch); 93 srt_command_line.AppendSwitch(
94 chrome_cleaner::kChromeSystemInstallSwitch);
98 95
99 if (metrics_enabled) { 96 if (metrics_enabled) {
100 srt_command_line.AppendSwitch(kUmaUserSwitch); 97 srt_command_line.AppendSwitch(chrome_cleaner::kUmaUserSwitch);
101 srt_command_line.AppendSwitch(kEnableCrashReporting); 98 srt_command_line.AppendSwitch(chrome_cleaner::kEnableCrashReporting);
102 } 99 }
103 100
104 if (sber_enabled) 101 if (sber_enabled)
105 srt_command_line.AppendSwitch(kExtendedSafeBrowsingEnabledSwitch); 102 srt_command_line.AppendSwitch(
103 chrome_cleaner::kExtendedSafeBrowsingEnabledSwitch);
106 104
107 base::Process srt_process( 105 base::Process srt_process(
108 base::LaunchProcess(srt_command_line, base::LaunchOptions())); 106 base::LaunchProcess(srt_command_line, base::LaunchOptions()));
109 if (srt_process.IsValid()) { 107 if (srt_process.IsValid()) {
110 task_runner->PostTask(FROM_HERE, success_callback); 108 task_runner->PostTask(FROM_HERE, success_callback);
111 return; 109 return;
112 } 110 }
113 } 111 }
114 } 112 }
115 113
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 void SRTGlobalError::OnUserinteractionDone() { 281 void SRTGlobalError::OnUserinteractionDone() {
284 DCHECK(interacted_); 282 DCHECK(interacted_);
285 // Once the user interacted with the bubble, we can forget about any pending 283 // Once the user interacted with the bubble, we can forget about any pending
286 // prompt. 284 // prompt.
287 g_browser_process->local_state()->SetBoolean(prefs::kSwReporterPendingPrompt, 285 g_browser_process->local_state()->SetBoolean(prefs::kSwReporterPendingPrompt,
288 false); 286 false);
289 delete this; 287 delete this;
290 } 288 }
291 289
292 } // namespace safe_browsing 290 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698