| 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 |
| 344 : public BrowserPluginMethodBinding { |
| 345 public: |
| 346 BrowserPluginBindingPersistRequestObject() |
| 347 : BrowserPluginMethodBinding(browser_plugin::kMethodInternalPersistObject, |
| 348 3) { |
| 349 } |
| 350 |
| 351 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 352 const NPVariant* args, |
| 353 NPVariant* result) OVERRIDE { |
| 354 bindings->instance()->PersistRequestObject( |
| 355 &args[0], StringFromNPVariant(args[1]), Int32FromNPVariant(args[2])); |
| 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 BrowserPluginBindingSetPermission : public BrowserPluginMethodBinding { |
| 400 public: |
| 401 BrowserPluginBindingSetPermission() |
| 402 : BrowserPluginMethodBinding( |
| 403 browser_plugin::kMethodInternalSetPermission, 2) { |
| 404 } |
| 405 |
| 406 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 407 const NPVariant* args, |
| 408 NPVariant* result) OVERRIDE { |
| 409 int request_id = Int32FromNPVariant(args[0]); |
| 410 bool allow = NPVARIANT_TO_BOOLEAN(args[1]); |
| 411 bindings->instance()->OnEmbedderDecidedPermission(request_id, allow); |
| 412 return true; |
| 413 } |
| 414 |
| 415 private: |
| 416 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingSetPermission); |
| 417 }; |
| 418 |
| 375 class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding { | 419 class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding { |
| 376 public: | 420 public: |
| 377 BrowserPluginBindingTerminate() | 421 BrowserPluginBindingTerminate() |
| 378 : BrowserPluginMethodBinding(browser_plugin::kMethodTerminate, 0) { | 422 : BrowserPluginMethodBinding(browser_plugin::kMethodTerminate, 0) { |
| 379 } | 423 } |
| 380 | 424 |
| 381 virtual bool Invoke(BrowserPluginBindings* bindings, | 425 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 382 const NPVariant* args, | 426 const NPVariant* args, |
| 383 NPVariant* result) OVERRIDE { | 427 NPVariant* result) OVERRIDE { |
| 384 bindings->instance()->TerminateGuest(); | 428 bindings->instance()->TerminateGuest(); |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); | 807 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); |
| 764 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); | 808 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); |
| 765 | 809 |
| 766 method_bindings_.push_back(new BrowserPluginBindingBack); | 810 method_bindings_.push_back(new BrowserPluginBindingBack); |
| 767 method_bindings_.push_back(new BrowserPluginBindingCanGoBack); | 811 method_bindings_.push_back(new BrowserPluginBindingCanGoBack); |
| 768 method_bindings_.push_back(new BrowserPluginBindingCanGoForward); | 812 method_bindings_.push_back(new BrowserPluginBindingCanGoForward); |
| 769 method_bindings_.push_back(new BrowserPluginBindingForward); | 813 method_bindings_.push_back(new BrowserPluginBindingForward); |
| 770 method_bindings_.push_back(new BrowserPluginBindingGetProcessID); | 814 method_bindings_.push_back(new BrowserPluginBindingGetProcessID); |
| 771 method_bindings_.push_back(new BrowserPluginBindingGetRouteID); | 815 method_bindings_.push_back(new BrowserPluginBindingGetRouteID); |
| 772 method_bindings_.push_back(new BrowserPluginBindingGo); | 816 method_bindings_.push_back(new BrowserPluginBindingGo); |
| 817 method_bindings_.push_back(new BrowserPluginBindingPersistRequestObject); |
| 773 method_bindings_.push_back(new BrowserPluginBindingReload); | 818 method_bindings_.push_back(new BrowserPluginBindingReload); |
| 819 method_bindings_.push_back(new BrowserPluginBindingSetPermission); |
| 774 method_bindings_.push_back(new BrowserPluginBindingStop); | 820 method_bindings_.push_back(new BrowserPluginBindingStop); |
| 775 method_bindings_.push_back(new BrowserPluginBindingTerminate); | 821 method_bindings_.push_back(new BrowserPluginBindingTerminate); |
| 776 | 822 |
| 777 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); | 823 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); |
| 778 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); | 824 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); |
| 779 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); | 825 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); |
| 780 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); | 826 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); |
| 781 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); | 827 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); |
| 782 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); | 828 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); |
| 783 property_bindings_.push_back(new BrowserPluginPropertyBindingName); | 829 property_bindings_.push_back(new BrowserPluginPropertyBindingName); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 for (PropertyBindingList::iterator iter = property_bindings_.begin(); | 901 for (PropertyBindingList::iterator iter = property_bindings_.begin(); |
| 856 iter != property_bindings_.end(); | 902 iter != property_bindings_.end(); |
| 857 ++iter) { | 903 ++iter) { |
| 858 if ((*iter)->MatchesName(name)) | 904 if ((*iter)->MatchesName(name)) |
| 859 return (*iter)->GetProperty(this, result); | 905 return (*iter)->GetProperty(this, result); |
| 860 } | 906 } |
| 861 return false; | 907 return false; |
| 862 } | 908 } |
| 863 | 909 |
| 864 } // namespace content | 910 } // namespace content |
| OLD | NEW |