| 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 25 matching lines...) Expand all Loading... |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 // Method bindings. | 38 // Method bindings. |
| 39 const char kMethodBack[] = "back"; | 39 const char kMethodBack[] = "back"; |
| 40 const char kMethodCanGoBack[] = "canGoBack"; | 40 const char kMethodCanGoBack[] = "canGoBack"; |
| 41 const char kMethodCanGoForward[] = "canGoForward"; | 41 const char kMethodCanGoForward[] = "canGoForward"; |
| 42 const char kMethodForward[] = "forward"; | 42 const char kMethodForward[] = "forward"; |
| 43 const char kMethodGetProcessId[] = "getProcessId"; | 43 const char kMethodGetProcessId[] = "getProcessId"; |
| 44 const char kMethodGo[] = "go"; | 44 const char kMethodGo[] = "go"; |
| 45 const char kMethodReload[] = "reload"; | 45 const char kMethodReload[] = "reload"; |
| 46 const char kMethodSetMediaPermission[] = "setMediaPermission"; |
| 46 const char kMethodStop[] = "stop"; | 47 const char kMethodStop[] = "stop"; |
| 47 const char kMethodTerminate[] = "terminate"; | 48 const char kMethodTerminate[] = "terminate"; |
| 48 | 49 |
| 49 // Attributes. | 50 // Attributes. |
| 50 const char kAttributeAutoSize[] = "autoSize"; | 51 const char kAttributeAutoSize[] = "autoSize"; |
| 51 const char kAttributeContentWindow[] = "contentWindow"; | 52 const char kAttributeContentWindow[] = "contentWindow"; |
| 52 const char kAttributeMaxHeight[] = "maxHeight"; | 53 const char kAttributeMaxHeight[] = "maxHeight"; |
| 53 const char kAttributeMaxWidth[] = "maxWidth"; | 54 const char kAttributeMaxWidth[] = "maxWidth"; |
| 54 const char kAttributeMinHeight[] = "minHeight"; | 55 const char kAttributeMinHeight[] = "minHeight"; |
| 55 const char kAttributeMinWidth[] = "minWidth"; | 56 const char kAttributeMinWidth[] = "minWidth"; |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 const NPVariant* args, | 362 const NPVariant* args, |
| 362 NPVariant* result) OVERRIDE { | 363 NPVariant* result) OVERRIDE { |
| 363 bindings->instance()->Stop(); | 364 bindings->instance()->Stop(); |
| 364 return true; | 365 return true; |
| 365 } | 366 } |
| 366 | 367 |
| 367 private: | 368 private: |
| 368 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingStop); | 369 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingStop); |
| 369 }; | 370 }; |
| 370 | 371 |
| 372 class BrowserPluginBindingSetMediaPermission |
| 373 : public BrowserPluginMethodBinding { |
| 374 public: |
| 375 BrowserPluginBindingSetMediaPermission() |
| 376 : BrowserPluginMethodBinding(kMethodSetMediaPermission, 2) { |
| 377 } |
| 378 |
| 379 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 380 const NPVariant* args, |
| 381 NPVariant* result) OVERRIDE { |
| 382 int request_id = Int32FromNPVariant(args[0]); |
| 383 bool allow = NPVARIANT_TO_BOOLEAN(args[1]); |
| 384 bindings->instance()->RespondMediaAccess(request_id, allow); |
| 385 return true; |
| 386 } |
| 387 |
| 388 private: |
| 389 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingSetMediaPermission); |
| 390 }; |
| 391 |
| 371 class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding { | 392 class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding { |
| 372 public: | 393 public: |
| 373 BrowserPluginBindingTerminate() | 394 BrowserPluginBindingTerminate() |
| 374 : BrowserPluginMethodBinding(kMethodTerminate, 0) { | 395 : BrowserPluginMethodBinding(kMethodTerminate, 0) { |
| 375 } | 396 } |
| 376 | 397 |
| 377 virtual bool Invoke(BrowserPluginBindings* bindings, | 398 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 378 const NPVariant* args, | 399 const NPVariant* args, |
| 379 NPVariant* result) OVERRIDE { | 400 NPVariant* result) OVERRIDE { |
| 380 bindings->instance()->TerminateGuest(); | 401 bindings->instance()->TerminateGuest(); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); | 638 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); |
| 618 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); | 639 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); |
| 619 | 640 |
| 620 method_bindings_.push_back(new BrowserPluginBindingBack); | 641 method_bindings_.push_back(new BrowserPluginBindingBack); |
| 621 method_bindings_.push_back(new BrowserPluginBindingCanGoBack); | 642 method_bindings_.push_back(new BrowserPluginBindingCanGoBack); |
| 622 method_bindings_.push_back(new BrowserPluginBindingCanGoForward); | 643 method_bindings_.push_back(new BrowserPluginBindingCanGoForward); |
| 623 method_bindings_.push_back(new BrowserPluginBindingForward); | 644 method_bindings_.push_back(new BrowserPluginBindingForward); |
| 624 method_bindings_.push_back(new BrowserPluginBindingGetProcessID); | 645 method_bindings_.push_back(new BrowserPluginBindingGetProcessID); |
| 625 method_bindings_.push_back(new BrowserPluginBindingGo); | 646 method_bindings_.push_back(new BrowserPluginBindingGo); |
| 626 method_bindings_.push_back(new BrowserPluginBindingReload); | 647 method_bindings_.push_back(new BrowserPluginBindingReload); |
| 648 method_bindings_.push_back(new BrowserPluginBindingSetMediaPermission); |
| 627 method_bindings_.push_back(new BrowserPluginBindingStop); | 649 method_bindings_.push_back(new BrowserPluginBindingStop); |
| 628 method_bindings_.push_back(new BrowserPluginBindingTerminate); | 650 method_bindings_.push_back(new BrowserPluginBindingTerminate); |
| 629 | 651 |
| 630 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); | 652 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); |
| 631 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); | 653 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); |
| 632 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); | 654 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); |
| 633 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); | 655 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); |
| 634 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); | 656 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); |
| 635 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); | 657 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); |
| 636 property_bindings_.push_back(new BrowserPluginPropertyBindingPartition); | 658 property_bindings_.push_back(new BrowserPluginPropertyBindingPartition); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 for (PropertyBindingList::iterator iter = property_bindings_.begin(); | 712 for (PropertyBindingList::iterator iter = property_bindings_.begin(); |
| 691 iter != property_bindings_.end(); | 713 iter != property_bindings_.end(); |
| 692 ++iter) { | 714 ++iter) { |
| 693 if ((*iter)->MatchesName(name)) | 715 if ((*iter)->MatchesName(name)) |
| 694 return (*iter)->GetProperty(this, result); | 716 return (*iter)->GetProperty(this, result); |
| 695 } | 717 } |
| 696 return false; | 718 return false; |
| 697 } | 719 } |
| 698 | 720 |
| 699 } // namespace content | 721 } // namespace content |
| OLD | NEW |