Rename iframe-security to node-integration.
This commit is contained in:
parent
d4929de33c
commit
ec00da416f
8 changed files with 44 additions and 23 deletions
|
@ -55,6 +55,9 @@ bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
|
|||
|
||||
void AtomRenderViewObserver::OnBrowserMessage(const string16& channel,
|
||||
const base::ListValue& args) {
|
||||
if (!render_view()->GetWebView())
|
||||
return;
|
||||
|
||||
WebKit::WebFrame* frame = render_view()->GetWebView()->mainFrame();
|
||||
if (!renderer_client_->IsNodeBindingEnabled(frame))
|
||||
return;
|
||||
|
|
|
@ -18,13 +18,17 @@
|
|||
namespace atom {
|
||||
|
||||
AtomRendererClient::AtomRendererClient()
|
||||
: iframe_security_(FULL) {
|
||||
std::string security = CommandLine::ForCurrentProcess()->
|
||||
GetSwitchValueASCII(switches::kIframeSecurity);
|
||||
if (security == "manual")
|
||||
iframe_security_ = MANUAL;
|
||||
else if (security == "none")
|
||||
iframe_security_ = NONE;
|
||||
: node_integration_(ALL),
|
||||
main_frame_(NULL) {
|
||||
// Translate the token.
|
||||
std::string token = CommandLine::ForCurrentProcess()->
|
||||
GetSwitchValueASCII(switches::kNodeIntegration);
|
||||
if (token == "except-iframe")
|
||||
node_integration_ = EXCEPT_IFRAME;
|
||||
else if (token == "manual-enable-iframe")
|
||||
node_integration_ = MANUAL_ENABLE_IFRAME;
|
||||
else if (token == "disable")
|
||||
node_integration_ = DISABLE;
|
||||
|
||||
if (IsNodeBindingEnabled()) {
|
||||
node_bindings_.reset(NodeBindings::Create(false));
|
||||
|
@ -59,6 +63,10 @@ void AtomRendererClient::DidCreateScriptContext(WebKit::WebFrame* frame,
|
|||
v8::Handle<v8::Context> context,
|
||||
int extension_group,
|
||||
int world_id) {
|
||||
// The first web frame is the main frame.
|
||||
if (main_frame_ == NULL)
|
||||
main_frame_ = frame;
|
||||
|
||||
if (!IsNodeBindingEnabled(frame))
|
||||
return;
|
||||
|
||||
|
@ -131,12 +139,17 @@ bool AtomRendererClient::ShouldFork(WebKit::WebFrame* frame,
|
|||
}
|
||||
|
||||
bool AtomRendererClient::IsNodeBindingEnabled(WebKit::WebFrame* frame) {
|
||||
if (iframe_security_ == FULL)
|
||||
if (node_integration_ == DISABLE)
|
||||
return false;
|
||||
else if (iframe_security_ == MANUAL &&
|
||||
// Node integration is enabled in main frame unless explictly disabled.
|
||||
else if (frame == main_frame_)
|
||||
return true;
|
||||
else if (node_integration_ == MANUAL_ENABLE_IFRAME &&
|
||||
frame != NULL &&
|
||||
frame->uniqueName().utf8().find("-enable-node") == std::string::npos)
|
||||
return false;
|
||||
else if (node_integration_ == EXCEPT_IFRAME && frame != NULL)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -28,10 +28,11 @@ class AtomRendererClient : public content::ContentRendererClient {
|
|||
AtomRendererBindings* atom_bindings() const { return atom_bindings_.get(); }
|
||||
|
||||
private:
|
||||
enum IframeSecurity {
|
||||
FULL,
|
||||
MANUAL,
|
||||
NONE,
|
||||
enum NodeIntegration {
|
||||
ALL,
|
||||
EXCEPT_IFRAME,
|
||||
MANUAL_ENABLE_IFRAME,
|
||||
DISABLE,
|
||||
};
|
||||
|
||||
virtual void RenderThreadStarted() OVERRIDE;
|
||||
|
@ -55,7 +56,11 @@ class AtomRendererClient : public content::ContentRendererClient {
|
|||
scoped_ptr<NodeBindings> node_bindings_;
|
||||
scoped_ptr<AtomRendererBindings> atom_bindings_;
|
||||
|
||||
IframeSecurity iframe_security_;
|
||||
// The level of node integration we should support.
|
||||
NodeIntegration node_integration_;
|
||||
|
||||
// The main frame.
|
||||
WebKit::WebFrame* main_frame_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomRendererClient);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue