| OLD | NEW |
| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 bool SRTGlobalError::ShouldCloseOnDeactivate() const { | 214 bool SRTGlobalError::ShouldCloseOnDeactivate() const { |
| 215 return false; | 215 return false; |
| 216 } | 216 } |
| 217 | 217 |
| 218 void SRTGlobalError::MaybeExecuteSRT() { | 218 void SRTGlobalError::MaybeExecuteSRT() { |
| 219 if (downloaded_path_.empty()) { | 219 if (downloaded_path_.empty()) { |
| 220 FallbackToDownloadPage(); | 220 FallbackToDownloadPage(); |
| 221 return; | 221 return; |
| 222 } | 222 } |
| 223 // At this point, this object owns itself, since ownership has been taken back | 223 // At this point, this object owns itself, since ownership has been taken back |
| 224 // from the global_error_service_ in the call to RemoveGlobalError. This means | 224 // from the global_error_service_ in the call to OnUserInteractionStarted. |
| 225 // that it is safe to use base::Unretained here. | 225 // This means that it is safe to use base::Unretained here. |
| 226 BrowserThread::PostBlockingPoolTask( | 226 BrowserThread::PostBlockingPoolTask( |
| 227 FROM_HERE, | 227 FROM_HERE, |
| 228 base::Bind( | 228 base::Bind( |
| 229 &MaybeExecuteSRTFromBlockingPool, downloaded_path_, | 229 &MaybeExecuteSRTFromBlockingPool, downloaded_path_, |
| 230 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(), | 230 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(), |
| 231 bubble_shown_from_menu_ ? ChromePromptValue::kShownFromMenu | 231 bubble_shown_from_menu_ ? ChromePromptValue::kShownFromMenu |
| 232 : ChromePromptValue::kPrompted, | 232 : ChromePromptValue::kPrompted, |
| 233 base::ThreadTaskRunnerHandle::Get(), | 233 base::ThreadTaskRunnerHandle::Get(), |
| 234 base::Bind(&SRTGlobalError::OnUserinteractionDone, | 234 base::Bind(&SRTGlobalError::OnUserinteractionDone, |
| 235 base::Unretained(this)), | 235 base::Unretained(this)), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 255 | 255 |
| 256 void SRTGlobalError::OnUserinteractionStarted( | 256 void SRTGlobalError::OnUserinteractionStarted( |
| 257 SRTPromptHistogramValue histogram_value) { | 257 SRTPromptHistogramValue histogram_value) { |
| 258 // This is for cases where the UI doesn't go away quickly enough and user | 258 // This is for cases where the UI doesn't go away quickly enough and user |
| 259 // might click on the button more than once, or more than one button. | 259 // might click on the button more than once, or more than one button. |
| 260 if (interacted_) | 260 if (interacted_) |
| 261 return; | 261 return; |
| 262 RecordSRTPromptHistogram(histogram_value); | 262 RecordSRTPromptHistogram(histogram_value); |
| 263 interacted_ = true; | 263 interacted_ = true; |
| 264 if (global_error_service_) { | 264 if (global_error_service_) { |
| 265 global_error_service_->RemoveGlobalError(this); | 265 global_error_service_->RemoveGlobalError(this).release(); |
| 266 global_error_service_ = nullptr; | 266 global_error_service_ = nullptr; |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 | 269 |
| 270 void SRTGlobalError::OnUserinteractionDone() { | 270 void SRTGlobalError::OnUserinteractionDone() { |
| 271 DCHECK(interacted_); | 271 DCHECK(interacted_); |
| 272 // Once the user interacted with the bubble, we can forget about any pending | 272 // Once the user interacted with the bubble, we can forget about any pending |
| 273 // prompt. | 273 // prompt. |
| 274 g_browser_process->local_state()->SetBoolean(prefs::kSwReporterPendingPrompt, | 274 g_browser_process->local_state()->SetBoolean(prefs::kSwReporterPendingPrompt, |
| 275 false); | 275 false); |
| 276 delete this; | 276 delete this; |
| 277 } | 277 } |
| 278 | 278 |
| 279 } // namespace safe_browsing | 279 } // namespace safe_browsing |
| OLD | NEW |