void WebContents::EnterFullscreenModeForTab(content::WebContents* source,
const GURL& origin) {
+ auto permission_helper =
+ WebContentsPermissionHelper::FromWebContents(source);
+ auto callback = base::Bind(&WebContents::OnEnterFullscreenModeForTab,
+ base::Unretained(this), source, origin);
+ permission_helper->RequestFullscreenPermission(callback);
+}
+
+void WebContents::OnEnterFullscreenModeForTab(content::WebContents* source,
+ const GURL& origin,
+ bool allowed) {
+ if (!allowed)
+ return;
CommonWebContentsDelegate::EnterFullscreenModeForTab(source, origin);
Emit("enter-html-full-screen");
}
void SetAllowTransparency(bool allow);
bool IsGuest() const;
+ // Callback triggered on permission response.
+ void OnEnterFullscreenModeForTab(content::WebContents* source,
+ const GURL& origin,
+ bool allowed);
+
// Returns the web preferences of current WebContents.
v8::Local<v8::Value> GetWebPreferences(v8::Isolate* isolate);
base::Bind(&OnPermissionResponse, callback));
}
+void WebContentsPermissionHelper::RequestFullscreenPermission(
+ const base::Callback<void(bool)>& callback) {
+ RequestPermission((content::PermissionType)(PermissionType::FULLSCREEN),
+ callback);
+}
+
void WebContentsPermissionHelper::RequestMediaAccessPermission(
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& response_callback) {
FULLSCREEN
};
+ void RequestFullscreenPermission(
+ const base::Callback<void(bool)>& callback);
void RequestMediaAccessPermission(
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback);
* `handler` Function
* `webContents` Object - [WebContents](web-contents.md) requesting the permission.
- * `permission` String - Enum of 'media', 'geolocation', 'notifications', 'midiSysex'.
+ * `permission` String - Enum of 'media', 'geolocation', 'notifications', 'midiSysex', 'pointerLock', 'fullscreen'.
* `callback` Function - Allow or deny the permission.
Sets the handler which can be used to respond to permission requests for the `session`.
-Calling `callback('granted')` will allow the permission and `callback('denied')` will reject it.
+Calling `callback(true)` will allow the permission and `callback(false)` will reject it.
```javascript
session.fromPartition(partition).setPermissionRequestHandler(function(webContents, permission, callback) {
if (webContents.getURL() === host) {
if (permission == "notifications") {
- callback(); // denied.
+ callback(false); // denied.
return;
}
}
- callback('granted');
+ callback(true);
});
```
var listener = function(webContents, permission, callback) {
if (webContents.getId() === webview.getId() ) {
assert.equal(permission, requested_permission);
- callback("denied");
+ callback(false);
}
};
session.fromPartition(webview.partition).setPermissionRequestHandler(listener);