From 80d574482e4e68006fbd794e4fbdf576cf1cfcb8 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 5 Nov 2014 14:59:28 +0800 Subject: [PATCH] Add "plugins" attribute for --- atom/browser/atom_browser_client.cc | 2 ++ atom/browser/lib/guest-view-manager.coffee | 2 +- atom/browser/web_view/web_view_manager.cc | 5 +++-- atom/browser/web_view/web_view_manager.h | 3 ++- atom/browser/web_view/web_view_renderer_state.h | 1 + atom/renderer/lib/web-view.coffee | 2 ++ 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index f197cc4a1fb..0ae8bfed674 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -154,6 +154,8 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches( command_line->AppendSwitchASCII( switches::kNodeIntegration, info.node_integration ? "true" : "false"); + if (info.plugins) + command_line->AppendSwitch(switches::kEnablePlugins); } } diff --git a/atom/browser/lib/guest-view-manager.coffee b/atom/browser/lib/guest-view-manager.coffee index b2827ad54d0..bec53ef30f2 100644 --- a/atom/browser/lib/guest-view-manager.coffee +++ b/atom/browser/lib/guest-view-manager.coffee @@ -33,7 +33,7 @@ createGuest = (embedder, params) -> guestInstanceId: id storagePartitionId: params.storagePartitionId 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. embedder.once 'render-view-deleted', -> diff --git a/atom/browser/web_view/web_view_manager.cc b/atom/browser/web_view/web_view_manager.cc index 05692841c8c..88a1bdb2f7b 100644 --- a/atom/browser/web_view/web_view_manager.cc +++ b/atom/browser/web_view/web_view_manager.cc @@ -43,11 +43,12 @@ WebViewManager::~WebViewManager() { void WebViewManager::AddGuest(int guest_instance_id, content::WebContents* embedder, content::WebContents* web_contents, - bool node_integration) { + bool node_integration, + bool plugins) { web_contents_map_[guest_instance_id] = { web_contents, embedder }; WebViewRendererState::WebViewInfo web_view_info = { - guest_instance_id, node_integration + guest_instance_id, node_integration, plugins }; content::BrowserThread::PostTask( content::BrowserThread::IO, diff --git a/atom/browser/web_view/web_view_manager.h b/atom/browser/web_view/web_view_manager.h index 855026b1a46..f00e5a6607f 100644 --- a/atom/browser/web_view/web_view_manager.h +++ b/atom/browser/web_view/web_view_manager.h @@ -23,7 +23,8 @@ class WebViewManager : public content::BrowserPluginGuestManager { void AddGuest(int guest_instance_id, content::WebContents* embedder, content::WebContents* web_contents, - bool node_integration); + bool node_integration, + bool plugins); void RemoveGuest(int guest_instance_id); protected: diff --git a/atom/browser/web_view/web_view_renderer_state.h b/atom/browser/web_view/web_view_renderer_state.h index 4186a6de95a..2de8308a9d4 100644 --- a/atom/browser/web_view/web_view_renderer_state.h +++ b/atom/browser/web_view/web_view_renderer_state.h @@ -22,6 +22,7 @@ class WebViewRendererState { struct WebViewInfo { int guest_instance_id; bool node_integration; + bool plugins; }; static WebViewRendererState* GetInstance(); diff --git a/atom/renderer/lib/web-view.coffee b/atom/renderer/lib/web-view.coffee index 781a712a11e..456ce931f15 100644 --- a/atom/renderer/lib/web-view.coffee +++ b/atom/renderer/lib/web-view.coffee @@ -20,6 +20,7 @@ WEB_VIEW_ATTRIBUTE_MINHEIGHT = 'minheight' WEB_VIEW_ATTRIBUTE_MINWIDTH = 'minwidth' WEB_VIEW_ATTRIBUTE_PARTITION = 'partition' WEB_VIEW_ATTRIBUTE_NODEINTEGRATION = 'nodeintegration' +WEB_VIEW_ATTRIBUTE_PLUGINS = 'plugins' AUTO_SIZE_ATTRIBUTES = [ WEB_VIEW_ATTRIBUTE_AUTOSIZE, WEB_VIEW_ATTRIBUTE_MAXHEIGHT, @@ -377,6 +378,7 @@ class WebView params = storagePartitionId: storagePartitionId nodeIntegration: @webviewNode.hasAttribute WEB_VIEW_ATTRIBUTE_NODEINTEGRATION + plugins: @webviewNode.hasAttribute WEB_VIEW_ATTRIBUTE_PLUGINS guestViewInternal.createGuest 'webview', params, (guestInstanceId) => @pendingGuestCreation = false unless @elementAttached