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

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

Powered by Google App Engine
This is Rietveld 408576698