Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 331 const NPVariant* args, | 331 const NPVariant* args, |
| 332 NPVariant* result) OVERRIDE { | 332 NPVariant* result) OVERRIDE { |
| 333 bindings->instance()->Go(Int32FromNPVariant(args[0])); | 333 bindings->instance()->Go(Int32FromNPVariant(args[0])); |
| 334 return true; | 334 return true; |
| 335 } | 335 } |
| 336 | 336 |
| 337 private: | 337 private: |
| 338 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingGo); | 338 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingGo); |
| 339 }; | 339 }; |
| 340 | 340 |
| 341 // Note: This is a method that is used internally by the <webview> shim only. | |
| 342 // This should not be exposed to developers. | |
| 343 class BrowserPluginBindingPersistRequestObject | |
|
Fady Samuel
2013/02/07 15:40:34
Get rid of "request" to allow this to be used by w
lazyboy
2013/02/07 21:24:41
See my comments in .cc file.
| |
| 344 : public BrowserPluginMethodBinding { | |
| 345 public: | |
| 346 BrowserPluginBindingPersistRequestObject() | |
| 347 : BrowserPluginMethodBinding(browser_plugin::kMethodInternalPersistObject, | |
| 348 2) { | |
| 349 } | |
| 350 | |
| 351 virtual bool Invoke(BrowserPluginBindings* bindings, | |
| 352 const NPVariant* args, | |
| 353 NPVariant* result) OVERRIDE { | |
| 354 bindings->instance()->PersistRequestObject( | |
| 355 &args[0], Int32FromNPVariant(args[1])); | |
| 356 return true; | |
| 357 } | |
| 358 | |
| 359 private: | |
| 360 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingPersistRequestObject); | |
| 361 }; | |
| 362 | |
| 341 class BrowserPluginBindingReload : public BrowserPluginMethodBinding { | 363 class BrowserPluginBindingReload : public BrowserPluginMethodBinding { |
| 342 public: | 364 public: |
| 343 BrowserPluginBindingReload() | 365 BrowserPluginBindingReload() |
| 344 : BrowserPluginMethodBinding(browser_plugin::kMethodReload, 0) { | 366 : BrowserPluginMethodBinding(browser_plugin::kMethodReload, 0) { |
| 345 } | 367 } |
| 346 | 368 |
| 347 virtual bool Invoke(BrowserPluginBindings* bindings, | 369 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 348 const NPVariant* args, | 370 const NPVariant* args, |
| 349 NPVariant* result) OVERRIDE { | 371 NPVariant* result) OVERRIDE { |
| 350 bindings->instance()->Reload(); | 372 bindings->instance()->Reload(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 365 const NPVariant* args, | 387 const NPVariant* args, |
| 366 NPVariant* result) OVERRIDE { | 388 NPVariant* result) OVERRIDE { |
| 367 bindings->instance()->Stop(); | 389 bindings->instance()->Stop(); |
| 368 return true; | 390 return true; |
| 369 } | 391 } |
| 370 | 392 |
| 371 private: | 393 private: |
| 372 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingStop); | 394 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingStop); |
| 373 }; | 395 }; |
| 374 | 396 |
| 397 // Note: This is a method that is used internally by the <webview> shim only. | |
| 398 // This should not be exposed to developers. | |
| 399 class BrowserPluginBindingSetMediaPermission | |
| 400 : public BrowserPluginMethodBinding { | |
| 401 public: | |
| 402 BrowserPluginBindingSetMediaPermission() | |
|
Fady Samuel
2013/02/07 15:40:34
To reduce the number of new methods we introduce,
lazyboy
2013/02/07 21:24:41
Done.
| |
| 403 : BrowserPluginMethodBinding( | |
| 404 browser_plugin::kMethodInternalSetMediaPermission, 2) { | |
| 405 } | |
| 406 | |
| 407 virtual bool Invoke(BrowserPluginBindings* bindings, | |
| 408 const NPVariant* args, | |
| 409 NPVariant* result) OVERRIDE { | |
| 410 int request_id = Int32FromNPVariant(args[0]); | |
| 411 bool allow = NPVARIANT_TO_BOOLEAN(args[1]); | |
| 412 bindings->instance()->OnListenerCallMediaAccess(request_id, allow); | |
| 413 return true; | |
| 414 } | |
| 415 | |
| 416 private: | |
| 417 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingSetMediaPermission); | |
| 418 }; | |
| 419 | |
| 375 class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding { | 420 class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding { |
| 376 public: | 421 public: |
| 377 BrowserPluginBindingTerminate() | 422 BrowserPluginBindingTerminate() |
| 378 : BrowserPluginMethodBinding(browser_plugin::kMethodTerminate, 0) { | 423 : BrowserPluginMethodBinding(browser_plugin::kMethodTerminate, 0) { |
| 379 } | 424 } |
| 380 | 425 |
| 381 virtual bool Invoke(BrowserPluginBindings* bindings, | 426 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 382 const NPVariant* args, | 427 const NPVariant* args, |
| 383 NPVariant* result) OVERRIDE { | 428 NPVariant* result) OVERRIDE { |
| 384 bindings->instance()->TerminateGuest(); | 429 bindings->instance()->TerminateGuest(); |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 748 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); | 793 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); |
| 749 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); | 794 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); |
| 750 | 795 |
| 751 method_bindings_.push_back(new BrowserPluginBindingBack); | 796 method_bindings_.push_back(new BrowserPluginBindingBack); |
| 752 method_bindings_.push_back(new BrowserPluginBindingCanGoBack); | 797 method_bindings_.push_back(new BrowserPluginBindingCanGoBack); |
| 753 method_bindings_.push_back(new BrowserPluginBindingCanGoForward); | 798 method_bindings_.push_back(new BrowserPluginBindingCanGoForward); |
| 754 method_bindings_.push_back(new BrowserPluginBindingForward); | 799 method_bindings_.push_back(new BrowserPluginBindingForward); |
| 755 method_bindings_.push_back(new BrowserPluginBindingGetProcessID); | 800 method_bindings_.push_back(new BrowserPluginBindingGetProcessID); |
| 756 method_bindings_.push_back(new BrowserPluginBindingGetRouteID); | 801 method_bindings_.push_back(new BrowserPluginBindingGetRouteID); |
| 757 method_bindings_.push_back(new BrowserPluginBindingGo); | 802 method_bindings_.push_back(new BrowserPluginBindingGo); |
| 803 method_bindings_.push_back(new BrowserPluginBindingPersistRequestObject); | |
| 758 method_bindings_.push_back(new BrowserPluginBindingReload); | 804 method_bindings_.push_back(new BrowserPluginBindingReload); |
| 805 method_bindings_.push_back(new BrowserPluginBindingSetMediaPermission); | |
| 759 method_bindings_.push_back(new BrowserPluginBindingStop); | 806 method_bindings_.push_back(new BrowserPluginBindingStop); |
| 760 method_bindings_.push_back(new BrowserPluginBindingTerminate); | 807 method_bindings_.push_back(new BrowserPluginBindingTerminate); |
| 761 | 808 |
| 762 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); | 809 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); |
| 763 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); | 810 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); |
| 764 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); | 811 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); |
| 765 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); | 812 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); |
| 766 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); | 813 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); |
| 767 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); | 814 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); |
| 768 property_bindings_.push_back(new BrowserPluginPropertyBindingName); | 815 property_bindings_.push_back(new BrowserPluginPropertyBindingName); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 840 for (PropertyBindingList::iterator iter = property_bindings_.begin(); | 887 for (PropertyBindingList::iterator iter = property_bindings_.begin(); |
| 841 iter != property_bindings_.end(); | 888 iter != property_bindings_.end(); |
| 842 ++iter) { | 889 ++iter) { |
| 843 if ((*iter)->MatchesName(name)) | 890 if ((*iter)->MatchesName(name)) |
| 844 return (*iter)->GetProperty(this, result); | 891 return (*iter)->GetProperty(this, result); |
| 845 } | 892 } |
| 846 return false; | 893 return false; |
| 847 } | 894 } |
| 848 | 895 |
| 849 } // namespace content | 896 } // namespace content |
| OLD | NEW |