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

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

Issue 11103040: Upstream latest DownloadController changes for android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
« 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.h" 5 #include "content/browser/android/download_controller.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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 282
283 return GetContentViewCoreFromWebContents(web_contents); 283 return GetContentViewCoreFromWebContents(web_contents);
284 } 284 }
285 285
286 ScopedJavaLocalRef<jobject> 286 ScopedJavaLocalRef<jobject>
287 DownloadController::GetContentViewCoreFromWebContents( 287 DownloadController::GetContentViewCoreFromWebContents(
288 WebContents* web_contents) { 288 WebContents* web_contents) {
289 if (!web_contents) 289 if (!web_contents)
290 return ScopedJavaLocalRef<jobject>(); 290 return ScopedJavaLocalRef<jobject>();
291 291
292 NOTIMPLEMENTED(); 292 ContentViewCore* view_core = web_contents->GetContentNativeView();
293 return ScopedJavaLocalRef<jobject>(); 293 return view_core ? view_core->GetJavaObject() :
294 ScopedJavaLocalRef<jobject>();
294 } 295 }
295 296
296 DownloadController::JavaObject* DownloadController::GetJavaObject() { 297 DownloadController::JavaObject* DownloadController::GetJavaObject() {
297 if (!java_object_) { 298 if (!java_object_) {
298 // Initialize Java DownloadController by calling 299 // Initialize Java DownloadController by calling
299 // DownloadController.getInstance(), which will call Init() 300 // DownloadController.getInstance(), which will call Init()
300 // if Java DownloadController is not instantiated already. 301 // if Java DownloadController is not instantiated already.
301 JNIEnv* env = AttachCurrentThread(); 302 JNIEnv* env = AttachCurrentThread();
302 ScopedJavaLocalRef<jclass> clazz = 303 ScopedJavaLocalRef<jclass> clazz =
303 GetClass(env, kDownloadControllerClassPathName); 304 GetClass(env, kDownloadControllerClassPathName);
304 jmethodID get_instance = GetStaticMethodID(env, clazz, "getInstance", 305 jmethodID get_instance = GetStaticMethodID(env, clazz, "getInstance",
305 "()Lorg/chromium/content/browser/DownloadController;"); 306 "()Lorg/chromium/content/browser/DownloadController;");
306 ScopedJavaLocalRef<jobject> jobj(env, 307 ScopedJavaLocalRef<jobject> jobj(env,
307 env->CallStaticObjectMethod(clazz.obj(), get_instance)); 308 env->CallStaticObjectMethod(clazz.obj(), get_instance));
308 CheckException(env); 309 CheckException(env);
309 } 310 }
310 311
311 DCHECK(java_object_); 312 DCHECK(java_object_);
312 return java_object_; 313 return java_object_;
313 } 314 }
314 315
315 DownloadController::DownloadInfoAndroid::DownloadInfoAndroid( 316 DownloadController::DownloadInfoAndroid::DownloadInfoAndroid(
316 net::URLRequest* request) { 317 net::URLRequest* request) {
317 request->GetResponseHeaderByName("content-disposition", &content_disposition); 318 request->GetResponseHeaderByName("content-disposition", &content_disposition);
318 request->GetResponseHeaderByName("mime-type", &original_mime_type); 319 request->GetMimeType(&original_mime_type);
319 request->extra_request_headers().GetHeader( 320 request->extra_request_headers().GetHeader(
320 net::HttpRequestHeaders::kUserAgent, &user_agent); 321 net::HttpRequestHeaders::kUserAgent, &user_agent);
321 GURL referer_url(request->GetSanitizedReferrer()); 322 GURL referer_url(request->GetSanitizedReferrer());
322 if (referer_url.is_valid()) 323 if (referer_url.is_valid())
323 referer = referer_url.spec(); 324 referer = referer_url.spec();
324 if (!request->url_chain().empty()) { 325 if (!request->url_chain().empty()) {
325 original_url = request->url_chain().front(); 326 original_url = request->url_chain().front();
326 url = request->url_chain().back(); 327 url = request->url_chain().back();
327 } 328 }
328 } 329 }
329 330
330 DownloadController::DownloadInfoAndroid::~DownloadInfoAndroid() {} 331 DownloadController::DownloadInfoAndroid::~DownloadInfoAndroid() {}
331 332
332 } // namespace content 333 } // 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