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" |
11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h" | 13 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h" |
14 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h" | 14 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/profiles/profile_android.h" | 16 #include "chrome/browser/profiles/profile_android.h" |
17 #include "jni/AnswersImage_jni.h" | 17 #include "jni/AnswersImage_jni.h" |
18 #include "third_party/skia/include/core/SkBitmap.h" | 18 #include "third_party/skia/include/core/SkBitmap.h" |
19 #include "ui/gfx/android/java_bitmap.h" | 19 #include "ui/gfx/android/java_bitmap.h" |
20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
21 | 21 |
| 22 using base::android::JavaParamRef; |
22 using base::android::ScopedJavaLocalRef; | 23 using base::android::ScopedJavaLocalRef; |
23 using base::android::ConvertUTF8ToJavaString; | 24 using base::android::ConvertUTF8ToJavaString; |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 class AnswersImageObserverAndroid : public BitmapFetcherService::Observer { | 28 class AnswersImageObserverAndroid : public BitmapFetcherService::Observer { |
28 public: | 29 public: |
29 explicit AnswersImageObserverAndroid(JNIEnv* env, | 30 explicit AnswersImageObserverAndroid(JNIEnv* env, |
30 jobject java_answers_image_observer) { | 31 jobject java_answers_image_observer) { |
31 java_answers_image_observer_.Reset(env, java_answers_image_observer); | 32 java_answers_image_observer_.Reset(env, java_answers_image_observer); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 std::string url; | 75 std::string url; |
75 base::android::ConvertJavaStringToUTF8(env, java_url, &url); | 76 base::android::ConvertJavaStringToUTF8(env, java_url, &url); |
76 return bitmap_fetcher_service->RequestImage( | 77 return bitmap_fetcher_service->RequestImage( |
77 GURL(url), new AnswersImageObserverAndroid(env, java_callback)); | 78 GURL(url), new AnswersImageObserverAndroid(env, java_callback)); |
78 } | 79 } |
79 | 80 |
80 // static | 81 // static |
81 bool RegisterAnswersImageBridge(JNIEnv* env) { | 82 bool RegisterAnswersImageBridge(JNIEnv* env) { |
82 return RegisterNativesImpl(env); | 83 return RegisterNativesImpl(env); |
83 } | 84 } |
OLD | NEW |