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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin_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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" 5 #include "content/renderer/browser_plugin/browser_plugin_bindings.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 virtual uint32 GetArgCount() const OVERRIDE { return arg_count_; } 215 virtual uint32 GetArgCount() const OVERRIDE { return arg_count_; }
216 216
217 private: 217 private:
218 BrowserPluginImpl* browser_plugin_; 218 BrowserPluginImpl* browser_plugin_;
219 std::string name_; 219 std::string name_;
220 uint32 arg_count_; 220 uint32 arg_count_;
221 221
222 DISALLOW_COPY_AND_ASSIGN(BrowserPluginMethodBindingImpl); 222 DISALLOW_COPY_AND_ASSIGN(BrowserPluginMethodBindingImpl);
223 }; 223 };
224 224
225 class BrowserPluginBindingBack : public BrowserPluginMethodBindingImpl {
226 public:
227 BrowserPluginBindingBack(BrowserPluginImpl* browser_plugin)
228 : BrowserPluginMethodBindingImpl(browser_plugin,
229 browser_plugin::kMethodBack, 0) {
230 }
231
232 virtual bool Invoke(const NPVariant* args, NPVariant* result) OVERRIDE {
233 browser_plugin()->Back();
234 return true;
235 }
236
237 private:
238 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingBack);
239 };
240
241 class BrowserPluginBindingCanGoBack : public BrowserPluginMethodBindingImpl { 225 class BrowserPluginBindingCanGoBack : public BrowserPluginMethodBindingImpl {
242 public: 226 public:
243 BrowserPluginBindingCanGoBack(BrowserPluginImpl* browser_plugin) 227 BrowserPluginBindingCanGoBack(BrowserPluginImpl* browser_plugin)
244 : BrowserPluginMethodBindingImpl(browser_plugin, 228 : BrowserPluginMethodBindingImpl(browser_plugin,
245 browser_plugin::kMethodCanGoBack, 0) { 229 browser_plugin::kMethodCanGoBack, 0) {
246 } 230 }
247 231
248 virtual bool Invoke(const NPVariant* args, NPVariant* result) OVERRIDE { 232 virtual bool Invoke(const NPVariant* args, NPVariant* result) OVERRIDE {
249 BOOLEAN_TO_NPVARIANT(browser_plugin()->CanGoBack(), *result); 233 BOOLEAN_TO_NPVARIANT(browser_plugin()->CanGoBack(), *result);
250 return true; 234 return true;
(...skipping 12 matching lines...) Expand all
263 247
264 virtual bool Invoke(const NPVariant* args, NPVariant* result) OVERRIDE { 248 virtual bool Invoke(const NPVariant* args, NPVariant* result) OVERRIDE {
265 BOOLEAN_TO_NPVARIANT(browser_plugin()->CanGoForward(), *result); 249 BOOLEAN_TO_NPVARIANT(browser_plugin()->CanGoForward(), *result);
266 return true; 250 return true;
267 } 251 }
268 252
269 private: 253 private:
270 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingCanGoForward); 254 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingCanGoForward);
271 }; 255 };
272 256
273 class BrowserPluginBindingForward : public BrowserPluginMethodBindingImpl {
274 public:
275 BrowserPluginBindingForward(BrowserPluginImpl* browser_plugin)
276 : BrowserPluginMethodBindingImpl(browser_plugin,
277 browser_plugin::kMethodForward, 0) {
278 }
279
280 virtual bool Invoke(const NPVariant* args, NPVariant* result) OVERRIDE {
281 browser_plugin()->Forward();
282 return true;
283 }
284
285 private:
286 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingForward);
287 };
288
289 // Note: This is a method that is used internally by the <webview> shim only. 257 // Note: This is a method that is used internally by the <webview> shim only.
290 // This should not be exposed to developers. 258 // This should not be exposed to developers.
291 class BrowserPluginBindingGetRouteID : public BrowserPluginMethodBindingImpl { 259 class BrowserPluginBindingGetRouteID : public BrowserPluginMethodBindingImpl {
292 public: 260 public:
293 BrowserPluginBindingGetRouteID(BrowserPluginImpl* browser_plugin) 261 BrowserPluginBindingGetRouteID(BrowserPluginImpl* browser_plugin)
294 : BrowserPluginMethodBindingImpl(browser_plugin, 262 : BrowserPluginMethodBindingImpl(browser_plugin,
295 browser_plugin::kMethodGetRouteId, 0) { 263 browser_plugin::kMethodGetRouteId, 0) {
296 } 264 }
297 265
298 virtual bool Invoke(const NPVariant* args, NPVariant* result) OVERRIDE { 266 virtual bool Invoke(const NPVariant* args, NPVariant* result) OVERRIDE {
(...skipping 15 matching lines...) Expand all
314 282
315 virtual bool Invoke(const NPVariant* args, NPVariant* result) OVERRIDE { 283 virtual bool Invoke(const NPVariant* args, NPVariant* result) OVERRIDE {
316 INT32_TO_NPVARIANT(browser_plugin()->guest_process_id(), *result); 284 INT32_TO_NPVARIANT(browser_plugin()->guest_process_id(), *result);
317 return true; 285 return true;
318 } 286 }
319 287
320 private: 288 private:
321 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingGetProcessID); 289 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingGetProcessID);
322 }; 290 };
323 291
324 class BrowserPluginBindingGo : public BrowserPluginMethodBindingImpl {
325 public:
326 BrowserPluginBindingGo(BrowserPluginImpl* browser_plugin)
327 : BrowserPluginMethodBindingImpl(browser_plugin,
328 browser_plugin::kMethodGo, 1) {
329 }
330
331 virtual bool Invoke(const NPVariant* args, NPVariant* result) OVERRIDE {
332 browser_plugin()->Go(Int32FromNPVariant(args[0]));
333 return true;
334 }
335
336 private:
337 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingGo);
338 };
339
340 // Note: This is a method that is used internally by the <webview> shim only. 292 // Note: This is a method that is used internally by the <webview> shim only.
341 // This should not be exposed to developers. 293 // This should not be exposed to developers.
342 class BrowserPluginBindingPersistRequestObject 294 class BrowserPluginBindingPersistRequestObject
343 : public BrowserPluginMethodBindingImpl { 295 : public BrowserPluginMethodBindingImpl {
344 public: 296 public:
345 BrowserPluginBindingPersistRequestObject(BrowserPluginImpl* browser_plugin) 297 BrowserPluginBindingPersistRequestObject(BrowserPluginImpl* browser_plugin)
346 : BrowserPluginMethodBindingImpl( 298 : BrowserPluginMethodBindingImpl(
347 browser_plugin, browser_plugin::kMethodInternalPersistObject, 3) { 299 browser_plugin, browser_plugin::kMethodInternalPersistObject, 3) {
348 } 300 }
349 301
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 725
774 BrowserPluginBindings::BrowserPluginBindings(BrowserPluginImpl* instance) 726 BrowserPluginBindings::BrowserPluginBindings(BrowserPluginImpl* instance)
775 : instance_(instance), 727 : instance_(instance),
776 np_object_(NULL), 728 np_object_(NULL),
777 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 729 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
778 NPObject* obj = 730 NPObject* obj =
779 WebBindings::createObject(NULL, &browser_plugin_message_class); 731 WebBindings::createObject(NULL, &browser_plugin_message_class);
780 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); 732 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj);
781 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); 733 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr();
782 734
783 method_bindings_.push_back(new BrowserPluginBindingBack(instance));
784 method_bindings_.push_back(new BrowserPluginBindingCanGoBack(instance)); 735 method_bindings_.push_back(new BrowserPluginBindingCanGoBack(instance));
785 method_bindings_.push_back(new BrowserPluginBindingCanGoForward(instance)); 736 method_bindings_.push_back(new BrowserPluginBindingCanGoForward(instance));
786 method_bindings_.push_back(new BrowserPluginBindingForward(instance));
787 method_bindings_.push_back(new BrowserPluginBindingGetProcessID(instance)); 737 method_bindings_.push_back(new BrowserPluginBindingGetProcessID(instance));
788 method_bindings_.push_back(new BrowserPluginBindingGetRouteID(instance)); 738 method_bindings_.push_back(new BrowserPluginBindingGetRouteID(instance));
789 method_bindings_.push_back(new BrowserPluginBindingGo(instance));
790 method_bindings_.push_back( 739 method_bindings_.push_back(
791 new BrowserPluginBindingPersistRequestObject(instance)); 740 new BrowserPluginBindingPersistRequestObject(instance));
792 method_bindings_.push_back(new BrowserPluginBindingReload(instance)); 741 method_bindings_.push_back(new BrowserPluginBindingReload(instance));
793 method_bindings_.push_back(new BrowserPluginBindingSetPermission(instance)); 742 method_bindings_.push_back(new BrowserPluginBindingSetPermission(instance));
794 method_bindings_.push_back(new BrowserPluginBindingStop(instance)); 743 method_bindings_.push_back(new BrowserPluginBindingStop(instance));
795 method_bindings_.push_back(new BrowserPluginBindingTerminate(instance)); 744 method_bindings_.push_back(new BrowserPluginBindingTerminate(instance));
796 745
797 property_bindings_.push_back( 746 property_bindings_.push_back(
798 new BrowserPluginPropertyBindingAutoSize(instance)); 747 new BrowserPluginPropertyBindingAutoSize(instance));
799 property_bindings_.push_back( 748 property_bindings_.push_back(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 BrowserPluginMethodBinding* method_binding) { 849 BrowserPluginMethodBinding* method_binding) {
901 method_bindings_.push_back(method_binding); 850 method_bindings_.push_back(method_binding);
902 } 851 }
903 852
904 void BrowserPluginBindings::AddPropertyBinding( 853 void BrowserPluginBindings::AddPropertyBinding(
905 BrowserPluginPropertyBinding* property_binding) { 854 BrowserPluginPropertyBinding* property_binding) {
906 property_bindings_.push_back(property_binding); 855 property_bindings_.push_back(property_binding);
907 } 856 }
908 857
909 } // namespace content 858 } // namespace content
OLDNEW
« no previous file with comments | « content/public/renderer/browser_plugin/browser_plugin.h ('k') | content/renderer/browser_plugin/browser_plugin_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698