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

Unified Diff: chrome/renderer/browser_plugin/chrome_webview_bindings.cc

Issue 12326168: Move <webview> API to chrome layer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT Created 7 years, 10 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
Index: chrome/renderer/browser_plugin/chrome_webview_bindings.cc
diff --git a/chrome/renderer/browser_plugin/chrome_webview_bindings.cc b/chrome/renderer/browser_plugin/chrome_webview_bindings.cc
new file mode 100644
index 0000000000000000000000000000000000000000..951d1a03c8f202872edffce3df7521e0e9e2055f
--- /dev/null
+++ b/chrome/renderer/browser_plugin/chrome_webview_bindings.cc
@@ -0,0 +1,108 @@
+// Copyright (c) 2013 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 "chrome/renderer/browser_plugin/chrome_browser_plugin_observer.h"
+#include "chrome/renderer/browser_plugin/chrome_webview_bindings.h"
+#include "chrome/renderer/browser_plugin/chrome_webview_constants.h"
+
+namespace chrome {
+
+namespace {
+
+int Int32FromNPVariant(const NPVariant& variant) {
+ if (NPVARIANT_IS_INT32(variant))
+ return NPVARIANT_TO_INT32(variant);
+
+ if (NPVARIANT_IS_DOUBLE(variant))
+ return NPVARIANT_TO_DOUBLE(variant);
+
+ return 0;
+}
+
+} // namespace
+
+WebViewMethodBinding::WebViewMethodBinding(
+ ChromeBrowserPluginObserver* browser_plugin_observer,
+ const char name[],
+ uint32 arg_count)
+ : browser_plugin_observer_(browser_plugin_observer),
+ name_(name),
+ arg_count_(arg_count) {
+}
+
+WebViewMethodBinding::~WebViewMethodBinding() {
+}
+
+const std::string& WebViewMethodBinding::GetName() const {
+ return name_;
+}
+
+uint32 WebViewMethodBinding::GetArgCount() const {
+ return arg_count_;
+}
+
+//------------------------------------------------------------------------------
+
+WebViewPropertyBinding::WebViewPropertyBinding(const char name[])
+ : name_(name) {
+}
+
+WebViewPropertyBinding::~WebViewPropertyBinding() {
+}
+
+const std::string& WebViewPropertyBinding::GetName() const {
+ return name_;
+}
+
+//------------------------------------------------------------------------------
+
+WebViewMethodBindingBack::WebViewMethodBindingBack(
+ ChromeBrowserPluginObserver* browser_plugin_observer)
+ : WebViewMethodBinding(browser_plugin_observer, webview::kMethodBack, 0) {
+}
+
+WebViewMethodBindingBack::~WebViewMethodBindingBack() {
+}
+
+bool WebViewMethodBindingBack::Invoke(const NPVariant* args,
+ NPVariant* result) {
+ browser_plugin_observer()->Go(-1);
+ return true;
+}
+
+//------------------------------------------------------------------------------
+
+WebViewMethodBindingForward::WebViewMethodBindingForward(
+ ChromeBrowserPluginObserver* browser_plugin_observer)
+ : WebViewMethodBinding(browser_plugin_observer,
+ webview::kMethodForward, 0) {
+}
+
+WebViewMethodBindingForward::~WebViewMethodBindingForward() {
+}
+
+bool WebViewMethodBindingForward::Invoke(const NPVariant* args,
+ NPVariant* result) {
+ browser_plugin_observer()->Go(1);
+ return true;
+}
+
+//------------------------------------------------------------------------------
+
+WebViewMethodBindingGo::WebViewMethodBindingGo(
+ ChromeBrowserPluginObserver* browser_plugin_observer)
+ : WebViewMethodBinding(browser_plugin_observer,
+ webview::kMethodGo, 1) {
+}
+
+WebViewMethodBindingGo::~WebViewMethodBindingGo() {
+}
+
+bool WebViewMethodBindingGo::Invoke(const NPVariant* args,
+ NPVariant* result) {
+ browser_plugin_observer()->Go(Int32FromNPVariant(args[0]));
+ return true;
+}
+
+} // namespace chrome
« no previous file with comments | « chrome/renderer/browser_plugin/chrome_webview_bindings.h ('k') | chrome/renderer/browser_plugin/chrome_webview_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698