Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java |
| index fa5965df126a8751638e78dc0f156cd0aedea01d..d230e68901e56cff90f4ed2889fe9daf2cf3abc2 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java |
| @@ -5,8 +5,12 @@ |
| package org.chromium.chrome.browser.vr_shell; |
| import android.annotation.SuppressLint; |
| +import android.graphics.Bitmap; |
| import android.graphics.Canvas; |
| import android.graphics.Point; |
| +import android.graphics.drawable.BitmapDrawable; |
| +import android.graphics.drawable.Drawable; |
| +import android.os.AsyncTask; |
| import android.os.StrictMode; |
| import android.view.MotionEvent; |
| import android.view.Surface; |
| @@ -20,10 +24,12 @@ import android.widget.FrameLayout.LayoutParams; |
| import com.google.vr.ndk.base.AndroidCompat; |
| import com.google.vr.ndk.base.GvrLayout; |
| +import org.chromium.base.ApiCompatibilityUtils; |
| import org.chromium.base.ThreadUtils; |
| import org.chromium.base.VisibleForTesting; |
| import org.chromium.base.annotations.CalledByNative; |
| import org.chromium.base.annotations.JNINamespace; |
| +import org.chromium.chrome.R; |
| import org.chromium.chrome.browser.ChromeActivity; |
| import org.chromium.chrome.browser.ChromeTabbedActivity; |
| import org.chromium.chrome.browser.NativePage; |
| @@ -208,8 +214,7 @@ public class VrShellImpl |
| } |
| @Override |
| - public void onWebContentsSwapped( |
| - Tab tab, boolean didStartLoad, boolean didFinishLoad) { |
| + public void onWebContentsSwapped(Tab tab, boolean didStartLoad, boolean didFinishLoad) { |
| onContentChanged(tab); |
| } |
| @@ -309,14 +314,39 @@ public class VrShellImpl |
| addView(mRenderToSurfaceLayoutParent); |
| } |
| + private void setSplashScreenIcon() { |
| + new AsyncTask<Void, Void, Bitmap>() { |
| + @Override |
| + protected Bitmap doInBackground(Void... params) { |
| + Drawable drawable = ApiCompatibilityUtils.getDrawable( |
| + mActivity.getResources(), R.mipmap.app_icon); |
| + if (drawable instanceof BitmapDrawable) { |
| + BitmapDrawable bd = (BitmapDrawable) drawable; |
| + return bd.getBitmap(); |
| + } |
| + assert false : "The drawable was not a bitmap drawable as expected"; |
| + return null; |
| + } |
| + @Override |
| + protected void onPostExecute(Bitmap bitmap) { |
| + nativeSetSplashScreenIcon(mNativeVrShell, bitmap); |
| + } |
| + } |
| + .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); |
|
cjgrant
2017/06/23 19:26:32
Is this supposed to be floating out here?
mthiesse
2017/06/23 23:11:25
yes.
ymalik
2017/06/25 20:27:14
Yeah the formatter is weird. Others are also like
|
| + } |
| + |
| @Override |
| - public void initializeNative( |
| - Tab currentTab, boolean forWebVr, boolean webVrAutopresented, boolean inCct) { |
| + public void initializeNative(Tab currentTab, boolean forWebVr, |
| + boolean webVrAutopresentationExpected, boolean inCct) { |
| mContentVrWindowAndroid = new VrWindowAndroid(mActivity, mContentVirtualDisplay); |
| mNativeVrShell = nativeInit(mDelegate, mContentVrWindowAndroid.getNativePointer(), forWebVr, |
| - webVrAutopresented, inCct, getGvrApi().getNativeGvrContext(), |
| + webVrAutopresentationExpected, inCct, getGvrApi().getNativeGvrContext(), |
| mReprojectedRendering); |
| + // We need to set the icon bitmap from here because we can't read the app icon from native |
| + // code. |
| + setSplashScreenIcon(); |
| + |
| // Set the UI and content sizes before we load the UI. |
| updateWebVrDisplaySize(forWebVr); |
| @@ -521,9 +551,9 @@ public class VrShellImpl |
| } |
| @Override |
| - public void setWebVrModeEnabled(boolean enabled, boolean autoPresented) { |
| + public void setWebVrModeEnabled(boolean enabled) { |
| mContentVrWindowAndroid.setVSyncPaused(enabled); |
| - nativeSetWebVrMode(mNativeVrShell, enabled, autoPresented); |
| + nativeSetWebVrMode(mNativeVrShell, enabled); |
| updateWebVrDisplaySize(enabled); |
| } |
| @@ -689,9 +719,10 @@ public class VrShellImpl |
| } |
| private native long nativeInit(VrShellDelegate delegate, long nativeWindowAndroid, |
| - boolean forWebVR, boolean webVRAutopresented, boolean inCct, long gvrApi, |
| + boolean forWebVR, boolean webVrAutopresentationExpected, boolean inCct, long gvrApi, |
| boolean reprojectedRendering); |
| private native void nativeSetSurface(long nativeVrShell, Surface surface); |
| + private native void nativeSetSplashScreenIcon(long nativeVrShell, Bitmap bitmap); |
| private native void nativeSwapContents( |
| long nativeVrShell, WebContents webContents, MotionEventSynthesizer eventSynthesizer); |
| private native void nativeDestroy(long nativeVrShell); |
| @@ -703,8 +734,7 @@ public class VrShellImpl |
| long nativeVrShell, WebContents webContents, int width, int height); |
| private native void nativeContentPhysicalBoundsChanged(long nativeVrShell, int width, |
| int height, float dpr); |
| - private native void nativeSetWebVrMode( |
| - long nativeVrShell, boolean enabled, boolean autoPresented); |
| + private native void nativeSetWebVrMode(long nativeVrShell, boolean enabled); |
| private native boolean nativeGetWebVrMode(long nativeVrShell); |
| private native void nativeOnTabListCreated(long nativeVrShell, Tab[] mainTabs, |
| Tab[] incognitoTabs); |