Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java

Issue 1749603002: Store URLs in WebappDataStorage, and purge them when history is cleared. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 scope may have been purged by the user clearing their history. It is
256 // needed to be able to launch a webapp from a notification. Make sure t hat the
257 // scope exists by restoring it on webapp launch; this method will no-op if the
258 // scope does exist as it should not be possible to overwrite any set sc ope.
259 WebappDataStorage.setScope(this, mWebappInfo.id(), mWebappInfo.uri().toS tring());
260
261 // Retrieve the splash image if it exists.
255 WebappDataStorage.open(this, mWebappInfo.id()).getSplashScreenImage( 262 WebappDataStorage.open(this, mWebappInfo.id()).getSplashScreenImage(
256 new WebappDataStorage.FetchCallback<Bitmap>() { 263 new WebappDataStorage.FetchCallback<Bitmap>() {
257 @Override 264 @Override
258 public void onDataRetrieved(Bitmap splashImage) { 265 public void onDataRetrieved(Bitmap splashImage) {
259 initializeSplashScreenWidgets(backgroundColor, splashIma ge); 266 initializeSplashScreenWidgets(backgroundColor, splashIma ge);
260 } 267 }
261 }); 268 });
262 } 269 }
263 270
264 private void initializeSplashScreenWidgets(int backgroundColor, Bitmap splas hImage) { 271 private void initializeSplashScreenWidgets(int backgroundColor, Bitmap splas hImage) {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 return visible; 576 return visible;
570 } 577 }
571 578
572 // We're temporarily disable CS on webapp since there are some issues. (http ://crbug.com/471950) 579 // 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. 580 // TODO(changwan): re-enable it once the issues are resolved.
574 @Override 581 @Override
575 protected boolean isContextualSearchAllowed() { 582 protected boolean isContextualSearchAllowed() {
576 return false; 583 return false;
577 } 584 }
578 } 585 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698