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

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: Sync and reup patch for review. Created 8 years, 1 month 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 25 matching lines...) Expand all
36 namespace { 36 namespace {
37 37
38 // Method bindings. 38 // Method bindings.
39 const char kMethodBack[] = "back"; 39 const char kMethodBack[] = "back";
40 const char kMethodCanGoBack[] = "canGoBack"; 40 const char kMethodCanGoBack[] = "canGoBack";
41 const char kMethodCanGoForward[] = "canGoForward"; 41 const char kMethodCanGoForward[] = "canGoForward";
42 const char kMethodForward[] = "forward"; 42 const char kMethodForward[] = "forward";
43 const char kMethodGetProcessId[] = "getProcessId"; 43 const char kMethodGetProcessId[] = "getProcessId";
44 const char kMethodGo[] = "go"; 44 const char kMethodGo[] = "go";
45 const char kMethodReload[] = "reload"; 45 const char kMethodReload[] = "reload";
46 const char kMethodSetMediaPermission[] = "setMediaPermission";
46 const char kMethodStop[] = "stop"; 47 const char kMethodStop[] = "stop";
47 const char kMethodTerminate[] = "terminate"; 48 const char kMethodTerminate[] = "terminate";
48 49
49 // Attributes. 50 // Attributes.
50 const char kAttributeAutoSize[] = "autoSize"; 51 const char kAttributeAutoSize[] = "autoSize";
51 const char kAttributeContentWindow[] = "contentWindow"; 52 const char kAttributeContentWindow[] = "contentWindow";
52 const char kAttributeMaxHeight[] = "maxHeight"; 53 const char kAttributeMaxHeight[] = "maxHeight";
53 const char kAttributeMaxWidth[] = "maxWidth"; 54 const char kAttributeMaxWidth[] = "maxWidth";
54 const char kAttributeMinHeight[] = "minHeight"; 55 const char kAttributeMinHeight[] = "minHeight";
55 const char kAttributeMinWidth[] = "minWidth"; 56 const char kAttributeMinWidth[] = "minWidth";
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 const NPVariant* args, 362 const NPVariant* args,
362 NPVariant* result) OVERRIDE { 363 NPVariant* result) OVERRIDE {
363 bindings->instance()->Stop(); 364 bindings->instance()->Stop();
364 return true; 365 return true;
365 } 366 }
366 367
367 private: 368 private:
368 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingStop); 369 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingStop);
369 }; 370 };
370 371
372 class BrowserPluginBindingSetMediaPermission
373 : public BrowserPluginMethodBinding {
374 public:
375 BrowserPluginBindingSetMediaPermission()
376 : BrowserPluginMethodBinding(kMethodSetMediaPermission, 2) {
377 }
378
379 virtual bool Invoke(BrowserPluginBindings* bindings,
380 const NPVariant* args,
381 NPVariant* result) OVERRIDE {
382 int request_id = Int32FromNPVariant(args[0]);
383 bool allow = NPVARIANT_TO_BOOLEAN(args[1]);
384 bindings->instance()->RespondMediaAccess(request_id, allow);
385 return true;
386 }
387
388 private:
389 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingSetMediaPermission);
390 };
391
371 class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding { 392 class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding {
372 public: 393 public:
373 BrowserPluginBindingTerminate() 394 BrowserPluginBindingTerminate()
374 : BrowserPluginMethodBinding(kMethodTerminate, 0) { 395 : BrowserPluginMethodBinding(kMethodTerminate, 0) {
375 } 396 }
376 397
377 virtual bool Invoke(BrowserPluginBindings* bindings, 398 virtual bool Invoke(BrowserPluginBindings* bindings,
378 const NPVariant* args, 399 const NPVariant* args,
379 NPVariant* result) OVERRIDE { 400 NPVariant* result) OVERRIDE {
380 bindings->instance()->TerminateGuest(); 401 bindings->instance()->TerminateGuest();
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 658
638 method_bindings_.push_back(new BrowserPluginBindingBack); 659 method_bindings_.push_back(new BrowserPluginBindingBack);
639 method_bindings_.push_back(new BrowserPluginBindingCanGoBack); 660 method_bindings_.push_back(new BrowserPluginBindingCanGoBack);
640 method_bindings_.push_back(new BrowserPluginBindingCanGoForward); 661 method_bindings_.push_back(new BrowserPluginBindingCanGoForward);
641 method_bindings_.push_back(new BrowserPluginBindingForward); 662 method_bindings_.push_back(new BrowserPluginBindingForward);
642 method_bindings_.push_back(new BrowserPluginBindingGetProcessID); 663 method_bindings_.push_back(new BrowserPluginBindingGetProcessID);
643 method_bindings_.push_back(new BrowserPluginBindingGo); 664 method_bindings_.push_back(new BrowserPluginBindingGo);
644 method_bindings_.push_back(new BrowserPluginBindingReload); 665 method_bindings_.push_back(new BrowserPluginBindingReload);
645 method_bindings_.push_back(new BrowserPluginBindingStop); 666 method_bindings_.push_back(new BrowserPluginBindingStop);
646 method_bindings_.push_back(new BrowserPluginBindingTerminate); 667 method_bindings_.push_back(new BrowserPluginBindingTerminate);
668 method_bindings_.push_back(new BrowserPluginBindingSetMediaPermission);
647 669
648 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); 670 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize);
649 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); 671 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow);
650 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); 672 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight);
651 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); 673 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth);
652 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); 674 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight);
653 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); 675 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth);
654 property_bindings_.push_back(new BrowserPluginPropertyBindingPartition); 676 property_bindings_.push_back(new BrowserPluginPropertyBindingPartition);
655 property_bindings_.push_back(new BrowserPluginPropertyBindingSrc); 677 property_bindings_.push_back(new BrowserPluginPropertyBindingSrc);
656 } 678 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 for (PropertyBindingList::iterator iter = property_bindings_.begin(); 730 for (PropertyBindingList::iterator iter = property_bindings_.begin();
709 iter != property_bindings_.end(); 731 iter != property_bindings_.end();
710 ++iter) { 732 ++iter) {
711 if ((*iter)->MatchesName(name)) 733 if ((*iter)->MatchesName(name))
712 return (*iter)->GetProperty(this, name, result); 734 return (*iter)->GetProperty(this, name, result);
713 } 735 }
714 return false; 736 return false;
715 } 737 }
716 738
717 } // namespace content 739 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698