Chromium Code Reviews| Index: chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastWebContentsActivity.java |
| diff --git a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastWebContentsActivity.java b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastWebContentsActivity.java |
| index 11a5b319c2e4eb379d87106a920d56f852506c9f..dade123eacc01cd0e4b0b0b964f637b2d7df9127 100644 |
| --- a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastWebContentsActivity.java |
| +++ b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastWebContentsActivity.java |
| @@ -11,7 +11,6 @@ import android.content.Intent; |
| import android.content.IntentFilter; |
| import android.graphics.Color; |
| import android.media.AudioManager; |
| -import android.net.Uri; |
| import android.os.Bundle; |
| import android.os.Handler; |
| import android.os.PatternMatcher; |
| @@ -20,7 +19,6 @@ import android.view.KeyEvent; |
| import android.view.MotionEvent; |
| import android.view.WindowManager; |
| import android.widget.FrameLayout; |
| -import android.widget.Toast; |
| import org.chromium.base.Log; |
| import org.chromium.base.annotations.JNINamespace; |
| @@ -35,7 +33,7 @@ import org.chromium.ui.base.WindowAndroid; |
| /** |
| * Activity for displaying a WebContents in CastShell. |
| - * |
| + * <p> |
| * Typically, this class is controlled by CastContentWindowAndroid, which will |
| * start a new instance of this activity. If the CastContentWindowAndroid is |
| * destroyed, CastWebContentsActivity should finish(). Similarily, if this |
| @@ -59,19 +57,9 @@ public class CastWebContentsActivity extends Activity { |
| private boolean mReceivedUserLeave = false; |
| private static final int TEARDOWN_GRACE_PERIOD_TIMEOUT_MILLIS = 300; |
| - public static final String ACTION_DATA_SCHEME = "cast"; |
| - public static final String ACTION_DATA_AUTHORITY = "webcontents"; |
| - |
| - public static final String ACTION_EXTRA_WEB_CONTENTS = |
| - "com.google.android.apps.castshell.intent.extra.WEB_CONTENTS"; |
| - public static final String ACTION_EXTRA_KEY_CODE = |
| - "com.google.android.apps.castshell.intent.extra.KEY_CODE"; |
| - public static final String ACTION_KEY_EVENT = |
| - "com.google.android.apps.castshell.intent.action.KEY_EVENT"; |
| + |
| public static final String ACTION_STOP_ACTIVITY = |
| "com.google.android.apps.castshell.intent.action.STOP_ACTIVITY"; |
| - public static final String ACTION_ACTIVITY_STOPPED = |
| - "com.google.android.apps.castshell.intent.action.ACTIVITY_STOPPED"; |
| /* |
| * Intended to be called from "onStop" to determine if this is a "legitimate" stop or not. |
| @@ -91,13 +79,6 @@ public class CastWebContentsActivity extends Activity { |
| mHandler = new Handler(); |
| - // TODO(derekjchow): Remove this call. |
| - if (!CastBrowserHelper.initializeBrowser(getApplicationContext())) { |
|
halliwell
2017/05/19 17:04:08
What's the story behind removing this?
thoren
2017/05/19 17:19:49
Mostly because the TODO said to and it didn't seem
halliwell
2017/05/19 18:14:06
I see. I think we still want upstream CastShell t
|
| - Toast.makeText(this, R.string.browser_process_initialization_failed, Toast.LENGTH_SHORT) |
| - .show(); |
| - finish(); |
| - } |
| - |
| // Whenever our app is visible, volume controls should modify the music stream. |
| // For more information read: |
| // http://developer.android.com/training/managing-audio/volume-playback.html |
| @@ -138,7 +119,6 @@ public class CastWebContentsActivity extends Activity { |
| intent.setExtrasClassLoader(WebContents.class.getClassLoader()); |
| mInstanceId = intent.getData().getPath(); |
| - final String instanceId = mInstanceId; |
| if (mWindowDestroyedBroadcastReceiver != null) { |
| LocalBroadcastManager.getInstance(this).unregisterReceiver( |
| mWindowDestroyedBroadcastReceiver); |
| @@ -158,8 +138,8 @@ public class CastWebContentsActivity extends Activity { |
| LocalBroadcastManager.getInstance(this).registerReceiver( |
| mWindowDestroyedBroadcastReceiver, mWindowDestroyedIntentFilter); |
| - WebContents webContents = |
| - (WebContents) intent.getParcelableExtra(ACTION_EXTRA_WEB_CONTENTS); |
| + WebContents webContents = (WebContents) intent.getParcelableExtra( |
| + CastWebContentsComponent.ACTION_EXTRA_WEB_CONTENTS); |
| if (webContents == null) { |
| Log.e(TAG, "Received null WebContents in intent."); |
| maybeFinishLater(); |
| @@ -215,8 +195,9 @@ public class CastWebContentsActivity extends Activity { |
| if (DEBUG) Log.d(TAG, "onResume"); |
| super.onResume(); |
| - if (mAudioManager.requestAudioFocus(null, AudioManager.STREAM_MUSIC, |
| - AudioManager.AUDIOFOCUS_GAIN) != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { |
| + if (mAudioManager.requestAudioFocus( |
| + null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN) |
| + != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { |
| Log.e(TAG, "Failed to obtain audio focus"); |
| } |
| } |
| @@ -254,9 +235,7 @@ public class CastWebContentsActivity extends Activity { |
| || keyCode == KeyEvent.KEYCODE_MEDIA_STOP |
| || keyCode == KeyEvent.KEYCODE_MEDIA_NEXT |
| || keyCode == KeyEvent.KEYCODE_MEDIA_PREVIOUS) { |
| - Intent intent = new Intent(ACTION_KEY_EVENT, getInstanceUri()); |
| - intent.putExtra(ACTION_EXTRA_KEY_CODE, keyCode); |
| - LocalBroadcastManager.getInstance(this).sendBroadcastSync(intent); |
| + CastWebContentsComponent.onKeyDown(this, mInstanceId, keyCode); |
| // Stop key should end the entire session. |
| if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP) { |
| @@ -342,9 +321,9 @@ public class CastWebContentsActivity extends Activity { |
| mContentView, webContents, mWindow); |
| // Enable display of current webContents. |
| if (getParent() != null) mContentViewCore.onShow(); |
| - mCastWebContentsLayout.addView( |
| - mContentView, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, |
| - FrameLayout.LayoutParams.MATCH_PARENT)); |
| + mCastWebContentsLayout.addView(mContentView, |
| + new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, |
| + FrameLayout.LayoutParams.MATCH_PARENT)); |
| mContentView.requestFocus(); |
| mContentViewRenderView.setCurrentContentViewCore(mContentViewCore); |
| } |
| @@ -357,21 +336,10 @@ public class CastWebContentsActivity extends Activity { |
| mContentView = null; |
| mContentViewCore = null; |
| - // Inform CastContentWindowAndroid we're detaching. |
| - Intent intent = new Intent(ACTION_ACTIVITY_STOPPED, getInstanceUri()); |
| - LocalBroadcastManager.getInstance(this).sendBroadcastSync(intent); |
| + CastWebContentsComponent.onComponentClosed(this, mInstanceId); |
| } |
| } |
| - private Uri getInstanceUri() { |
| - Uri instanceUri = new Uri.Builder() |
| - .scheme(CastWebContentsActivity.ACTION_DATA_SCHEME) |
| - .authority(CastWebContentsActivity.ACTION_DATA_AUTHORITY) |
| - .path(mInstanceId) |
| - .build(); |
| - return instanceUri; |
| - } |
| - |
| private native void nativeSetContentVideoViewEmbedder( |
| WebContents webContents, ContentVideoViewEmbedder embedder); |
| } |