| 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 26 matching lines...) Expand all Loading... |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 // Method bindings. | 39 // Method bindings. |
| 40 const char kMethodBack[] = "back"; | 40 const char kMethodBack[] = "back"; |
| 41 const char kMethodCanGoBack[] = "canGoBack"; | 41 const char kMethodCanGoBack[] = "canGoBack"; |
| 42 const char kMethodCanGoForward[] = "canGoForward"; | 42 const char kMethodCanGoForward[] = "canGoForward"; |
| 43 const char kMethodForward[] = "forward"; | 43 const char kMethodForward[] = "forward"; |
| 44 const char kMethodGetProcessId[] = "getProcessId"; | 44 const char kMethodGetProcessId[] = "getProcessId"; |
| 45 const char kMethodGo[] = "go"; | 45 const char kMethodGo[] = "go"; |
| 46 const char kMethodReload[] = "reload"; | 46 const char kMethodReload[] = "reload"; |
| 47 const char kMethodSetMediaPermission[] = "setMediaPermission"; |
| 47 const char kMethodStop[] = "stop"; | 48 const char kMethodStop[] = "stop"; |
| 48 const char kMethodTerminate[] = "terminate"; | 49 const char kMethodTerminate[] = "terminate"; |
| 49 | 50 |
| 50 // Attributes. | 51 // Attributes. |
| 51 const char kAttributeAutoSize[] = "autoSize"; | 52 const char kAttributeAutoSize[] = "autoSize"; |
| 52 const char kAttributeContentWindow[] = "contentWindow"; | 53 const char kAttributeContentWindow[] = "contentWindow"; |
| 53 const char kAttributeMaxHeight[] = "maxHeight"; | 54 const char kAttributeMaxHeight[] = "maxHeight"; |
| 54 const char kAttributeMaxWidth[] = "maxWidth"; | 55 const char kAttributeMaxWidth[] = "maxWidth"; |
| 55 const char kAttributeMinHeight[] = "minHeight"; | 56 const char kAttributeMinHeight[] = "minHeight"; |
| 56 const char kAttributeMinWidth[] = "minWidth"; | 57 const char kAttributeMinWidth[] = "minWidth"; |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 const NPVariant* args, | 363 const NPVariant* args, |
| 363 NPVariant* result) OVERRIDE { | 364 NPVariant* result) OVERRIDE { |
| 364 bindings->instance()->Stop(); | 365 bindings->instance()->Stop(); |
| 365 return true; | 366 return true; |
| 366 } | 367 } |
| 367 | 368 |
| 368 private: | 369 private: |
| 369 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingStop); | 370 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingStop); |
| 370 }; | 371 }; |
| 371 | 372 |
| 373 class BrowserPluginBindingSetMediaPermission |
| 374 : public BrowserPluginMethodBinding { |
| 375 public: |
| 376 BrowserPluginBindingSetMediaPermission() |
| 377 : BrowserPluginMethodBinding(kMethodSetMediaPermission, 2) { |
| 378 } |
| 379 |
| 380 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 381 const NPVariant* args, |
| 382 NPVariant* result) OVERRIDE { |
| 383 int request_id = Int32FromNPVariant(args[0]); |
| 384 bool allow = NPVARIANT_TO_BOOLEAN(args[1]); |
| 385 bindings->instance()->OnListenerCallMediaAccess(request_id, allow); |
| 386 return true; |
| 387 } |
| 388 |
| 389 private: |
| 390 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingSetMediaPermission); |
| 391 }; |
| 392 |
| 372 class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding { | 393 class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding { |
| 373 public: | 394 public: |
| 374 BrowserPluginBindingTerminate() | 395 BrowserPluginBindingTerminate() |
| 375 : BrowserPluginMethodBinding(kMethodTerminate, 0) { | 396 : BrowserPluginMethodBinding(kMethodTerminate, 0) { |
| 376 } | 397 } |
| 377 | 398 |
| 378 virtual bool Invoke(BrowserPluginBindings* bindings, | 399 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 379 const NPVariant* args, | 400 const NPVariant* args, |
| 380 NPVariant* result) OVERRIDE { | 401 NPVariant* result) OVERRIDE { |
| 381 bindings->instance()->TerminateGuest(); | 402 bindings->instance()->TerminateGuest(); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); | 677 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); |
| 657 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); | 678 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); |
| 658 | 679 |
| 659 method_bindings_.push_back(new BrowserPluginBindingBack); | 680 method_bindings_.push_back(new BrowserPluginBindingBack); |
| 660 method_bindings_.push_back(new BrowserPluginBindingCanGoBack); | 681 method_bindings_.push_back(new BrowserPluginBindingCanGoBack); |
| 661 method_bindings_.push_back(new BrowserPluginBindingCanGoForward); | 682 method_bindings_.push_back(new BrowserPluginBindingCanGoForward); |
| 662 method_bindings_.push_back(new BrowserPluginBindingForward); | 683 method_bindings_.push_back(new BrowserPluginBindingForward); |
| 663 method_bindings_.push_back(new BrowserPluginBindingGetProcessID); | 684 method_bindings_.push_back(new BrowserPluginBindingGetProcessID); |
| 664 method_bindings_.push_back(new BrowserPluginBindingGo); | 685 method_bindings_.push_back(new BrowserPluginBindingGo); |
| 665 method_bindings_.push_back(new BrowserPluginBindingReload); | 686 method_bindings_.push_back(new BrowserPluginBindingReload); |
| 687 method_bindings_.push_back(new BrowserPluginBindingSetMediaPermission); |
| 666 method_bindings_.push_back(new BrowserPluginBindingStop); | 688 method_bindings_.push_back(new BrowserPluginBindingStop); |
| 667 method_bindings_.push_back(new BrowserPluginBindingTerminate); | 689 method_bindings_.push_back(new BrowserPluginBindingTerminate); |
| 668 | 690 |
| 669 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); | 691 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); |
| 670 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); | 692 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); |
| 671 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); | 693 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); |
| 672 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); | 694 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); |
| 673 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); | 695 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); |
| 674 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); | 696 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); |
| 675 property_bindings_.push_back(new BrowserPluginPropertyBindingPartition); | 697 property_bindings_.push_back(new BrowserPluginPropertyBindingPartition); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 for (PropertyBindingList::iterator iter = property_bindings_.begin(); | 756 for (PropertyBindingList::iterator iter = property_bindings_.begin(); |
| 735 iter != property_bindings_.end(); | 757 iter != property_bindings_.end(); |
| 736 ++iter) { | 758 ++iter) { |
| 737 if ((*iter)->MatchesName(name)) | 759 if ((*iter)->MatchesName(name)) |
| 738 return (*iter)->GetProperty(this, result); | 760 return (*iter)->GetProperty(this, result); |
| 739 } | 761 } |
| 740 return false; | 762 return false; |
| 741 } | 763 } |
| 742 | 764 |
| 743 } // namespace content | 765 } // namespace content |
| OLD | NEW |