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

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

Issue 1459793002: Android: Allow compiling browser without Java UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/content_settings/host_content_settings_map_factory.h" 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
11 #include "chrome/browser/infobars/infobar_service.h" 11 #include "chrome/browser/infobars/infobar_service.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/tab_contents/tab_util.h" 13 #include "chrome/browser/tab_contents/tab_util.h"
14 #include "components/content_settings/core/browser/host_content_settings_map.h" 14 #include "components/content_settings/core/browser/host_content_settings_map.h"
15 #include "content/public/browser/browser_context.h" 15 #include "content/public/browser/browser_context.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/navigation_controller.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/render_process_host.h" 21 #include "content/public/browser/render_process_host.h"
22 #include "content/public/browser/resource_dispatcher_host.h" 22 #include "content/public/browser/resource_dispatcher_host.h"
23 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
24 #include "content/public/browser/web_contents_delegate.h" 24 #include "content/public/browser/web_contents_delegate.h"
25 #include "url/gurl.h" 25 #include "url/gurl.h"
26 26
27 #if defined(OS_ANDROID) 27 #if defined(ANDROID_JAVA_UI)
Ted C 2015/11/30 19:39:05 I think there will need a broader discussion of wh
28 #include "chrome/browser/download/download_request_infobar_delegate_android.h" 28 #include "chrome/browser/download/download_request_infobar_delegate_android.h"
29 #else 29 #else
30 #include "chrome/browser/download/download_permission_request.h" 30 #include "chrome/browser/download/download_permission_request.h"
31 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 31 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
32 #endif 32 #endif
33 33
34 using content::BrowserThread; 34 using content::BrowserThread;
35 using content::NavigationController; 35 using content::NavigationController;
36 using content::NavigationEntry; 36 using content::NavigationEntry;
37 37
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 NOTREACHED(); 92 NOTREACHED();
93 } 93 }
94 } 94 }
95 95
96 void DownloadRequestLimiter::TabDownloadState::DidGetUserGesture() { 96 void DownloadRequestLimiter::TabDownloadState::DidGetUserGesture() {
97 if (is_showing_prompt()) { 97 if (is_showing_prompt()) {
98 // Don't change the state if the user clicks on the page somewhere. 98 // Don't change the state if the user clicks on the page somewhere.
99 return; 99 return;
100 } 100 }
101 101
102 #if defined(OS_ANDROID) 102 #if defined(ANDROID_JAVA_UI)
103 bool promptable = InfoBarService::FromWebContents(web_contents()) != nullptr; 103 bool promptable = InfoBarService::FromWebContents(web_contents()) != nullptr;
104 #else 104 #else
105 bool promptable = 105 bool promptable =
106 PermissionBubbleManager::FromWebContents(web_contents()) != nullptr; 106 PermissionBubbleManager::FromWebContents(web_contents()) != nullptr;
107 #endif 107 #endif
108 108
109 // See PromptUserForDownload(): if there's no InfoBarService, then 109 // See PromptUserForDownload(): if there's no InfoBarService, then
110 // DOWNLOADS_NOT_ALLOWED is functionally equivalent to PROMPT_BEFORE_DOWNLOAD. 110 // DOWNLOADS_NOT_ALLOWED is functionally equivalent to PROMPT_BEFORE_DOWNLOAD.
111 if ((status_ != DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS) && 111 if ((status_ != DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS) &&
112 (!promptable || 112 (!promptable ||
(...skipping 13 matching lines...) Expand all
126 // WARNING: We've been deleted. 126 // WARNING: We've been deleted.
127 } 127 }
128 128
129 void DownloadRequestLimiter::TabDownloadState::PromptUserForDownload( 129 void DownloadRequestLimiter::TabDownloadState::PromptUserForDownload(
130 const DownloadRequestLimiter::Callback& callback) { 130 const DownloadRequestLimiter::Callback& callback) {
131 callbacks_.push_back(callback); 131 callbacks_.push_back(callback);
132 DCHECK(web_contents_); 132 DCHECK(web_contents_);
133 if (is_showing_prompt()) 133 if (is_showing_prompt())
134 return; 134 return;
135 135
136 #if defined(OS_ANDROID) 136 #if defined(ANDROID_JAVA_UI)
137 DownloadRequestInfoBarDelegateAndroid::Create( 137 DownloadRequestInfoBarDelegateAndroid::Create(
138 InfoBarService::FromWebContents(web_contents_), factory_.GetWeakPtr()); 138 InfoBarService::FromWebContents(web_contents_), factory_.GetWeakPtr());
139 #else 139 #else
140 PermissionBubbleManager* bubble_manager = 140 PermissionBubbleManager* bubble_manager =
141 PermissionBubbleManager::FromWebContents(web_contents_); 141 PermissionBubbleManager::FromWebContents(web_contents_);
142 if (bubble_manager) { 142 if (bubble_manager) {
143 bubble_manager->AddRequest(new DownloadPermissionRequest( 143 bubble_manager->AddRequest(new DownloadPermissionRequest(
144 factory_.GetWeakPtr())); 144 factory_.GetWeakPtr()));
145 } else { 145 } else {
146 Cancel(); 146 Cancel();
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 NOTREACHED(); 443 NOTREACHED();
444 } 444 }
445 } 445 }
446 446
447 void DownloadRequestLimiter::Remove(TabDownloadState* state, 447 void DownloadRequestLimiter::Remove(TabDownloadState* state,
448 content::WebContents* contents) { 448 content::WebContents* contents) {
449 DCHECK(ContainsKey(state_map_, contents)); 449 DCHECK(ContainsKey(state_map_, contents));
450 state_map_.erase(contents); 450 state_map_.erase(contents);
451 delete state; 451 delete state;
452 } 452 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698