| 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" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "content/renderer/browser_plugin/browser_plugin.h" | 16 #include "content/renderer/browser_plugin/browser_plugin.h" |
| 17 #include "content/renderer/browser_plugin/browser_plugin_constants.h" | 17 #include "content/renderer/browser_plugin/browser_plugin_constants.h" |
| 18 #include "third_party/npapi/bindings/npapi.h" | |
| 19 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 18 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMMessageEvent.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMMessageEvent.h" | |
| 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
| 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
| 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
| 26 #include "third_party/npapi/bindings/npapi.h" |
| 27 #include "v8/include/v8.h" | 27 #include "v8/include/v8.h" |
| 28 | 28 |
| 29 using WebKit::WebBindings; | 29 using WebKit::WebBindings; |
| 30 using WebKit::WebElement; | 30 using WebKit::WebElement; |
| 31 using WebKit::WebDOMEvent; | 31 using WebKit::WebDOMEvent; |
| 32 using WebKit::WebDOMMessageEvent; | 32 using WebKit::WebDOMMessageEvent; |
| 33 using WebKit::WebPluginContainer; | 33 using WebKit::WebPluginContainer; |
| 34 using WebKit::WebString; | 34 using WebKit::WebString; |
| 35 | 35 |
| 36 namespace content { | 36 namespace content { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 const NPVariant* args, | 331 const NPVariant* args, |
| 332 NPVariant* result) OVERRIDE { | 332 NPVariant* result) OVERRIDE { |
| 333 bindings->instance()->Go(Int32FromNPVariant(args[0])); | 333 bindings->instance()->Go(Int32FromNPVariant(args[0])); |
| 334 return true; | 334 return true; |
| 335 } | 335 } |
| 336 | 336 |
| 337 private: | 337 private: |
| 338 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingGo); | 338 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingGo); |
| 339 }; | 339 }; |
| 340 | 340 |
| 341 // Note: This is a method that is used internally by the <webview> shim only. |
| 342 // This should not be exposed to developers. |
| 343 class BrowserPluginBindingPersistRequestObject |
| 344 : public BrowserPluginMethodBinding { |
| 345 public: |
| 346 BrowserPluginBindingPersistRequestObject() |
| 347 : BrowserPluginMethodBinding(browser_plugin::kMethodInternalPersistObject, |
| 348 3) { |
| 349 } |
| 350 |
| 351 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 352 const NPVariant* args, |
| 353 NPVariant* result) OVERRIDE { |
| 354 bindings->instance()->PersistRequestObject( |
| 355 &args[0], StringFromNPVariant(args[1]), Int32FromNPVariant(args[2])); |
| 356 return true; |
| 357 } |
| 358 |
| 359 private: |
| 360 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingPersistRequestObject); |
| 361 }; |
| 362 |
| 341 class BrowserPluginBindingReload : public BrowserPluginMethodBinding { | 363 class BrowserPluginBindingReload : public BrowserPluginMethodBinding { |
| 342 public: | 364 public: |
| 343 BrowserPluginBindingReload() | 365 BrowserPluginBindingReload() |
| 344 : BrowserPluginMethodBinding(browser_plugin::kMethodReload, 0) { | 366 : BrowserPluginMethodBinding(browser_plugin::kMethodReload, 0) { |
| 345 } | 367 } |
| 346 | 368 |
| 347 virtual bool Invoke(BrowserPluginBindings* bindings, | 369 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 348 const NPVariant* args, | 370 const NPVariant* args, |
| 349 NPVariant* result) OVERRIDE { | 371 NPVariant* result) OVERRIDE { |
| 350 bindings->instance()->Reload(); | 372 bindings->instance()->Reload(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 365 const NPVariant* args, | 387 const NPVariant* args, |
| 366 NPVariant* result) OVERRIDE { | 388 NPVariant* result) OVERRIDE { |
| 367 bindings->instance()->Stop(); | 389 bindings->instance()->Stop(); |
| 368 return true; | 390 return true; |
| 369 } | 391 } |
| 370 | 392 |
| 371 private: | 393 private: |
| 372 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingStop); | 394 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingStop); |
| 373 }; | 395 }; |
| 374 | 396 |
| 397 // Note: This is a method that is used internally by the <webview> shim only. |
| 398 // This should not be exposed to developers. |
| 399 class BrowserPluginBindingSetPermission : public BrowserPluginMethodBinding { |
| 400 public: |
| 401 BrowserPluginBindingSetPermission() |
| 402 : BrowserPluginMethodBinding( |
| 403 browser_plugin::kMethodInternalSetPermission, 2) { |
| 404 } |
| 405 |
| 406 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 407 const NPVariant* args, |
| 408 NPVariant* result) OVERRIDE { |
| 409 int request_id = Int32FromNPVariant(args[0]); |
| 410 bool allow = NPVARIANT_TO_BOOLEAN(args[1]); |
| 411 bindings->instance()->OnEmbedderDecidedPermission(request_id, allow); |
| 412 return true; |
| 413 } |
| 414 |
| 415 private: |
| 416 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingSetPermission); |
| 417 }; |
| 418 |
| 375 class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding { | 419 class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding { |
| 376 public: | 420 public: |
| 377 BrowserPluginBindingTerminate() | 421 BrowserPluginBindingTerminate() |
| 378 : BrowserPluginMethodBinding(browser_plugin::kMethodTerminate, 0) { | 422 : BrowserPluginMethodBinding(browser_plugin::kMethodTerminate, 0) { |
| 379 } | 423 } |
| 380 | 424 |
| 381 virtual bool Invoke(BrowserPluginBindings* bindings, | 425 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 382 const NPVariant* args, | 426 const NPVariant* args, |
| 383 NPVariant* result) OVERRIDE { | 427 NPVariant* result) OVERRIDE { |
| 384 bindings->instance()->TerminateGuest(); | 428 bindings->instance()->TerminateGuest(); |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); | 808 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); |
| 765 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); | 809 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); |
| 766 | 810 |
| 767 method_bindings_.push_back(new BrowserPluginBindingBack); | 811 method_bindings_.push_back(new BrowserPluginBindingBack); |
| 768 method_bindings_.push_back(new BrowserPluginBindingCanGoBack); | 812 method_bindings_.push_back(new BrowserPluginBindingCanGoBack); |
| 769 method_bindings_.push_back(new BrowserPluginBindingCanGoForward); | 813 method_bindings_.push_back(new BrowserPluginBindingCanGoForward); |
| 770 method_bindings_.push_back(new BrowserPluginBindingForward); | 814 method_bindings_.push_back(new BrowserPluginBindingForward); |
| 771 method_bindings_.push_back(new BrowserPluginBindingGetProcessID); | 815 method_bindings_.push_back(new BrowserPluginBindingGetProcessID); |
| 772 method_bindings_.push_back(new BrowserPluginBindingGetRouteID); | 816 method_bindings_.push_back(new BrowserPluginBindingGetRouteID); |
| 773 method_bindings_.push_back(new BrowserPluginBindingGo); | 817 method_bindings_.push_back(new BrowserPluginBindingGo); |
| 818 method_bindings_.push_back(new BrowserPluginBindingPersistRequestObject); |
| 774 method_bindings_.push_back(new BrowserPluginBindingReload); | 819 method_bindings_.push_back(new BrowserPluginBindingReload); |
| 820 method_bindings_.push_back(new BrowserPluginBindingSetPermission); |
| 775 method_bindings_.push_back(new BrowserPluginBindingStop); | 821 method_bindings_.push_back(new BrowserPluginBindingStop); |
| 776 method_bindings_.push_back(new BrowserPluginBindingTerminate); | 822 method_bindings_.push_back(new BrowserPluginBindingTerminate); |
| 777 | 823 |
| 778 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); | 824 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); |
| 779 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); | 825 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); |
| 780 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); | 826 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); |
| 781 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); | 827 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); |
| 782 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); | 828 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); |
| 783 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); | 829 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); |
| 784 property_bindings_.push_back(new BrowserPluginPropertyBindingName); | 830 property_bindings_.push_back(new BrowserPluginPropertyBindingName); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 for (PropertyBindingList::iterator iter = property_bindings_.begin(); | 902 for (PropertyBindingList::iterator iter = property_bindings_.begin(); |
| 857 iter != property_bindings_.end(); | 903 iter != property_bindings_.end(); |
| 858 ++iter) { | 904 ++iter) { |
| 859 if ((*iter)->MatchesName(name)) | 905 if ((*iter)->MatchesName(name)) |
| 860 return (*iter)->GetProperty(this, result); | 906 return (*iter)->GetProperty(this, result); |
| 861 } | 907 } |
| 862 return false; | 908 return false; |
| 863 } | 909 } |
| 864 | 910 |
| 865 } // namespace content | 911 } // namespace content |
| OLD | NEW |