| OLD | NEW |
| 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 } |
| OLD | NEW |