OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 package org.chromium.chrome.browser.webapps; | 5 package org.chromium.chrome.browser.webapps; |
6 | 6 |
7 import android.content.Intent; | 7 import android.content.Intent; |
8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
9 import android.graphics.BitmapFactory; | |
10 import android.net.Uri; | 9 import android.net.Uri; |
11 import android.text.TextUtils; | |
12 import android.util.Base64; | |
13 import android.util.Log; | 10 import android.util.Log; |
14 | 11 |
15 import org.chromium.chrome.browser.ShortcutHelper; | 12 import org.chromium.chrome.browser.ShortcutHelper; |
16 import org.chromium.chrome.browser.ShortcutSource; | 13 import org.chromium.chrome.browser.ShortcutSource; |
17 import org.chromium.chrome.browser.util.IntentUtils; | 14 import org.chromium.chrome.browser.util.IntentUtils; |
18 import org.chromium.content_public.common.ScreenOrientationValues; | 15 import org.chromium.content_public.common.ScreenOrientationValues; |
19 | 16 |
20 /** | 17 /** |
21 * Stores info about a web app. | 18 * Stores info about a web app. |
22 */ | 19 */ |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // This is needed for clients that want to send the icon trough an intent. | 187 // This is needed for clients that want to send the icon trough an intent. |
191 public String encodedIcon() { | 188 public String encodedIcon() { |
192 return mEncodedIcon; | 189 return mEncodedIcon; |
193 } | 190 } |
194 | 191 |
195 /** | 192 /** |
196 * Returns the icon in Bitmap form. Caches the result for future retrievals
. | 193 * Returns the icon in Bitmap form. Caches the result for future retrievals
. |
197 */ | 194 */ |
198 public Bitmap icon() { | 195 public Bitmap icon() { |
199 if (mDecodedIcon != null) return mDecodedIcon; | 196 if (mDecodedIcon != null) return mDecodedIcon; |
200 if (TextUtils.isEmpty(mEncodedIcon)) return null; | 197 mDecodedIcon = ShortcutHelper.decodeBitmapFromString(mEncodedIcon); |
201 | |
202 byte[] decoded = Base64.decode(mEncodedIcon, Base64.DEFAULT); | |
203 mDecodedIcon = BitmapFactory.decodeByteArray(decoded, 0, decoded.length)
; | |
204 return mDecodedIcon; | 198 return mDecodedIcon; |
205 } | 199 } |
206 | 200 |
207 /** | 201 /** |
208 * Sets extras on an Intent that will launch a WebappActivity. | 202 * Sets extras on an Intent that will launch a WebappActivity. |
209 * @param intent Intent that will be used to launch a WebappActivity. | 203 * @param intent Intent that will be used to launch a WebappActivity. |
210 */ | 204 */ |
211 public void setWebappIntentExtras(Intent intent) { | 205 public void setWebappIntentExtras(Intent intent) { |
212 intent.putExtra(ShortcutHelper.EXTRA_ID, id()); | 206 intent.putExtra(ShortcutHelper.EXTRA_ID, id()); |
213 intent.putExtra(ShortcutHelper.EXTRA_URL, uri().toString()); | 207 intent.putExtra(ShortcutHelper.EXTRA_URL, uri().toString()); |
214 intent.putExtra(ShortcutHelper.EXTRA_ICON, encodedIcon()); | 208 intent.putExtra(ShortcutHelper.EXTRA_ICON, encodedIcon()); |
215 intent.putExtra(ShortcutHelper.EXTRA_NAME, name()); | 209 intent.putExtra(ShortcutHelper.EXTRA_NAME, name()); |
216 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName()); | 210 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName()); |
217 intent.putExtra(ShortcutHelper.EXTRA_ORIENTATION, orientation()); | 211 intent.putExtra(ShortcutHelper.EXTRA_ORIENTATION, orientation()); |
218 intent.putExtra(ShortcutHelper.EXTRA_SOURCE, source()); | 212 intent.putExtra(ShortcutHelper.EXTRA_SOURCE, source()); |
219 intent.putExtra(ShortcutHelper.EXTRA_THEME_COLOR, themeColor()); | 213 intent.putExtra(ShortcutHelper.EXTRA_THEME_COLOR, themeColor()); |
220 intent.putExtra(ShortcutHelper.EXTRA_BACKGROUND_COLOR, backgroundColor()
); | 214 intent.putExtra(ShortcutHelper.EXTRA_BACKGROUND_COLOR, backgroundColor()
); |
221 } | 215 } |
222 } | 216 } |
OLD | NEW |