Skip to content

Commit be71692

Browse files
author
Ben Murdoch
committed
Add support for HTML Media Capture "capture" attribute.
Plumb the value of the "capture" attribute through the framework down to the embedder. Requires a change in WebKit (I0a921be31fda79a43c05da4fe22d9c808d92709c) and Browser (I38dfe2df043fdba1388384dbd3b5370737eb38e5). Bug: 5771207 Change-Id: I494adc1274ca21ce8fe52a6c7b6b758217927e66
1 parent 5573ac0 commit be71692

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

core/java/android/webkit/CallbackProxy.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,8 @@ public void onClick(
791791
case OPEN_FILE_CHOOSER:
792792
if (mWebChromeClient != null) {
793793
UploadFileMessageData data = (UploadFileMessageData)msg.obj;
794-
mWebChromeClient.openFileChooser(data.getUploadFile(), data.getAcceptType());
794+
mWebChromeClient.openFileChooser(data.getUploadFile(), data.getAcceptType(),
795+
data.getCapture());
795796
}
796797
break;
797798

@@ -1566,10 +1567,12 @@ public void getVisitedHistory(ValueCallback<String[]> callback) {
15661567
private static class UploadFileMessageData {
15671568
private UploadFile mCallback;
15681569
private String mAcceptType;
1570+
private String mCapture;
15691571

1570-
public UploadFileMessageData(UploadFile uploadFile, String acceptType) {
1572+
public UploadFileMessageData(UploadFile uploadFile, String acceptType, String capture) {
15711573
mCallback = uploadFile;
15721574
mAcceptType = acceptType;
1575+
mCapture = capture;
15731576
}
15741577

15751578
public UploadFile getUploadFile() {
@@ -1579,6 +1582,10 @@ public UploadFile getUploadFile() {
15791582
public String getAcceptType() {
15801583
return mAcceptType;
15811584
}
1585+
1586+
public String getCapture() {
1587+
return mCapture;
1588+
}
15821589
}
15831590

15841591
private class UploadFile implements ValueCallback<Uri> {
@@ -1597,13 +1604,13 @@ public Uri getResult() {
15971604
/**
15981605
* Called by WebViewCore to open a file chooser.
15991606
*/
1600-
/* package */ Uri openFileChooser(String acceptType) {
1607+
/* package */ Uri openFileChooser(String acceptType, String capture) {
16011608
if (mWebChromeClient == null) {
16021609
return null;
16031610
}
16041611
Message myMessage = obtainMessage(OPEN_FILE_CHOOSER);
16051612
UploadFile uploadFile = new UploadFile();
1606-
UploadFileMessageData data = new UploadFileMessageData(uploadFile, acceptType);
1613+
UploadFileMessageData data = new UploadFileMessageData(uploadFile, acceptType, capture);
16071614
myMessage.obj = data;
16081615
synchronized (this) {
16091616
sendMessage(myMessage);

core/java/android/webkit/WebChromeClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,11 @@ public void getVisitedHistory(ValueCallback<String[]> callback) {
346346
* onReceiveValue must be called to wake up the thread.a
347347
* @param acceptType The value of the 'accept' attribute of the input tag
348348
* associated with this file picker.
349+
* @param capture The value of the 'capture' attribute of the input tag
350+
* associated with this file picker.
349351
* @hide
350352
*/
351-
public void openFileChooser(ValueCallback<Uri> uploadFile, String acceptType) {
353+
public void openFileChooser(ValueCallback<Uri> uploadFile, String acceptType, String capture) {
352354
uploadFile.onReceiveValue(null);
353355
}
354356

core/java/android/webkit/WebViewCore.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,12 @@ enum FocusDirection {
394394
* Called by JNI. Open a file chooser to upload a file.
395395
* @param acceptType The value of the 'accept' attribute of the
396396
* input tag associated with this file picker.
397+
* @param capture The value of the 'capture' attribute of the
398+
* input tag associated with this file picker.
397399
* @return String version of the URI.
398400
*/
399-
private String openFileChooser(String acceptType) {
400-
Uri uri = mCallbackProxy.openFileChooser(acceptType);
401+
private String openFileChooser(String acceptType, String capture) {
402+
Uri uri = mCallbackProxy.openFileChooser(acceptType, capture);
401403
if (uri != null) {
402404
String filePath = "";
403405
// Note - querying for MediaStore.Images.Media.DATA

0 commit comments

Comments
 (0)