| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shortcut_helper.h" | 5 #include "chrome/browser/android/shortcut_helper.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 info.source, | 57 info.source, |
| 58 info.theme_color, | 58 info.theme_color, |
| 59 info.background_color); | 59 info.background_color); |
| 60 } | 60 } |
| 61 | 61 |
| 62 // static | 62 // static |
| 63 void ShortcutHelper::FetchSplashScreenImage( | 63 void ShortcutHelper::FetchSplashScreenImage( |
| 64 content::WebContents* web_contents, | 64 content::WebContents* web_contents, |
| 65 const GURL& image_url, | 65 const GURL& image_url, |
| 66 const int ideal_splash_image_size_in_dp, | 66 const int ideal_splash_image_size_in_dp, |
| 67 const int minimum_splash_image_size_in_dp, |
| 67 const std::string& webapp_id) { | 68 const std::string& webapp_id) { |
| 68 // This is a fire and forget task. It is not vital for the splash screen image | 69 // This is a fire and forget task. It is not vital for the splash screen image |
| 69 // to be downloaded so if the downloader returns false there is no fallback. | 70 // to be downloaded so if the downloader returns false there is no fallback. |
| 70 ManifestIconDownloader::Download( | 71 ManifestIconDownloader::Download( |
| 71 web_contents, | 72 web_contents, |
| 72 image_url, | 73 image_url, |
| 73 ideal_splash_image_size_in_dp, | 74 ideal_splash_image_size_in_dp, |
| 75 minimum_splash_image_size_in_dp, |
| 74 base::Bind(&ShortcutHelper::StoreWebappData, webapp_id)); | 76 base::Bind(&ShortcutHelper::StoreWebappData, webapp_id)); |
| 75 } | 77 } |
| 76 | 78 |
| 77 // static | 79 // static |
| 78 void ShortcutHelper::StoreWebappData( | 80 void ShortcutHelper::StoreWebappData( |
| 79 const std::string& webapp_id, | 81 const std::string& webapp_id, |
| 80 const SkBitmap& splash_image) { | 82 const SkBitmap& splash_image) { |
| 81 if (splash_image.drawsNothing()) | 83 if (splash_image.drawsNothing()) |
| 82 return; | 84 return; |
| 83 | 85 |
| 84 JNIEnv* env = base::android::AttachCurrentThread(); | 86 JNIEnv* env = base::android::AttachCurrentThread(); |
| 85 ScopedJavaLocalRef<jstring> java_webapp_id = | 87 ScopedJavaLocalRef<jstring> java_webapp_id = |
| 86 base::android::ConvertUTF8ToJavaString(env, webapp_id); | 88 base::android::ConvertUTF8ToJavaString(env, webapp_id); |
| 87 ScopedJavaLocalRef<jobject> java_splash_image = | 89 ScopedJavaLocalRef<jobject> java_splash_image = |
| 88 gfx::ConvertToJavaBitmap(&splash_image); | 90 gfx::ConvertToJavaBitmap(&splash_image); |
| 89 | 91 |
| 90 Java_ShortcutHelper_storeWebappData( | 92 Java_ShortcutHelper_storeWebappData( |
| 91 env, | 93 env, |
| 92 base::android::GetApplicationContext(), | 94 base::android::GetApplicationContext(), |
| 93 java_webapp_id.obj(), | 95 java_webapp_id.obj(), |
| 94 java_splash_image.obj()); | 96 java_splash_image.obj()); |
| 95 } | 97 } |
| 96 | 98 |
| 97 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { | 99 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { |
| 98 return RegisterNativesImpl(env); | 100 return RegisterNativesImpl(env); |
| 99 } | 101 } |
| OLD | NEW |