| 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 super.onResume(); | 287 super.onResume(); |
| 288 } | 288 } |
| 289 | 289 |
| 290 @Override | 290 @Override |
| 291 public void onResumeWithNative() { | 291 public void onResumeWithNative() { |
| 292 super.onResumeWithNative(); | 292 super.onResumeWithNative(); |
| 293 mWebappUma.commitMetrics(); | 293 mWebappUma.commitMetrics(); |
| 294 } | 294 } |
| 295 | 295 |
| 296 @Override | 296 @Override |
| 297 public void onDeferredStartup() { |
| 298 super.onDeferredStartup(); |
| 299 |
| 300 WebappDataStorage storage = |
| 301 WebappRegistry.getInstance().getWebappDataStorage(mWebappInfo.id
()); |
| 302 if (storage != null) { |
| 303 onDeferredStartupWithStorage(storage); |
| 304 } else { |
| 305 onDeferredStartupWithNullStorage(); |
| 306 } |
| 307 } |
| 308 |
| 309 protected void onDeferredStartupWithStorage(WebappDataStorage storage) { |
| 310 updateStorage(storage); |
| 311 } |
| 312 |
| 313 protected void onDeferredStartupWithNullStorage() { |
| 314 return; |
| 315 } |
| 316 |
| 317 @Override |
| 297 protected int getControlContainerLayoutId() { | 318 protected int getControlContainerLayoutId() { |
| 298 return R.layout.webapp_control_container; | 319 return R.layout.webapp_control_container; |
| 299 } | 320 } |
| 300 | 321 |
| 301 @Override | 322 @Override |
| 302 public void postInflationStartup() { | 323 public void postInflationStartup() { |
| 303 initializeWebappData(); | 324 initializeWebappData(); |
| 304 | 325 |
| 305 super.postInflationStartup(); | 326 super.postInflationStartup(); |
| 306 WebappControlContainer controlContainer = | 327 WebappControlContainer controlContainer = |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 ? WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM | 362 ? WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM |
| 342 : WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT); | 363 : WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT); |
| 343 | 364 |
| 344 initializeSplashScreenWidgets(backgroundColor); | 365 initializeSplashScreenWidgets(backgroundColor); |
| 345 } | 366 } |
| 346 | 367 |
| 347 protected void initializeSplashScreenWidgets(final int backgroundColor) { | 368 protected void initializeSplashScreenWidgets(final int backgroundColor) { |
| 348 WebappDataStorage storage = | 369 WebappDataStorage storage = |
| 349 WebappRegistry.getInstance().getWebappDataStorage(mWebappInfo.id
()); | 370 WebappRegistry.getInstance().getWebappDataStorage(mWebappInfo.id
()); |
| 350 if (storage == null) { | 371 if (storage == null) { |
| 351 onStorageIsNull(backgroundColor); | 372 initializeSplashScreenWidgets(backgroundColor, null); |
| 352 return; | 373 return; |
| 353 } | 374 } |
| 354 | 375 |
| 355 updateStorage(storage); | |
| 356 storage.getSplashScreenImage(new WebappDataStorage.FetchCallback<Bitmap>
() { | 376 storage.getSplashScreenImage(new WebappDataStorage.FetchCallback<Bitmap>
() { |
| 357 @Override | 377 @Override |
| 358 public void onDataRetrieved(Bitmap splashImage) { | 378 public void onDataRetrieved(Bitmap splashImage) { |
| 359 initializeSplashScreenWidgets(backgroundColor, splashImage); | 379 initializeSplashScreenWidgets(backgroundColor, splashImage); |
| 360 } | 380 } |
| 361 }); | 381 }); |
| 362 } | 382 } |
| 363 | 383 |
| 364 protected void onStorageIsNull(int backgroundColor) {} | |
| 365 | |
| 366 protected void updateStorage(WebappDataStorage storage) { | 384 protected void updateStorage(WebappDataStorage storage) { |
| 367 // The information in the WebappDataStorage may have been purged by the | 385 // The information in the WebappDataStorage may have been purged by the |
| 368 // user clearing their history or not launching the web app recently. | 386 // user clearing their history or not launching the web app recently. |
| 369 // Restore the data if necessary from the intent. | 387 // Restore the data if necessary from the intent. |
| 370 storage.updateFromShortcutIntent(getIntent()); | 388 storage.updateFromShortcutIntent(getIntent()); |
| 371 | 389 |
| 372 // A recent last used time is the indicator that the web app is still | 390 // A recent last used time is the indicator that the web app is still |
| 373 // present on the home screen, and enables sources such as notifications
to | 391 // present on the home screen, and enables sources such as notifications
to |
| 374 // launch web apps. Thus, we do not update the last used time when the w
eb | 392 // launch web apps. Thus, we do not update the last used time when the w
eb |
| 375 // app is not directly launched from the home screen, as this interferes | 393 // app is not directly launched from the home screen, as this interferes |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 return new WebappDelegateFactory(this); | 693 return new WebappDelegateFactory(this); |
| 676 } | 694 } |
| 677 | 695 |
| 678 // We're temporarily disable CS on webapp since there are some issues. (http
://crbug.com/471950) | 696 // We're temporarily disable CS on webapp since there are some issues. (http
://crbug.com/471950) |
| 679 // TODO(changwan): re-enable it once the issues are resolved. | 697 // TODO(changwan): re-enable it once the issues are resolved. |
| 680 @Override | 698 @Override |
| 681 protected boolean isContextualSearchAllowed() { | 699 protected boolean isContextualSearchAllowed() { |
| 682 return false; | 700 return false; |
| 683 } | 701 } |
| 684 } | 702 } |
| OLD | NEW |