OLD | NEW |
---|---|
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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/ui/webui/settings/chrome_cleanup_handler.h" | 5 #include "chrome/browser/ui/webui/settings/chrome_cleanup_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
11 #include "base/metrics/histogram_macros.h" | |
11 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "chrome/browser/safe_browsing/chrome_cleaner/srt_field_trial_win.h" | 14 #include "chrome/browser/safe_browsing/chrome_cleaner/srt_field_trial_win.h" |
14 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
16 #include "content/public/browser/web_ui.h" | 17 #include "content/public/browser/web_ui.h" |
17 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
18 | 19 |
19 using safe_browsing::ChromeCleanerController; | 20 using safe_browsing::ChromeCleanerController; |
20 | 21 |
21 namespace settings { | 22 namespace settings { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
26 // These values are used to send UMA information and are replicated in the | |
27 // histograms.xml file, so the order MUST NOT CHANGE. | |
28 enum CleanupCardHistogramValue { | |
29 CLEANUP_CARD_SHOWN = 0, | |
30 | |
tommycli
2017/07/07 21:32:26
nit: no \n here
ftirelo
2017/07/10 19:08:51
Done.
| |
31 CLEANUP_CARD_MAX, | |
32 }; | |
33 | |
25 // Returns a ListValue containing a copy of the file paths stored in |files|. | 34 // Returns a ListValue containing a copy of the file paths stored in |files|. |
26 base::ListValue GetFilesAsListStorage(const std::set<base::FilePath>& files) { | 35 base::ListValue GetFilesAsListStorage(const std::set<base::FilePath>& files) { |
27 base::ListValue value; | 36 base::ListValue value; |
28 for (const base::FilePath& path : files) | 37 for (const base::FilePath& path : files) |
29 value.AppendString(path.value()); | 38 value.AppendString(path.value()); |
30 | 39 |
31 return value; | 40 return value; |
32 } | 41 } |
33 | 42 |
34 std::string IdleReasonToString( | 43 std::string IdleReasonToString( |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 } | 145 } |
137 | 146 |
138 void ChromeCleanupHandler::HandleRegisterChromeCleanerObserver( | 147 void ChromeCleanupHandler::HandleRegisterChromeCleanerObserver( |
139 const base::ListValue* args) { | 148 const base::ListValue* args) { |
140 DCHECK_EQ(0U, args->GetSize()); | 149 DCHECK_EQ(0U, args->GetSize()); |
141 // The Polymer element should never be attached if the feature is | 150 // The Polymer element should never be attached if the feature is |
142 // disabled. | 151 // disabled. |
143 DCHECK( | 152 DCHECK( |
144 base::FeatureList::IsEnabled(safe_browsing::kInBrowserCleanerUIFeature)); | 153 base::FeatureList::IsEnabled(safe_browsing::kInBrowserCleanerUIFeature)); |
145 | 154 |
155 UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.CleanupCard", CLEANUP_CARD_SHOWN, | |
156 CLEANUP_CARD_MAX); | |
146 AllowJavascript(); | 157 AllowJavascript(); |
147 | 158 |
148 // Send the current logs upload state. | 159 // Send the current logs upload state. |
149 OnLogsEnabledChanged(controller_->logs_enabled()); | 160 OnLogsEnabledChanged(controller_->logs_enabled()); |
150 } | 161 } |
151 | 162 |
152 void ChromeCleanupHandler::HandleRestartComputer(const base::ListValue* args) { | 163 void ChromeCleanupHandler::HandleRestartComputer(const base::ListValue* args) { |
153 DCHECK_EQ(0U, args->GetSize()); | 164 DCHECK_EQ(0U, args->GetSize()); |
154 | 165 |
155 CallJavascriptFunction("cr.webUIListenerCallback", | 166 CallJavascriptFunction("cr.webUIListenerCallback", |
(...skipping 12 matching lines...) Expand all Loading... | |
168 } | 179 } |
169 | 180 |
170 void ChromeCleanupHandler::HandleStartCleanup(const base::ListValue* args) { | 181 void ChromeCleanupHandler::HandleStartCleanup(const base::ListValue* args) { |
171 CHECK_EQ(1U, args->GetSize()); | 182 CHECK_EQ(1U, args->GetSize()); |
172 bool allow_logs_upload = false; | 183 bool allow_logs_upload = false; |
173 args->GetBoolean(0, &allow_logs_upload); | 184 args->GetBoolean(0, &allow_logs_upload); |
174 | 185 |
175 // The state is propagated to all open tabs and should be consistent. | 186 // The state is propagated to all open tabs and should be consistent. |
176 DCHECK_EQ(controller_->logs_enabled(), allow_logs_upload); | 187 DCHECK_EQ(controller_->logs_enabled(), allow_logs_upload); |
177 | 188 |
189 safe_browsing::RecordCleanupStartedHistogram( | |
190 safe_browsing::CLEANUP_STARTED_FROM_PROMPT_IN_SETTINGS); | |
178 controller_->ReplyWithUserResponse( | 191 controller_->ReplyWithUserResponse( |
179 profile_, | 192 profile_, |
180 allow_logs_upload | 193 allow_logs_upload |
181 ? ChromeCleanerController::UserResponse::kAcceptedWithLogs | 194 ? ChromeCleanerController::UserResponse::kAcceptedWithLogs |
182 : ChromeCleanerController::UserResponse::kAcceptedWithoutLogs); | 195 : ChromeCleanerController::UserResponse::kAcceptedWithoutLogs); |
183 } | 196 } |
184 | 197 |
185 } // namespace settings | 198 } // namespace settings |
OLD | NEW |