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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 void UpdateDOMAttribute(BrowserPluginBindings* bindings, | 305 void UpdateDOMAttribute(BrowserPluginBindings* bindings, |
306 std::string new_value) { | 306 std::string new_value) { |
307 bindings->instance()->UpdateDOMAttribute(name(), new_value); | 307 bindings->instance()->UpdateDOMAttribute(name(), new_value); |
308 } | 308 } |
309 private: | 309 private: |
310 std::string name_; | 310 std::string name_; |
311 | 311 |
312 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBinding); | 312 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBinding); |
313 }; | 313 }; |
314 | 314 |
| 315 class BrowserPluginPropertyBindingAllowTransparency |
| 316 : public BrowserPluginPropertyBinding { |
| 317 public: |
| 318 BrowserPluginPropertyBindingAllowTransparency() |
| 319 : BrowserPluginPropertyBinding( |
| 320 browser_plugin::kAttributeAllowTransparency) { |
| 321 } |
| 322 virtual bool GetProperty(BrowserPluginBindings* bindings, |
| 323 NPVariant* result) OVERRIDE { |
| 324 bool allow_transparency = |
| 325 bindings->instance()->GetAllowTransparencyAttribute(); |
| 326 BOOLEAN_TO_NPVARIANT(allow_transparency, *result); |
| 327 return true; |
| 328 } |
| 329 virtual bool SetProperty(BrowserPluginBindings* bindings, |
| 330 NPObject* np_obj, |
| 331 const NPVariant* variant) OVERRIDE { |
| 332 std::string value = StringFromNPVariant(*variant); |
| 333 if (!bindings->instance()->HasDOMAttribute(name())) { |
| 334 UpdateDOMAttribute(bindings, value); |
| 335 bindings->instance()->ParseAllowTransparencyAttribute(); |
| 336 } else { |
| 337 UpdateDOMAttribute(bindings, value); |
| 338 } |
| 339 return true; |
| 340 } |
| 341 virtual void RemoveProperty(BrowserPluginBindings* bindings, |
| 342 NPObject* np_obj) OVERRIDE { |
| 343 bindings->instance()->RemoveDOMAttribute(name()); |
| 344 bindings->instance()->ParseAllowTransparencyAttribute(); |
| 345 } |
| 346 private: |
| 347 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingAllowTransparency); |
| 348 }; |
| 349 |
315 class BrowserPluginPropertyBindingAutoSize | 350 class BrowserPluginPropertyBindingAutoSize |
316 : public BrowserPluginPropertyBinding { | 351 : public BrowserPluginPropertyBinding { |
317 public: | 352 public: |
318 BrowserPluginPropertyBindingAutoSize() | 353 BrowserPluginPropertyBindingAutoSize() |
319 : BrowserPluginPropertyBinding(browser_plugin::kAttributeAutoSize) { | 354 : BrowserPluginPropertyBinding(browser_plugin::kAttributeAutoSize) { |
320 } | 355 } |
321 virtual bool GetProperty(BrowserPluginBindings* bindings, | 356 virtual bool GetProperty(BrowserPluginBindings* bindings, |
322 NPVariant* result) OVERRIDE { | 357 NPVariant* result) OVERRIDE { |
323 bool auto_size = bindings->instance()->GetAutoSizeAttribute(); | 358 bool auto_size = bindings->instance()->GetAutoSizeAttribute(); |
324 BOOLEAN_TO_NPVARIANT(auto_size, *result); | 359 BOOLEAN_TO_NPVARIANT(auto_size, *result); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 weak_ptr_factory_(this) { | 666 weak_ptr_factory_(this) { |
632 NPObject* obj = | 667 NPObject* obj = |
633 WebBindings::createObject(instance->pluginNPP(), | 668 WebBindings::createObject(instance->pluginNPP(), |
634 &browser_plugin_message_class); | 669 &browser_plugin_message_class); |
635 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); | 670 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); |
636 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); | 671 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); |
637 | 672 |
638 method_bindings_.push_back(new BrowserPluginBindingAttach); | 673 method_bindings_.push_back(new BrowserPluginBindingAttach); |
639 method_bindings_.push_back(new BrowserPluginBindingAttachWindowTo); | 674 method_bindings_.push_back(new BrowserPluginBindingAttachWindowTo); |
640 | 675 |
| 676 property_bindings_.push_back( |
| 677 new BrowserPluginPropertyBindingAllowTransparency); |
641 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); | 678 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); |
642 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); | 679 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); |
643 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); | 680 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); |
644 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); | 681 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); |
645 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); | 682 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); |
646 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); | 683 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); |
647 property_bindings_.push_back(new BrowserPluginPropertyBindingName); | 684 property_bindings_.push_back(new BrowserPluginPropertyBindingName); |
648 property_bindings_.push_back(new BrowserPluginPropertyBindingPartition); | 685 property_bindings_.push_back(new BrowserPluginPropertyBindingPartition); |
649 property_bindings_.push_back(new BrowserPluginPropertyBindingSrc); | 686 property_bindings_.push_back(new BrowserPluginPropertyBindingSrc); |
650 } | 687 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 for (PropertyBindingList::iterator iter = property_bindings_.begin(); | 756 for (PropertyBindingList::iterator iter = property_bindings_.begin(); |
720 iter != property_bindings_.end(); | 757 iter != property_bindings_.end(); |
721 ++iter) { | 758 ++iter) { |
722 if ((*iter)->MatchesName(name)) | 759 if ((*iter)->MatchesName(name)) |
723 return (*iter)->GetProperty(this, result); | 760 return (*iter)->GetProperty(this, result); |
724 } | 761 } |
725 return false; | 762 return false; |
726 } | 763 } |
727 | 764 |
728 } // namespace content | 765 } // namespace content |
OLD | NEW |