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

Side by Side Diff: chrome/browser/android/download/download_controller.cc

Issue 2975593002: [vr] Deny permission requests in VR mode
Patch Set: . Created 3 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
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/android/tab_web_contents_delegate_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/android/download/download_controller.h" 5 #include "chrome/browser/android/download/download_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
11 #include "base/android/jni_string.h" 11 #include "base/android/jni_string.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/metrics/field_trial_params.h" 15 #include "base/metrics/field_trial_params.h"
16 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
17 #include "base/synchronization/lock.h" 17 #include "base/synchronization/lock.h"
18 #include "chrome/browser/android/chrome_feature_list.h" 18 #include "chrome/browser/android/chrome_feature_list.h"
19 #include "chrome/browser/android/download/dangerous_download_infobar_delegate.h" 19 #include "chrome/browser/android/download/dangerous_download_infobar_delegate.h"
20 #include "chrome/browser/android/download/download_manager_service.h" 20 #include "chrome/browser/android/download/download_manager_service.h"
21 #include "chrome/browser/android/tab_android.h" 21 #include "chrome/browser/android/tab_android.h"
22 #include "chrome/browser/infobars/infobar_service.h" 22 #include "chrome/browser/infobars/infobar_service.h"
23 #include "chrome/browser/permissions/permission_update_infobar_delegate_android. h" 23 #include "chrome/browser/permissions/permission_update_infobar_delegate_android. h"
24 #include "chrome/browser/ui/android/view_android_helper.h" 24 #include "chrome/browser/ui/android/view_android_helper.h"
25 #include "chrome/browser/vr/vr_tab_helper.h"
25 #include "chrome/grit/chromium_strings.h" 26 #include "chrome/grit/chromium_strings.h"
26 #include "content/public/browser/browser_context.h" 27 #include "content/public/browser/browser_context.h"
27 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/download_manager.h" 29 #include "content/public/browser/download_manager.h"
29 #include "content/public/browser/download_url_parameters.h" 30 #include "content/public/browser/download_url_parameters.h"
30 #include "content/public/browser/render_process_host.h" 31 #include "content/public/browser/render_process_host.h"
31 #include "content/public/browser/render_view_host.h" 32 #include "content/public/browser/render_view_host.h"
32 #include "content/public/common/referrer.h" 33 #include "content/public/common/referrer.h"
33 #include "device/vr/features/features.h"
34 #include "jni/DownloadController_jni.h" 34 #include "jni/DownloadController_jni.h"
35 #include "net/base/filename_util.h" 35 #include "net/base/filename_util.h"
36 #include "net/traffic_annotation/network_traffic_annotation.h" 36 #include "net/traffic_annotation/network_traffic_annotation.h"
37 #include "ui/android/view_android.h" 37 #include "ui/android/view_android.h"
38 #include "ui/android/window_android.h" 38 #include "ui/android/window_android.h"
39 #include "ui/base/page_transition_types.h" 39 #include "ui/base/page_transition_types.h"
40 40
41 #if BUILDFLAG(ENABLE_VR)
42 #include "chrome/browser/android/vr_shell/vr_tab_helper.h"
43 #endif // BUILDFLAG(ENABLE_VR)
44
45 using base::android::ConvertUTF8ToJavaString; 41 using base::android::ConvertUTF8ToJavaString;
46 using base::android::JavaParamRef; 42 using base::android::JavaParamRef;
47 using base::android::ScopedJavaLocalRef; 43 using base::android::ScopedJavaLocalRef;
48 using content::BrowserContext; 44 using content::BrowserContext;
49 using content::BrowserThread; 45 using content::BrowserThread;
50 using content::ContextMenuParams; 46 using content::ContextMenuParams;
51 using content::DownloadItem; 47 using content::DownloadItem;
52 using content::DownloadManager; 48 using content::DownloadManager;
53 using content::WebContents; 49 using content::WebContents;
54 50
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 212
217 DownloadController::DownloadController() = default; 213 DownloadController::DownloadController() = default;
218 214
219 DownloadController::~DownloadController() = default; 215 DownloadController::~DownloadController() = default;
220 216
221 void DownloadController::AcquireFileAccessPermission( 217 void DownloadController::AcquireFileAccessPermission(
222 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, 218 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
223 const DownloadControllerBase::AcquireFileAccessPermissionCallback& cb) { 219 const DownloadControllerBase::AcquireFileAccessPermissionCallback& cb) {
224 DCHECK_CURRENTLY_ON(BrowserThread::UI); 220 DCHECK_CURRENTLY_ON(BrowserThread::UI);
225 221
226 #if BUILDFLAG(ENABLE_VR)
227 WebContents* web_contents = web_contents_getter.Run(); 222 WebContents* web_contents = web_contents_getter.Run();
228 if (vr_shell::VrTabHelper::IsInVr(web_contents)) 223 if (vr::VrTabHelper::IsInVr(web_contents))
229 return; 224 return;
230 #endif
231 225
232 if (HasFileAccessPermission()) { 226 if (HasFileAccessPermission()) {
233 BrowserThread::PostTask( 227 BrowserThread::PostTask(
234 BrowserThread::UI, FROM_HERE, base::Bind(cb, true)); 228 BrowserThread::UI, FROM_HERE, base::Bind(cb, true));
235 return; 229 return;
236 } 230 }
237 231
238 AcquirePermissionCallback callback( 232 AcquirePermissionCallback callback(
239 base::Bind(&OnRequestFileAccessResult, web_contents_getter, cb)); 233 base::Bind(&OnRequestFileAccessResult, web_contents_getter, cb));
240 // Make copy on the heap so we can pass the pointer through JNI. 234 // Make copy on the heap so we can pass the pointer through JNI.
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 453
460 int interrupt_reason = download_item->GetLastReason(); 454 int interrupt_reason = download_item->GetLastReason();
461 DCHECK_NE(interrupt_reason, content::DOWNLOAD_INTERRUPT_REASON_NONE); 455 DCHECK_NE(interrupt_reason, content::DOWNLOAD_INTERRUPT_REASON_NONE);
462 return interrupt_reason == 456 return interrupt_reason ==
463 content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT || 457 content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT ||
464 interrupt_reason == 458 interrupt_reason ==
465 content::DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED || 459 content::DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED ||
466 interrupt_reason == 460 interrupt_reason ==
467 content::DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED; 461 content::DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED;
468 } 462 }
OLDNEW
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/android/tab_web_contents_delegate_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698