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

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: address comments Created 4 years, 3 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 210dea89961b880d2d5a430be5ae824343617bc3..fb920ec4c3ecd5acb6b33edc50ed3cebc741954c 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
@@ -36,6 +36,7 @@ import org.chromium.chrome.browser.tabmodel.TabCreatorManager.TabCreator;
import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
import org.chromium.chrome.browser.tabmodel.TabModelUtils;
+import org.chromium.chrome.browser.tabmodel.TabWindowManager;
import org.chromium.components.web_contents_delegate_android.WebContentsDelegateAndroid;
import org.chromium.content_public.browser.InvalidateTypes;
import org.chromium.content_public.browser.WebContents;
@@ -73,6 +74,7 @@ public class TabWebContentsDelegateAndroid extends WebContentsDelegateAndroid {
private int mDisplayMode = WebDisplayMode.Browser;
protected Handler mHandler;
+
private final Runnable mCloseContentsRunnable = new Runnable() {
@Override
public void run() {
@@ -221,9 +223,10 @@ public class TabWebContentsDelegateAndroid extends WebContentsDelegateAndroid {
@Override
public void navigationStateChanged(int flags) {
if ((flags & InvalidateTypes.TAB) != 0) {
+ int mediaType = MediaCaptureNotificationService.getMediaType(
+ isCapturingAudio(), isCapturingVideo(), isCapturingScreen());
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.
@@ -470,8 +473,26 @@ 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) {
+ final Tab tab = TabWindowManager.getInstance().getTabById(tabId);
+ if (tab != null) nativeNotifyStopped(tab.getWebContents());
+ }
+
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