summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-13 23:26:13 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-13 23:26:13 +0000
commitbad146c5b3b1a7d0368320fecdbd5b50dbe97501 (patch)
tree8d5aad70f51fcfba24ccebd3359b7d33209370d7 /webkit/glue
parentccef48cca72fbc8905a643759092ee0d913aca9c (diff)
downloadchromium_src-bad146c5b3b1a7d0368320fecdbd5b50dbe97501.zip
chromium_src-bad146c5b3b1a7d0368320fecdbd5b50dbe97501.tar.gz
chromium_src-bad146c5b3b1a7d0368320fecdbd5b50dbe97501.tar.bz2
Commit 40144. I had to move to to a separate CL to use gcl's
"try multiple commits" feature. Review URL: http://codereview.chromium.org/46062 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11683 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/glue.vcproj4
-rw-r--r--webkit/glue/webdevtoolsclient_impl.cc5
-rw-r--r--webkit/glue/webframe.h19
-rw-r--r--webkit/glue/webframe_impl.cc28
-rw-r--r--webkit/glue/webframe_impl.h6
-rw-r--r--webkit/glue/webscriptsource.h29
6 files changed, 68 insertions, 23 deletions
diff --git a/webkit/glue/glue.vcproj b/webkit/glue/glue.vcproj
index 20bc1f4..08b5246 100644
--- a/webkit/glue/glue.vcproj
+++ b/webkit/glue/glue.vcproj
@@ -705,6 +705,10 @@
>
</File>
<File
+ RelativePath=".\webscriptsource.h"
+ >
+ </File>
+ <File
RelativePath=".\webtextinput_impl.cc"
>
</File>
diff --git a/webkit/glue/webdevtoolsclient_impl.cc b/webkit/glue/webdevtoolsclient_impl.cc
index 647bbfd..dbbe2d8 100644
--- a/webkit/glue/webdevtoolsclient_impl.cc
+++ b/webkit/glue/webdevtoolsclient_impl.cc
@@ -185,10 +185,7 @@ void WebDevToolsClientImpl::JsHideDOMNodeHighlight(const CppArgumentList& args,
}
void WebDevToolsClientImpl::EvaluateJs(const std::string& expr) {
- web_view_impl_->GetMainFrame()->ExecuteJavaScript(
- expr,
- GURL(), // script url
- 1); // base line number
+ web_view_impl_->GetMainFrame()->ExecuteScript(expr);
}
void WebDevToolsClientImpl::DispatchMessageFromAgent(
diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h
index 571b281..ce441d6 100644
--- a/webkit/glue/webframe.h
+++ b/webkit/glue/webframe.h
@@ -6,13 +6,14 @@
#define WEBKIT_GLUE_WEBFRAME_H_
#include "base/scoped_ptr.h"
+#include "googleurl/src/gurl.h"
#include "skia/ext/bitmap_platform_device.h"
#include "skia/ext/platform_canvas.h"
#include "webkit/glue/console_message_level.h"
#include "webkit/glue/feed.h"
#include "webkit/glue/find_in_page_request.h"
+#include "webkit/glue/webscriptsource.h"
-class GURL;
class PlatformContextSkia;
class WebDataSource;
class WebError;
@@ -88,13 +89,15 @@ class WebFrame {
bool replace,
const GURL& fake_url) = 0;
- // Executes a string of JavaScript in the web frame. The script_url param is
- // the URL where the script in question can be found, if any. The renderer may
- // request this URL to show the developer the source of the error. The
- // start_line parameter is the base line number to use for error reporting.
- virtual void ExecuteJavaScript(const std::string& js_code,
- const GURL& script_url,
- int start_line) = 0;
+ // Executes JavaScript in the web frame.
+ virtual void ExecuteScript(const webkit_glue::WebScriptSource& source) = 0;
+
+ // Executes JavaScript in a new context 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 shares the wrappers for
+ // all DOM nodes and DOM constructors.
+ virtual void ExecuteScriptInNewContext(
+ const webkit_glue::WebScriptSource* sources, int num_sources) = 0;
// Returns a string representing the state of the previous page load for
// later use when loading. The previous page is the page that was loaded
diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc
index 62b27a8..16a0bde8 100644
--- a/webkit/glue/webframe_impl.cc
+++ b/webkit/glue/webframe_impl.cc
@@ -1632,14 +1632,26 @@ void WebFrameImpl::LoadAlternateHTMLErrorPage(const WebRequest* request,
error_page_url));
}
-void WebFrameImpl::ExecuteJavaScript(const std::string& js_code,
- const GURL& script_url,
- int start_line) {
- WebCore::ScriptSourceCode source_code(
- webkit_glue::StdStringToString(js_code),
- webkit_glue::GURLToKURL(script_url),
- start_line);
- frame_->loader()->executeScript(source_code);
+void WebFrameImpl::ExecuteScript(const webkit_glue::WebScriptSource& source) {
+ frame_->loader()->executeScript(
+ WebCore::ScriptSourceCode(
+ webkit_glue::StdStringToString(source.source),
+ webkit_glue::GURLToKURL(source.url),
+ source.start_line));
+}
+
+void WebFrameImpl::ExecuteScriptInNewContext(
+ const webkit_glue::WebScriptSource* sources_in, int num_sources) {
+ Vector<WebCore::ScriptSourceCode> sources;
+
+ for (int i = 0; i < num_sources; ++i) {
+ sources.append(WebCore::ScriptSourceCode(
+ webkit_glue::StdStringToString(sources_in[i].source),
+ webkit_glue::GURLToKURL(sources_in[i].url),
+ sources_in[i].start_line));
+ }
+
+ frame_->script()->evaluateInNewContext(sources);
}
std::wstring WebFrameImpl::GetName() {
diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h
index e49802f..f448fa3 100644
--- a/webkit/glue/webframe_impl.h
+++ b/webkit/glue/webframe_impl.h
@@ -90,9 +90,9 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> {
const GURL& error_page_url,
bool replace,
const GURL& fake_url);
- virtual void ExecuteJavaScript(const std::string& js_code,
- const GURL& script_url,
- int start_line);
+ virtual void ExecuteScript(const webkit_glue::WebScriptSource& source);
+ virtual void ExecuteScriptInNewContext(
+ const webkit_glue::WebScriptSource* sources, int num_sources);
virtual bool GetPreviousHistoryState(std::string* history_state) const;
virtual bool GetCurrentHistoryState(std::string* history_state) const;
virtual bool HasCurrentHistoryState() const;
diff --git a/webkit/glue/webscriptsource.h b/webkit/glue/webscriptsource.h
new file mode 100644
index 0000000..5f9fd23
--- /dev/null
+++ b/webkit/glue/webscriptsource.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_GLUE_WEBSCRIPT_SOURCE_H_
+#define WEBKIT_GLUE_WEBSCRIPT_SOURCE_H_
+
+namespace webkit_glue {
+
+// Describes some script that can be executed within a frame.
+// NOTE: start_line is 1-based (like the corresponding object in WebCore).
+// TODO(aa): Allow clients to specify external data intead of strings to avoid
+// copies.
+struct WebScriptSource {
+ WebScriptSource(const std::string& source)
+ : source(source), start_line(1) {}
+ WebScriptSource(const std::string& source, const GURL& url)
+ : source(source), url(url), start_line(1) {}
+ WebScriptSource(const std::string& source, const GURL& url, int start_line)
+ : source(source), url(url), start_line(start_line) {}
+
+ std::string source;
+ GURL url;
+ int start_line;
+};
+
+} // namespace webkit_glue
+
+#endif // WEBKIT_GLUE_WEBSCRIPT_SOURCE_H_