| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 94 } |
| 95 | 95 |
| 96 // Number of "ALLOWED" downloads. | 96 // Number of "ALLOWED" downloads. |
| 97 void increment_download_count() { | 97 void increment_download_count() { |
| 98 download_count_++; | 98 download_count_++; |
| 99 } | 99 } |
| 100 size_t download_count() const { | 100 size_t download_count() const { |
| 101 return download_count_; | 101 return download_count_; |
| 102 } | 102 } |
| 103 | 103 |
| 104 // Promote protected accessor to public. | |
| 105 content::WebContents* web_contents() const { | |
| 106 return content::WebContentsObserver::web_contents(); | |
| 107 } | |
| 108 | |
| 109 // content::WebContentsObserver overrides. | 104 // content::WebContentsObserver overrides. |
| 110 virtual void AboutToNavigateRenderView( | 105 virtual void AboutToNavigateRenderView( |
| 111 content::RenderViewHost* render_view_host) OVERRIDE; | 106 content::RenderViewHost* render_view_host) OVERRIDE; |
| 112 // Invoked when a user gesture occurs (mouse click, enter or space). This | 107 // Invoked when a user gesture occurs (mouse click, enter or space). This |
| 113 // may result in invoking Remove on DownloadRequestLimiter. | 108 // may result in invoking Remove on DownloadRequestLimiter. |
| 114 virtual void DidGetUserGesture() OVERRIDE; | 109 virtual void DidGetUserGesture() OVERRIDE; |
| 115 virtual void WebContentsDestroyed() OVERRIDE; | 110 virtual void WebContentsDestroyed() OVERRIDE; |
| 116 | 111 |
| 117 // Asks the user if they really want to allow the download. | 112 // Asks the user if they really want to allow the download. |
| 118 // See description above CanDownloadOnIOThread for details on lifetime of | 113 // See description above CanDownloadOnIOThread for details on lifetime of |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 StateMap state_map_; | 250 StateMap state_map_; |
| 256 | 251 |
| 257 // Weak ptr factory used when |CanDownload| asks the delegate asynchronously | 252 // Weak ptr factory used when |CanDownload| asks the delegate asynchronously |
| 258 // about the download. | 253 // about the download. |
| 259 base::WeakPtrFactory<DownloadRequestLimiter> factory_; | 254 base::WeakPtrFactory<DownloadRequestLimiter> factory_; |
| 260 | 255 |
| 261 DISALLOW_COPY_AND_ASSIGN(DownloadRequestLimiter); | 256 DISALLOW_COPY_AND_ASSIGN(DownloadRequestLimiter); |
| 262 }; | 257 }; |
| 263 | 258 |
| 264 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ | 259 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ |
| OLD | NEW |