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

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

Issue 2123863004: ScreenCapture for Android phase1, part II (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: UI tweaking and rebase Created 4 years, 4 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: chrome/android/java/src/org/chromium/chrome/browser/tab/TabWebContentsDelegateAndroid.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabWebContentsDelegateAndroid.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabWebContentsDelegateAndroid.java
index c99d98f24b48bb72ca3e6895a25bfef2885ab331..58a0b313e555661d37104dae7eb0e9a7aeaab697 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabWebContentsDelegateAndroid.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabWebContentsDelegateAndroid.java
@@ -15,6 +15,7 @@ import android.media.AudioManager;
import android.os.Build;
import android.os.Handler;
import android.util.Pair;
+import android.util.SparseArray;
import android.view.KeyEvent;
import android.view.View;
@@ -74,6 +75,9 @@ public class TabWebContentsDelegateAndroid extends WebContentsDelegateAndroid {
private int mDisplayMode = WebDisplayMode.Browser;
protected Handler mHandler;
+ // Static array for NotifyStopped() method under a static context for screen capture.
+ private static SparseArray<WebContents> sWebContentsMap = new SparseArray<WebContents>();
gone 2016/08/10 19:04:02 1) private static final 2) Use javadoc syntax:
braveyao 2016/08/12 23:37:44 Done. Removed.
+
private final Runnable mCloseContentsRunnable = new Runnable() {
@Override
public void run() {
@@ -226,9 +230,17 @@ public class TabWebContentsDelegateAndroid extends WebContentsDelegateAndroid {
@Override
public void navigationStateChanged(int flags) {
if ((flags & InvalidateTypes.TAB) != 0) {
+ int mediaType = MediaCaptureNotificationService.getMediaType(
+ isCapturingAudio(), isCapturingVideo(), isCapturingScreen());
+ // Update webcontents map for notifying stop action to native for screen capture.
+ if (isCapturingScreen()) {
+ sWebContentsMap.put(mTab.getId(), mTab.getWebContents());
gone 2016/08/10 19:04:02 1) Tabs can swap their WebContents, but you don't
braveyao 2016/08/12 23:37:44 Done. Use the newly added TabWindowManager#getTabB
+ } else {
+ sWebContentsMap.delete(mTab.getId());
+ }
+
MediaCaptureNotificationService.updateMediaNotificationForTab(
- mTab.getApplicationContext(), mTab.getId(), isCapturingAudio(),
- isCapturingVideo(), mTab.getUrl());
+ mTab.getApplicationContext(), mTab.getId(), mediaType, mTab.getUrl());
}
if ((flags & InvalidateTypes.TITLE) != 0) {
// Update cached title then notify observers.
@@ -475,8 +487,25 @@ public class TabWebContentsDelegateAndroid extends WebContentsDelegateAndroid {
return !mTab.isClosing() && nativeIsCapturingVideo(mTab.getWebContents());
}
+ /**
+ * @return Whether screen is being captured.
+ */
+ private boolean isCapturingScreen() {
+ return !mTab.isClosing() && nativeIsCapturingScreen(mTab.getWebContents());
+ }
+
+ /**
+ * When STOP button in the media capture notification is clicked, pass the event to native
+ * to stop the media capture.
+ **/
+ public static void notifyStopped(int tabId) {
+ if (sWebContentsMap.indexOfKey(tabId) >= 0) nativeNotifyStopped(sWebContentsMap.get(tabId));
+ }
+
private static native void nativeOnRendererUnresponsive(WebContents webContents);
private static native void nativeOnRendererResponsive(WebContents webContents);
private static native boolean nativeIsCapturingAudio(WebContents webContents);
private static native boolean nativeIsCapturingVideo(WebContents webContents);
+ private static native boolean nativeIsCapturingScreen(WebContents webContents);
+ private static native void nativeNotifyStopped(WebContents webContents);
}

Powered by Google App Engine
This is Rietveld 408576698