| 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 1193612b50221fd7c59ccd0312c671577d9e35f9..41e58a9263a64556a0d3b4999c56a03f127b8982 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>();
|
| +
|
| 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());
|
| + } 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);
|
| }
|
|
|