| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 static const size_t kMaxDownloadsAtOnce = 50; | 67 static const size_t kMaxDownloadsAtOnce = 50; |
| 68 | 68 |
| 69 // The callback from CanDownloadOnIOThread. This is invoked on the io thread. | 69 // The callback from CanDownloadOnIOThread. This is invoked on the io thread. |
| 70 // The boolean parameter indicates whether or not the download is allowed. | 70 // The boolean parameter indicates whether or not the download is allowed. |
| 71 typedef base::Callback<void(bool /*allow*/)> Callback; | 71 typedef base::Callback<void(bool /*allow*/)> Callback; |
| 72 | 72 |
| 73 // TabDownloadState maintains the download state for a particular tab. | 73 // TabDownloadState maintains the download state for a particular tab. |
| 74 // TabDownloadState prompts the user with an infobar as necessary. | 74 // TabDownloadState prompts the user with an infobar as necessary. |
| 75 // TabDownloadState deletes itself (by invoking | 75 // TabDownloadState deletes itself (by invoking |
| 76 // DownloadRequestLimiter::Remove) as necessary. | 76 // DownloadRequestLimiter::Remove) as necessary. |
| 77 // TODO(gbillock): just make this class implement PermissionBubbleRequest. | 77 // TODO(gbillock): just make this class implement PermissionRequest. |
| 78 class TabDownloadState : public content::NotificationObserver, | 78 class TabDownloadState : public content::NotificationObserver, |
| 79 public content::WebContentsObserver { | 79 public content::WebContentsObserver { |
| 80 public: | 80 public: |
| 81 // Creates a new TabDownloadState. |controller| is the controller the | 81 // Creates a new TabDownloadState. |controller| is the controller the |
| 82 // TabDownloadState tracks the state of and is the host for any dialogs that | 82 // TabDownloadState tracks the state of and is the host for any dialogs that |
| 83 // are displayed. |originating_controller| is used to determine the host of | 83 // are displayed. |originating_controller| is used to determine the host of |
| 84 // the initial download. If |originating_controller| is null, |controller| | 84 // the initial download. If |originating_controller| is null, |controller| |
| 85 // is used. |originating_controller| is typically null, but differs from | 85 // is used. |originating_controller| is typically null, but differs from |
| 86 // |controller| in the case of a constrained popup requesting the download. | 86 // |controller| in the case of a constrained popup requesting the download. |
| 87 TabDownloadState(DownloadRequestLimiter* host, | 87 TabDownloadState(DownloadRequestLimiter* host, |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 StateMap state_map_; | 244 StateMap state_map_; |
| 245 | 245 |
| 246 // Weak ptr factory used when |CanDownload| asks the delegate asynchronously | 246 // Weak ptr factory used when |CanDownload| asks the delegate asynchronously |
| 247 // about the download. | 247 // about the download. |
| 248 base::WeakPtrFactory<DownloadRequestLimiter> factory_; | 248 base::WeakPtrFactory<DownloadRequestLimiter> factory_; |
| 249 | 249 |
| 250 DISALLOW_COPY_AND_ASSIGN(DownloadRequestLimiter); | 250 DISALLOW_COPY_AND_ASSIGN(DownloadRequestLimiter); |
| 251 }; | 251 }; |
| 252 | 252 |
| 253 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ | 253 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ |
| OLD | NEW |