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

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

Issue 1686903002: [Abandoned] Rename PermissionBubbleManager to PermissionRequestManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests compile Created 4 years, 8 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
OLDNEW
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 #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/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
(...skipping 12 matching lines...) Expand all
23 #include "content/public/browser/render_process_host.h" 23 #include "content/public/browser/render_process_host.h"
24 #include "content/public/browser/resource_dispatcher_host.h" 24 #include "content/public/browser/resource_dispatcher_host.h"
25 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
26 #include "content/public/browser/web_contents_delegate.h" 26 #include "content/public/browser/web_contents_delegate.h"
27 #include "url/gurl.h" 27 #include "url/gurl.h"
28 28
29 #if BUILDFLAG(ANDROID_JAVA_UI) 29 #if BUILDFLAG(ANDROID_JAVA_UI)
30 #include "chrome/browser/download/download_request_infobar_delegate_android.h" 30 #include "chrome/browser/download/download_request_infobar_delegate_android.h"
31 #else 31 #else
32 #include "chrome/browser/download/download_permission_request.h" 32 #include "chrome/browser/download/download_permission_request.h"
33 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 33 #include "chrome/browser/permissions/permission_request_manager.h"
34 #endif 34 #endif
35 35
36 using content::BrowserThread; 36 using content::BrowserThread;
37 using content::NavigationController; 37 using content::NavigationController;
38 using content::NavigationEntry; 38 using content::NavigationEntry;
39 39
40 // TabDownloadState ------------------------------------------------------------ 40 // TabDownloadState ------------------------------------------------------------
41 41
42 DownloadRequestLimiter::TabDownloadState::TabDownloadState( 42 DownloadRequestLimiter::TabDownloadState::TabDownloadState(
43 DownloadRequestLimiter* host, 43 DownloadRequestLimiter* host,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 const blink::WebInputEvent::Type type) { 101 const blink::WebInputEvent::Type type) {
102 if (is_showing_prompt() || type == blink::WebInputEvent::GestureScrollBegin) { 102 if (is_showing_prompt() || type == blink::WebInputEvent::GestureScrollBegin) {
103 // Don't change state if a prompt is showing or if the user has scrolled. 103 // Don't change state if a prompt is showing or if the user has scrolled.
104 return; 104 return;
105 } 105 }
106 106
107 #if BUILDFLAG(ANDROID_JAVA_UI) 107 #if BUILDFLAG(ANDROID_JAVA_UI)
108 bool promptable = InfoBarService::FromWebContents(web_contents()) != nullptr; 108 bool promptable = InfoBarService::FromWebContents(web_contents()) != nullptr;
109 #else 109 #else
110 bool promptable = 110 bool promptable =
111 PermissionBubbleManager::FromWebContents(web_contents()) != nullptr; 111 PermissionRequestManager::FromWebContents(web_contents()) != nullptr;
112 #endif 112 #endif
113 113
114 // See PromptUserForDownload(): if there's no InfoBarService, then 114 // See PromptUserForDownload(): if there's no InfoBarService, then
115 // DOWNLOADS_NOT_ALLOWED is functionally equivalent to PROMPT_BEFORE_DOWNLOAD. 115 // DOWNLOADS_NOT_ALLOWED is functionally equivalent to PROMPT_BEFORE_DOWNLOAD.
116 if ((status_ != DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS) && 116 if ((status_ != DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS) &&
117 (!promptable || 117 (!promptable ||
118 (status_ != DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED))) { 118 (status_ != DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED))) {
119 // Revert to default status. 119 // Revert to default status.
120 host_->Remove(this, web_contents()); 120 host_->Remove(this, web_contents());
121 // WARNING: We've been deleted. 121 // WARNING: We've been deleted.
(...skipping 13 matching lines...) Expand all
135 const DownloadRequestLimiter::Callback& callback) { 135 const DownloadRequestLimiter::Callback& callback) {
136 callbacks_.push_back(callback); 136 callbacks_.push_back(callback);
137 DCHECK(web_contents_); 137 DCHECK(web_contents_);
138 if (is_showing_prompt()) 138 if (is_showing_prompt())
139 return; 139 return;
140 140
141 #if BUILDFLAG(ANDROID_JAVA_UI) 141 #if BUILDFLAG(ANDROID_JAVA_UI)
142 DownloadRequestInfoBarDelegateAndroid::Create( 142 DownloadRequestInfoBarDelegateAndroid::Create(
143 InfoBarService::FromWebContents(web_contents_), factory_.GetWeakPtr()); 143 InfoBarService::FromWebContents(web_contents_), factory_.GetWeakPtr());
144 #else 144 #else
145 PermissionBubbleManager* bubble_manager = 145 PermissionRequestManager* permission_request_manager =
146 PermissionBubbleManager::FromWebContents(web_contents_); 146 PermissionRequestManager::FromWebContents(web_contents_);
147 if (bubble_manager) { 147 if (permission_request_manager) {
148 bubble_manager->AddRequest(new DownloadPermissionRequest( 148 permission_request_manager->AddRequest(new DownloadPermissionRequest(
149 factory_.GetWeakPtr())); 149 factory_.GetWeakPtr()));
150 } else { 150 } else {
151 Cancel(); 151 Cancel();
152 } 152 }
153 #endif 153 #endif
154 } 154 }
155 155
156 void DownloadRequestLimiter::TabDownloadState::SetContentSetting( 156 void DownloadRequestLimiter::TabDownloadState::SetContentSetting(
157 ContentSetting setting) { 157 ContentSetting setting) {
158 if (!web_contents_) 158 if (!web_contents_)
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 NOTREACHED(); 483 NOTREACHED();
484 } 484 }
485 } 485 }
486 486
487 void DownloadRequestLimiter::Remove(TabDownloadState* state, 487 void DownloadRequestLimiter::Remove(TabDownloadState* state,
488 content::WebContents* contents) { 488 content::WebContents* contents) {
489 DCHECK(ContainsKey(state_map_, contents)); 489 DCHECK(ContainsKey(state_map_, contents));
490 state_map_.erase(contents); 490 state_map_.erase(contents);
491 delete state; 491 delete state;
492 } 492 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | chrome/browser/download/download_request_limiter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698