| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 mWebappUma.commitMetrics(); | 212 mWebappUma.commitMetrics(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 @Override | 215 @Override |
| 216 protected int getControlContainerLayoutId() { | 216 protected int getControlContainerLayoutId() { |
| 217 return R.layout.webapp_control_container; | 217 return R.layout.webapp_control_container; |
| 218 } | 218 } |
| 219 | 219 |
| 220 @Override | 220 @Override |
| 221 public void postInflationStartup() { | 221 public void postInflationStartup() { |
| 222 initializeSplashScreen(); | 222 initializeWebappData(); |
| 223 | 223 |
| 224 super.postInflationStartup(); | 224 super.postInflationStartup(); |
| 225 WebappControlContainer controlContainer = | 225 WebappControlContainer controlContainer = |
| 226 (WebappControlContainer) findViewById(R.id.control_container); | 226 (WebappControlContainer) findViewById(R.id.control_container); |
| 227 mUrlBar = (WebappUrlBar) controlContainer.findViewById(R.id.webapp_url_b
ar); | 227 mUrlBar = (WebappUrlBar) controlContainer.findViewById(R.id.webapp_url_b
ar); |
| 228 } | 228 } |
| 229 | 229 |
| 230 /** | 230 /** |
| 231 * @return Structure containing data about the webapp currently displayed. | 231 * @return Structure containing data about the webapp currently displayed. |
| 232 */ | 232 */ |
| 233 WebappInfo getWebappInfo() { | 233 WebappInfo getWebappInfo() { |
| 234 return mWebappInfo; | 234 return mWebappInfo; |
| 235 } | 235 } |
| 236 | 236 |
| 237 private void initializeSplashScreen() { | 237 private void initializeWebappData() { |
| 238 final int backgroundColor = ColorUtils.getOpaqueColor(mWebappInfo.backgr
oundColor( | 238 final int backgroundColor = ColorUtils.getOpaqueColor(mWebappInfo.backgr
oundColor( |
| 239 ApiCompatibilityUtils.getColor(getResources(), R.color.webapp_de
fault_bg))); | 239 ApiCompatibilityUtils.getColor(getResources(), R.color.webapp_de
fault_bg))); |
| 240 | 240 |
| 241 mSplashScreen = new FrameLayout(this); | 241 mSplashScreen = new FrameLayout(this); |
| 242 mSplashScreen.setBackgroundColor(backgroundColor); | 242 mSplashScreen.setBackgroundColor(backgroundColor); |
| 243 | 243 |
| 244 ViewGroup contentView = (ViewGroup) findViewById(android.R.id.content); | 244 ViewGroup contentView = (ViewGroup) findViewById(android.R.id.content); |
| 245 contentView.addView(mSplashScreen); | 245 contentView.addView(mSplashScreen); |
| 246 | 246 |
| 247 mWebappUma.splashscreenVisible(); | 247 mWebappUma.splashscreenVisible(); |
| 248 mWebappUma.recordSplashscreenBackgroundColor(mWebappInfo.hasValidBackgro
undColor() | 248 mWebappUma.recordSplashscreenBackgroundColor(mWebappInfo.hasValidBackgro
undColor() |
| 249 ? WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM | 249 ? WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM |
| 250 : WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT); | 250 : WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT); |
| 251 mWebappUma.recordSplashscreenThemeColor(mWebappInfo.hasValidThemeColor() | 251 mWebappUma.recordSplashscreenThemeColor(mWebappInfo.hasValidThemeColor() |
| 252 ? WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM | 252 ? WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM |
| 253 : WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT); | 253 : WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT); |
| 254 | 254 |
| 255 // The origin URL may have been purged by the user clearing their histor
y. It is |
| 256 // needed to be able to launch a webapp from a notification. Make sure t
hat the |
| 257 // URL exists by restoring it on webapp launch. |
| 258 WebappDataStorage.updateOriginUrl(this, mWebappInfo.id(), mWebappInfo.ur
i().toString()); |
| 259 |
| 260 // Retrieve the splash image if it exists. |
| 255 WebappDataStorage.open(this, mWebappInfo.id()).getSplashScreenImage( | 261 WebappDataStorage.open(this, mWebappInfo.id()).getSplashScreenImage( |
| 256 new WebappDataStorage.FetchCallback<Bitmap>() { | 262 new WebappDataStorage.FetchCallback<Bitmap>() { |
| 257 @Override | 263 @Override |
| 258 public void onDataRetrieved(Bitmap splashImage) { | 264 public void onDataRetrieved(Bitmap splashImage) { |
| 259 initializeSplashScreenWidgets(backgroundColor, splashIma
ge); | 265 initializeSplashScreenWidgets(backgroundColor, splashIma
ge); |
| 260 } | 266 } |
| 261 }); | 267 }); |
| 262 } | 268 } |
| 263 | 269 |
| 264 private void initializeSplashScreenWidgets(int backgroundColor, Bitmap splas
hImage) { | 270 private void initializeSplashScreenWidgets(int backgroundColor, Bitmap splas
hImage) { |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 return visible; | 575 return visible; |
| 570 } | 576 } |
| 571 | 577 |
| 572 // We're temporarily disable CS on webapp since there are some issues. (http
://crbug.com/471950) | 578 // We're temporarily disable CS on webapp since there are some issues. (http
://crbug.com/471950) |
| 573 // TODO(changwan): re-enable it once the issues are resolved. | 579 // TODO(changwan): re-enable it once the issues are resolved. |
| 574 @Override | 580 @Override |
| 575 protected boolean isContextualSearchAllowed() { | 581 protected boolean isContextualSearchAllowed() { |
| 576 return false; | 582 return false; |
| 577 } | 583 } |
| 578 } | 584 } |
| OLD | NEW |