Merge pull request #787 from atom/webview-plugins
Add "plugins" attribute for <webview>
This commit is contained in:
commit
e004d53d2a
7 changed files with 21 additions and 6 deletions
|
@ -154,6 +154,8 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||||
command_line->AppendSwitchASCII(
|
command_line->AppendSwitchASCII(
|
||||||
switches::kNodeIntegration,
|
switches::kNodeIntegration,
|
||||||
info.node_integration ? "true" : "false");
|
info.node_integration ? "true" : "false");
|
||||||
|
if (info.plugins)
|
||||||
|
command_line->AppendSwitch(switches::kEnablePlugins);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ createGuest = (embedder, params) ->
|
||||||
guestInstanceId: id
|
guestInstanceId: id
|
||||||
storagePartitionId: params.storagePartitionId
|
storagePartitionId: params.storagePartitionId
|
||||||
guestInstances[id] = {guest, embedder}
|
guestInstances[id] = {guest, embedder}
|
||||||
webViewManager.addGuest id, embedder, guest, params.nodeIntegration
|
webViewManager.addGuest id, embedder, guest, params.nodeIntegration, params.plugins
|
||||||
|
|
||||||
# Destroy guest when the embedder is gone.
|
# Destroy guest when the embedder is gone.
|
||||||
embedder.once 'render-view-deleted', ->
|
embedder.once 'render-view-deleted', ->
|
||||||
|
|
|
@ -43,11 +43,12 @@ WebViewManager::~WebViewManager() {
|
||||||
void WebViewManager::AddGuest(int guest_instance_id,
|
void WebViewManager::AddGuest(int guest_instance_id,
|
||||||
content::WebContents* embedder,
|
content::WebContents* embedder,
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
bool node_integration) {
|
bool node_integration,
|
||||||
|
bool plugins) {
|
||||||
web_contents_map_[guest_instance_id] = { web_contents, embedder };
|
web_contents_map_[guest_instance_id] = { web_contents, embedder };
|
||||||
|
|
||||||
WebViewRendererState::WebViewInfo web_view_info = {
|
WebViewRendererState::WebViewInfo web_view_info = {
|
||||||
guest_instance_id, node_integration
|
guest_instance_id, node_integration, plugins
|
||||||
};
|
};
|
||||||
content::BrowserThread::PostTask(
|
content::BrowserThread::PostTask(
|
||||||
content::BrowserThread::IO,
|
content::BrowserThread::IO,
|
||||||
|
|
|
@ -23,7 +23,8 @@ class WebViewManager : public content::BrowserPluginGuestManager {
|
||||||
void AddGuest(int guest_instance_id,
|
void AddGuest(int guest_instance_id,
|
||||||
content::WebContents* embedder,
|
content::WebContents* embedder,
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
bool node_integration);
|
bool node_integration,
|
||||||
|
bool plugins);
|
||||||
void RemoveGuest(int guest_instance_id);
|
void RemoveGuest(int guest_instance_id);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -22,6 +22,7 @@ class WebViewRendererState {
|
||||||
struct WebViewInfo {
|
struct WebViewInfo {
|
||||||
int guest_instance_id;
|
int guest_instance_id;
|
||||||
bool node_integration;
|
bool node_integration;
|
||||||
|
bool plugins;
|
||||||
};
|
};
|
||||||
|
|
||||||
static WebViewRendererState* GetInstance();
|
static WebViewRendererState* GetInstance();
|
||||||
|
|
|
@ -20,6 +20,7 @@ WEB_VIEW_ATTRIBUTE_MINHEIGHT = 'minheight'
|
||||||
WEB_VIEW_ATTRIBUTE_MINWIDTH = 'minwidth'
|
WEB_VIEW_ATTRIBUTE_MINWIDTH = 'minwidth'
|
||||||
WEB_VIEW_ATTRIBUTE_PARTITION = 'partition'
|
WEB_VIEW_ATTRIBUTE_PARTITION = 'partition'
|
||||||
WEB_VIEW_ATTRIBUTE_NODEINTEGRATION = 'nodeintegration'
|
WEB_VIEW_ATTRIBUTE_NODEINTEGRATION = 'nodeintegration'
|
||||||
|
WEB_VIEW_ATTRIBUTE_PLUGINS = 'plugins'
|
||||||
AUTO_SIZE_ATTRIBUTES = [
|
AUTO_SIZE_ATTRIBUTES = [
|
||||||
WEB_VIEW_ATTRIBUTE_AUTOSIZE,
|
WEB_VIEW_ATTRIBUTE_AUTOSIZE,
|
||||||
WEB_VIEW_ATTRIBUTE_MAXHEIGHT,
|
WEB_VIEW_ATTRIBUTE_MAXHEIGHT,
|
||||||
|
@ -377,6 +378,7 @@ class WebView
|
||||||
params =
|
params =
|
||||||
storagePartitionId: storagePartitionId
|
storagePartitionId: storagePartitionId
|
||||||
nodeIntegration: @webviewNode.hasAttribute WEB_VIEW_ATTRIBUTE_NODEINTEGRATION
|
nodeIntegration: @webviewNode.hasAttribute WEB_VIEW_ATTRIBUTE_NODEINTEGRATION
|
||||||
|
plugins: @webviewNode.hasAttribute WEB_VIEW_ATTRIBUTE_PLUGINS
|
||||||
guestViewInternal.createGuest 'webview', params, (guestInstanceId) =>
|
guestViewInternal.createGuest 'webview', params, (guestInstanceId) =>
|
||||||
@pendingGuestCreation = false
|
@pendingGuestCreation = false
|
||||||
unless @elementAttached
|
unless @elementAttached
|
||||||
|
|
|
@ -50,7 +50,7 @@ and displays a "loading..." message during the load time:
|
||||||
### src
|
### src
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<webview src="http://www.google.com/"></webview>
|
<webview src="https://www.github.com/"></webview>
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns the visible URL. Writing to this attribute initiates top-level
|
Returns the visible URL. Writing to this attribute initiates top-level
|
||||||
|
@ -64,7 +64,7 @@ The `src` attribute can also accept data URLs, such as
|
||||||
### autosize
|
### autosize
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<webview src="http://www.google.com/" autosize="on" minwidth="576" minheight="432"></webview>
|
<webview src="https://www.github.com/" autosize="on" minwidth="576" minheight="432"></webview>
|
||||||
```
|
```
|
||||||
|
|
||||||
If "on", the `webview` will container will automatically resize within the
|
If "on", the `webview` will container will automatically resize within the
|
||||||
|
@ -82,6 +82,14 @@ than the minimum values or greater than the maximum.
|
||||||
If "on", the guest page in `webview` will have node integration and can use node
|
If "on", the guest page in `webview` will have node integration and can use node
|
||||||
APIs like `require` and `process` to access low level system resources.
|
APIs like `require` and `process` to access low level system resources.
|
||||||
|
|
||||||
|
### plugins
|
||||||
|
|
||||||
|
```html
|
||||||
|
<webview src="https://www.github.com/" plugins></webview>
|
||||||
|
```
|
||||||
|
|
||||||
|
If "on", the guest page in `webview` will be able to use browser plugins.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
### `<webview>`.getUrl()
|
### `<webview>`.getUrl()
|
||||||
|
|
Loading…
Reference in a new issue