| Index: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
|
| index 0821ec3dd4d99d495da416926d0e2dc2b9e9fdd0..a4a1fce4de38f338711cdce623bf6516203f9014 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
|
| @@ -7,6 +7,7 @@ package org.chromium.chrome.browser.tab;
|
| import android.app.Activity;
|
| import android.content.Context;
|
| import android.content.Intent;
|
| +import android.content.res.Resources;
|
| import android.graphics.Bitmap;
|
| import android.graphics.Color;
|
| import android.text.TextUtils;
|
| @@ -318,6 +319,9 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
|
| */
|
| private View mSadTabView;
|
|
|
| + private final int mDefaultThemeColor;
|
| + private int mThemeColor;
|
| +
|
| /**
|
| * A default {@link ChromeContextMenuItemDelegate} that supports some of the context menu
|
| * functionality.
|
| @@ -685,8 +689,19 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
|
|
|
| @Override
|
| public void didChangeThemeColor(int color) {
|
| + int securityLevel = getSecurityLevel();
|
| + if (securityLevel == ConnectionSecurityLevel.SECURITY_ERROR
|
| + || securityLevel == ConnectionSecurityLevel.SECURITY_WARNING
|
| + || securityLevel == ConnectionSecurityLevel.SECURITY_POLICY_WARNING) {
|
| + color = mDefaultThemeColor;
|
| + }
|
| + if (isShowingInterstitialPage()) color = mDefaultThemeColor;
|
| + if (color == Color.TRANSPARENT) color = mDefaultThemeColor;
|
| + color |= 0xFF000000;
|
| + if (mThemeColor == color) return;
|
| + mThemeColor = color;
|
| for (TabObserver observer : mObservers) {
|
| - observer.onDidChangeThemeColor(color);
|
| + observer.onDidChangeThemeColor(Tab.this, mThemeColor);
|
| }
|
| }
|
|
|
| @@ -694,6 +709,7 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
|
| public void didAttachInterstitialPage() {
|
| getInfoBarContainer().setVisibility(View.INVISIBLE);
|
| showRenderedPage();
|
| + didChangeThemeColor(mDefaultThemeColor);
|
|
|
| for (TabObserver observer : mObservers) {
|
| observer.onDidAttachInterstitialPage(Tab.this);
|
| @@ -706,6 +722,7 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
|
| @Override
|
| public void didDetachInterstitialPage() {
|
| getInfoBarContainer().setVisibility(View.VISIBLE);
|
| + didChangeThemeColor(getWebContents().getThemeColor(mDefaultThemeColor));
|
|
|
| for (TabObserver observer : mObservers) {
|
| observer.onDidDetachInterstitialPage(Tab.this);
|
| @@ -782,8 +799,14 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
|
| mLaunchType = type;
|
| if (mContext != null) {
|
| mNumPixel16DP = (int) (DeviceDisplayInfo.create(mContext).getDIPScale() * 16);
|
| + Resources resources = mContext.getResources();
|
| + mDefaultThemeColor = mIncognito ? resources.getColor(R.color.incognito_primary_color)
|
| + : resources.getColor(R.color.default_primary_color);
|
| + mThemeColor = mDefaultThemeColor;
|
| + } else {
|
| + mDefaultThemeColor = 0;
|
| + mNumPixel16DP = 16;
|
| }
|
| - if (mNumPixel16DP == 0) mNumPixel16DP = 16;
|
|
|
| // Restore data from the TabState, if it existed.
|
| if (frozenState == null) {
|
| @@ -1104,6 +1127,14 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
|
| }
|
|
|
| /**
|
| + * @return The current theme color based on the value passed from the web contents and the
|
| + * security state.
|
| + */
|
| + public int getThemeColor() {
|
| + return mThemeColor;
|
| + }
|
| +
|
| + /**
|
| * @return The web contents associated with this tab.
|
| */
|
| public WebContents getWebContents() {
|
| @@ -2261,6 +2292,8 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
|
| mContentViewCore.onShow();
|
| mContentViewCore.attachImeAdapter();
|
| destroyNativePageInternal(previousNativePage);
|
| + mWebContentsObserver.didChangeThemeColor(
|
| + getWebContents().getThemeColor(mDefaultThemeColor));
|
| for (TabObserver observer : mObservers) {
|
| observer.onWebContentsSwapped(this, didStartLoad, didFinishLoad);
|
| }
|
|
|