| OLD | NEW |
| 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/context_utils.h" | 10 #include "base/android/context_utils.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 using base::android::ScopedJavaLocalRef; | 38 using base::android::ScopedJavaLocalRef; |
| 39 using content::BrowserContext; | 39 using content::BrowserContext; |
| 40 using content::BrowserThread; | 40 using content::BrowserThread; |
| 41 using content::ContextMenuParams; | 41 using content::ContextMenuParams; |
| 42 using content::DownloadItem; | 42 using content::DownloadItem; |
| 43 using content::DownloadManager; | 43 using content::DownloadManager; |
| 44 using content::WebContents; | 44 using content::WebContents; |
| 45 | 45 |
| 46 namespace { | 46 namespace { |
| 47 // Guards download_controller_ | 47 // Guards download_controller_ |
| 48 base::LazyInstance<base::Lock> g_download_controller_lock_; | 48 base::LazyInstance<base::Lock>::DestructorAtExit g_download_controller_lock_; |
| 49 | 49 |
| 50 WebContents* GetWebContents(int render_process_id, int render_view_id) { | 50 WebContents* GetWebContents(int render_process_id, int render_view_id) { |
| 51 content::RenderViewHost* render_view_host = | 51 content::RenderViewHost* render_view_host = |
| 52 content::RenderViewHost::FromID(render_process_id, render_view_id); | 52 content::RenderViewHost::FromID(render_process_id, render_view_id); |
| 53 | 53 |
| 54 if (!render_view_host) | 54 if (!render_view_host) |
| 55 return nullptr; | 55 return nullptr; |
| 56 | 56 |
| 57 return WebContents::FromRenderViewHost(render_view_host); | 57 return WebContents::FromRenderViewHost(render_view_host); |
| 58 } | 58 } |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 void DownloadController::StartContextMenuDownload( | 380 void DownloadController::StartContextMenuDownload( |
| 381 const ContextMenuParams& params, WebContents* web_contents, bool is_link, | 381 const ContextMenuParams& params, WebContents* web_contents, bool is_link, |
| 382 const std::string& extra_headers) { | 382 const std::string& extra_headers) { |
| 383 int process_id = web_contents->GetRenderProcessHost()->GetID(); | 383 int process_id = web_contents->GetRenderProcessHost()->GetID(); |
| 384 int routing_id = web_contents->GetRenderViewHost()->GetRoutingID(); | 384 int routing_id = web_contents->GetRenderViewHost()->GetRoutingID(); |
| 385 AcquireFileAccessPermission( | 385 AcquireFileAccessPermission( |
| 386 web_contents, base::Bind(&CreateContextMenuDownload, process_id, | 386 web_contents, base::Bind(&CreateContextMenuDownload, process_id, |
| 387 routing_id, params, is_link, extra_headers)); | 387 routing_id, params, is_link, extra_headers)); |
| 388 } | 388 } |
| 389 | 389 |
| OLD | NEW |