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

Side by Side Diff: chrome/browser/download/download_request_limiter_observer.cc

Issue 10412061: Fix crashes in DownloadRequestLimiter when extension popups/bubbles initiate downloads automatically (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/download/download_request_limiter_observer.h" 5 #include "chrome/browser/download/download_request_limiter_observer.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/download/download_request_limiter.h" 8 #include "chrome/browser/download/download_request_limiter.h"
9 9
10 using content::WebContents; 10 using content::WebContents;
11 11
12 DownloadRequestLimiterObserver::DownloadRequestLimiterObserver( 12 DownloadRequestLimiterObserver::DownloadRequestLimiterObserver(
13 WebContents* web_contents) 13 WebContents* web_contents,
14 : content::WebContentsObserver(web_contents) { 14 const DownloadRequestLimiterObserver::DestroyedCallback& on_destroyed)
15 : content::WebContentsObserver(web_contents),
16 on_destroyed_(on_destroyed) {
15 } 17 }
16 18
17 DownloadRequestLimiterObserver::~DownloadRequestLimiterObserver() { 19 DownloadRequestLimiterObserver::~DownloadRequestLimiterObserver() {
18 } 20 }
19 21
20 void DownloadRequestLimiterObserver::DidGetUserGesture() { 22 void DownloadRequestLimiterObserver::DidGetUserGesture() {
21 if (!g_browser_process->download_request_limiter()) 23 if (!g_browser_process->download_request_limiter())
22 return; // NULL in unitests. 24 return; // NULL in unitests.
23 g_browser_process->download_request_limiter()->OnUserGesture(web_contents()); 25 g_browser_process->download_request_limiter()->OnUserGesture(web_contents());
24 } 26 }
27
28 void DownloadRequestLimiterObserver::WebContentsDestroyed(
29 WebContents* contents) {
30 if (!on_destroyed_.is_null())
31 on_destroyed_.Run(this);
32 delete this;
33 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698