Load the "preload" script in <webview>
This commit is contained in:
parent
8d8bfcd120
commit
217b1afe87
8 changed files with 24 additions and 3 deletions
|
@ -156,6 +156,10 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
|||
info.node_integration ? "true" : "false");
|
||||
if (info.plugins)
|
||||
command_line->AppendSwitch(switches::kEnablePlugins);
|
||||
if (!info.preload_script.empty())
|
||||
command_line->AppendSwitchPath(
|
||||
switches::kPreloadScript,
|
||||
info.preload_script);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ createGuest = (embedder, params) ->
|
|||
guestInstanceId: id
|
||||
storagePartitionId: params.storagePartitionId
|
||||
guestInstances[id] = {guest, embedder}
|
||||
webViewManager.addGuest id, embedder, guest, params.nodeIntegration, params.plugins
|
||||
preload = params.preload ? ''
|
||||
webViewManager.addGuest id, embedder, guest, params.nodeIntegration, params.plugins, preload
|
||||
|
||||
# Destroy guest when the embedder is gone.
|
||||
embedder.once 'render-view-deleted', ->
|
||||
|
|
|
@ -7,12 +7,14 @@
|
|||
#include "atom/browser/api/atom_api_web_contents.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/web_view/web_view_renderer_state.h"
|
||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "net/base/filename_util.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
|
@ -44,12 +46,14 @@ void WebViewManager::AddGuest(int guest_instance_id,
|
|||
content::WebContents* embedder,
|
||||
content::WebContents* web_contents,
|
||||
bool node_integration,
|
||||
bool plugins) {
|
||||
bool plugins,
|
||||
const GURL& preload_url) {
|
||||
web_contents_map_[guest_instance_id] = { web_contents, embedder };
|
||||
|
||||
WebViewRendererState::WebViewInfo web_view_info = {
|
||||
guest_instance_id, node_integration, plugins
|
||||
};
|
||||
net::FileURLToFilePath(preload_url, &web_view_info.preload_script);
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::IO,
|
||||
FROM_HERE,
|
||||
|
|
|
@ -24,7 +24,8 @@ class WebViewManager : public content::BrowserPluginGuestManager {
|
|||
content::WebContents* embedder,
|
||||
content::WebContents* web_contents,
|
||||
bool node_integration,
|
||||
bool plugins);
|
||||
bool plugins,
|
||||
const GURL& preload_url);
|
||||
void RemoveGuest(int guest_instance_id);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/memory/singleton.h"
|
||||
|
||||
namespace atom {
|
||||
|
@ -23,6 +24,7 @@ class WebViewRendererState {
|
|||
int guest_instance_id;
|
||||
bool node_integration;
|
||||
bool plugins;
|
||||
base::FilePath preload_script;
|
||||
};
|
||||
|
||||
static WebViewRendererState* GetInstance();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue