Index: chrome/android/java/src/org/chromium/chrome/browser/document/DocumentActivity.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/document/DocumentActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/document/DocumentActivity.java |
index b22e66a8afb42569560719b9fe2332c1f37674e8..1ede45b25d91c86f03fb4ceb8fdd613deaf53d63 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/document/DocumentActivity.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/document/DocumentActivity.java |
@@ -58,6 +58,7 @@ |
import org.chromium.chrome.browser.toolbar.ToolbarControlContainer; |
import org.chromium.chrome.browser.util.FeatureUtilities; |
import org.chromium.chrome.browser.util.IntentUtils; |
+import org.chromium.chrome.browser.widget.ControlContainer; |
import org.chromium.chrome.browser.widget.RoundedIconGenerator; |
import org.chromium.chrome.browser.widget.findinpage.FindToolbarManager; |
import org.chromium.components.service_tab_launcher.ServiceTabLauncher; |
@@ -103,6 +104,7 @@ |
// Indicates whether mIcon was generated by RoundedIconGenerator. |
private boolean mIsUsingGeneratedIcon; |
+ private Integer mThemeColor; |
private int mDefaultThemeColor; |
private DocumentTab mDocumentTab; |
@@ -532,7 +534,9 @@ |
@Override |
public void onWebContentsSwapped(Tab tab, boolean didStartLoad, boolean didFinishLoad) { |
if (!didStartLoad) return; |
- onFaviconReceived(tab.getFavicon()); |
+ mThemeColor = tab.getWebContents().getThemeColor(mDefaultThemeColor); |
+ mIcon = null; |
+ updateTaskDescription(); |
} |
@Override |
@@ -568,7 +572,7 @@ |
@Override |
public void onSSLStateUpdated(Tab tab) { |
- if (hasSecurityWarningOrError(tab)) resetIcon(); |
+ if (hasSecurityWarningOrError(tab)) resetThemeColorAndIcon(); |
} |
@Override |
@@ -585,6 +589,30 @@ |
updateTaskDescription(); |
mTabModel.updateEntry(getIntent(), mDocumentTab); |
+ } |
+ |
+ @Override |
+ public void onDidChangeThemeColor(int color) { |
+ if (hasSecurityWarningOrError(mDocumentTab)) return; |
+ if (color == Color.TRANSPARENT) color = mDefaultThemeColor; |
+ |
+ // Ignore any transparency value. |
+ color |= 0xFF000000; |
+ |
+ mThemeColor = Integer.valueOf(color); |
+ updateTaskDescription(); |
+ } |
+ |
+ @Override |
+ public void onDidAttachInterstitialPage(Tab tab) { |
+ resetThemeColorAndIcon(); |
+ } |
+ |
+ @Override |
+ public void onDidDetachInterstitialPage(Tab tab) { |
+ mThemeColor = tab.getWebContents().getThemeColor(mDefaultThemeColor); |
+ mIcon = null; |
+ updateTaskDescription(); |
} |
@Override |
@@ -627,7 +655,8 @@ |
} |
} |
- private void resetIcon() { |
+ private void resetThemeColorAndIcon() { |
+ mThemeColor = null; |
mIcon = null; |
updateTaskDescription(); |
} |
@@ -799,19 +828,27 @@ |
updateTaskDescription(label, mIcon); |
} |
+ protected int getThemeColor() { |
+ if (isIncognito()) { |
+ return mDefaultThemeColor; |
+ } else { |
+ return mThemeColor != null ? mThemeColor.intValue() : mDefaultThemeColor; |
+ } |
+ } |
+ |
private boolean shouldUseDefaultStatusBarColor() { |
- return isIncognito() || mThemeColor == mDefaultThemeColor; |
+ return isIncognito() || mThemeColor == null || mThemeColor == mDefaultThemeColor; |
} |
protected void updateTaskDescription(String label, Bitmap icon) { |
- DocumentUtils.updateTaskDescription(this, label, icon, mThemeColor, |
+ int color = getThemeColor(); |
+ DocumentUtils.updateTaskDescription(this, label, icon, color, |
shouldUseDefaultStatusBarColor()); |
- } |
- |
- @Override |
- protected void onThemeColorUpdate() { |
- super.onThemeColorUpdate(); |
- updateTaskDescription(); |
+ getToolbarManager().updatePrimaryColor(color); |
+ |
+ ControlContainer controlContainer = |
+ (ControlContainer) findViewById(R.id.control_container); |
+ controlContainer.getToolbarResourceAdapter().invalidate(null); |
} |
/** |