Chromium Code Reviews| Index: chrome/browser/android/logo_bridge.cc |
| diff --git a/chrome/browser/android/logo_bridge.cc b/chrome/browser/android/logo_bridge.cc |
| index 95780e1e1fdaa176e2ca54d21d21bec4212b2835..09cd4ee327f5c6872fec81538195f3fcb50b9ee0 100644 |
| --- a/chrome/browser/android/logo_bridge.cc |
| +++ b/chrome/browser/android/logo_bridge.cc |
| @@ -19,8 +19,6 @@ |
| #include "chrome/browser/doodle/doodle_service_factory.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/profiles/profile_android.h" |
| -#include "chrome/browser/search/suggestions/image_decoder_impl.h" |
| -#include "components/image_fetcher/core/image_fetcher_impl.h" |
| #include "components/search_provider_logos/logo_tracker.h" |
| #include "jni/LogoBridge_jni.h" |
| #include "net/url_request/url_fetcher.h" |
| @@ -40,8 +38,6 @@ using base::android::ToJavaByteArray; |
| namespace { |
| -const int64_t kMaxImageDownloadBytes = 1024 * 1024; |
| - |
| ScopedJavaLocalRef<jobject> MakeJavaLogo(JNIEnv* env, |
| const SkBitmap* bitmap, |
| const GURL& on_click_url, |
| @@ -200,11 +196,6 @@ LogoBridge::LogoBridge(jobject j_profile) |
| if (base::FeatureList::IsEnabled(chrome::android::kUseNewDoodleApi)) { |
| doodle_service_ = DoodleServiceFactory::GetForProfile(profile); |
| - image_fetcher_ = base::MakeUnique<image_fetcher::ImageFetcherImpl>( |
| - base::MakeUnique<suggestions::ImageDecoderImpl>(), |
| - profile->GetRequestContext()); |
| - image_fetcher_->SetImageDownloadLimit(kMaxImageDownloadBytes); |
| - |
| doodle_observer_.Add(doodle_service_); |
| } else { |
| logo_service_ = LogoServiceFactory::GetForProfile(profile); |
| @@ -284,47 +275,32 @@ void LogoBridge::FetchDoodleImage(const doodle::DoodleConfig& doodle_config, |
| bool from_cache) { |
| DCHECK(!j_logo_observer_.is_null()); |
| - // If there is a CTA image, that means the main image is animated. Show the |
| + // If there is a CTA image, that means the main image is animated. We show the |
| // non-animated CTA image first, and load the animated one only when the |
| // user requests it. |
| bool has_cta = doodle_config.large_cta_image.has_value(); |
| - const GURL& image_url = has_cta ? doodle_config.large_cta_image->url |
| - : doodle_config.large_image.url; |
| const GURL& animated_image_url = |
| has_cta ? doodle_config.large_image.url : GURL::EmptyGURL(); |
| - // TODO(treib): For interactive doodles, use |fullpage_interactive_url| |
|
fhorschig
2017/05/15 13:54:35
Why has that changed?
Marc Treib
2017/05/15 14:25:21
Sorry, I meant to comment on that and then forgot
|
| - // instead of |target_url|? |
| const GURL& on_click_url = doodle_config.target_url; |
| const std::string& alt_text = doodle_config.alt_text; |
| - image_fetcher_->StartOrQueueNetworkRequest( |
| - image_url.spec(), image_url, |
| + doodle_service_->GetImage( |
| base::Bind(&LogoBridge::DoodleImageFetched, base::Unretained(this), |
| from_cache, on_click_url, alt_text, animated_image_url)); |
| } |
| -void LogoBridge::DoodleImageFetched( |
| - bool config_from_cache, |
| - const GURL& on_click_url, |
| - const std::string& alt_text, |
| - const GURL& animated_image_url, |
| - const std::string& image_fetch_id, |
| - const gfx::Image& image, |
| - const image_fetcher::RequestMetadata& metadata) { |
| +void LogoBridge::DoodleImageFetched(bool config_from_cache, |
| + const GURL& on_click_url, |
| + const std::string& alt_text, |
| + const GURL& animated_image_url, |
| + const gfx::Image& image) { |
| JNIEnv* env = base::android::AttachCurrentThread(); |
| - if (image.IsEmpty()) { |
| - DLOG(WARNING) << "Failed to download doodle image"; |
| - Java_LogoObserver_onLogoAvailable(env, j_logo_observer_, |
| - ScopedJavaLocalRef<jobject>(), |
| - config_from_cache); |
| - return; |
| + ScopedJavaLocalRef<jobject> j_logo; |
| + if (!image.IsEmpty()) { |
| + j_logo = MakeJavaLogo(env, image.ToSkBitmap(), on_click_url, alt_text, |
| + animated_image_url); |
| } |
| - UMA_HISTOGRAM_BOOLEAN("NewTabPage.LogoImageDownloaded", |
| - metadata.from_http_cache); |
| - |
| - ScopedJavaLocalRef<jobject> j_logo = MakeJavaLogo( |
| - env, image.ToSkBitmap(), on_click_url, alt_text, animated_image_url); |
| Java_LogoObserver_onLogoAvailable(env, j_logo_observer_, j_logo, |
| config_from_cache); |
| } |