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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/renderer/browser_plugin/chrome_browser_plugin_observer.h"
6 #include "chrome/renderer/browser_plugin/chrome_webview_bindings.h"
7 #include "chrome/renderer/browser_plugin/chrome_webview_constants.h"
8
9 namespace chrome {
10
11 namespace {
12
13 int Int32FromNPVariant(const NPVariant& variant) {
14 if (NPVARIANT_IS_INT32(variant))
15 return NPVARIANT_TO_INT32(variant);
16
17 if (NPVARIANT_IS_DOUBLE(variant))
18 return NPVARIANT_TO_DOUBLE(variant);
19
20 return 0;
21 }
22
23 } // namespace
24
25 WebViewMethodBinding::WebViewMethodBinding(
26 ChromeBrowserPluginObserver* browser_plugin_observer,
27 const char name[],
28 uint32 arg_count)
29 : browser_plugin_observer_(browser_plugin_observer),
30 name_(name),
31 arg_count_(arg_count) {
32 }
33
34 WebViewMethodBinding::~WebViewMethodBinding() {
35 }
36
37 const std::string& WebViewMethodBinding::GetName() const {
38 return name_;
39 }
40
41 uint32 WebViewMethodBinding::GetArgCount() const {
42 return arg_count_;
43 }
44
45 //------------------------------------------------------------------------------
46
47 WebViewPropertyBinding::WebViewPropertyBinding(const char name[])
48 : name_(name) {
49 }
50
51 WebViewPropertyBinding::~WebViewPropertyBinding() {
52 }
53
54 const std::string& WebViewPropertyBinding::GetName() const {
55 return name_;
56 }
57
58 //------------------------------------------------------------------------------
59
60 WebViewMethodBindingBack::WebViewMethodBindingBack(
61 ChromeBrowserPluginObserver* browser_plugin_observer)
62 : WebViewMethodBinding(browser_plugin_observer, webview::kMethodBack, 0) {
63 }
64
65 WebViewMethodBindingBack::~WebViewMethodBindingBack() {
66 }
67
68 bool WebViewMethodBindingBack::Invoke(const NPVariant* args,
69 NPVariant* result) {
70 browser_plugin_observer()->Go(-1);
71 return true;
72 }
73
74 //------------------------------------------------------------------------------
75
76 WebViewMethodBindingForward::WebViewMethodBindingForward(
77 ChromeBrowserPluginObserver* browser_plugin_observer)
78 : WebViewMethodBinding(browser_plugin_observer,
79 webview::kMethodForward, 0) {
80 }
81
82 WebViewMethodBindingForward::~WebViewMethodBindingForward() {
83 }
84
85 bool WebViewMethodBindingForward::Invoke(const NPVariant* args,
86 NPVariant* result) {
87 browser_plugin_observer()->Go(1);
88 return true;
89 }
90
91 //------------------------------------------------------------------------------
92
93 WebViewMethodBindingGo::WebViewMethodBindingGo(
94 ChromeBrowserPluginObserver* browser_plugin_observer)
95 : WebViewMethodBinding(browser_plugin_observer,
96 webview::kMethodGo, 1) {
97 }
98
99 WebViewMethodBindingGo::~WebViewMethodBindingGo() {
100 }
101
102 bool WebViewMethodBindingGo::Invoke(const NPVariant* args,
103 NPVariant* result) {
104 browser_plugin_observer()->Go(Int32FromNPVariant(args[0]));
105 return true;
106 }
107
108 } // namespace chrome
OLDNEW
« 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