return new AtomBrowserMainParts;
}
-void AtomBrowserClient::WebNotificationAllowed(int render_process_id,
- const base::Closure& callback) {
+void AtomBrowserClient::WebNotificationAllowed(
+ int render_process_id,
+ const base::Callback<void(bool)>& callback) {
content::WebContents* web_contents = content::WebContents::FromRenderViewHost(
content::RenderViewHost::FromID(render_process_id, kDefaultRoutingID));
if (!web_contents) {
- callback.Run();
+ callback.Run(true);
return;
}
auto permission_helper =
WebContentsPermissionHelper::FromWebContents(web_contents);
if (!permission_helper) {
- callback.Run();
+ callback.Run(true);
return;
}
permission_helper->RequestWebNotificationPermission(callback);
// brightray::BrowserClient:
brightray::BrowserMainParts* OverrideCreateBrowserMainParts(
const content::MainFunctionParams&) override;
- void WebNotificationAllowed(int render_process_id,
- const base::Closure& callback) override;
+ void WebNotificationAllowed(
+ int render_process_id,
+ const base::Callback<void(bool)>& callback) override;
// content::RenderProcessHostObserver:
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
// Doesn't exist in early initialization.
var webViewManager = null;
-var supportedWebViewEvents = ['load-commit', 'did-finish-load', 'did-fail-load', 'did-frame-finish-load', 'did-start-loading', 'did-stop-loading', 'did-get-response-details', 'did-get-redirect-request', 'dom-ready', 'console-message', 'devtools-opened', 'devtools-closed', 'devtools-focused', 'new-window', 'will-navigate', 'did-navigate', 'did-navigate-in-page', 'close', 'crashed', 'gpu-crashed', 'plugin-crashed', 'destroyed', 'page-title-updated', 'page-favicon-updated', 'enter-html-full-screen', 'leave-html-full-screen', 'media-started-playing', 'media-paused', 'found-in-page', 'did-change-theme-color', 'permission-request'];
+var supportedWebViewEvents = [
+ 'load-commit',
+ 'did-finish-load',
+ 'did-fail-load',
+ 'did-frame-finish-load',
+ 'did-start-loading',
+ 'did-stop-loading',
+ 'did-get-response-details',
+ 'did-get-redirect-request',
+ 'dom-ready',
+ 'console-message',
+ 'devtools-opened',
+ 'devtools-closed',
+ 'devtools-focused',
+ 'new-window',
+ 'will-navigate',
+ 'did-navigate',
+ 'did-navigate-in-page',
+ 'close',
+ 'crashed',
+ 'gpu-crashed',
+ 'plugin-crashed',
+ 'destroyed',
+ 'page-title-updated',
+ 'page-favicon-updated',
+ 'enter-html-full-screen',
+ 'leave-html-full-screen',
+ 'media-started-playing',
+ 'media-paused',
+ 'found-in-page',
+ 'did-change-theme-color',
+ 'permission-request'
+];
var nextInstanceId = 0;
var permissionRequests;
webViewManager.removeGuest(embedder, id);
guestInstances[id].guest.destroy();
delete guestInstances[id];
- delete permissionRequests[id];
+ delete guestPermissionRequestsMap[id];
key = reverseEmbedderElementsMap[id];
if (key != null) {
delete reverseEmbedderElementsMap[id];
void MediaAccessAllowed(
const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback) {
+ const content::MediaResponseCallback& callback,
+ bool allowed) {
+ if (!allowed) {
+ callback.Run(content::MediaStreamDevices(),
+ content::MEDIA_DEVICE_PERMISSION_DENIED,
+ scoped_ptr<content::MediaStreamUI>());
+ return;
+ }
+
content::MediaStreamDevices devices;
content::MediaStreamRequestResult result = content::MEDIA_DEVICE_NO_HARDWARE;
base::Unretained(this), permission));
return;
}
- MediaAccessAllowed(request, callback);
+ MediaAccessAllowed(request, callback, true);
}
void WebContentsPermissionHelper::RequestWebNotificationPermission(
- const base::Closure& callback) {
+ const base::Callback<void(bool)>& callback) {
if (api_web_contents_->IsGuest()) {
const std::string& permission = "webNotification";
permission_map_[permission] = callback;
base::Unretained(this), permission));
return;
}
- callback.Run();
+ callback.Run(true);
}
void WebContentsPermissionHelper::OnPermissionResponse(
const std::string& permission, bool allowed) {
auto it = permission_map_.find(permission);
if (it != permission_map_.end()) {
- if (allowed)
- it->second.Run();
+ it->second.Run(allowed);
permission_map_.erase(permission);
}
}
void RequestMediaAccessPermission(
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback);
- void RequestWebNotificationPermission(const base::Closure& callback);
+ void RequestWebNotificationPermission(
+ const base::Callback<void(bool)>& callback);
void OnPermissionResponse(const std::string& permission, bool allowed);
private:
friend class content::WebContentsUserData<WebContentsPermissionHelper>;
- std::map<std::string, base::Closure> permission_map_;
+ std::map<std::string, base::Callback<void(bool)>> permission_map_;
api::WebContents* api_web_contents_; // Weak reference
this.attributes[webViewConstants.ATTRIBUTE_ALLOWPOPUPS] = new BooleanAttribute(webViewConstants.ATTRIBUTE_ALLOWPOPUPS, this);
this.attributes[webViewConstants.ATTRIBUTE_PRELOAD] = new PreloadAttribute(this);
this.attributes[webViewConstants.ATTRIBUTE_BLINKFEATURES] = new BlinkFeaturesAttribute(this);
- this.attributes[webViewConstants.ATTRIBUTE_DISABLEWEBNOTIFICATION] = new BooleanAttribute(webViewConstants.ATTRIBUTE_DISABLEWEBNOTIFICATION, this);
autosizeAttributes = [webViewConstants.ATTRIBUTE_MAXHEIGHT, webViewConstants.ATTRIBUTE_MAXWIDTH, webViewConstants.ATTRIBUTE_MINHEIGHT, webViewConstants.ATTRIBUTE_MINWIDTH];
results = [];
for (i = 0, len = autosizeAttributes.length; i < len; i++) {
The full list of supported feature strings can be found in the
[setFeatureEnabledFromString][blink-feature-string] function.
-### `disablewebnotification`
-
-```html
-<webview src="https://www.github.com/" disablewebnotification></webview>
-```
-
-If "on", the guest page will have web notifications disabled.
-
## Methods
The `webview` tag has the following methods:
--- /dev/null
+<script>
+ navigator.webkitGetUserMedia({ audio: true, video: true }, function(mediaStream) {
+
+ }, function(err) {
+ require('electron').ipcRenderer.sendToHost('message', err.name);
+ });
+</script>
return document.body.appendChild(webview);
});
});
- return xdescribe('did-change-theme-color event', function() {
+ xdescribe('did-change-theme-color event', function() {
return it('emits when theme color changes', function(done) {
webview.addEventListener('did-change-theme-color', function() {
return done();
return document.body.appendChild(webview);
});
});
+ describe('permission-request event', function() {
+ it ('emits when using navigator.getUserMedia api', function(done) {
+ webview.addEventListener('ipc-message', function(e) {
+ assert(e.channel, 'message');
+ assert(e.args, ['PermissionDeniedError']);
+ done();
+ });
+ webview.addEventListener('permission-request', function(e) {
+ if (e.permission === 'media') {
+ e.deny();
+ }
+ });
+ webview.src = "file://" + fixtures + "/pages/permission-request.html";
+ webview.setAttribute('nodeintegration', 'on');
+ document.body.appendChild(webview);
+ });
+ });
});