diff options
-rw-r--r-- | base/base_switches.cc | 4 | ||||
-rw-r--r-- | base/base_switches.h | 1 | ||||
-rw-r--r-- | chrome/browser/renderer_host/browser_render_process_host.cc | 1 | ||||
-rw-r--r-- | chrome/renderer/user_script_slave.cc | 2 | ||||
-rw-r--r-- | webkit/api/public/WebFrame.h | 7 | ||||
-rw-r--r-- | webkit/glue/webframe.h | 7 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.cc | 19 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.h | 2 | ||||
-rw-r--r-- | webkit/tools/test_shell/layout_test_controller.cc | 2 |
9 files changed, 33 insertions, 12 deletions
diff --git a/base/base_switches.cc b/base/base_switches.cc index 46b7676..77d263c 100644 --- a/base/base_switches.cc +++ b/base/base_switches.cc @@ -40,8 +40,4 @@ const wchar_t kEnableDCHECK[] = L"enable-dcheck"; // Available at http://www.adambarth.com/papers/2008/jackson-barth.pdf const wchar_t kForceHTTPS[] = L"force-https"; -// Run content scripts in their own isolated world instead of just in a new -// context. -const wchar_t kIsolatedWorld[] = L"isolated-world"; - } // namespace switches diff --git a/base/base_switches.h b/base/base_switches.h index 7b66ad5..97a3691 100644 --- a/base/base_switches.h +++ b/base/base_switches.h @@ -17,7 +17,6 @@ extern const wchar_t kNoErrorDialogs[]; extern const wchar_t kProcessType[]; extern const wchar_t kEnableDCHECK[]; extern const wchar_t kForceHTTPS[]; -extern const wchar_t kIsolatedWorld[]; } // namespace switches diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index b18e729..bde0294 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -346,7 +346,6 @@ bool BrowserRenderProcessHost::Init() { switches::kDisableAudio, switches::kSimpleDataSource, switches::kEnableBenchmarking, - switches::kIsolatedWorld, }; for (size_t i = 0; i < arraysize(switch_names); ++i) { diff --git a/chrome/renderer/user_script_slave.cc b/chrome/renderer/user_script_slave.cc index 9692736..48017c1 100644 --- a/chrome/renderer/user_script_slave.cc +++ b/chrome/renderer/user_script_slave.cc @@ -160,7 +160,7 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame, StringPrintf(kInitExtension, script->extension_id().c_str())))); } - frame->ExecuteScriptInNewContext(&sources.front(), sources.size()); + frame->ExecuteScriptInNewWorld(&sources.front(), sources.size()); } } diff --git a/webkit/api/public/WebFrame.h b/webkit/api/public/WebFrame.h index fa7e5f5..acb8dff 100644 --- a/webkit/api/public/WebFrame.h +++ b/webkit/api/public/WebFrame.h @@ -145,6 +145,13 @@ namespace WebKit { virtual void executeScriptInNewContext(const WebScriptSource* sources, unsigned numSources) = 0; + // Executes JavaScript in a new world associated with the web frame. + // The script gets its own global scope and its own prototypes for + // intrinsic JavaScript objects (String, Array, and so-on). It also + // gets its own wrappers for all DOM nodes and DOM constructors. + virtual void executeScriptInNewWorld(const WebScriptSource* sources, + unsigned numSources) = 0; + // Logs to the console associated with this frame. virtual void addMessageToConsole(const WebConsoleMessage&) = 0; diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h index 2d624d4..4fdede8 100644 --- a/webkit/glue/webframe.h +++ b/webkit/glue/webframe.h @@ -143,6 +143,13 @@ class WebFrame { virtual void ExecuteScriptInNewContext( const WebKit::WebScriptSource* sources, int num_sources) = 0; + // Executes JavaScript in a new world associated with the web frame. The + // script gets its own global scope and its own prototypes for intrinsic + // JavaScript objects (String, Array, and so-on). It also gets its own + // wrappers for all DOM nodes and DOM constructors. + virtual void ExecuteScriptInNewWorld( + const WebKit::WebScriptSource* sources, int num_sources) = 0; + // Inserts the given CSS styles at the beginning of the document. virtual bool InsertCSSStyles(const std::string& css) = 0; diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc index f74dd2c..09a049f 100644 --- a/webkit/glue/webframe_impl.cc +++ b/webkit/glue/webframe_impl.cc @@ -1604,10 +1604,21 @@ void WebFrameImpl::ExecuteScriptInNewContext( sources_in[i].startLine)); } - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kIsolatedWorld)) - frame_->script()->evaluateInNewWorld(sources); - else - frame_->script()->evaluateInNewContext(sources); + frame_->script()->evaluateInNewContext(sources); +} + +void WebFrameImpl::ExecuteScriptInNewWorld( + const WebScriptSource* sources_in, int num_sources) { + Vector<WebCore::ScriptSourceCode> sources; + + for (int i = 0; i < num_sources; ++i) { + sources.append(WebCore::ScriptSourceCode( + webkit_glue::WebStringToString(sources_in[i].code), + webkit_glue::WebURLToKURL(sources_in[i].url), + sources_in[i].startLine)); + } + + frame_->script()->evaluateInNewWorld(sources); } std::wstring WebFrameImpl::GetName() { diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h index f22f58b..1795bc8 100644 --- a/webkit/glue/webframe_impl.h +++ b/webkit/glue/webframe_impl.h @@ -105,6 +105,8 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> { virtual void ExecuteScript(const WebKit::WebScriptSource& source); virtual void ExecuteScriptInNewContext( const WebKit::WebScriptSource* sources, int num_sources); + virtual void ExecuteScriptInNewWorld( + const WebKit::WebScriptSource* sources, int num_sources); virtual bool InsertCSSStyles(const std::string& css); virtual WebKit::WebHistoryItem GetPreviousHistoryItem() const; virtual WebKit::WebHistoryItem GetCurrentHistoryItem() const; diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc index 374f95f..5ae2bb3 100644 --- a/webkit/tools/test_shell/layout_test_controller.cc +++ b/webkit/tools/test_shell/layout_test_controller.cc @@ -351,7 +351,7 @@ class WorkItemIsolatedWorldScript : public LayoutTestController::WorkItem { WorkItemIsolatedWorldScript(const string& script) : script_(script) {} bool Run(TestShell* shell) { WebScriptSource source(WebString::fromUTF8(script_)); - shell->webView()->GetMainFrame()->ExecuteScriptInNewContext(&source, 1); + shell->webView()->GetMainFrame()->ExecuteScriptInNewWorld(&source, 1); return false; } private: |