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

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

Issue 1145303004: Pass browser user agent to android DownloadManager if no override UA is present. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/time/time.h" 12 #include "base/time/time.h"
13 #include "content/browser/android/content_view_core_impl.h" 13 #include "content/browser/android/content_view_core_impl.h"
14 #include "content/browser/android/deferred_download_observer.h" 14 #include "content/browser/android/deferred_download_observer.h"
15 #include "content/browser/download/download_item_impl.h" 15 #include "content/browser/download/download_item_impl.h"
16 #include "content/browser/download/download_manager_impl.h" 16 #include "content/browser/download/download_manager_impl.h"
17 #include "content/browser/loader/resource_dispatcher_host_impl.h" 17 #include "content/browser/loader/resource_dispatcher_host_impl.h"
18 #include "content/browser/renderer_host/render_process_host_impl.h" 18 #include "content/browser/renderer_host/render_process_host_impl.h"
19 #include "content/browser/renderer_host/render_view_host_delegate.h" 19 #include "content/browser/renderer_host/render_view_host_delegate.h"
20 #include "content/browser/renderer_host/render_view_host_impl.h" 20 #include "content/browser/renderer_host/render_view_host_impl.h"
21 #include "content/browser/web_contents/web_contents_impl.h" 21 #include "content/browser/web_contents/web_contents_impl.h"
22 #include "content/public/browser/browser_context.h" 22 #include "content/public/browser/browser_context.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/download_url_parameters.h" 24 #include "content/public/browser/download_url_parameters.h"
25 #include "content/public/browser/global_request_id.h" 25 #include "content/public/browser/global_request_id.h"
26 #include "content/public/browser/resource_request_info.h" 26 #include "content/public/browser/resource_request_info.h"
27 #include "content/public/common/content_client.h"
27 #include "content/public/common/referrer.h" 28 #include "content/public/common/referrer.h"
28 #include "jni/DownloadController_jni.h" 29 #include "jni/DownloadController_jni.h"
29 #include "net/cookies/cookie_options.h" 30 #include "net/cookies/cookie_options.h"
30 #include "net/cookies/cookie_store.h" 31 #include "net/cookies/cookie_store.h"
31 #include "net/http/http_content_disposition.h" 32 #include "net/http/http_content_disposition.h"
32 #include "net/http/http_request_headers.h" 33 #include "net/http/http_request_headers.h"
33 #include "net/http/http_response_headers.h" 34 #include "net/http/http_response_headers.h"
34 #include "net/url_request/url_request.h" 35 #include "net/url_request/url_request.h"
35 #include "net/url_request/url_request_context.h" 36 #include "net/url_request/url_request_context.h"
36 37
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 DownloadControllerAndroidImpl::DownloadInfoAndroid::DownloadInfoAndroid( 429 DownloadControllerAndroidImpl::DownloadInfoAndroid::DownloadInfoAndroid(
429 net::URLRequest* request) 430 net::URLRequest* request)
430 : has_user_gesture(false) { 431 : has_user_gesture(false) {
431 request->GetResponseHeaderByName("content-disposition", &content_disposition); 432 request->GetResponseHeaderByName("content-disposition", &content_disposition);
432 433
433 if (request->response_headers()) 434 if (request->response_headers())
434 request->response_headers()->GetMimeType(&original_mime_type); 435 request->response_headers()->GetMimeType(&original_mime_type);
435 436
436 request->extra_request_headers().GetHeader( 437 request->extra_request_headers().GetHeader(
437 net::HttpRequestHeaders::kUserAgent, &user_agent); 438 net::HttpRequestHeaders::kUserAgent, &user_agent);
439 if (user_agent.empty())
440 user_agent = GetContentClient()->GetUserAgent();
438 GURL referer_url(request->referrer()); 441 GURL referer_url(request->referrer());
439 if (referer_url.is_valid()) 442 if (referer_url.is_valid())
440 referer = referer_url.spec(); 443 referer = referer_url.spec();
441 if (!request->url_chain().empty()) { 444 if (!request->url_chain().empty()) {
442 original_url = request->url_chain().front(); 445 original_url = request->url_chain().front();
443 url = request->url_chain().back(); 446 url = request->url_chain().back();
444 } 447 }
445 448
446 const content::ResourceRequestInfo* info = 449 const content::ResourceRequestInfo* info =
447 content::ResourceRequestInfo::ForRequest(request); 450 content::ResourceRequestInfo::ForRequest(request);
448 if (info) 451 if (info)
449 has_user_gesture = info->HasUserGesture(); 452 has_user_gesture = info->HasUserGesture();
450 } 453 }
451 454
452 DownloadControllerAndroidImpl::DownloadInfoAndroid::~DownloadInfoAndroid() {} 455 DownloadControllerAndroidImpl::DownloadInfoAndroid::~DownloadInfoAndroid() {}
453 456
454 } // namespace content 457 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698