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

Unified Diff: chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastWebContentsActivity.java

Issue 2874943002: [Chromecast] Add service for "displaying" cast web contents. (Closed)
Patch Set: [Chromecast] Add service for "displaying" cast web contents. Created 3 years, 7 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
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..a80de1cbf481fc77c2a543f5c35374cc63fe8548 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;
@@ -35,7 +34,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 +58,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,7 +80,6 @@ public class CastWebContentsActivity extends Activity {
mHandler = new Handler();
- // TODO(derekjchow): Remove this call.
if (!CastBrowserHelper.initializeBrowser(getApplicationContext())) {
Toast.makeText(this, R.string.browser_process_initialization_failed, Toast.LENGTH_SHORT)
.show();
@@ -138,7 +126,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 +145,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 +202,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 +242,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 +328,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 +343,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);
}

Powered by Google App Engine
This is Rietveld 408576698