Commit 4a7757ad authored by Tao Bai's avatar Tao Bai Committed by Commit Bot

ContentCapture: Add commandline to dump the captured content

This is for QA to test the feature.

Bug: 924681
Change-Id: Ia9856b4970197fc9da4ae04fbb83528d5482247d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1498382
Commit-Queue: Tao Bai <michaelbai@chromium.org>
Reviewed-by: default avatarChangwan Ryu <changwan@chromium.org>
Reviewed-by: default avatarMartin Šrámek <msramek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638026}
parent 6bf58bbf
...@@ -6,6 +6,7 @@ package org.chromium.components.content_capture; ...@@ -6,6 +6,7 @@ package org.chromium.components.content_capture;
import android.view.ViewGroup; import android.view.ViewGroup;
import org.chromium.base.CommandLine;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
...@@ -17,7 +18,8 @@ import java.util.Arrays; ...@@ -17,7 +18,8 @@ import java.util.Arrays;
*/ */
public class ContentCaptureReceiverManager { public class ContentCaptureReceiverManager {
private static final String TAG = "ContentCapture"; private static final String TAG = "ContentCapture";
private static final boolean DEBUG = false; private static final String FLAG = "dump-captured-content-to-logcat-for-testing";
private static Boolean sDump;
private ContentCaptureConsumer mContentCaptureConsumer; private ContentCaptureConsumer mContentCaptureConsumer;
...@@ -27,7 +29,9 @@ public class ContentCaptureReceiverManager { ...@@ -27,7 +29,9 @@ public class ContentCaptureReceiverManager {
return manager; return manager;
} }
public ContentCaptureReceiverManager() {} public ContentCaptureReceiverManager() {
if (sDump == null) sDump = CommandLine.getInstance().hasSwitch(FLAG);
}
public void onContainerViewChanged(ViewGroup containerView) { public void onContainerViewChanged(ViewGroup containerView) {
// Reset current consumer, the new consumer that associates with contanerView shall be set // Reset current consumer, the new consumer that associates with contanerView shall be set
...@@ -44,7 +48,7 @@ public class ContentCaptureReceiverManager { ...@@ -44,7 +48,7 @@ public class ContentCaptureReceiverManager {
if (mContentCaptureConsumer != null) { if (mContentCaptureConsumer != null) {
mContentCaptureConsumer.onContentCaptured(toFrameSession(session), data); mContentCaptureConsumer.onContentCaptured(toFrameSession(session), data);
} }
if (DEBUG) Log.i(TAG, "Captured Content: %s", data); if (sDump.booleanValue()) Log.i(TAG, "Captured Content: %s", data);
} }
@CalledByNative @CalledByNative
...@@ -52,15 +56,16 @@ public class ContentCaptureReceiverManager { ...@@ -52,15 +56,16 @@ public class ContentCaptureReceiverManager {
FrameSession frameSession = toFrameSession(session); FrameSession frameSession = toFrameSession(session);
if (mContentCaptureConsumer != null) if (mContentCaptureConsumer != null)
mContentCaptureConsumer.onContentRemoved(frameSession, data); mContentCaptureConsumer.onContentRemoved(frameSession, data);
if (DEBUG) if (sDump.booleanValue()) {
Log.i(TAG, "Removed Content: %s", frameSession.get(0) + " " + Arrays.toString(data)); Log.i(TAG, "Removed Content: %s", frameSession.get(0) + " " + Arrays.toString(data));
}
} }
@CalledByNative @CalledByNative
private void didRemoveSession(Object[] session) { private void didRemoveSession(Object[] session) {
FrameSession frameSession = toFrameSession(session); FrameSession frameSession = toFrameSession(session);
if (mContentCaptureConsumer != null) mContentCaptureConsumer.onSessionRemoved(frameSession); if (mContentCaptureConsumer != null) mContentCaptureConsumer.onSessionRemoved(frameSession);
if (DEBUG) Log.i(TAG, "Removed Session: %s", frameSession.get(0)); if (sDump.booleanValue()) Log.i(TAG, "Removed Session: %s", frameSession.get(0));
} }
private FrameSession toFrameSession(Object[] session) { private FrameSession toFrameSession(Object[] session) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment