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

Unified Diff: chrome/browser/android/download/download_controller.cc

Issue 2014803002: Move DownloadControllerAndroid from content/ to chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reverted ResourceDispatcherHost Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/download/download_controller.cc
diff --git a/content/browser/android/download_controller_android_impl.cc b/chrome/browser/android/download/download_controller.cc
similarity index 55%
rename from content/browser/android/download_controller_android_impl.cc
rename to chrome/browser/android/download/download_controller.cc
index 874e47a361e1c8d3902820bf84da03321c1a2557..4ffc808ee59d1860bb4b968321357c1f8c718f6f 100644
--- a/content/browser/android/download_controller_android_impl.cc
+++ b/chrome/browser/android/download/download_controller.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/android/download_controller_android_impl.h"
+#include "chrome/browser/android/download/download_controller.h"
#include <memory>
#include <utility>
@@ -15,21 +15,15 @@
#include "base/logging.h"
#include "base/synchronization/lock.h"
#include "base/time/time.h"
-#include "content/browser/android/content_view_core_impl.h"
-#include "content/browser/android/deferred_download_observer.h"
-#include "content/browser/download/download_item_impl.h"
-#include "content/browser/download/download_manager_impl.h"
-#include "content/browser/loader/resource_dispatcher_host_impl.h"
-#include "content/browser/renderer_host/render_process_host_impl.h"
-#include "content/browser/renderer_host/render_view_host_delegate.h"
-#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/browser/web_contents/web_contents_impl.h"
+#include "chrome/browser/android/download/chrome_download_delegate.h"
+#include "chrome/common/chrome_content_client.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/download_manager.h"
#include "content/public/browser/download_url_parameters.h"
-#include "content/public/browser/global_request_id.h"
+#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_request_info.h"
-#include "content/public/common/content_client.h"
#include "content/public/common/referrer.h"
#include "jni/DownloadController_jni.h"
#include "net/base/filename_util.h"
@@ -40,23 +34,31 @@
#include "net/http/http_response_headers.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
+#include "ui/android/view_android.h"
+#include "ui/android/window_android.h"
using base::android::ConvertUTF8ToJavaString;
using base::android::ScopedJavaLocalRef;
+using content::BrowserContext;
+using content::BrowserThread;
+using content::ContextMenuParams;
+using content::DownloadItem;
+using content::DownloadManager;
+using content::ResourceRequestInfo;
+using content::WebContents;
namespace {
// Guards download_controller_
base::LazyInstance<base::Lock> g_download_controller_lock_;
-content::WebContents* GetWebContents(int render_process_id,
- int render_view_id) {
+WebContents* GetWebContents(int render_process_id, int render_view_id) {
content::RenderViewHost* render_view_host =
content::RenderViewHost::FromID(render_process_id, render_view_id);
if (!render_view_host)
return nullptr;
- return content::WebContents::FromRenderViewHost(render_view_host);
+ return WebContents::FromRenderViewHost(render_view_host);
}
void CreateContextMenuDownload(int render_process_id,
@@ -76,10 +78,9 @@ void CreateContextMenuDownload(int render_process_id,
const GURL& url = is_link ? params.link_url : params.src_url;
const GURL& referring_url =
params.frame_url.is_empty() ? params.page_url : params.frame_url;
- content::DownloadManagerImpl* dlm =
- static_cast<content::DownloadManagerImpl*>(
- content::BrowserContext::GetDownloadManager(
- web_contents->GetBrowserContext()));
+ content::DownloadManager* dlm =
+ content::BrowserContext::GetDownloadManager(
+ web_contents->GetBrowserContext());
std::unique_ptr<content::DownloadUrlParameters> dl_params(
content::DownloadUrlParameters::CreateForWebContentsMainFrame(
web_contents, url));
@@ -112,11 +113,9 @@ bool IsInterruptedDownloadAutoResumable(content::DownloadItem* download_item) {
} // namespace
-namespace content {
-
// JNI methods
static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
- DownloadControllerAndroidImpl::GetInstance()->Init(env, obj);
+ DownloadController::GetInstance()->Init(env, obj);
}
static void OnRequestFileAccessResult(JNIEnv* env,
@@ -128,14 +127,14 @@ static void OnRequestFileAccessResult(JNIEnv* env,
// Convert java long long int to c++ pointer, take ownership.
std::unique_ptr<
- DownloadControllerAndroid::AcquireFileAccessPermissionCallback>
+ DownloadControllerBase::AcquireFileAccessPermissionCallback>
cb(reinterpret_cast<
- DownloadControllerAndroid::AcquireFileAccessPermissionCallback*>(
+ DownloadControllerBase::AcquireFileAccessPermissionCallback*>(
callback_id));
cb->Run(granted);
}
-struct DownloadControllerAndroidImpl::JavaObject {
+struct DownloadController::JavaObject {
ScopedJavaLocalRef<jobject> Controller(JNIEnv* env) {
return GetRealObject(env, obj);
}
@@ -143,35 +142,35 @@ struct DownloadControllerAndroidImpl::JavaObject {
};
// static
-bool DownloadControllerAndroidImpl::RegisterDownloadController(JNIEnv* env) {
+bool DownloadController::RegisterDownloadController(JNIEnv* env) {
return RegisterNativesImpl(env);
}
// static
-DownloadControllerAndroid* DownloadControllerAndroid::Get() {
+DownloadControllerBase* DownloadControllerBase::Get() {
base::AutoLock lock(g_download_controller_lock_.Get());
- if (!DownloadControllerAndroid::download_controller_)
- download_controller_ = DownloadControllerAndroidImpl::GetInstance();
- return DownloadControllerAndroid::download_controller_;
+ if (!DownloadControllerBase::download_controller_)
+ download_controller_ = DownloadController::GetInstance();
+ return DownloadControllerBase::download_controller_;
}
-//static
-void DownloadControllerAndroid::SetDownloadControllerAndroid(
- DownloadControllerAndroid* download_controller) {
+// static
+void DownloadControllerBase::SetDownloadControllerBase(
+ DownloadControllerBase* download_controller) {
base::AutoLock lock(g_download_controller_lock_.Get());
- DownloadControllerAndroid::download_controller_ = download_controller;
+ DownloadControllerBase::download_controller_ = download_controller;
}
// static
-DownloadControllerAndroidImpl* DownloadControllerAndroidImpl::GetInstance() {
- return base::Singleton<DownloadControllerAndroidImpl>::get();
+DownloadController* DownloadController::GetInstance() {
+ return base::Singleton<DownloadController>::get();
}
-DownloadControllerAndroidImpl::DownloadControllerAndroidImpl()
+DownloadController::DownloadController()
: java_object_(NULL) {
}
-DownloadControllerAndroidImpl::~DownloadControllerAndroidImpl() {
+DownloadController::~DownloadController() {
if (java_object_) {
JNIEnv* env = base::android::AttachCurrentThread();
env->DeleteWeakGlobalRef(java_object_->obj);
@@ -181,118 +180,97 @@ DownloadControllerAndroidImpl::~DownloadControllerAndroidImpl() {
}
// Initialize references to Java object.
-void DownloadControllerAndroidImpl::Init(JNIEnv* env, jobject obj) {
+void DownloadController::Init(JNIEnv* env, jobject obj) {
java_object_ = new JavaObject;
java_object_->obj = env->NewWeakGlobalRef(obj);
}
-void DownloadControllerAndroidImpl::CancelDeferredDownload(
- DeferredDownloadObserver* observer) {
- for (auto iter = deferred_downloads_.begin();
- iter != deferred_downloads_.end(); ++iter) {
- if (*iter == observer) {
- deferred_downloads_.erase(iter);
- return;
- }
- }
-}
-
-void DownloadControllerAndroidImpl::AcquireFileAccessPermission(
+void DownloadController::AcquireFileAccessPermission(
WebContents* web_contents,
- const DownloadControllerAndroid::AcquireFileAccessPermissionCallback& cb) {
+ const DownloadControllerBase::AcquireFileAccessPermissionCallback& cb) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(web_contents);
- ScopedJavaLocalRef<jobject> view =
- GetContentViewCoreFromWebContents(web_contents);
- if (view.is_null()) {
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE, base::Bind(cb, false));
- return;
- }
-
- if (HasFileAccessPermission(view)) {
+ ui::WindowAndroid* window_android =
+ ViewAndroidHelper::FromWebContents(web_contents)->
+ GetViewAndroid()->GetWindowAndroid();
+ if (window_android && HasFileAccessPermission(window_android)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, base::Bind(cb, true));
return;
}
-
- JNIEnv* env = base::android::AttachCurrentThread();
// Make copy on the heap so we can pass the pointer through JNI.
intptr_t callback_id = reinterpret_cast<intptr_t>(
- new DownloadControllerAndroid::AcquireFileAccessPermissionCallback(cb));
- Java_DownloadController_requestFileAccess(
- env, GetJavaObject()->Controller(env).obj(), view.obj(), callback_id);
+ new DownloadControllerBase::AcquireFileAccessPermissionCallback(cb));
+ ChromeDownloadDelegate::FromWebContents(web_contents)->
+ RequestFileAccess(callback_id);
}
-void DownloadControllerAndroidImpl::SetDefaultDownloadFileName(
+void DownloadController::SetDefaultDownloadFileName(
const std::string& file_name) {
default_file_name_ = file_name;
}
-bool DownloadControllerAndroidImpl::HasFileAccessPermission(
- ScopedJavaLocalRef<jobject> j_content_view_core) {
+bool DownloadController::HasFileAccessPermission(
+ ui::WindowAndroid* window_android) {
+ ScopedJavaLocalRef<jobject> jwindow_android = window_android->GetJavaObject();
+
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DCHECK(!j_content_view_core.is_null());
+ DCHECK(!jwindow_android.is_null());
JNIEnv* env = base::android::AttachCurrentThread();
return Java_DownloadController_hasFileAccess(
- env, GetJavaObject()->Controller(env).obj(), j_content_view_core.obj());
+ env, GetJavaObject()->Controller(env).obj(), jwindow_android.obj());
}
-void DownloadControllerAndroidImpl::CreateGETDownload(
- int render_process_id, int render_view_id, int request_id,
+void DownloadController::CreateGETDownload(
+ int render_process_id, int render_view_id, const net::URLRequest* request,
bool must_download) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- GlobalRequestID global_id(render_process_id, request_id);
// We are yielding the UI thread and render_view_host may go away by
// the time we come back. Pass along render_process_id and render_view_id
// to retrieve it later (if it still exists).
GetDownloadInfoCB cb = base::Bind(
- &DownloadControllerAndroidImpl::StartAndroidDownload,
+ &DownloadController::StartAndroidDownload,
base::Unretained(this), render_process_id,
render_view_id, must_download);
PrepareDownloadInfo(
- global_id,
- base::Bind(&DownloadControllerAndroidImpl::StartDownloadOnUIThread,
+ request,
+ base::Bind(&DownloadController::StartDownloadOnUIThread,
base::Unretained(this), cb));
}
-void DownloadControllerAndroidImpl::PrepareDownloadInfo(
- const GlobalRequestID& global_id,
+void DownloadController::PrepareDownloadInfo(
+ const net::URLRequest* request,
const GetDownloadInfoCB& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- net::URLRequest* request =
- ResourceDispatcherHostImpl::Get()->GetURLRequest(global_id);
if (!request) {
LOG(ERROR) << "Request to download not found.";
return;
}
- DownloadInfoAndroid info_android(request);
+ DownloadInfo info(request);
net::CookieStore* cookie_store = request->context()->cookie_store();
if (cookie_store) {
cookie_store->GetAllCookiesForURLAsync(
request->url(),
- base::Bind(&DownloadControllerAndroidImpl::CheckPolicyAndLoadCookies,
- base::Unretained(this), info_android, callback, global_id));
+ base::Bind(&DownloadController::CheckPolicyAndLoadCookies,
+ base::Unretained(this), info, callback, request));
qinmin 2016/06/09 17:07:44 is it safe to pass request instead of global_id? R
Jinsuk Kim 2016/06/10 01:50:27 Pulled all the info in advance and passed it to Cr
} else {
// Can't get any cookies, start android download.
- callback.Run(info_android);
+ callback.Run(info);
}
}
-void DownloadControllerAndroidImpl::CheckPolicyAndLoadCookies(
- const DownloadInfoAndroid& info, const GetDownloadInfoCB& callback,
- const GlobalRequestID& global_id, const net::CookieList& cookie_list) {
+void DownloadController::CheckPolicyAndLoadCookies(
+ const DownloadInfo& info, const GetDownloadInfoCB& callback,
+ const net::URLRequest* request, const net::CookieList& cookie_list) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- net::URLRequest* request =
- ResourceDispatcherHostImpl::Get()->GetURLRequest(global_id);
if (!request) {
LOG(ERROR) << "Request to download not found.";
return;
@@ -300,22 +278,20 @@ void DownloadControllerAndroidImpl::CheckPolicyAndLoadCookies(
if (request->context()->network_delegate()->CanGetCookies(
*request, cookie_list)) {
- DoLoadCookies(info, callback, global_id);
+ DoLoadCookies(info, callback, request);
} else {
callback.Run(info);
}
}
-void DownloadControllerAndroidImpl::DoLoadCookies(
- const DownloadInfoAndroid& info, const GetDownloadInfoCB& callback,
- const GlobalRequestID& global_id) {
+void DownloadController::DoLoadCookies(
+ const DownloadInfo& info, const GetDownloadInfoCB& callback,
+ const net::URLRequest* request) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
net::CookieOptions options;
options.set_include_httponly();
- net::URLRequest* request =
- ResourceDispatcherHostImpl::Get()->GetURLRequest(global_id);
if (!request) {
LOG(ERROR) << "Request to download not found.";
return;
@@ -323,12 +299,12 @@ void DownloadControllerAndroidImpl::DoLoadCookies(
request->context()->cookie_store()->GetCookiesWithOptionsAsync(
info.url, options,
- base::Bind(&DownloadControllerAndroidImpl::OnCookieResponse,
+ base::Bind(&DownloadController::OnCookieResponse,
base::Unretained(this), info, callback));
}
-void DownloadControllerAndroidImpl::OnCookieResponse(
- DownloadInfoAndroid download_info,
+void DownloadController::OnCookieResponse(
+ DownloadInfo download_info,
const GetDownloadInfoCB& callback,
const std::string& cookie) {
download_info.cookie = cookie;
@@ -337,17 +313,17 @@ void DownloadControllerAndroidImpl::OnCookieResponse(
callback.Run(download_info);
}
-void DownloadControllerAndroidImpl::StartDownloadOnUIThread(
+void DownloadController::StartDownloadOnUIThread(
const GetDownloadInfoCB& callback,
- const DownloadInfoAndroid& info) {
+ const DownloadInfo& info) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, base::Bind(callback, info));
}
-void DownloadControllerAndroidImpl::StartAndroidDownload(
+void DownloadController::StartAndroidDownload(
int render_process_id, int render_view_id, bool must_download,
- const DownloadInfoAndroid& info) {
+ const DownloadInfo& info) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
WebContents* web_contents = GetWebContents(render_process_id, render_view_id);
@@ -356,101 +332,56 @@ void DownloadControllerAndroidImpl::StartAndroidDownload(
LOG(ERROR) << "Download failed on URL:" << info.url.spec();
return;
}
- ScopedJavaLocalRef<jobject> view =
- GetContentViewCoreFromWebContents(web_contents);
- if (view.is_null()) {
- // ContentViewCore might not have been created yet, pass a callback to
- // DeferredDownloadTaskManager so that the download can restart when
- // ContentViewCore is created.
- deferred_downloads_.push_back(new DeferredDownloadObserver(
- web_contents,
- base::Bind(&DownloadControllerAndroidImpl::StartAndroidDownload,
- base::Unretained(this), render_process_id, render_view_id,
- must_download, info)));
- return;
- }
AcquireFileAccessPermission(
web_contents,
- base::Bind(&DownloadControllerAndroidImpl::StartAndroidDownloadInternal,
+ base::Bind(&DownloadController::StartAndroidDownloadInternal,
base::Unretained(this), render_process_id, render_view_id,
must_download, info));
}
-void DownloadControllerAndroidImpl::StartAndroidDownloadInternal(
+void DownloadController::StartAndroidDownloadInternal(
int render_process_id, int render_view_id, bool must_download,
- const DownloadInfoAndroid& info, bool allowed) {
+ const DownloadInfo& info, bool allowed) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!allowed)
return;
- // Call newHttpGetDownload
WebContents* web_contents = GetWebContents(render_process_id, render_view_id);
// The view went away. Can't proceed.
if (!web_contents)
return;
- ScopedJavaLocalRef<jobject> view =
- GetContentViewCoreFromWebContents(web_contents);
- if (view.is_null())
- return;
- JNIEnv* env = base::android::AttachCurrentThread();
- ScopedJavaLocalRef<jstring> jurl =
- ConvertUTF8ToJavaString(env, info.url.spec());
- ScopedJavaLocalRef<jstring> juser_agent =
- ConvertUTF8ToJavaString(env, info.user_agent);
- ScopedJavaLocalRef<jstring> jcontent_disposition =
- ConvertUTF8ToJavaString(env, info.content_disposition);
- ScopedJavaLocalRef<jstring> jmime_type =
- ConvertUTF8ToJavaString(env, info.original_mime_type);
- ScopedJavaLocalRef<jstring> jcookie =
- ConvertUTF8ToJavaString(env, info.cookie);
- ScopedJavaLocalRef<jstring> jreferer =
- ConvertUTF8ToJavaString(env, info.referer);
-
- // net::GetSuggestedFilename will fallback to "download" as filename.
- ScopedJavaLocalRef<jstring> jfilename =
- base::android::ConvertUTF16ToJavaString(
- env, net::GetSuggestedFilename(info.url, info.content_disposition,
- std::string(), // referrer_charset
- std::string(), // suggested_name
- info.original_mime_type,
- default_file_name_));
-
- Java_DownloadController_newHttpGetDownload(
- env, GetJavaObject()->Controller(env).obj(), view.obj(), jurl.obj(),
- juser_agent.obj(), jcontent_disposition.obj(), jmime_type.obj(),
- jcookie.obj(), jreferer.obj(), info.has_user_gesture, jfilename.obj(),
- info.total_bytes, must_download);
-}
-
-void DownloadControllerAndroidImpl::OnDownloadStarted(
+ base::string16 filename = net::GetSuggestedFilename(
+ info.url, info.content_disposition,
+ std::string(), // referrer_charset
+ std::string(), // suggested_name
+ info.original_mime_type,
+ default_file_name_);
+ ChromeDownloadDelegate::FromWebContents(web_contents)->RequestHTTPGetDownload(
+ info.url.spec(), info.user_agent,
+ info.content_disposition, info.original_mime_type,
+ info.cookie, info.referer, filename,
+ info.total_bytes, info.has_user_gesture,
+ must_download);
+}
+
+void DownloadController::OnDownloadStarted(
DownloadItem* download_item) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- if (!download_item->GetWebContents())
+ WebContents* web_contents = download_item->GetWebContents();
+ if (!web_contents)
return;
- JNIEnv* env = base::android::AttachCurrentThread();
-
// Register for updates to the DownloadItem.
download_item->AddObserver(this);
- ScopedJavaLocalRef<jobject> view =
- GetContentViewCoreFromWebContents(download_item->GetWebContents());
- // The view went away. Can't proceed.
- if (view.is_null())
- return;
-
- ScopedJavaLocalRef<jstring> jmime_type =
- ConvertUTF8ToJavaString(env, download_item->GetMimeType());
- ScopedJavaLocalRef<jstring> jfilename = ConvertUTF8ToJavaString(
- env, download_item->GetTargetFilePath().BaseName().value());
- Java_DownloadController_onDownloadStarted(
- env, GetJavaObject()->Controller(env).obj(), view.obj(), jfilename.obj(),
- jmime_type.obj());
+ ChromeDownloadDelegate::FromWebContents(web_contents)->OnDownloadStarted(
+ download_item->GetTargetFilePath().BaseName().value(),
+ download_item->GetMimeType());
}
-void DownloadControllerAndroidImpl::OnDownloadUpdated(DownloadItem* item) {
+void DownloadController::OnDownloadUpdated(DownloadItem* item) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (item->IsDangerous() && (item->GetState() != DownloadItem::CANCELLED))
OnDangerousDownload(item);
@@ -517,34 +448,16 @@ void DownloadControllerAndroidImpl::OnDownloadUpdated(DownloadItem* item) {
}
}
-void DownloadControllerAndroidImpl::OnDangerousDownload(DownloadItem* item) {
- JNIEnv* env = base::android::AttachCurrentThread();
- ScopedJavaLocalRef<jstring> jfilename = ConvertUTF8ToJavaString(
- env, item->GetTargetFilePath().BaseName().value());
- ScopedJavaLocalRef<jstring> jguid =
- ConvertUTF8ToJavaString(env, item->GetGuid());
- ScopedJavaLocalRef<jobject> view_core = GetContentViewCoreFromWebContents(
- item->GetWebContents());
- if (!view_core.is_null()) {
- Java_DownloadController_onDangerousDownload(
- env, GetJavaObject()->Controller(env).obj(), view_core.obj(),
- jfilename.obj(), jguid.obj());
- }
-}
-
-ScopedJavaLocalRef<jobject>
- DownloadControllerAndroidImpl::GetContentViewCoreFromWebContents(
- WebContents* web_contents) {
+void DownloadController::OnDangerousDownload(DownloadItem* item) {
+ WebContents* web_contents = item->GetWebContents();
if (!web_contents)
- return ScopedJavaLocalRef<jobject>();
-
- ContentViewCore* view_core = ContentViewCore::FromWebContents(web_contents);
- return view_core ? view_core->GetJavaObject() :
- ScopedJavaLocalRef<jobject>();
+ return;
+ ChromeDownloadDelegate::FromWebContents(web_contents)->OnDangerousDownload(
+ item->GetTargetFilePath().BaseName().value(), item->GetGuid());
}
-DownloadControllerAndroidImpl::JavaObject*
- DownloadControllerAndroidImpl::GetJavaObject() {
+DownloadController::JavaObject*
+ DownloadController::GetJavaObject() {
if (!java_object_) {
// Initialize Java DownloadController by calling
// DownloadController.getInstance(), which will call Init()
@@ -557,7 +470,7 @@ DownloadControllerAndroidImpl::JavaObject*
return java_object_;
}
-void DownloadControllerAndroidImpl::StartContextMenuDownload(
+void DownloadController::StartContextMenuDownload(
const ContextMenuParams& params, WebContents* web_contents, bool is_link,
const std::string& extra_headers) {
int process_id = web_contents->GetRenderProcessHost()->GetID();
@@ -567,14 +480,14 @@ void DownloadControllerAndroidImpl::StartContextMenuDownload(
routing_id, params, is_link, extra_headers));
}
-void DownloadControllerAndroidImpl::DangerousDownloadValidated(
+void DownloadController::DangerousDownloadValidated(
WebContents* web_contents,
const std::string& download_guid,
bool accept) {
if (!web_contents)
return;
- DownloadManagerImpl* dlm = static_cast<DownloadManagerImpl*>(
- BrowserContext::GetDownloadManager(web_contents->GetBrowserContext()));
+ DownloadManager* dlm =
+ BrowserContext::GetDownloadManager(web_contents->GetBrowserContext());
DownloadItem* item = dlm->GetDownloadByGuid(download_guid);
if (!item)
return;
@@ -584,8 +497,8 @@ void DownloadControllerAndroidImpl::DangerousDownloadValidated(
item->Remove();
}
-DownloadControllerAndroidImpl::DownloadInfoAndroid::DownloadInfoAndroid(
- net::URLRequest* request)
+DownloadController::DownloadInfo::DownloadInfo(
+ const net::URLRequest* request)
: has_user_gesture(false) {
request->GetResponseHeaderByName("content-disposition", &content_disposition);
@@ -595,7 +508,7 @@ DownloadControllerAndroidImpl::DownloadInfoAndroid::DownloadInfoAndroid(
request->extra_request_headers().GetHeader(
net::HttpRequestHeaders::kUserAgent, &user_agent);
if (user_agent.empty())
- user_agent = GetContentClient()->GetUserAgent();
+ user_agent = GetUserAgent();
GURL referer_url(request->referrer());
if (referer_url.is_valid())
referer = referer_url.spec();
@@ -609,9 +522,7 @@ DownloadControllerAndroidImpl::DownloadInfoAndroid::DownloadInfoAndroid(
has_user_gesture = info->HasUserGesture();
}
-DownloadControllerAndroidImpl::DownloadInfoAndroid::DownloadInfoAndroid(
- const DownloadInfoAndroid& other) = default;
-
-DownloadControllerAndroidImpl::DownloadInfoAndroid::~DownloadInfoAndroid() {}
+DownloadController::DownloadInfo::DownloadInfo(
+ const DownloadInfo& other) = default;
-} // namespace content
+DownloadController::DownloadInfo::~DownloadInfo() {}
« no previous file with comments | « chrome/browser/android/download/download_controller.h ('k') | chrome/browser/android/download/download_controller_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698