@@ -33,7 +33,7 @@ namespace mate {
3333template <>
3434struct Converter <blink::WebLocalFrame::ScriptExecutionType> {
3535 static bool FromV8 (v8::Isolate* isolate,
36- v8::Handle <v8::Value> val,
36+ v8::Local <v8::Value> val,
3737 blink::WebLocalFrame::ScriptExecutionType* out) {
3838 std::string execution_type;
3939 if (!ConvertFromV8 (isolate, val, &execution_type))
@@ -51,6 +51,7 @@ struct Converter<blink::WebLocalFrame::ScriptExecutionType> {
5151 return true ;
5252 }
5353};
54+
5455} // namespace mate
5556
5657namespace atom {
@@ -251,17 +252,34 @@ void WebFrame::ExecuteJavaScript(const base::string16& code,
251252 callback.release ());
252253}
253254
254- void WebFrame::ExecuteJavaScriptInIsolatedWorld (int world_id,
255- const base::string16& code,
256- mate::Arguments* args) {
255+ void WebFrame::ExecuteJavaScriptInIsolatedWorld (
256+ int world_id,
257+ const std::vector<mate::Dictionary>& scripts,
258+ mate::Arguments* args) {
257259 std::vector<blink::WebScriptSource> sources;
258- sources.push_back (blink::WebScriptSource (blink::WebString::FromUTF16 (code)));
260+
261+ for (const auto & script : scripts) {
262+ base::string16 code;
263+ base::string16 url;
264+ int start_line = 1 ;
265+ script.Get (" url" , &url);
266+ script.Get (" startLine" , &start_line);
267+
268+ if (!script.Get (" code" , &code)) {
269+ args->ThrowError (" Invalid 'code'" );
270+ return ;
271+ }
272+
273+ sources.emplace_back (blink::WebScriptSource (
274+ blink::WebString::FromUTF16 (code),
275+ blink::WebURL (GURL (url)), start_line));
276+ }
259277
260278 bool has_user_gesture = false ;
261279 args->GetNext (&has_user_gesture);
262280
263281 blink::WebLocalFrame::ScriptExecutionType scriptExecutionType =
264- blink::WebLocalFrame::kSynchronous ;
282+ blink::WebLocalFrame::kSynchronous ;
265283 args->GetNext (&scriptExecutionType);
266284
267285 ScriptExecutionCallback::CompletionCallback completion_callback;
@@ -274,6 +292,14 @@ void WebFrame::ExecuteJavaScriptInIsolatedWorld(int world_id,
274292 scriptExecutionType, callback.release ());
275293}
276294
295+ void WebFrame::SetIsolatedWorldSecurityOrigin (int world_id,
296+ const std::string& origin_url) {
297+ web_frame_->SetIsolatedWorldSecurityOrigin (
298+ world_id,
299+ blink::WebSecurityOrigin::CreateFromString (
300+ blink::WebString::FromUTF8 (origin_url)));
301+ }
302+
277303void WebFrame::SetIsolatedWorldContentSecurityPolicy (int world_id,
278304 const std::string& security_policy) {
279305 web_frame_->SetIsolatedWorldContentSecurityPolicy (
@@ -337,6 +363,8 @@ void WebFrame::BuildPrototype(
337363 .SetMethod (" executeJavaScript" , &WebFrame::ExecuteJavaScript)
338364 .SetMethod (" executeJavaScriptInIsolatedWorld" ,
339365 &WebFrame::ExecuteJavaScriptInIsolatedWorld)
366+ .SetMethod (" setIsolatedWorldSecurityOrigin" ,
367+ &WebFrame::SetIsolatedWorldSecurityOrigin)
340368 .SetMethod (" setIsolatedWorldContentSecurityPolicy" ,
341369 &WebFrame::SetIsolatedWorldContentSecurityPolicy)
342370 .SetMethod (" setIsolatedWorldHumanReadableName" ,
0 commit comments