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

Side by Side Diff: chrome/browser/safe_browsing/srt_global_error_win.cc

Issue 2409443002: Make GlobalErrorService's ownership model slightly less insane. (Closed)
Patch Set: windows, ownership Created 4 years, 2 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 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/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 bool SRTGlobalError::ShouldCloseOnDeactivate() const { 198 bool SRTGlobalError::ShouldCloseOnDeactivate() const {
199 return false; 199 return false;
200 } 200 }
201 201
202 void SRTGlobalError::MaybeExecuteSRT() { 202 void SRTGlobalError::MaybeExecuteSRT() {
203 if (downloaded_path_.empty()) { 203 if (downloaded_path_.empty()) {
204 FallbackToDownloadPage(); 204 FallbackToDownloadPage();
205 return; 205 return;
206 } 206 }
207 // At this point, this object owns itself, since ownership has been taken back 207 // At this point, this object owns itself, since ownership has been taken back
208 // from the global_error_service_ in the call to RemoveGlobalError. This means 208 // from the global_error_service_ in the call to OnUserInteractionStarted.
209 // that it is safe to use base::Unretained here. 209 // This means that it is safe to use base::Unretained here.
210 BrowserThread::PostBlockingPoolTask( 210 BrowserThread::PostBlockingPoolTask(
211 FROM_HERE, 211 FROM_HERE,
212 base::Bind( 212 base::Bind(
213 &MaybeExecuteSRTFromBlockingPool, downloaded_path_, 213 &MaybeExecuteSRTFromBlockingPool, downloaded_path_,
214 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(), 214 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(),
215 base::ThreadTaskRunnerHandle::Get(), 215 base::ThreadTaskRunnerHandle::Get(),
216 base::Bind(&SRTGlobalError::OnUserinteractionDone, 216 base::Bind(&SRTGlobalError::OnUserinteractionDone,
217 base::Unretained(this)), 217 base::Unretained(this)),
218 base::Bind(&SRTGlobalError::FallbackToDownloadPage, 218 base::Bind(&SRTGlobalError::FallbackToDownloadPage,
219 base::Unretained(this)))); 219 base::Unretained(this))));
(...skipping 17 matching lines...) Expand all
237 237
238 void SRTGlobalError::OnUserinteractionStarted( 238 void SRTGlobalError::OnUserinteractionStarted(
239 SRTPromptHistogramValue histogram_value) { 239 SRTPromptHistogramValue histogram_value) {
240 // This is for cases where the UI doesn't go away quickly enough and user 240 // This is for cases where the UI doesn't go away quickly enough and user
241 // might click on the button more than once, or more than one button. 241 // might click on the button more than once, or more than one button.
242 if (interacted_) 242 if (interacted_)
243 return; 243 return;
244 RecordSRTPromptHistogram(histogram_value); 244 RecordSRTPromptHistogram(histogram_value);
245 interacted_ = true; 245 interacted_ = true;
246 if (global_error_service_) { 246 if (global_error_service_) {
247 global_error_service_->RemoveGlobalError(this); 247 global_error_service_->RemoveOwnedGlobalError(this).release();
248 global_error_service_ = nullptr; 248 global_error_service_ = nullptr;
249 } 249 }
250 } 250 }
251 251
252 void SRTGlobalError::OnUserinteractionDone() { 252 void SRTGlobalError::OnUserinteractionDone() {
253 DCHECK(interacted_); 253 DCHECK(interacted_);
254 // Once the user interacted with the bubble, we can forget about any pending 254 // Once the user interacted with the bubble, we can forget about any pending
255 // prompt. 255 // prompt.
256 g_browser_process->local_state()->SetBoolean(prefs::kSwReporterPendingPrompt, 256 g_browser_process->local_state()->SetBoolean(prefs::kSwReporterPendingPrompt,
257 false); 257 false);
258 delete this; 258 delete this;
259 } 259 }
260 260
261 } // namespace safe_browsing 261 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698