Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: apps/shell/renderer/shell_custom_bindings.cc

Issue 254473011: Introduce chrome.shell.createWindow stub API for app_shell (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix deps (shell-api) Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « apps/shell/renderer/shell_custom_bindings.h ('k') | apps/shell/renderer/shell_custom_bindings.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/shell/renderer/shell_custom_bindings.cc
diff --git a/apps/shell/renderer/shell_custom_bindings.cc b/apps/shell/renderer/shell_custom_bindings.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c4101b6ba0886dbe852fda02367bd54a8b703e95
--- /dev/null
+++ b/apps/shell/renderer/shell_custom_bindings.cc
@@ -0,0 +1,57 @@
+// Copyright 2014 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.
+
+#include "apps/shell/renderer/shell_custom_bindings.h"
+
+#include "content/public/renderer/render_thread.h"
+#include "content/public/renderer/render_view.h"
+#include "content/public/renderer/v8_value_converter.h"
+#include "extensions/common/extension_messages.h"
+#include "extensions/renderer/script_context.h"
+#include "extensions/renderer/script_context_set.h"
+#include "third_party/WebKit/public/web/WebFrame.h"
+#include "third_party/WebKit/public/web/WebView.h"
+#include "v8/include/v8.h"
+
+namespace apps {
+
+ShellCustomBindings::ShellCustomBindings(extensions::ScriptContext* context)
+ : extensions::ObjectBackedNativeHandler(context) {
+ RouteFunction(
+ "GetView",
+ base::Bind(&ShellCustomBindings::GetView, base::Unretained(this)));
+}
+
+void ShellCustomBindings::GetView(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ if (args.Length() != 1 || !args[0]->IsInt32())
+ return;
+
+ int view_id = args[0]->Int32Value();
+ if (view_id == MSG_ROUTING_NONE)
+ return;
+
+ content::RenderView* view = content::RenderView::FromRoutingID(view_id);
+ if (!view)
+ return;
+
+ // Set the opener so we have a security origin set up before returning the DOM
+ // reference.
+ content::RenderView* render_view = context()->GetRenderView();
+ if (!render_view)
+ return;
+ blink::WebFrame* opener = render_view->GetWebView()->mainFrame();
+ blink::WebFrame* frame = view->GetWebView()->mainFrame();
+ frame->setOpener(opener);
+
+ // Resume resource requests.
+ content::RenderThread::Get()->Send(
+ new ExtensionHostMsg_ResumeRequests(view->GetRoutingID()));
+
+ // Return the script context.
+ v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global();
+ args.GetReturnValue().Set(window);
+}
+
+} // namespace apps
« no previous file with comments | « apps/shell/renderer/shell_custom_bindings.h ('k') | apps/shell/renderer/shell_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698