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

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

Issue 1182293002: Save image should download the original image when Data Saver is enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 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 "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"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 // if Java DownloadController is not instantiated already. 383 // if Java DownloadController is not instantiated already.
384 JNIEnv* env = base::android::AttachCurrentThread(); 384 JNIEnv* env = base::android::AttachCurrentThread();
385 Java_DownloadController_getInstance(env); 385 Java_DownloadController_getInstance(env);
386 } 386 }
387 387
388 DCHECK(java_object_); 388 DCHECK(java_object_);
389 return java_object_; 389 return java_object_;
390 } 390 }
391 391
392 void DownloadControllerAndroidImpl::StartContextMenuDownload( 392 void DownloadControllerAndroidImpl::StartContextMenuDownload(
393 const ContextMenuParams& params, WebContents* web_contents, bool is_link) { 393 const ContextMenuParams& params, WebContents* web_contents, bool is_link,
394 const std::string& headers) {
394 const GURL& url = is_link ? params.link_url : params.src_url; 395 const GURL& url = is_link ? params.link_url : params.src_url;
395 const GURL& referring_url = params.frame_url.is_empty() ? 396 const GURL& referring_url = params.frame_url.is_empty() ?
396 params.page_url : params.frame_url; 397 params.page_url : params.frame_url;
397 DownloadManagerImpl* dlm = static_cast<DownloadManagerImpl*>( 398 DownloadManagerImpl* dlm = static_cast<DownloadManagerImpl*>(
398 BrowserContext::GetDownloadManager(web_contents->GetBrowserContext())); 399 BrowserContext::GetDownloadManager(web_contents->GetBrowserContext()));
399 scoped_ptr<DownloadUrlParameters> dl_params( 400 scoped_ptr<DownloadUrlParameters> dl_params(
400 DownloadUrlParameters::FromWebContents(web_contents, url)); 401 DownloadUrlParameters::FromWebContents(web_contents, url));
401 content::Referrer referrer = content::Referrer::SanitizeForRequest( 402 content::Referrer referrer = content::Referrer::SanitizeForRequest(
402 url, 403 url,
403 content::Referrer(referring_url.GetAsReferrer(), 404 content::Referrer(referring_url.GetAsReferrer(),
404 params.referrer_policy)); 405 params.referrer_policy));
405 dl_params->set_referrer(referrer); 406 dl_params->set_referrer(referrer);
406 if (is_link) 407 if (is_link)
407 dl_params->set_referrer_encoding(params.frame_charset); 408 dl_params->set_referrer_encoding(params.frame_charset);
408 else 409 if (!headers.empty()) {
410 std::vector<std::string> key_value_list;
411 base::SplitString(headers, '\n', &key_value_list);
Ted C 2015/06/22 20:40:49 Instead of this, could it use something like HttpR
bengr 2015/06/22 22:13:10 Agreed.
megjablon 2015/06/22 23:21:02 I don't see another way to add the headers here ot
Ted C 2015/06/22 23:25:28 I was thinking that you would still use DownloadUR
megjablon 2015/06/23 00:54:27 Ah my bad. I misunderstood. Done.
412 for (const auto& key_value : key_value_list) {
413 std::vector<std::string> pair;
414 base::SplitString(key_value, ':', &pair);
415 DCHECK_EQ(2ul, pair.size());
416 dl_params->add_request_header(pair[0], pair[1]);
417 }
418 }
419 if (!is_link && headers.empty())
409 dl_params->set_prefer_cache(true); 420 dl_params->set_prefer_cache(true);
410 dl_params->set_prompt(false); 421 dl_params->set_prompt(false);
411 dlm->DownloadUrl(dl_params.Pass()); 422 dlm->DownloadUrl(dl_params.Pass());
412 } 423 }
413 424
414 void DownloadControllerAndroidImpl::DangerousDownloadValidated( 425 void DownloadControllerAndroidImpl::DangerousDownloadValidated(
415 WebContents* web_contents, int download_id, bool accept) { 426 WebContents* web_contents, int download_id, bool accept) {
416 if (!web_contents) 427 if (!web_contents)
417 return; 428 return;
418 DownloadManagerImpl* dlm = static_cast<DownloadManagerImpl*>( 429 DownloadManagerImpl* dlm = static_cast<DownloadManagerImpl*>(
(...skipping 29 matching lines...) Expand all
448 459
449 const content::ResourceRequestInfo* info = 460 const content::ResourceRequestInfo* info =
450 content::ResourceRequestInfo::ForRequest(request); 461 content::ResourceRequestInfo::ForRequest(request);
451 if (info) 462 if (info)
452 has_user_gesture = info->HasUserGesture(); 463 has_user_gesture = info->HasUserGesture();
453 } 464 }
454 465
455 DownloadControllerAndroidImpl::DownloadInfoAndroid::~DownloadInfoAndroid() {} 466 DownloadControllerAndroidImpl::DownloadInfoAndroid::~DownloadInfoAndroid() {}
456 467
457 } // namespace content 468 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698