| 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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 } | 503 } |
| 504 virtual void RemoveProperty(BrowserPluginBindings* bindings, | 504 virtual void RemoveProperty(BrowserPluginBindings* bindings, |
| 505 NPObject* np_obj) OVERRIDE { | 505 NPObject* np_obj) OVERRIDE { |
| 506 bindings->instance()->RemoveDOMAttribute(name()); | 506 bindings->instance()->RemoveDOMAttribute(name()); |
| 507 bindings->instance()->ParseSizeContraintsChanged(); | 507 bindings->instance()->ParseSizeContraintsChanged(); |
| 508 } | 508 } |
| 509 private: | 509 private: |
| 510 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMinWidth); | 510 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMinWidth); |
| 511 }; | 511 }; |
| 512 | 512 |
| 513 class BrowserPluginPropertyBindingName | |
| 514 : public BrowserPluginPropertyBinding { | |
| 515 public: | |
| 516 BrowserPluginPropertyBindingName() | |
| 517 : BrowserPluginPropertyBinding(browser_plugin::kAttributeName) { | |
| 518 } | |
| 519 virtual bool GetProperty(BrowserPluginBindings* bindings, | |
| 520 NPVariant* result) OVERRIDE { | |
| 521 std::string name = bindings->instance()->GetNameAttribute(); | |
| 522 return StringToNPVariant(name, result); | |
| 523 } | |
| 524 virtual bool SetProperty(BrowserPluginBindings* bindings, | |
| 525 NPObject* np_obj, | |
| 526 const NPVariant* variant) OVERRIDE { | |
| 527 std::string new_value = StringFromNPVariant(*variant); | |
| 528 if (bindings->instance()->GetNameAttribute() != new_value) { | |
| 529 UpdateDOMAttribute(bindings, new_value); | |
| 530 bindings->instance()->ParseNameAttribute(); | |
| 531 } | |
| 532 return true; | |
| 533 } | |
| 534 virtual void RemoveProperty(BrowserPluginBindings* bindings, | |
| 535 NPObject* np_obj) OVERRIDE { | |
| 536 bindings->instance()->RemoveDOMAttribute(name()); | |
| 537 bindings->instance()->ParseNameAttribute(); | |
| 538 } | |
| 539 private: | |
| 540 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingName); | |
| 541 }; | |
| 542 | |
| 543 class BrowserPluginPropertyBindingPartition | 513 class BrowserPluginPropertyBindingPartition |
| 544 : public BrowserPluginPropertyBinding { | 514 : public BrowserPluginPropertyBinding { |
| 545 public: | 515 public: |
| 546 BrowserPluginPropertyBindingPartition() | 516 BrowserPluginPropertyBindingPartition() |
| 547 : BrowserPluginPropertyBinding(browser_plugin::kAttributePartition) { | 517 : BrowserPluginPropertyBinding(browser_plugin::kAttributePartition) { |
| 548 } | 518 } |
| 549 virtual bool GetProperty(BrowserPluginBindings* bindings, | 519 virtual bool GetProperty(BrowserPluginBindings* bindings, |
| 550 NPVariant* result) OVERRIDE { | 520 NPVariant* result) OVERRIDE { |
| 551 std::string partition_id = bindings->instance()->GetPartitionAttribute(); | 521 std::string partition_id = bindings->instance()->GetPartitionAttribute(); |
| 552 return StringToNPVariant(partition_id, result); | 522 return StringToNPVariant(partition_id, result); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 method_bindings_.push_back(new BrowserPluginBindingAttach); | 623 method_bindings_.push_back(new BrowserPluginBindingAttach); |
| 654 | 624 |
| 655 property_bindings_.push_back( | 625 property_bindings_.push_back( |
| 656 new BrowserPluginPropertyBindingAllowTransparency); | 626 new BrowserPluginPropertyBindingAllowTransparency); |
| 657 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); | 627 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); |
| 658 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); | 628 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); |
| 659 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); | 629 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); |
| 660 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); | 630 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); |
| 661 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); | 631 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); |
| 662 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); | 632 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); |
| 663 property_bindings_.push_back(new BrowserPluginPropertyBindingName); | |
| 664 property_bindings_.push_back(new BrowserPluginPropertyBindingPartition); | 633 property_bindings_.push_back(new BrowserPluginPropertyBindingPartition); |
| 665 property_bindings_.push_back(new BrowserPluginPropertyBindingSrc); | 634 property_bindings_.push_back(new BrowserPluginPropertyBindingSrc); |
| 666 } | 635 } |
| 667 | 636 |
| 668 BrowserPluginBindings::~BrowserPluginBindings() { | 637 BrowserPluginBindings::~BrowserPluginBindings() { |
| 669 WebBindings::releaseObject(np_object_); | 638 WebBindings::releaseObject(np_object_); |
| 670 } | 639 } |
| 671 | 640 |
| 672 bool BrowserPluginBindings::HasMethod(NPIdentifier name) const { | 641 bool BrowserPluginBindings::HasMethod(NPIdentifier name) const { |
| 673 for (BindingList::const_iterator iter = method_bindings_.begin(); | 642 for (BindingList::const_iterator iter = method_bindings_.begin(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 for (PropertyBindingList::iterator iter = property_bindings_.begin(); | 704 for (PropertyBindingList::iterator iter = property_bindings_.begin(); |
| 736 iter != property_bindings_.end(); | 705 iter != property_bindings_.end(); |
| 737 ++iter) { | 706 ++iter) { |
| 738 if ((*iter)->MatchesName(name)) | 707 if ((*iter)->MatchesName(name)) |
| 739 return (*iter)->GetProperty(this, result); | 708 return (*iter)->GetProperty(this, result); |
| 740 } | 709 } |
| 741 return false; | 710 return false; |
| 742 } | 711 } |
| 743 | 712 |
| 744 } // namespace content | 713 } // namespace content |
| OLD | NEW |