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

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

Issue 2613573003: Fix blank NTP bug on Clank. (Closed)
Patch Set: Address nit. Created 3 years, 11 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/ChromeActivity.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
index 18adaf61d65f89a3135c1cb7af9a987f9ee260f7..878805fce72c652dedc2f343252339eeecac2c14 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
@@ -206,6 +206,8 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
private boolean mDeferredStartupPosted;
private boolean mTabModelsInitialized;
+ private boolean mNativeInitialized;
+ private boolean mRemoveWindowBackgroundDone;
// The class cannot implement TouchExplorationStateChangeListener,
// because it is only available for Build.VERSION_CODES.KITKAT and later.
@@ -682,6 +684,9 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
+
+ maybeRemoveWindowBackground();
+
Tab tab = getActivityTab();
if (tab == null) return;
if (hasFocus) {
@@ -1039,8 +1044,15 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
ApiCompatibilityUtils.getColor(getResources(), R.color.light_background_color));
}
- @Override
- public void finishNativeInitialization() {
+ private void maybeRemoveWindowBackground() {
+ // Only need to do this logic once.
+ if (mRemoveWindowBackgroundDone) return;
+
+ // Remove the window background only after native init and window getting focus. It's done
+ // after native init because before native init, a fake background gets shown. The window
+ // focus dependency is because doing it earlier can cause drawing bugs, e.g. crbug/673831.
+ if (!mNativeInitialized || !hasWindowFocus()) return;
+
// The window background color is used as the resizing background color in Android N+
// multi-window mode. See crbug.com/602366.
if (Build.VERSION.CODENAME.equals("N") || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
@@ -1050,6 +1062,14 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
} else {
removeWindowBackground();
}
+
+ mRemoveWindowBackgroundDone = true;
+ }
+
+ @Override
+ public void finishNativeInitialization() {
+ mNativeInitialized = true;
+ maybeRemoveWindowBackground();
DownloadManagerService.getDownloadManagerService(
getApplicationContext()).onActivityLaunched();
« 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