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

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

Issue 8983010: Convert WebContents to return a content::NavigationController instead of the implementation. Upda... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac 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 #include "chrome/browser/download/download_request_limiter.h" 5 #include "chrome/browser/download/download_request_limiter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "chrome/browser/download/download_request_infobar_delegate.h" 9 #include "chrome/browser/download/download_request_infobar_delegate.h"
10 #include "chrome/browser/infobars/infobar_tab_helper.h" 10 #include "chrome/browser/infobars/infobar_tab_helper.h"
11 #include "chrome/browser/tab_contents/tab_util.h" 11 #include "chrome/browser/tab_contents/tab_util.h"
12 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" 12 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
13 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate. h" 13 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate. h"
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
15 #include "content/browser/tab_contents/navigation_controller.h"
16 #include "content/browser/tab_contents/tab_contents.h" 15 #include "content/browser/tab_contents/tab_contents.h"
17 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/navigation_controller.h"
18 #include "content/public/browser/navigation_entry.h" 18 #include "content/public/browser/navigation_entry.h"
19 #include "content/public/browser/notification_source.h" 19 #include "content/public/browser/notification_source.h"
20 #include "content/public/browser/notification_types.h" 20 #include "content/public/browser/notification_types.h"
21 #include "content/public/browser/web_contents_delegate.h" 21 #include "content/public/browser/web_contents_delegate.h"
22 22
23 using content::BrowserThread; 23 using content::BrowserThread;
24 using content::NavigationEntry; 24 using content::NavigationEntry;
25 using content::WebContents; 25 using content::WebContents;
26 26
27 // TabDownloadState ------------------------------------------------------------ 27 // TabDownloadState ------------------------------------------------------------
28 28
29 DownloadRequestLimiter::TabDownloadState::TabDownloadState( 29 DownloadRequestLimiter::TabDownloadState::TabDownloadState(
30 DownloadRequestLimiter* host, 30 DownloadRequestLimiter* host,
31 NavigationController* controller, 31 content::NavigationController* controller,
32 NavigationController* originating_controller) 32 content::NavigationController* originating_controller)
33 : host_(host), 33 : host_(host),
34 controller_(controller), 34 controller_(controller),
35 status_(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD), 35 status_(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD),
36 download_count_(0), 36 download_count_(0),
37 infobar_(NULL) { 37 infobar_(NULL) {
38 content::Source<content::NavigationController> notification_source( 38 content::Source<content::NavigationController> notification_source(
39 controller); 39 controller);
40 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, 40 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
41 notification_source); 41 notification_source);
42 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, notification_source); 42 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, notification_source);
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 state->OnUserGesture(); 225 state->OnUserGesture();
226 } 226 }
227 227
228 // static 228 // static
229 void DownloadRequestLimiter::SetTestingDelegate(TestingDelegate* delegate) { 229 void DownloadRequestLimiter::SetTestingDelegate(TestingDelegate* delegate) {
230 delegate_ = delegate; 230 delegate_ = delegate;
231 } 231 }
232 232
233 DownloadRequestLimiter::TabDownloadState* DownloadRequestLimiter:: 233 DownloadRequestLimiter::TabDownloadState* DownloadRequestLimiter::
234 GetDownloadState(NavigationController* controller, 234 GetDownloadState(content::NavigationController* controller,
235 NavigationController* originating_controller, 235 content::NavigationController* originating_controller,
236 bool create) { 236 bool create) {
237 DCHECK(controller); 237 DCHECK(controller);
238 StateMap::iterator i = state_map_.find(controller); 238 StateMap::iterator i = state_map_.find(controller);
239 if (i != state_map_.end()) 239 if (i != state_map_.end())
240 return i->second; 240 return i->second;
241 241
242 if (!create) 242 if (!create)
243 return NULL; 243 return NULL;
244 244
245 TabDownloadState* state = 245 TabDownloadState* state =
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 340
341 void DownloadRequestLimiter::Remove(TabDownloadState* state) { 341 void DownloadRequestLimiter::Remove(TabDownloadState* state) {
342 DCHECK(ContainsKey(state_map_, state->controller())); 342 DCHECK(ContainsKey(state_map_, state->controller()));
343 state_map_.erase(state->controller()); 343 state_map_.erase(state->controller());
344 delete state; 344 delete state;
345 } 345 }
346 346
347 // static 347 // static
348 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ = 348 DownloadRequestLimiter::TestingDelegate* DownloadRequestLimiter::delegate_ =
349 NULL; 349 NULL;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698