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 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 137 } |
137 | 138 |
138 void ChromeCleanupHandler::HandleRegisterChromeCleanerObserver( | 139 void ChromeCleanupHandler::HandleRegisterChromeCleanerObserver( |
139 const base::ListValue* args) { | 140 const base::ListValue* args) { |
140 DCHECK_EQ(0U, args->GetSize()); | 141 DCHECK_EQ(0U, args->GetSize()); |
141 // The Polymer element should never be attached if the feature is | 142 // The Polymer element should never be attached if the feature is |
142 // disabled. | 143 // disabled. |
143 DCHECK( | 144 DCHECK( |
144 base::FeatureList::IsEnabled(safe_browsing::kInBrowserCleanerUIFeature)); | 145 base::FeatureList::IsEnabled(safe_browsing::kInBrowserCleanerUIFeature)); |
145 | 146 |
| 147 UMA_HISTOGRAM_BOOLEAN("SoftwareReporter.CleanupCard", true); |
146 AllowJavascript(); | 148 AllowJavascript(); |
147 | 149 |
148 // Send the current logs upload state. | 150 // Send the current logs upload state. |
149 OnLogsEnabledChanged(controller_->logs_enabled()); | 151 OnLogsEnabledChanged(controller_->logs_enabled()); |
150 } | 152 } |
151 | 153 |
152 void ChromeCleanupHandler::HandleRestartComputer(const base::ListValue* args) { | 154 void ChromeCleanupHandler::HandleRestartComputer(const base::ListValue* args) { |
153 DCHECK_EQ(0U, args->GetSize()); | 155 DCHECK_EQ(0U, args->GetSize()); |
154 | 156 |
155 CallJavascriptFunction("cr.webUIListenerCallback", | 157 CallJavascriptFunction("cr.webUIListenerCallback", |
(...skipping 12 matching lines...) Expand all Loading... |
168 } | 170 } |
169 | 171 |
170 void ChromeCleanupHandler::HandleStartCleanup(const base::ListValue* args) { | 172 void ChromeCleanupHandler::HandleStartCleanup(const base::ListValue* args) { |
171 CHECK_EQ(1U, args->GetSize()); | 173 CHECK_EQ(1U, args->GetSize()); |
172 bool allow_logs_upload = false; | 174 bool allow_logs_upload = false; |
173 args->GetBoolean(0, &allow_logs_upload); | 175 args->GetBoolean(0, &allow_logs_upload); |
174 | 176 |
175 // The state is propagated to all open tabs and should be consistent. | 177 // The state is propagated to all open tabs and should be consistent. |
176 DCHECK_EQ(controller_->logs_enabled(), allow_logs_upload); | 178 DCHECK_EQ(controller_->logs_enabled(), allow_logs_upload); |
177 | 179 |
| 180 safe_browsing::RecordCleanupStartedHistogram( |
| 181 safe_browsing::CLEANUP_STARTED_FROM_PROMPT_IN_SETTINGS); |
178 controller_->ReplyWithUserResponse( | 182 controller_->ReplyWithUserResponse( |
179 profile_, | 183 profile_, |
180 allow_logs_upload | 184 allow_logs_upload |
181 ? ChromeCleanerController::UserResponse::kAcceptedWithLogs | 185 ? ChromeCleanerController::UserResponse::kAcceptedWithLogs |
182 : ChromeCleanerController::UserResponse::kAcceptedWithoutLogs); | 186 : ChromeCleanerController::UserResponse::kAcceptedWithoutLogs); |
183 } | 187 } |
184 | 188 |
185 } // namespace settings | 189 } // namespace settings |
OLD | NEW |