| 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/logo_bridge.h" | 5 #include "chrome/browser/android/logo_bridge.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| 11 #include "base/android/jni_array.h" | 11 #include "base/android/jni_array.h" |
| 12 #include "base/android/jni_string.h" | 12 #include "base/android/jni_string.h" |
| 13 #include "base/android/scoped_java_ref.h" | 13 #include "base/android/scoped_java_ref.h" |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/feature_list.h" | 15 #include "base/feature_list.h" |
| 16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
| 17 #include "chrome/browser/android/chrome_feature_list.h" | 17 #include "chrome/browser/android/chrome_feature_list.h" |
| 18 #include "chrome/browser/android/logo_service.h" | 18 #include "chrome/browser/android/logo_service.h" |
| 19 #include "chrome/browser/doodle/doodle_service_factory.h" | 19 #include "chrome/browser/doodle/doodle_service_factory.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/profiles/profile_android.h" | 21 #include "chrome/browser/profiles/profile_android.h" |
| 22 #include "chrome/browser/search/suggestions/image_decoder_impl.h" | 22 #include "components/image_fetcher/content/image_decoder_impl.h" |
| 23 #include "components/image_fetcher/core/image_fetcher_impl.h" | 23 #include "components/image_fetcher/core/image_fetcher_impl.h" |
| 24 #include "components/search_provider_logos/logo_tracker.h" | 24 #include "components/search_provider_logos/logo_tracker.h" |
| 25 #include "jni/LogoBridge_jni.h" | 25 #include "jni/LogoBridge_jni.h" |
| 26 #include "net/url_request/url_fetcher.h" | 26 #include "net/url_request/url_fetcher.h" |
| 27 #include "net/url_request/url_fetcher_delegate.h" | 27 #include "net/url_request/url_fetcher_delegate.h" |
| 28 #include "net/url_request/url_request_context_getter.h" | 28 #include "net/url_request/url_request_context_getter.h" |
| 29 #include "net/url_request/url_request_status.h" | 29 #include "net/url_request/url_request_status.h" |
| 30 #include "third_party/skia/include/core/SkBitmap.h" | 30 #include "third_party/skia/include/core/SkBitmap.h" |
| 31 #include "ui/gfx/android/java_bitmap.h" | 31 #include "ui/gfx/android/java_bitmap.h" |
| 32 #include "ui/gfx/image/image.h" | 32 #include "ui/gfx/image/image.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 : logo_service_(nullptr), | 192 : logo_service_(nullptr), |
| 193 doodle_service_(nullptr), | 193 doodle_service_(nullptr), |
| 194 doodle_observer_(this), | 194 doodle_observer_(this), |
| 195 weak_ptr_factory_(this) { | 195 weak_ptr_factory_(this) { |
| 196 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); | 196 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); |
| 197 DCHECK(profile); | 197 DCHECK(profile); |
| 198 | 198 |
| 199 if (base::FeatureList::IsEnabled(chrome::android::kUseNewDoodleApi)) { | 199 if (base::FeatureList::IsEnabled(chrome::android::kUseNewDoodleApi)) { |
| 200 doodle_service_ = DoodleServiceFactory::GetForProfile(profile); | 200 doodle_service_ = DoodleServiceFactory::GetForProfile(profile); |
| 201 image_fetcher_ = base::MakeUnique<image_fetcher::ImageFetcherImpl>( | 201 image_fetcher_ = base::MakeUnique<image_fetcher::ImageFetcherImpl>( |
| 202 base::MakeUnique<suggestions::ImageDecoderImpl>(), | 202 base::MakeUnique<image_fetcher::ImageDecoderImpl>(), |
| 203 profile->GetRequestContext()); | 203 profile->GetRequestContext()); |
| 204 | 204 |
| 205 doodle_observer_.Add(doodle_service_); | 205 doodle_observer_.Add(doodle_service_); |
| 206 } else { | 206 } else { |
| 207 logo_service_ = LogoServiceFactory::GetForProfile(profile); | 207 logo_service_ = LogoServiceFactory::GetForProfile(profile); |
| 208 } | 208 } |
| 209 | 209 |
| 210 animated_logo_fetcher_ = base::MakeUnique<AnimatedLogoFetcher>( | 210 animated_logo_fetcher_ = base::MakeUnique<AnimatedLogoFetcher>( |
| 211 profile->GetRequestContext()); | 211 profile->GetRequestContext()); |
| 212 } | 212 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 ScopedJavaLocalRef<jobject> j_logo = MakeJavaLogo( | 305 ScopedJavaLocalRef<jobject> j_logo = MakeJavaLogo( |
| 306 env, image.ToSkBitmap(), on_click_url, alt_text, animated_image_url); | 306 env, image.ToSkBitmap(), on_click_url, alt_text, animated_image_url); |
| 307 Java_LogoObserver_onLogoAvailable(env, j_logo_observer_, j_logo, | 307 Java_LogoObserver_onLogoAvailable(env, j_logo_observer_, j_logo, |
| 308 config_from_cache); | 308 config_from_cache); |
| 309 } | 309 } |
| 310 | 310 |
| 311 // static | 311 // static |
| 312 bool RegisterLogoBridge(JNIEnv* env) { | 312 bool RegisterLogoBridge(JNIEnv* env) { |
| 313 return RegisterNativesImpl(env); | 313 return RegisterNativesImpl(env); |
| 314 } | 314 } |
| OLD | NEW |