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

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

Issue 2081103002: Rename PermissionBubbleManager to PermissionRequestManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 4 years, 5 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 13 matching lines...) Expand all
24 #include "content/public/browser/render_process_host.h" 24 #include "content/public/browser/render_process_host.h"
25 #include "content/public/browser/resource_dispatcher_host.h" 25 #include "content/public/browser/resource_dispatcher_host.h"
26 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
27 #include "content/public/browser/web_contents_delegate.h" 27 #include "content/public/browser/web_contents_delegate.h"
28 #include "url/gurl.h" 28 #include "url/gurl.h"
29 29
30 #if BUILDFLAG(ANDROID_JAVA_UI) 30 #if BUILDFLAG(ANDROID_JAVA_UI)
31 #include "chrome/browser/download/download_request_infobar_delegate_android.h" 31 #include "chrome/browser/download/download_request_infobar_delegate_android.h"
32 #else 32 #else
33 #include "chrome/browser/download/download_permission_request.h" 33 #include "chrome/browser/download/download_permission_request.h"
34 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 34 #include "chrome/browser/permissions/permission_request_manager.h"
35 #endif 35 #endif
36 36
37 using content::BrowserThread; 37 using content::BrowserThread;
38 using content::NavigationController; 38 using content::NavigationController;
39 using content::NavigationEntry; 39 using content::NavigationEntry;
40 40
41 // TabDownloadState ------------------------------------------------------------ 41 // TabDownloadState ------------------------------------------------------------
42 42
43 DownloadRequestLimiter::TabDownloadState::TabDownloadState( 43 DownloadRequestLimiter::TabDownloadState::TabDownloadState(
44 DownloadRequestLimiter* host, 44 DownloadRequestLimiter* host,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 const blink::WebInputEvent::Type type) { 128 const blink::WebInputEvent::Type type) {
129 if (is_showing_prompt() || type == blink::WebInputEvent::GestureScrollBegin) { 129 if (is_showing_prompt() || type == blink::WebInputEvent::GestureScrollBegin) {
130 // Don't change state if a prompt is showing or if the user has scrolled. 130 // Don't change state if a prompt is showing or if the user has scrolled.
131 return; 131 return;
132 } 132 }
133 133
134 #if BUILDFLAG(ANDROID_JAVA_UI) 134 #if BUILDFLAG(ANDROID_JAVA_UI)
135 bool promptable = InfoBarService::FromWebContents(web_contents()) != nullptr; 135 bool promptable = InfoBarService::FromWebContents(web_contents()) != nullptr;
136 #else 136 #else
137 bool promptable = 137 bool promptable =
138 PermissionBubbleManager::FromWebContents(web_contents()) != nullptr; 138 PermissionRequestManager::FromWebContents(web_contents()) != nullptr;
139 #endif 139 #endif
140 140
141 // See PromptUserForDownload(): if there's no InfoBarService, then 141 // See PromptUserForDownload(): if there's no InfoBarService, then
142 // DOWNLOADS_NOT_ALLOWED is functionally equivalent to PROMPT_BEFORE_DOWNLOAD. 142 // DOWNLOADS_NOT_ALLOWED is functionally equivalent to PROMPT_BEFORE_DOWNLOAD.
143 if ((status_ != DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS) && 143 if ((status_ != DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS) &&
144 (!promptable || 144 (!promptable ||
145 (status_ != DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED))) { 145 (status_ != DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED))) {
146 // Revert to default status. 146 // Revert to default status.
147 host_->Remove(this, web_contents()); 147 host_->Remove(this, web_contents());
148 // WARNING: We've been deleted. 148 // WARNING: We've been deleted.
(...skipping 13 matching lines...) Expand all
162 const DownloadRequestLimiter::Callback& callback) { 162 const DownloadRequestLimiter::Callback& callback) {
163 callbacks_.push_back(callback); 163 callbacks_.push_back(callback);
164 DCHECK(web_contents_); 164 DCHECK(web_contents_);
165 if (is_showing_prompt()) 165 if (is_showing_prompt())
166 return; 166 return;
167 167
168 #if BUILDFLAG(ANDROID_JAVA_UI) 168 #if BUILDFLAG(ANDROID_JAVA_UI)
169 DownloadRequestInfoBarDelegateAndroid::Create( 169 DownloadRequestInfoBarDelegateAndroid::Create(
170 InfoBarService::FromWebContents(web_contents_), factory_.GetWeakPtr()); 170 InfoBarService::FromWebContents(web_contents_), factory_.GetWeakPtr());
171 #else 171 #else
172 PermissionBubbleManager* bubble_manager = 172 PermissionRequestManager* permission_request_manager =
173 PermissionBubbleManager::FromWebContents(web_contents_); 173 PermissionRequestManager::FromWebContents(web_contents_);
174 if (bubble_manager) { 174 if (permission_request_manager) {
175 bubble_manager->AddRequest( 175 permission_request_manager->AddRequest(
176 new DownloadPermissionRequest(factory_.GetWeakPtr())); 176 new DownloadPermissionRequest(factory_.GetWeakPtr()));
177 } else { 177 } else {
178 Cancel(); 178 Cancel();
179 } 179 }
180 #endif 180 #endif
181 } 181 }
182 182
183 void DownloadRequestLimiter::TabDownloadState::SetContentSetting( 183 void DownloadRequestLimiter::TabDownloadState::SetContentSetting(
184 ContentSetting setting) { 184 ContentSetting setting) {
185 if (!web_contents_) 185 if (!web_contents_)
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 NOTREACHED(); 466 NOTREACHED();
467 } 467 }
468 } 468 }
469 469
470 void DownloadRequestLimiter::Remove(TabDownloadState* state, 470 void DownloadRequestLimiter::Remove(TabDownloadState* state,
471 content::WebContents* contents) { 471 content::WebContents* contents) {
472 DCHECK(ContainsKey(state_map_, contents)); 472 DCHECK(ContainsKey(state_map_, contents));
473 state_map_.erase(contents); 473 state_map_.erase(contents);
474 delete state; 474 delete state;
475 } 475 }
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