| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 const char kForwardMethod[] = "forward"; | 44 const char kForwardMethod[] = "forward"; |
| 45 const char kGetProcessId[] = "getProcessId"; | 45 const char kGetProcessId[] = "getProcessId"; |
| 46 const char kGoMethod[] = "go"; | 46 const char kGoMethod[] = "go"; |
| 47 const char kMaxHeightAttribute[] = "maxHeight"; | 47 const char kMaxHeightAttribute[] = "maxHeight"; |
| 48 const char kMaxWidthAttribute[] = "maxWidth"; | 48 const char kMaxWidthAttribute[] = "maxWidth"; |
| 49 const char kMinHeightAttribute[] = "minHeight"; | 49 const char kMinHeightAttribute[] = "minHeight"; |
| 50 const char kMinWidthAttribute[] = "minWidth"; | 50 const char kMinWidthAttribute[] = "minWidth"; |
| 51 const char kPartitionAttribute[] = "partition"; | 51 const char kPartitionAttribute[] = "partition"; |
| 52 const char kReloadMethod[] = "reload"; | 52 const char kReloadMethod[] = "reload"; |
| 53 const char kRemoveEventListener[] = "removeEventListener"; | 53 const char kRemoveEventListener[] = "removeEventListener"; |
| 54 const char kSetMediaPermissionMethod[] = "setMediaPermission"; |
| 54 const char kSrcAttribute[] = "src"; | 55 const char kSrcAttribute[] = "src"; |
| 55 const char kStopMethod[] = "stop"; | 56 const char kStopMethod[] = "stop"; |
| 56 const char kTerminateMethod[] = "terminate"; | 57 const char kTerminateMethod[] = "terminate"; |
| 57 | 58 |
| 58 BrowserPluginBindings* GetBindings(NPObject* object) { | 59 BrowserPluginBindings* GetBindings(NPObject* object) { |
| 59 return static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(object)-> | 60 return static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(object)-> |
| 60 message_channel; | 61 message_channel; |
| 61 } | 62 } |
| 62 | 63 |
| 63 bool IdentifierIsContentWindow(NPIdentifier identifier) { | 64 bool IdentifierIsContentWindow(NPIdentifier identifier) { |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 const NPVariant* args, | 490 const NPVariant* args, |
| 490 NPVariant* result) OVERRIDE { | 491 NPVariant* result) OVERRIDE { |
| 491 bindings->instance()->Stop(); | 492 bindings->instance()->Stop(); |
| 492 return true; | 493 return true; |
| 493 } | 494 } |
| 494 | 495 |
| 495 private: | 496 private: |
| 496 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingStop); | 497 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingStop); |
| 497 }; | 498 }; |
| 498 | 499 |
| 500 class BrowserPluginBindingSetMediaPermission |
| 501 : public BrowserPluginMethodBinding { |
| 502 public: |
| 503 BrowserPluginBindingSetMediaPermission() |
| 504 : BrowserPluginMethodBinding(kSetMediaPermissionMethod, 2) { |
| 505 } |
| 506 |
| 507 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 508 const NPVariant* args, |
| 509 NPVariant* result) OVERRIDE { |
| 510 int request_id = Int32FromNPVariant(args[0]); |
| 511 bool allow = NPVARIANT_TO_BOOLEAN(args[1]); |
| 512 bindings->instance()->AllowMediaAccess(request_id, allow); |
| 513 return true; |
| 514 } |
| 515 |
| 516 private: |
| 517 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingSetMediaPermission); |
| 518 }; |
| 519 |
| 499 class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding { | 520 class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding { |
| 500 public: | 521 public: |
| 501 BrowserPluginBindingTerminate() | 522 BrowserPluginBindingTerminate() |
| 502 : BrowserPluginMethodBinding(kTerminateMethod, 0) { | 523 : BrowserPluginMethodBinding(kTerminateMethod, 0) { |
| 503 } | 524 } |
| 504 | 525 |
| 505 virtual bool Invoke(BrowserPluginBindings* bindings, | 526 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 506 const NPVariant* args, | 527 const NPVariant* args, |
| 507 NPVariant* result) OVERRIDE { | 528 NPVariant* result) OVERRIDE { |
| 508 bindings->instance()->TerminateGuest(); | 529 bindings->instance()->TerminateGuest(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 532 | 553 |
| 533 method_bindings_.push_back(new BrowserPluginBindingBack); | 554 method_bindings_.push_back(new BrowserPluginBindingBack); |
| 534 method_bindings_.push_back(new BrowserPluginBindingCanGoBack); | 555 method_bindings_.push_back(new BrowserPluginBindingCanGoBack); |
| 535 method_bindings_.push_back(new BrowserPluginBindingCanGoForward); | 556 method_bindings_.push_back(new BrowserPluginBindingCanGoForward); |
| 536 method_bindings_.push_back(new BrowserPluginBindingForward); | 557 method_bindings_.push_back(new BrowserPluginBindingForward); |
| 537 method_bindings_.push_back(new BrowserPluginBindingGetProcessID); | 558 method_bindings_.push_back(new BrowserPluginBindingGetProcessID); |
| 538 method_bindings_.push_back(new BrowserPluginBindingGo); | 559 method_bindings_.push_back(new BrowserPluginBindingGo); |
| 539 method_bindings_.push_back(new BrowserPluginBindingReload); | 560 method_bindings_.push_back(new BrowserPluginBindingReload); |
| 540 method_bindings_.push_back(new BrowserPluginBindingStop); | 561 method_bindings_.push_back(new BrowserPluginBindingStop); |
| 541 method_bindings_.push_back(new BrowserPluginBindingTerminate); | 562 method_bindings_.push_back(new BrowserPluginBindingTerminate); |
| 563 method_bindings_.push_back(new BrowserPluginBindingSetMediaPermission); |
| 542 } | 564 } |
| 543 | 565 |
| 544 BrowserPluginBindings::~BrowserPluginBindings() { | 566 BrowserPluginBindings::~BrowserPluginBindings() { |
| 545 WebBindings::releaseObject(np_object_); | 567 WebBindings::releaseObject(np_object_); |
| 546 } | 568 } |
| 547 | 569 |
| 548 bool BrowserPluginBindings::HasMethod(NPIdentifier name) const { | 570 bool BrowserPluginBindings::HasMethod(NPIdentifier name) const { |
| 549 for (BindingList::const_iterator iter = method_bindings_.begin(); | 571 for (BindingList::const_iterator iter = method_bindings_.begin(); |
| 550 iter != method_bindings_.end(); | 572 iter != method_bindings_.end(); |
| 551 ++iter) { | 573 ++iter) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 562 for (BindingList::iterator iter = method_bindings_.begin(); | 584 for (BindingList::iterator iter = method_bindings_.begin(); |
| 563 iter != method_bindings_.end(); | 585 iter != method_bindings_.end(); |
| 564 ++iter) { | 586 ++iter) { |
| 565 if ((*iter)->MatchesName(name) && (*iter)->arg_count() == arg_count) | 587 if ((*iter)->MatchesName(name) && (*iter)->arg_count() == arg_count) |
| 566 return (*iter)->Invoke(this, args, result); | 588 return (*iter)->Invoke(this, args, result); |
| 567 } | 589 } |
| 568 return false; | 590 return false; |
| 569 } | 591 } |
| 570 | 592 |
| 571 } // namespace content | 593 } // namespace content |
| OLD | NEW |