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

Side by Side Diff: chrome/browser/download/download_request_limiter.h

Issue 9030032: Get rid of a bunch of tab_contents.h includes from chrome. These are all trivial changes to use W... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros Created 8 years, 11 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 #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 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
16 16
17 class DownloadRequestInfoBarDelegate; 17 class DownloadRequestInfoBarDelegate;
18 class TabContents;
19 class TabContentsWrapper; 18 class TabContentsWrapper;
20 19
21 namespace content { 20 namespace content {
22 class NavigationController; 21 class NavigationController;
23 class WebContents; 22 class WebContents;
24 } 23 }
25 24
26 // DownloadRequestLimiter is responsible for determining whether a download 25 // DownloadRequestLimiter is responsible for determining whether a download
27 // should be allowed or not. It is designed to keep pages from downloading 26 // should be allowed or not. It is designed to keep pages from downloading
28 // multiple files without user interaction. DownloadRequestLimiter is invoked 27 // multiple files without user interaction. DownloadRequestLimiter is invoked
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 return download_count_; 101 return download_count_;
103 } 102 }
104 103
105 // Invoked when a user gesture occurs (mouse click, enter or space). This 104 // Invoked when a user gesture occurs (mouse click, enter or space). This
106 // may result in invoking Remove on DownloadRequestLimiter. 105 // may result in invoking Remove on DownloadRequestLimiter.
107 void OnUserGesture(); 106 void OnUserGesture();
108 107
109 // Asks the user if they really want to allow the download. 108 // Asks the user if they really want to allow the download.
110 // See description above CanDownloadOnIOThread for details on lifetime of 109 // See description above CanDownloadOnIOThread for details on lifetime of
111 // callback. 110 // callback.
112 void PromptUserForDownload(TabContents* tab, 111 void PromptUserForDownload(content::WebContents* tab,
113 DownloadRequestLimiter::Callback* callback); 112 DownloadRequestLimiter::Callback* callback);
114 113
115 // Are we showing a prompt to the user? 114 // Are we showing a prompt to the user?
116 bool is_showing_prompt() const { return (infobar_ != NULL); } 115 bool is_showing_prompt() const { return (infobar_ != NULL); }
117 116
118 // NavigationController we're tracking. 117 // NavigationController we're tracking.
119 content::NavigationController* controller() const { return controller_; } 118 content::NavigationController* controller() const { return controller_; }
120 119
121 // Invoked from DownloadRequestDialogDelegate. Notifies the delegates and 120 // Invoked from DownloadRequestDialogDelegate. Notifies the delegates and
122 // changes the status appropriately. Virtual for testing. 121 // changes the status appropriately. Virtual for testing.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // Handles showing the infobar to the user, may be null. 165 // Handles showing the infobar to the user, may be null.
167 DownloadRequestInfoBarDelegate* infobar_; 166 DownloadRequestInfoBarDelegate* infobar_;
168 167
169 DISALLOW_COPY_AND_ASSIGN(TabDownloadState); 168 DISALLOW_COPY_AND_ASSIGN(TabDownloadState);
170 }; 169 };
171 170
172 DownloadRequestLimiter(); 171 DownloadRequestLimiter();
173 172
174 // Returns the download status for a page. This does not change the state in 173 // Returns the download status for a page. This does not change the state in
175 // anyway. 174 // anyway.
176 DownloadStatus GetDownloadStatus(TabContents* tab); 175 DownloadStatus GetDownloadStatus(content::WebContents* tab);
177 176
178 // Updates the state of the page as necessary and notifies the callback. 177 // Updates the state of the page as necessary and notifies the callback.
179 // WARNING: both this call and the callback are invoked on the io thread. 178 // WARNING: both this call and the callback are invoked on the io thread.
180 // 179 //
181 // DownloadRequestLimiter does not retain/release the Callback. It is up to 180 // DownloadRequestLimiter does not retain/release the Callback. It is up to
182 // the caller to ensure the callback is valid until the request is complete. 181 // the caller to ensure the callback is valid until the request is complete.
183 void CanDownloadOnIOThread(int render_process_host_id, 182 void CanDownloadOnIOThread(int render_process_host_id,
184 int render_view_id, 183 int render_view_id,
185 int request_id, 184 int request_id,
186 Callback* callback); 185 Callback* callback);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // the TabDownloadState is removed and deleted (by way of Remove). 249 // the TabDownloadState is removed and deleted (by way of Remove).
251 typedef std::map<content::NavigationController*, TabDownloadState*> StateMap; 250 typedef std::map<content::NavigationController*, TabDownloadState*> StateMap;
252 StateMap state_map_; 251 StateMap state_map_;
253 252
254 static TestingDelegate* delegate_; 253 static TestingDelegate* delegate_;
255 254
256 DISALLOW_COPY_AND_ASSIGN(DownloadRequestLimiter); 255 DISALLOW_COPY_AND_ASSIGN(DownloadRequestLimiter);
257 }; 256 };
258 257
259 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ 258 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_
OLDNEW
« no previous file with comments | « chrome/browser/download/download_manager_unittest.cc ('k') | chrome/browser/download/download_request_limiter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698