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.Color; | 9 import android.graphics.Color; |
10 import android.graphics.drawable.Drawable; | 10 import android.graphics.drawable.Drawable; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 finish(); | 100 finish(); |
101 } else if (!TextUtils.equals(mWebappInfo.id(), newWebappInfo.id())) { | 101 } else if (!TextUtils.equals(mWebappInfo.id(), newWebappInfo.id())) { |
102 mWebappInfo = newWebappInfo; | 102 mWebappInfo = newWebappInfo; |
103 resetSavedInstanceState(); | 103 resetSavedInstanceState(); |
104 if (mIsInitialized) initializeUI(null); | 104 if (mIsInitialized) initializeUI(null); |
105 // TODO(dominickn): send the web app into fullscreen if mDisplayMode
is | 105 // TODO(dominickn): send the web app into fullscreen if mDisplayMode
is |
106 // WebDisplayMode.Fullscreen. See crbug.com/581522 | 106 // WebDisplayMode.Fullscreen. See crbug.com/581522 |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
| 110 protected boolean isInitialized() { |
| 111 return mIsInitialized; |
| 112 } |
| 113 |
110 private void initializeUI(Bundle savedInstanceState) { | 114 private void initializeUI(Bundle savedInstanceState) { |
111 // We do not load URL when restoring from saved instance states. | 115 // We do not load URL when restoring from saved instance states. |
112 if (savedInstanceState == null && mWebappInfo.isInitialized()) { | 116 if (savedInstanceState == null && mWebappInfo.isInitialized()) { |
113 if (TextUtils.isEmpty(getActivityTab().getUrl())) { | 117 if (TextUtils.isEmpty(getActivityTab().getUrl())) { |
114 getActivityTab().loadUrl(new LoadUrlParams( | 118 getActivityTab().loadUrl(new LoadUrlParams( |
115 mWebappInfo.uri().toString(), PageTransition.AUTO_TOPLEV
EL)); | 119 mWebappInfo.uri().toString(), PageTransition.AUTO_TOPLEV
EL)); |
116 } | 120 } |
117 } else { | 121 } else { |
118 if (NetworkChangeNotifier.isOnline()) getActivityTab().reloadIgnorin
gCache(); | 122 if (NetworkChangeNotifier.isOnline()) getActivityTab().reloadIgnorin
gCache(); |
119 } | 123 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 contentView.addView(mSplashScreen); | 256 contentView.addView(mSplashScreen); |
253 | 257 |
254 mWebappUma.splashscreenVisible(); | 258 mWebappUma.splashscreenVisible(); |
255 mWebappUma.recordSplashscreenBackgroundColor(mWebappInfo.hasValidBackgro
undColor() | 259 mWebappUma.recordSplashscreenBackgroundColor(mWebappInfo.hasValidBackgro
undColor() |
256 ? WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM | 260 ? WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM |
257 : WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT); | 261 : WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT); |
258 mWebappUma.recordSplashscreenThemeColor(mWebappInfo.hasValidThemeColor() | 262 mWebappUma.recordSplashscreenThemeColor(mWebappInfo.hasValidThemeColor() |
259 ? WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM | 263 ? WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM |
260 : WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT); | 264 : WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT); |
261 | 265 |
| 266 initializeSplashScreenWidgets(backgroundColor); |
| 267 } |
| 268 |
| 269 protected void initializeSplashScreenWidgets(final int backgroundColor) { |
262 final Intent intent = getIntent(); | 270 final Intent intent = getIntent(); |
263 WebappRegistry.getWebappDataStorage(this, mWebappInfo.id(), | 271 WebappRegistry.getWebappDataStorage(this, mWebappInfo.id(), |
264 new WebappRegistry.FetchWebappDataStorageCallback() { | 272 new WebappRegistry.FetchWebappDataStorageCallback() { |
265 @Override | 273 @Override |
266 public void onWebappDataStorageRetrieved(WebappDataStorage s
torage) { | 274 public void onWebappDataStorageRetrieved(WebappDataStorage s
torage) { |
267 if (storage == null) return; | 275 if (storage == null) return; |
268 | 276 |
269 // The information in the WebappDataStorage may have bee
n purged by the | 277 // The information in the WebappDataStorage may have bee
n purged by the |
270 // user clearing their history or not launching the web
app recently. | 278 // user clearing their history or not launching the web
app recently. |
271 // Restore the data if necessary from the intent. | 279 // Restore the data if necessary from the intent. |
(...skipping 13 matching lines...) Expand all Loading... |
285 @Override | 293 @Override |
286 public void onDataRetrieved(Bitmap splashImage) { | 294 public void onDataRetrieved(Bitmap splashImage) { |
287 initializeSplashScreenWidgets(backgroundColor, s
plashImage); | 295 initializeSplashScreenWidgets(backgroundColor, s
plashImage); |
288 } | 296 } |
289 }); | 297 }); |
290 } | 298 } |
291 } | 299 } |
292 ); | 300 ); |
293 } | 301 } |
294 | 302 |
295 private void initializeSplashScreenWidgets(int backgroundColor, Bitmap splas
hImage) { | 303 protected void initializeSplashScreenWidgets(int backgroundColor, Bitmap spl
ashImage) { |
296 Bitmap displayIcon = splashImage == null ? mWebappInfo.icon() : splashIm
age; | 304 Bitmap displayIcon = splashImage == null ? mWebappInfo.icon() : splashIm
age; |
297 int minimiumSizeThreshold = getResources().getDimensionPixelSize( | 305 int minimiumSizeThreshold = getResources().getDimensionPixelSize( |
298 R.dimen.webapp_splash_image_size_minimum); | 306 R.dimen.webapp_splash_image_size_minimum); |
299 int bigThreshold = getResources().getDimensionPixelSize( | 307 int bigThreshold = getResources().getDimensionPixelSize( |
300 R.dimen.webapp_splash_image_size_threshold); | 308 R.dimen.webapp_splash_image_size_threshold); |
301 | 309 |
302 // Inflate the correct layout for the image. | 310 // Inflate the correct layout for the image. |
303 int layoutId; | 311 int layoutId; |
304 if (displayIcon == null || displayIcon.getWidth() < minimiumSizeThreshol
d | 312 if (displayIcon == null || displayIcon.getWidth() < minimiumSizeThreshol
d |
305 || (displayIcon == mWebappInfo.icon() && mWebappInfo.isIconGener
ated())) { | 313 || (displayIcon == mWebappInfo.icon() && mWebappInfo.isIconGener
ated())) { |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 return visible; | 609 return visible; |
602 } | 610 } |
603 | 611 |
604 // We're temporarily disable CS on webapp since there are some issues. (http
://crbug.com/471950) | 612 // We're temporarily disable CS on webapp since there are some issues. (http
://crbug.com/471950) |
605 // TODO(changwan): re-enable it once the issues are resolved. | 613 // TODO(changwan): re-enable it once the issues are resolved. |
606 @Override | 614 @Override |
607 protected boolean isContextualSearchAllowed() { | 615 protected boolean isContextualSearchAllowed() { |
608 return false; | 616 return false; |
609 } | 617 } |
610 } | 618 } |
OLD | NEW |