Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: content/renderer/browser_plugin/browser_plugin_bindings.cc

Issue 11093080: <webview>: First stab at implementing media permission request for guests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Plugin can be destroyed before we get Weak Callback, fixed. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 2) {
349 }
350
351 virtual bool Invoke(BrowserPluginBindings* bindings,
352 const NPVariant* args,
353 NPVariant* result) OVERRIDE {
354 bindings->instance()->PersistRequestObject(
355 &args[0], Int32FromNPVariant(args[1]));
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
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, 3) {
404 }
405
406 virtual bool Invoke(BrowserPluginBindings* bindings,
407 const NPVariant* args,
Charlie Reis 2013/02/11 22:20:56 What kind of protections do we have in place to en
lazyboy 2013/02/12 05:03:45 BrowserPluginBindings::InvokeMethod checks for cor
408 NPVariant* result) OVERRIDE {
409 std::string type = StringFromNPVariant(args[0]);
410 int request_id = Int32FromNPVariant(args[1]);
411 bool allow = NPVARIANT_TO_BOOLEAN(args[2]);
412 if (type == "media")
413 bindings->instance()->OnListenerCallMediaAccess(request_id, allow);
414 return true;
415 }
416
417 private:
418 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingSetPermission);
419 };
420
375 class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding { 421 class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding {
376 public: 422 public:
377 BrowserPluginBindingTerminate() 423 BrowserPluginBindingTerminate()
378 : BrowserPluginMethodBinding(browser_plugin::kMethodTerminate, 0) { 424 : BrowserPluginMethodBinding(browser_plugin::kMethodTerminate, 0) {
379 } 425 }
380 426
381 virtual bool Invoke(BrowserPluginBindings* bindings, 427 virtual bool Invoke(BrowserPluginBindings* bindings,
382 const NPVariant* args, 428 const NPVariant* args,
383 NPVariant* result) OVERRIDE { 429 NPVariant* result) OVERRIDE {
384 bindings->instance()->TerminateGuest(); 430 bindings->instance()->TerminateGuest();
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); 794 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj);
749 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); 795 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr();
750 796
751 method_bindings_.push_back(new BrowserPluginBindingBack); 797 method_bindings_.push_back(new BrowserPluginBindingBack);
752 method_bindings_.push_back(new BrowserPluginBindingCanGoBack); 798 method_bindings_.push_back(new BrowserPluginBindingCanGoBack);
753 method_bindings_.push_back(new BrowserPluginBindingCanGoForward); 799 method_bindings_.push_back(new BrowserPluginBindingCanGoForward);
754 method_bindings_.push_back(new BrowserPluginBindingForward); 800 method_bindings_.push_back(new BrowserPluginBindingForward);
755 method_bindings_.push_back(new BrowserPluginBindingGetProcessID); 801 method_bindings_.push_back(new BrowserPluginBindingGetProcessID);
756 method_bindings_.push_back(new BrowserPluginBindingGetRouteID); 802 method_bindings_.push_back(new BrowserPluginBindingGetRouteID);
757 method_bindings_.push_back(new BrowserPluginBindingGo); 803 method_bindings_.push_back(new BrowserPluginBindingGo);
804 method_bindings_.push_back(new BrowserPluginBindingPersistRequestObject);
758 method_bindings_.push_back(new BrowserPluginBindingReload); 805 method_bindings_.push_back(new BrowserPluginBindingReload);
806 method_bindings_.push_back(new BrowserPluginBindingSetPermission);
759 method_bindings_.push_back(new BrowserPluginBindingStop); 807 method_bindings_.push_back(new BrowserPluginBindingStop);
760 method_bindings_.push_back(new BrowserPluginBindingTerminate); 808 method_bindings_.push_back(new BrowserPluginBindingTerminate);
761 809
762 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); 810 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize);
763 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); 811 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow);
764 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); 812 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight);
765 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); 813 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth);
766 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); 814 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight);
767 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); 815 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth);
768 property_bindings_.push_back(new BrowserPluginPropertyBindingName); 816 property_bindings_.push_back(new BrowserPluginPropertyBindingName);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 for (PropertyBindingList::iterator iter = property_bindings_.begin(); 888 for (PropertyBindingList::iterator iter = property_bindings_.begin();
841 iter != property_bindings_.end(); 889 iter != property_bindings_.end();
842 ++iter) { 890 ++iter) {
843 if ((*iter)->MatchesName(name)) 891 if ((*iter)->MatchesName(name))
844 return (*iter)->GetProperty(this, result); 892 return (*iter)->GetProperty(this, result);
845 } 893 }
846 return false; 894 return false;
847 } 895 }
848 896
849 } // namespace content 897 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698