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

Side by Side Diff: chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_controller_win.cc

Issue 2966453002: Chrome Cleaner UI: Add logs upload permission checkbox to the dialog (Closed)
Patch Set: Rebase Created 3 years, 5 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 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/safe_browsing/chrome_cleaner/chrome_cleaner_controller_ win.h" 5 #include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_controller_ win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // Short-circuit if the instance doesn't exist to avoid creating it during 150 // Short-circuit if the instance doesn't exist to avoid creating it during
151 // navigation to chrome://settings. 151 // navigation to chrome://settings.
152 if (!g_instance_exists) 152 if (!g_instance_exists)
153 return false; 153 return false;
154 154
155 State state = GetInstance()->state(); 155 State state = GetInstance()->state();
156 return state == State::kInfected || state == State::kCleaning || 156 return state == State::kInfected || state == State::kCleaning ||
157 state == State::kRebootRequired; 157 state == State::kRebootRequired;
158 } 158 }
159 159
160 void ChromeCleanerController::SetLogsEnabled(bool logs_enabled) {
161 if (logs_enabled_ == logs_enabled)
162 return;
163
164 logs_enabled_ = logs_enabled;
165 for (auto& observer : observer_list_)
166 observer.OnLogsEnabledChanged(logs_enabled_);
167 }
168
160 void ChromeCleanerController::SetDelegateForTesting( 169 void ChromeCleanerController::SetDelegateForTesting(
161 ChromeCleanerControllerDelegate* delegate) { 170 ChromeCleanerControllerDelegate* delegate) {
162 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); 171 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
163 delegate_ = delegate ? delegate : real_delegate_.get(); 172 delegate_ = delegate ? delegate : real_delegate_.get();
164 DCHECK(delegate_); 173 DCHECK(delegate_);
165 } 174 }
166 175
167 void ChromeCleanerController::DismissRebootForTesting() { 176 void ChromeCleanerController::DismissRebootForTesting() {
168 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); 177 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
169 DCHECK_EQ(State::kRebootRequired, state()); 178 DCHECK_EQ(State::kRebootRequired, state());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); 216 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
208 217
209 if (state() != State::kInfected) 218 if (state() != State::kInfected)
210 return; 219 return;
211 220
212 DCHECK(prompt_user_callback_); 221 DCHECK(prompt_user_callback_);
213 222
214 PromptAcceptance acceptance = PromptAcceptance::DENIED; 223 PromptAcceptance acceptance = PromptAcceptance::DENIED;
215 State new_state = State::kIdle; 224 State new_state = State::kIdle;
216 switch (user_response) { 225 switch (user_response) {
217 case UserResponse::kAccepted: 226 case UserResponse::kAcceptedWithLogs:
218 acceptance = PromptAcceptance::ACCEPTED; 227 acceptance = PromptAcceptance::ACCEPTED_WITH_LOGS;
228 SetLogsEnabled(true);
219 new_state = State::kCleaning; 229 new_state = State::kCleaning;
220 delegate_->TagForResetting(profile); 230 delegate_->TagForResetting(profile);
221 break; 231 break;
232 case UserResponse::kAcceptedWithoutLogs:
233 acceptance = PromptAcceptance::ACCEPTED_WITHOUT_LOGS;
234 SetLogsEnabled(false);
235 new_state = State::kCleaning;
236 delegate_->TagForResetting(profile);
237 break;
222 case UserResponse::kDenied: // Fallthrough 238 case UserResponse::kDenied: // Fallthrough
223 case UserResponse::kDismissed: 239 case UserResponse::kDismissed:
224 acceptance = PromptAcceptance::DENIED; 240 acceptance = PromptAcceptance::DENIED;
225 idle_reason_ = IdleReason::kUserDeclinedCleanup; 241 idle_reason_ = IdleReason::kUserDeclinedCleanup;
226 new_state = State::kIdle; 242 new_state = State::kIdle;
227 break; 243 break;
228 } 244 }
229 245
230 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO) 246 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)
231 ->PostTask(FROM_HERE, 247 ->PostTask(FROM_HERE,
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 observer.OnRebootFailed(); 465 observer.OnRebootFailed();
450 } 466 }
451 } 467 }
452 468
453 void ChromeCleanerController::OnSettingsResetCompleted() { 469 void ChromeCleanerController::OnSettingsResetCompleted() {
454 idle_reason_ = IdleReason::kCleaningSucceeded; 470 idle_reason_ = IdleReason::kCleaningSucceeded;
455 SetStateAndNotifyObservers(State::kIdle); 471 SetStateAndNotifyObservers(State::kIdle);
456 } 472 }
457 473
458 } // namespace safe_browsing 474 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698