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

Side by Side Diff: content/browser/android/download_controller_android_impl.cc

Issue 13859009: Adding a call to support download initiated context menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
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 "content/browser/android/download_controller_android_impl.h" 5 #include "content/browser/android/download_controller_android_impl.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "content/browser/android/content_view_core_impl.h" 12 #include "content/browser/android/content_view_core_impl.h"
13 #include "content/browser/download/download_item_impl.h" 13 #include "content/browser/download/download_item_impl.h"
14 #include "content/browser/loader/resource_dispatcher_host_impl.h" 14 #include "content/browser/loader/resource_dispatcher_host_impl.h"
15 #include "content/browser/renderer_host/render_process_host_impl.h" 15 #include "content/browser/renderer_host/render_process_host_impl.h"
16 #include "content/browser/renderer_host/render_view_host_delegate.h" 16 #include "content/browser/renderer_host/render_view_host_delegate.h"
17 #include "content/browser/renderer_host/render_view_host_impl.h" 17 #include "content/browser/renderer_host/render_view_host_impl.h"
18 #include "content/browser/web_contents/web_contents_impl.h" 18 #include "content/browser/web_contents/web_contents_impl.h"
19 #include "content/public/browser/browser_context.h"
19 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/global_request_id.h" 21 #include "content/public/browser/global_request_id.h"
21 #include "content/public/browser/web_contents_view.h" 22 #include "content/public/browser/web_contents_view.h"
22 #include "jni/DownloadController_jni.h" 23 #include "jni/DownloadController_jni.h"
23 #include "net/cookies/cookie_options.h" 24 #include "net/cookies/cookie_options.h"
24 #include "net/cookies/cookie_store.h" 25 #include "net/cookies/cookie_store.h"
25 #include "net/http/http_request_headers.h" 26 #include "net/http/http_request_headers.h"
26 #include "net/http/http_response_headers.h" 27 #include "net/http/http_response_headers.h"
27 #include "net/url_request/url_request.h" 28 #include "net/url_request/url_request.h"
28 #include "net/url_request/url_request_context.h" 29 #include "net/url_request/url_request_context.h"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 // DownloadController.getInstance(), which will call Init() 310 // DownloadController.getInstance(), which will call Init()
310 // if Java DownloadController is not instantiated already. 311 // if Java DownloadController is not instantiated already.
311 JNIEnv* env = base::android::AttachCurrentThread(); 312 JNIEnv* env = base::android::AttachCurrentThread();
312 Java_DownloadController_getInstance(env); 313 Java_DownloadController_getInstance(env);
313 } 314 }
314 315
315 DCHECK(java_object_); 316 DCHECK(java_object_);
316 return java_object_; 317 return java_object_;
317 } 318 }
318 319
320 void DownloadControllerAndroidImpl::StartContextMenuDownload(
321 const ContextMenuParams& params, WebContents* web_contents, bool is_link) {
322 const GURL& url = is_link ? params.link_url : params.src_url;
323 const GURL& referrer = params.frame_url.is_empty() ?
324 params.page_url : params.frame_url;
325 DownloadManager* dlm = content::BrowserContext::GetDownloadManager(
nilesh 2013/04/12 16:27:45 dont need content:: here and below
nilesh 2013/04/12 16:27:45 We are supposed to use the _impl version inside co
qinmin 2013/04/15 18:56:51 Done.
qinmin 2013/04/15 18:56:51 Done.
326 web_contents->GetBrowserContext());
327 scoped_ptr<content::DownloadUrlParameters> dl_params(
328 DownloadUrlParameters::FromWebContents(web_contents, url));
329 dl_params->set_referrer(
330 Referrer(referrer, params.referrer_policy));
331 if (!is_link)
nilesh 2013/04/12 16:27:45 if (is_link) .. else .. I find this easier to read
qinmin 2013/04/15 18:56:51 Done.
332 dl_params->set_prefer_cache(true);
333 else
334 dl_params->set_referrer_encoding(params.frame_charset);
nilesh 2013/04/12 16:27:45 Why is referrer encoding only set for is_link?
qinmin 2013/04/15 18:56:51 This is from the upstream saving logic. I think fo
335 dl_params->set_prompt(false);
336 dlm->DownloadUrl(dl_params.Pass());
337 }
338
319 DownloadControllerAndroidImpl::DownloadInfoAndroid::DownloadInfoAndroid( 339 DownloadControllerAndroidImpl::DownloadInfoAndroid::DownloadInfoAndroid(
320 net::URLRequest* request) { 340 net::URLRequest* request) {
321 request->GetResponseHeaderByName("content-disposition", &content_disposition); 341 request->GetResponseHeaderByName("content-disposition", &content_disposition);
322 342
323 if (request->response_headers()) 343 if (request->response_headers())
324 request->response_headers()->GetMimeType(&original_mime_type); 344 request->response_headers()->GetMimeType(&original_mime_type);
325 345
326 request->extra_request_headers().GetHeader( 346 request->extra_request_headers().GetHeader(
327 net::HttpRequestHeaders::kUserAgent, &user_agent); 347 net::HttpRequestHeaders::kUserAgent, &user_agent);
328 GURL referer_url(request->referrer()); 348 GURL referer_url(request->referrer());
329 if (referer_url.is_valid()) 349 if (referer_url.is_valid())
330 referer = referer_url.spec(); 350 referer = referer_url.spec();
331 if (!request->url_chain().empty()) { 351 if (!request->url_chain().empty()) {
332 original_url = request->url_chain().front(); 352 original_url = request->url_chain().front();
333 url = request->url_chain().back(); 353 url = request->url_chain().back();
334 } 354 }
335 } 355 }
336 356
337 DownloadControllerAndroidImpl::DownloadInfoAndroid::~DownloadInfoAndroid() {} 357 DownloadControllerAndroidImpl::DownloadInfoAndroid::~DownloadInfoAndroid() {}
338 358
339 } // namespace content 359 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698