summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorpaulmeyer <paulmeyer@chromium.org>2015-07-08 09:53:13 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-08 16:53:45 +0000
commit90bc5b73bb7232032689b034d8650934037d3baa (patch)
tree3d90f8c75bedf4d309c249cfe4845a7cdfff8c95 /extensions
parentf489a6606573530cabed24dfdb081853cba49c3f (diff)
downloadchromium_src-90bc5b73bb7232032689b034d8650934037d3baa.zip
chromium_src-90bc5b73bb7232032689b034d8650934037d3baa.tar.gz
chromium_src-90bc5b73bb7232032689b034d8650934037d3baa.tar.bz2
Changed the layout of permissionrequest events to match the documentation. Accessing info in the old way still works too, for backward compatibility.
BUG=485526 Review URL: https://codereview.chromium.org/1218753003 Cr-Commit-Position: refs/heads/master@{#337841}
Diffstat (limited to 'extensions')
-rw-r--r--extensions/browser/guest_view/web_view/web_view_constants.cc1
-rw-r--r--extensions/browser/guest_view/web_view/web_view_constants.h1
-rw-r--r--extensions/browser/guest_view/web_view/web_view_permission_helper.cc3
-rw-r--r--extensions/renderer/resources/guest_view/web_view/web_view_action_requests.js58
-rw-r--r--extensions/test/data/web_view/media_access/allow/embedder.js4
5 files changed, 38 insertions, 29 deletions
diff --git a/extensions/browser/guest_view/web_view/web_view_constants.cc b/extensions/browser/guest_view/web_view/web_view_constants.cc
index bce0922..18ae46f 100644
--- a/extensions/browser/guest_view/web_view/web_view_constants.cc
+++ b/extensions/browser/guest_view/web_view/web_view_constants.cc
@@ -83,6 +83,7 @@ const char kProcessId[] = "processId";
const char kProgress[] = "progress";
const char kReason[] = "reason";
const char kRequestId[] = "requestId";
+const char kRequestInfo[] = "requestInfo";
const char kSourceId[] = "sourceId";
const char kTargetURL[] = "targetUrl";
const char kWindowID[] = "windowId";
diff --git a/extensions/browser/guest_view/web_view/web_view_constants.h b/extensions/browser/guest_view/web_view/web_view_constants.h
index 97fd9ec..8dfd287 100644
--- a/extensions/browser/guest_view/web_view/web_view_constants.h
+++ b/extensions/browser/guest_view/web_view/web_view_constants.h
@@ -89,6 +89,7 @@ extern const char kProcessId[];
extern const char kProgress[];
extern const char kReason[];
extern const char kRequestId[];
+extern const char kRequestInfo[];
extern const char kSourceId[];
extern const char kTargetURL[];
extern const char kWindowID[];
diff --git a/extensions/browser/guest_view/web_view/web_view_permission_helper.cc b/extensions/browser/guest_view/web_view/web_view_permission_helper.cc
index b40fe7c..46ded6b 100644
--- a/extensions/browser/guest_view/web_view/web_view_permission_helper.cc
+++ b/extensions/browser/guest_view/web_view/web_view_permission_helper.cc
@@ -326,7 +326,8 @@ int WebViewPermissionHelper::RequestPermission(
int request_id = next_permission_request_id_++;
pending_permission_requests_[request_id] =
PermissionResponseInfo(callback, permission_type, allowed_by_default);
- scoped_ptr<base::DictionaryValue> args(request_info.DeepCopy());
+ scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ args->Set(webview::kRequestInfo, request_info.DeepCopy());
args->SetInteger(webview::kRequestId, request_id);
switch (permission_type) {
case WEB_VIEW_PERMISSION_TYPE_NEW_WINDOW: {
diff --git a/extensions/renderer/resources/guest_view/web_view/web_view_action_requests.js b/extensions/renderer/resources/guest_view/web_view/web_view_action_requests.js
index 9cf2c9a..c3cc28e 100644
--- a/extensions/renderer/resources/guest_view/web_view/web_view_action_requests.js
+++ b/extensions/renderer/resources/guest_view/web_view/web_view_action_requests.js
@@ -29,6 +29,12 @@ function WebViewActionRequest(webViewImpl, event, webViewEvent, interfaceName) {
this.guestInstanceId = this.webViewImpl.guest.getId();
this.requestId = event.requestId;
this.actionTaken = false;
+
+ // Add on the request information specific to the request type.
+ for (var infoName in this.event.requestInfo) {
+ this.event[infoName] = this.event.requestInfo[infoName];
+ this.webViewEvent[infoName] = this.event.requestInfo[infoName];
+ }
}
// Performs the default action for the request.
@@ -215,19 +221,28 @@ function PermissionRequest(webViewImpl, event, webViewEvent) {
PermissionRequest.prototype.__proto__ = WebViewActionRequest.prototype;
+PermissionRequest.prototype.allow = function() {
+ this.validateCall();
+ WebViewInternal.setPermission(this.guestInstanceId, this.requestId, 'allow');
+};
+
+PermissionRequest.prototype.deny = function() {
+ this.validateCall();
+ WebViewInternal.setPermission(this.guestInstanceId, this.requestId, 'deny');
+};
+
PermissionRequest.prototype.getInterfaceObject = function() {
- return {
- allow: function() {
- this.validateCall();
- WebViewInternal.setPermission(
- this.guestInstanceId, this.requestId, 'allow');
- }.bind(this),
- deny: function() {
- this.validateCall();
- WebViewInternal.setPermission(
- this.guestInstanceId, this.requestId, 'deny');
- }.bind(this)
+ var request = {
+ allow: this.allow.bind(this),
+ deny: this.deny.bind(this)
};
+
+ // Add on the request information specific to the request type.
+ for (var infoName in this.event.requestInfo) {
+ request[infoName] = this.event.requestInfo[infoName];
+ }
+
+ return $Object.freeze(request);
};
PermissionRequest.prototype.showWarningMessage = function() {
@@ -261,23 +276,14 @@ function FullscreenPermissionRequest(webViewImpl, event, webViewEvent) {
FullscreenPermissionRequest.prototype.__proto__ = PermissionRequest.prototype;
-FullscreenPermissionRequest.prototype.getInterfaceObject = function() {
- return {
- allow: function() {
- this.validateCall();
- WebViewInternal.setPermission(
- this.guestInstanceId, this.requestId, 'allow');
- // Now make the <webview> element go fullscreen.
- this.webViewImpl.makeElementFullscreen();
- }.bind(this),
- deny: function() {
- this.validateCall();
- WebViewInternal.setPermission(
- this.guestInstanceId, this.requestId, 'deny');
- }.bind(this)
- };
+FullscreenPermissionRequest.prototype.allow = function() {
+ PermissionRequest.prototype.allow.call(this);
+ // Now make the <webview> element go fullscreen.
+ this.webViewImpl.makeElementFullscreen();
};
+// -----------------------------------------------------------------------------
+
var WebViewActionRequests = {
WebViewActionRequest: WebViewActionRequest,
Dialog: Dialog,
diff --git a/extensions/test/data/web_view/media_access/allow/embedder.js b/extensions/test/data/web_view/media_access/allow/embedder.js
index fa7cbc16..48a841d 100644
--- a/extensions/test/data/web_view/media_access/allow/embedder.js
+++ b/extensions/test/data/web_view/media_access/allow/embedder.js
@@ -54,12 +54,12 @@ embedder.assertCorrectMediaEvent_ = function(e) {
embedder.failTest('wrong permission: ' + e.permission);
return false;
}
- if (!e.url) {
+ if (!e.url || !e.request.url) {
embedder.failTest('No url property in event');
return false;
}
if (e.url.indexOf(embedder.baseGuestURL)) {
- embedder.failTest('Wrong url: ' + e.rul +
+ embedder.failTest('Wrong url: ' + e.url +
', expected url to start with ' + embedder.baseGuestURL);
return false;
}