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 25 matching lines...) Expand all Loading... | |
46 return "user_declined_cleanup"; | 47 return "user_declined_cleanup"; |
47 case ChromeCleanerController::IdleReason::kCleaningFailed: | 48 case ChromeCleanerController::IdleReason::kCleaningFailed: |
48 return "cleaning_failed"; | 49 return "cleaning_failed"; |
49 case ChromeCleanerController::IdleReason::kCleaningSucceeded: | 50 case ChromeCleanerController::IdleReason::kCleaningSucceeded: |
50 return "cleaning_succeeded"; | 51 return "cleaning_succeeded"; |
51 } | 52 } |
52 NOTREACHED(); | 53 NOTREACHED(); |
53 return ""; | 54 return ""; |
54 } | 55 } |
55 | 56 |
57 enum CleanupCardHistogramValue { | |
csharp
2017/07/07 20:53:33
nit: Add a comment about how this needs to match u
ftirelo
2017/07/07 21:22:08
Done.
| |
58 CLEANUP_CARD_SHOWN = 0, | |
59 | |
60 CLEANUP_CARD_MAX, | |
61 }; | |
62 | |
56 } // namespace | 63 } // namespace |
57 | 64 |
58 ChromeCleanupHandler::ChromeCleanupHandler(Profile* profile) | 65 ChromeCleanupHandler::ChromeCleanupHandler(Profile* profile) |
59 : controller_(ChromeCleanerController::GetInstance()), profile_(profile) {} | 66 : controller_(ChromeCleanerController::GetInstance()), profile_(profile) {} |
60 | 67 |
61 ChromeCleanupHandler::~ChromeCleanupHandler() { | 68 ChromeCleanupHandler::~ChromeCleanupHandler() { |
62 controller_->RemoveObserver(this); | 69 controller_->RemoveObserver(this); |
63 } | 70 } |
64 | 71 |
65 void ChromeCleanupHandler::RegisterMessages() { | 72 void ChromeCleanupHandler::RegisterMessages() { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 } | 133 } |
127 | 134 |
128 void ChromeCleanupHandler::HandleRegisterChromeCleanerObserver( | 135 void ChromeCleanupHandler::HandleRegisterChromeCleanerObserver( |
129 const base::ListValue* args) { | 136 const base::ListValue* args) { |
130 DCHECK_EQ(0U, args->GetSize()); | 137 DCHECK_EQ(0U, args->GetSize()); |
131 // The Polymer element should never be attached if the feature is | 138 // The Polymer element should never be attached if the feature is |
132 // disabled. | 139 // disabled. |
133 DCHECK( | 140 DCHECK( |
134 base::FeatureList::IsEnabled(safe_browsing::kInBrowserCleanerUIFeature)); | 141 base::FeatureList::IsEnabled(safe_browsing::kInBrowserCleanerUIFeature)); |
135 | 142 |
143 UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.CleanupCard", CLEANUP_CARD_SHOWN, | |
144 CLEANUP_CARD_MAX); | |
136 AllowJavascript(); | 145 AllowJavascript(); |
137 } | 146 } |
138 | 147 |
139 void ChromeCleanupHandler::HandleRestartComputer(const base::ListValue* args) { | 148 void ChromeCleanupHandler::HandleRestartComputer(const base::ListValue* args) { |
140 DCHECK_EQ(0U, args->GetSize()); | 149 DCHECK_EQ(0U, args->GetSize()); |
141 | 150 |
142 CallJavascriptFunction("cr.webUIListenerCallback", | 151 CallJavascriptFunction("cr.webUIListenerCallback", |
143 base::Value("chrome-cleanup-on-dismiss")); | 152 base::Value("chrome-cleanup-on-dismiss")); |
144 // TODO(proberge): Show a prompt to reboot the system. | 153 // TODO(proberge): Show a prompt to reboot the system. |
145 } | 154 } |
146 | 155 |
147 void ChromeCleanupHandler::HandleStartCleanup(const base::ListValue* args) { | 156 void ChromeCleanupHandler::HandleStartCleanup(const base::ListValue* args) { |
148 DCHECK_EQ(0U, args->GetSize()); | 157 DCHECK_EQ(0U, args->GetSize()); |
149 | 158 |
159 safe_browsing::RecordCleanupStartedHistogram( | |
160 safe_browsing::CLEANUP_STARTED_FROM_PROMPT_IN_SETTINGS); | |
150 controller_->ReplyWithUserResponse( | 161 controller_->ReplyWithUserResponse( |
151 // TODO(proberge): Send kAcceptedWithLogs or kAcceptedWithoutLogs based on | 162 // TODO(proberge): Send kAcceptedWithLogs or kAcceptedWithoutLogs based on |
152 // the state of a logs upload permissions checkbox. | 163 // the state of a logs upload permissions checkbox. |
153 profile_, ChromeCleanerController::UserResponse::kAcceptedWithoutLogs); | 164 profile_, ChromeCleanerController::UserResponse::kAcceptedWithoutLogs); |
154 } | 165 } |
155 | 166 |
156 } // namespace settings | 167 } // namespace settings |
OLD | NEW |