| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/android/omnibox/answers_image_bridge.h" | 5 #include "chrome/browser/android/omnibox/answers_image_bridge.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 env, java_answers_image_observer_.obj(), java_bitmap.obj()); | 45 env, java_answers_image_observer_.obj(), java_bitmap.obj()); |
| 46 } | 46 } |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 base::android::ScopedJavaGlobalRef<jobject> java_answers_image_observer_; | 49 base::android::ScopedJavaGlobalRef<jobject> java_answers_image_observer_; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 } // namespace | 52 } // namespace |
| 53 | 53 |
| 54 static void CancelAnswersImageRequest(JNIEnv* env, | 54 static void CancelAnswersImageRequest(JNIEnv* env, |
| 55 jclass, | 55 const JavaParamRef<jclass>&, |
| 56 jobject java_profile, | 56 const JavaParamRef<jobject>& java_profile, |
| 57 jint java_request_id) { | 57 jint java_request_id) { |
| 58 Profile* profile = ProfileAndroid::FromProfileAndroid(java_profile); | 58 Profile* profile = ProfileAndroid::FromProfileAndroid(java_profile); |
| 59 DCHECK(profile); | 59 DCHECK(profile); |
| 60 BitmapFetcherService* bitmap_fetcher_service = | 60 BitmapFetcherService* bitmap_fetcher_service = |
| 61 BitmapFetcherServiceFactory::GetForBrowserContext(profile); | 61 BitmapFetcherServiceFactory::GetForBrowserContext(profile); |
| 62 bitmap_fetcher_service->CancelRequest(java_request_id); | 62 bitmap_fetcher_service->CancelRequest(java_request_id); |
| 63 } | 63 } |
| 64 | 64 |
| 65 static int RequestAnswersImage(JNIEnv* env, | 65 static int RequestAnswersImage(JNIEnv* env, |
| 66 jclass, | 66 const JavaParamRef<jclass>&, |
| 67 jobject java_profile, | 67 const JavaParamRef<jobject>& java_profile, |
| 68 jstring java_url, | 68 const JavaParamRef<jstring>& java_url, |
| 69 jobject java_callback) { | 69 const JavaParamRef<jobject>& java_callback) { |
| 70 Profile* profile = ProfileAndroid::FromProfileAndroid(java_profile); | 70 Profile* profile = ProfileAndroid::FromProfileAndroid(java_profile); |
| 71 DCHECK(profile); | 71 DCHECK(profile); |
| 72 BitmapFetcherService* bitmap_fetcher_service = | 72 BitmapFetcherService* bitmap_fetcher_service = |
| 73 BitmapFetcherServiceFactory::GetForBrowserContext(profile); | 73 BitmapFetcherServiceFactory::GetForBrowserContext(profile); |
| 74 std::string url; | 74 std::string url; |
| 75 base::android::ConvertJavaStringToUTF8(env, java_url, &url); | 75 base::android::ConvertJavaStringToUTF8(env, java_url, &url); |
| 76 return bitmap_fetcher_service->RequestImage( | 76 return bitmap_fetcher_service->RequestImage( |
| 77 GURL(url), new AnswersImageObserverAndroid(env, java_callback)); | 77 GURL(url), new AnswersImageObserverAndroid(env, java_callback)); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // static | 80 // static |
| 81 bool RegisterAnswersImageBridge(JNIEnv* env) { | 81 bool RegisterAnswersImageBridge(JNIEnv* env) { |
| 82 return RegisterNativesImpl(env); | 82 return RegisterNativesImpl(env); |
| 83 } | 83 } |
| OLD | NEW |