It is not allowed to run scripts in DidCreateDocumentElement

This commit is contained in:
Cheng Zhao 2016-05-10 15:43:25 +09:00
parent 906ae043f9
commit bb5b30b8a0
3 changed files with 9 additions and 4 deletions

View file

@ -27,7 +27,6 @@
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebKit.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "ui/base/resource/resource_bundle.h"
#include "native_mate/dictionary.h"
@ -89,9 +88,6 @@ void AtomRenderViewObserver::DidCreateDocumentElement(
blink::WebLocalFrame* frame) {
document_created_ = true;
// Make sure every page will get a script context created.
frame->executeScript(blink::WebScriptSource("void 0"));
// Read --zoom-factor from command line.
std::string zoom_factor_str = base::CommandLine::ForCurrentProcess()->
GetSwitchValueASCII(switches::kZoomFactor);

View file

@ -33,6 +33,7 @@
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebPluginParams.h"
#include "third_party/WebKit/public/web/WebKit.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
#include "third_party/WebKit/public/web/WebView.h"
@ -160,6 +161,13 @@ void AtomRendererClient::RenderViewCreated(content::RenderView* render_view) {
}
}
void AtomRendererClient::RunScriptsAtDocumentStart(
content::RenderFrame* render_frame) {
// Make sure every page will get a script context created.
render_frame->GetWebFrame()->executeScript(
blink::WebScriptSource("void 0"));
}
blink::WebSpeechSynthesizer* AtomRendererClient::OverrideSpeechSynthesizer(
blink::WebSpeechSynthesizerClient* client) {
return new TtsDispatcher(client);

View file

@ -40,6 +40,7 @@ class AtomRendererClient : public content::ContentRendererClient,
void RenderThreadStarted() override;
void RenderFrameCreated(content::RenderFrame*) override;
void RenderViewCreated(content::RenderView*) override;
void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override;
blink::WebSpeechSynthesizer* OverrideSpeechSynthesizer(
blink::WebSpeechSynthesizerClient* client) override;
bool OverrideCreatePlugin(content::RenderFrame* render_frame,