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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java

Issue 1804723002: [Offline pages] Showing offline bolt on chrome custom tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java
index 391b0cae5ddd7b50c94ce1701e0e26bf1442bcb1..919c5c6f7bf416fabd5071618c7a31d89fbc7c63 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java
@@ -74,6 +74,7 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
private long mInitializeTimeStamp;
private int mState = STATE_DOMAIN_ONLY;
private String mFirstUrl;
+ private boolean mShowsOfflinePage = false;
private Runnable mTitleAnimationStarter = new Runnable() {
@Override
@@ -283,6 +284,7 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
setUrlBarHidden(false);
}
}
+ showOfflineBoltIfNecessary();
}
@Override
@@ -380,6 +382,10 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
((TintedDrawable) mCustomActionButton.getDrawable()).setTint(
mUseDarkColors ? mDarkModeTint : mLightModeTint);
}
+ if (mSecurityButton.getDrawable() instanceof TintedDrawable) {
+ ((TintedDrawable) mSecurityButton.getDrawable()).setTint(
+ mUseDarkColors ? mDarkModeTint : mLightModeTint);
+ }
}
@Override
@@ -432,6 +438,7 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
@Override
public void updateSecurityIcon(int securityLevel) {
if (mSecurityIconType == securityLevel || mState == STATE_TITLE_ONLY) return;
+
mSecurityIconType = securityLevel;
if (securityLevel == ConnectionSecurityLevel.NONE) {
@@ -451,6 +458,25 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
mUrlBar.invalidate();
}
+ private void showOfflineBoltIfNecessary() {
+ boolean isOfflinePage = getCurrentTab() != null && getCurrentTab().isOfflinePage();
+ if (isOfflinePage == mShowsOfflinePage) return;
+
+ mShowsOfflinePage = isOfflinePage;
+ if (mShowsOfflinePage) {
+ // If we are showing an offline page, immediately update icon to offline bolt.
+ TintedDrawable bolt = TintedDrawable.constructTintedDrawable(
+ getResources(), R.drawable.offline_bolt);
+ bolt.setTint(mUseDarkColors ? mDarkModeTint : mLightModeTint);
+ mSecurityButton.setImageDrawable(bolt);
+ mAnimDelegate.showSecurityButton();
+ } else {
+ // We are hiding the offline page so connection security information will change.
+ mSecurityIconType = ConnectionSecurityLevel.NONE;
+ mAnimDelegate.hideSecurityButton();
+ }
+ }
+
/**
* For extending classes to override and carry out the changes related with the primary color
* for the current tab changing.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698