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

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

Issue 1464743005: Remove DocumentTabObserver and merge task description updates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 private boolean mOldWebappCleanupStarted; 56 private boolean mOldWebappCleanupStarted;
57 57
58 private ViewGroup mSplashScreen; 58 private ViewGroup mSplashScreen;
59 private WebappUrlBar mUrlBar; 59 private WebappUrlBar mUrlBar;
60 60
61 private boolean mIsInitialized; 61 private boolean mIsInitialized;
62 private Integer mBrandColor; 62 private Integer mBrandColor;
63 63
64 private WebappUma mWebappUma; 64 private WebappUma mWebappUma;
65 65
66 private Bitmap mLargestFavicon;
67
66 /** 68 /**
67 * Construct all the variables that shouldn't change. We do it here both to clarify when the 69 * Construct all the variables that shouldn't change. We do it here both to clarify when the
68 * objects are created and to ensure that they exist throughout the parallel ized initialization 70 * objects are created and to ensure that they exist throughout the parallel ized initialization
69 * of the WebappActivity. 71 * of the WebappActivity.
70 */ 72 */
71 public WebappActivity() { 73 public WebappActivity() {
72 mWebappInfo = WebappInfo.createEmpty(); 74 mWebappInfo = WebappInfo.createEmpty();
73 mDirectoryManager = new WebappDirectoryManager(); 75 mDirectoryManager = new WebappDirectoryManager();
74 mWebappUma = new WebappUma(); 76 mWebappUma = new WebappUma();
75 } 77 }
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 mUrlBar.update(tab.getUrl(), tab.getSecurityLevel()); 282 mUrlBar.update(tab.getUrl(), tab.getSecurityLevel());
281 } 283 }
282 284
283 private boolean isWebappDomain() { 285 private boolean isWebappDomain() {
284 return UrlUtilities.sameDomainOrHost( 286 return UrlUtilities.sameDomainOrHost(
285 getActivityTab().getUrl(), getWebappInfo().uri().toString(), tru e); 287 getActivityTab().getUrl(), getWebappInfo().uri().toString(), tru e);
286 } 288 }
287 289
288 protected TabObserver createTabObserver() { 290 protected TabObserver createTabObserver() {
289 return new EmptyTabObserver() { 291 return new EmptyTabObserver() {
292
290 @Override 293 @Override
291 public void onSSLStateUpdated(Tab tab) { 294 public void onSSLStateUpdated(Tab tab) {
292 updateUrlBar(); 295 updateUrlBar();
293 } 296 }
294 297
295 @Override 298 @Override
296 public void onDidStartProvisionalLoadForFrame( 299 public void onDidStartProvisionalLoadForFrame(
297 Tab tab, long frameId, long parentFrameId, boolean isMainFra me, 300 Tab tab, long frameId, long parentFrameId, boolean isMainFra me,
298 String validatedUrl, boolean isErrorPage, boolean isIframeSr cdoc) { 301 String validatedUrl, boolean isErrorPage, boolean isIframeSr cdoc) {
299 if (isMainFrame) updateUrlBar(); 302 if (isMainFrame) updateUrlBar();
300 } 303 }
301 304
302 @Override 305 @Override
303 public void onDidChangeThemeColor(Tab tab, int color) { 306 public void onDidChangeThemeColor(Tab tab, int color) {
304 if (!isWebappDomain()) return; 307 if (!isWebappDomain()) return;
305 mBrandColor = color; 308 mBrandColor = color;
306 updateTaskDescription(); 309 updateTaskDescription();
307 } 310 }
308 311
309 @Override 312 @Override
310 public void onTitleUpdated(Tab tab) { 313 public void onTitleUpdated(Tab tab) {
311 if (!isWebappDomain()) return; 314 if (!isWebappDomain()) return;
312 updateTaskDescription(); 315 updateTaskDescription();
313 } 316 }
314 317
315 @Override 318 @Override
316 public void onFaviconUpdated(Tab tab) { 319 public void onFaviconUpdated(Tab tab, Bitmap icon) {
317 if (!isWebappDomain()) return; 320 if (!isWebappDomain()) return;
318 updateTaskDescription(); 321 if (mWebappInfo.icon() != null) return;
gone 2015/11/20 23:37:13 Why'd this new condition appear? Seems like we sh
Yusuf 2015/11/20 23:38:54 See updateTaskDescription where if there is an ico
Yusuf 2015/11/20 23:47:33 Done.
322 if (mLargestFavicon == null || icon.getWidth() > mLargestFavicon .getWidth()
323 || icon.getHeight() > mLargestFavicon.getHeight()) {
324 mLargestFavicon = icon;
325 updateTaskDescription();
326 }
319 } 327 }
320 328
321 @Override 329 @Override
322 public void onDidNavigateMainFrame(Tab tab, String url, String baseU rl, 330 public void onDidNavigateMainFrame(Tab tab, String url, String baseU rl,
323 boolean isNavigationToDifferentPage, boolean isNavigationInP age, 331 boolean isNavigationToDifferentPage, boolean isNavigationInP age,
324 int statusCode) { 332 int statusCode) {
325 updateUrlBar(); 333 updateUrlBar();
326 } 334 }
327 335
328 @Override 336 @Override
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 if (!TextUtils.isEmpty(mWebappInfo.shortName())) { 392 if (!TextUtils.isEmpty(mWebappInfo.shortName())) {
385 title = mWebappInfo.shortName(); 393 title = mWebappInfo.shortName();
386 } else if (getActivityTab() != null) { 394 } else if (getActivityTab() != null) {
387 title = getActivityTab().getTitle(); 395 title = getActivityTab().getTitle();
388 } 396 }
389 397
390 Bitmap icon = null; 398 Bitmap icon = null;
391 if (mWebappInfo.icon() != null) { 399 if (mWebappInfo.icon() != null) {
392 icon = mWebappInfo.icon(); 400 icon = mWebappInfo.icon();
393 } else if (getActivityTab() != null) { 401 } else if (getActivityTab() != null) {
394 icon = getActivityTab().getFavicon(); 402 icon = mLargestFavicon;
395 } 403 }
396 404
397 if (mBrandColor == null && mWebappInfo.hasValidThemeColor()) { 405 if (mBrandColor == null && mWebappInfo.hasValidThemeColor()) {
398 mBrandColor = (int) mWebappInfo.themeColor(); 406 mBrandColor = (int) mWebappInfo.themeColor();
399 } 407 }
400 408
401 int taskDescriptionColor = 409 int taskDescriptionColor =
402 ApiCompatibilityUtils.getColor(getResources(), R.color.default_p rimary_color); 410 ApiCompatibilityUtils.getColor(getResources(), R.color.default_p rimary_color);
403 int statusBarColor = Color.BLACK; 411 int statusBarColor = Color.BLACK;
404 if (mBrandColor != null) { 412 if (mBrandColor != null) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 return visible; 507 return visible;
500 } 508 }
501 509
502 // We're temporarily disable CS on webapp since there are some issues. (http ://crbug.com/471950) 510 // We're temporarily disable CS on webapp since there are some issues. (http ://crbug.com/471950)
503 // TODO(changwan): re-enable it once the issues are resolved. 511 // TODO(changwan): re-enable it once the issues are resolved.
504 @Override 512 @Override
505 protected boolean isContextualSearchAllowed() { 513 protected boolean isContextualSearchAllowed() {
506 return false; 514 return false;
507 } 515 }
508 } 516 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698