| 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" |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // TODO(treib): For interactive doodles, use |fullpage_interactive_url| | 276 // TODO(treib): For interactive doodles, use |fullpage_interactive_url| |
| 277 // instead of |target_url|? | 277 // instead of |target_url|? |
| 278 const GURL& on_click_url = doodle_config.target_url; | 278 const GURL& on_click_url = doodle_config.target_url; |
| 279 const std::string& alt_text = doodle_config.alt_text; | 279 const std::string& alt_text = doodle_config.alt_text; |
| 280 image_fetcher_->StartOrQueueNetworkRequest( | 280 image_fetcher_->StartOrQueueNetworkRequest( |
| 281 image_url.spec(), image_url, | 281 image_url.spec(), image_url, |
| 282 base::Bind(&LogoBridge::DoodleImageFetched, base::Unretained(this), | 282 base::Bind(&LogoBridge::DoodleImageFetched, base::Unretained(this), |
| 283 from_cache, on_click_url, alt_text, animated_image_url)); | 283 from_cache, on_click_url, alt_text, animated_image_url)); |
| 284 } | 284 } |
| 285 | 285 |
| 286 void LogoBridge::DoodleImageFetched(bool config_from_cache, | 286 void LogoBridge::DoodleImageFetched( |
| 287 const GURL& on_click_url, | 287 bool config_from_cache, |
| 288 const std::string& alt_text, | 288 const GURL& on_click_url, |
| 289 const GURL& animated_image_url, | 289 const std::string& alt_text, |
| 290 const std::string& image_fetch_id, | 290 const GURL& animated_image_url, |
| 291 const gfx::Image& image) { | 291 const std::string& image_fetch_id, |
| 292 const gfx::Image& image, |
| 293 const image_fetcher::RequestMetadata& metadata) { |
| 292 JNIEnv* env = base::android::AttachCurrentThread(); | 294 JNIEnv* env = base::android::AttachCurrentThread(); |
| 293 | 295 |
| 294 if (image.IsEmpty()) { | 296 if (image.IsEmpty()) { |
| 295 DLOG(WARNING) << "Failed to download doodle image"; | 297 DLOG(WARNING) << "Failed to download doodle image"; |
| 296 Java_LogoObserver_onLogoAvailable(env, j_logo_observer_, | 298 Java_LogoObserver_onLogoAvailable(env, j_logo_observer_, |
| 297 ScopedJavaLocalRef<jobject>(), | 299 ScopedJavaLocalRef<jobject>(), |
| 298 config_from_cache); | 300 config_from_cache); |
| 299 return; | 301 return; |
| 300 } | 302 } |
| 301 | 303 |
| 302 ScopedJavaLocalRef<jobject> j_logo = MakeJavaLogo( | 304 ScopedJavaLocalRef<jobject> j_logo = MakeJavaLogo( |
| 303 env, image.ToSkBitmap(), on_click_url, alt_text, animated_image_url); | 305 env, image.ToSkBitmap(), on_click_url, alt_text, animated_image_url); |
| 304 Java_LogoObserver_onLogoAvailable(env, j_logo_observer_, j_logo, | 306 Java_LogoObserver_onLogoAvailable(env, j_logo_observer_, j_logo, |
| 305 config_from_cache); | 307 config_from_cache); |
| 306 } | 308 } |
| 307 | 309 |
| 308 // static | 310 // static |
| 309 bool RegisterLogoBridge(JNIEnv* env) { | 311 bool RegisterLogoBridge(JNIEnv* env) { |
| 310 return RegisterNativesImpl(env); | 312 return RegisterNativesImpl(env); |
| 311 } | 313 } |
| OLD | NEW |