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

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

Issue 2420663002: Custom Tabs: Preserve the offline bolt icon when showing an offline page. (Closed)
Patch Set: Hide security button if no drawable is available. Created 4 years, 2 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 d9358a58b7a3e22f2b6478e08ed47a92c0ddbe4f..e83afab71f8f3fc6ef68e1be666f62764b11ab16 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
@@ -342,7 +342,7 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
setUrlBarHidden(false);
}
}
- showOfflineBoltIfNecessary();
+ updateSecurityIcon(getSecurityLevel());
}
@Override
@@ -497,13 +497,22 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
mSecurityIconType = securityLevel;
+ boolean isOfflinePage = getCurrentTab() != null && getCurrentTab().isOfflinePage();
+ boolean showSecurityButton = securityLevel != ConnectionSecurityLevel.NONE || isOfflinePage;
+
if (securityLevel == ConnectionSecurityLevel.NONE) {
- mAnimDelegate.hideSecurityButton();
+ if (isOfflinePage && mShowsOfflinePage != isOfflinePage) {
+ TintedDrawable bolt = TintedDrawable.constructTintedDrawable(
+ getResources(), R.drawable.offline_pin);
+ bolt.setTint(mUseDarkColors ? mDarkModeTint : mLightModeTint);
+ mSecurityButton.setImageDrawable(bolt);
+ }
} else {
boolean isSmallDevice = !DeviceFormFactor.isTablet(getContext());
int id = LocationBarLayout.getSecurityIconResource(securityLevel, isSmallDevice);
if (id == 0) {
- mSecurityButton.setImageDrawable(null);
+ // Hide the button if we don't have an actual icon to display.
+ showSecurityButton = false;
} else {
// ImageView#setImageResource is no-op if given resource is the current one.
mSecurityButton.setImageResource(id);
@@ -511,29 +520,18 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
LocationBarLayout.getColorStateList(securityLevel, getToolbarDataProvider(),
getResources(), false /* omnibox is not opaque */));
}
- mAnimDelegate.showSecurityButton();
}
- mUrlBar.emphasizeUrl();
- 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_pin);
- bolt.setTint(mUseDarkColors ? mDarkModeTint : mLightModeTint);
- mSecurityButton.setImageDrawable(bolt);
+
+ if (showSecurityButton) {
mAnimDelegate.showSecurityButton();
} else {
- // We are hiding the offline page so connection security information will change.
- mSecurityIconType = ConnectionSecurityLevel.NONE;
mAnimDelegate.hideSecurityButton();
}
+
+ mUrlBar.emphasizeUrl();
+ mUrlBar.invalidate();
}
/**
« 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