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

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

Issue 21297005: <webview>: Refactor Permission API to chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_permissions
Patch Set: Fixed some bugs Created 7 years, 4 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
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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 const NPVariant* args, 340 const NPVariant* args,
341 NPVariant* result) OVERRIDE { 341 NPVariant* result) OVERRIDE {
342 bindings->instance()->TrackObjectLifetime(args, IntFromNPVariant(args[1])); 342 bindings->instance()->TrackObjectLifetime(args, IntFromNPVariant(args[1]));
343 return true; 343 return true;
344 } 344 }
345 345
346 private: 346 private:
347 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingTrackObjectLifetime); 347 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingTrackObjectLifetime);
348 }; 348 };
349 349
350 // Note: This is a method that is used internally by the <webview> shim only.
351 // This should not be exposed to developers.
352 class BrowserPluginBindingSetPermission : public BrowserPluginMethodBinding {
353 public:
354 BrowserPluginBindingSetPermission()
355 : BrowserPluginMethodBinding(
356 browser_plugin::kMethodInternalSetPermission, 3) {
357 }
358
359 virtual bool Invoke(BrowserPluginBindings* bindings,
360 const NPVariant* args,
361 NPVariant* result) OVERRIDE {
362 int request_id = IntFromNPVariant(args[0]);
363 bool allow = NPVARIANT_TO_BOOLEAN(args[1]);
364 std::string user_input = StringFromNPVariant(args[2]);
365 bool request_was_pending =
366 bindings->instance()->RespondPermissionIfRequestIsPending(
367 request_id, allow, user_input);
368 BOOLEAN_TO_NPVARIANT(request_was_pending, *result);
369 return true;
370 }
371
372 private:
373 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingSetPermission);
374 };
375
376 // BrowserPluginPropertyBinding ------------------------------------------------ 350 // BrowserPluginPropertyBinding ------------------------------------------------
377 351
378 class BrowserPluginPropertyBinding { 352 class BrowserPluginPropertyBinding {
379 public: 353 public:
380 explicit BrowserPluginPropertyBinding(const char name[]) : name_(name) {} 354 explicit BrowserPluginPropertyBinding(const char name[]) : name_(name) {}
381 virtual ~BrowserPluginPropertyBinding() {} 355 virtual ~BrowserPluginPropertyBinding() {}
382 const std::string& name() const { return name_; } 356 const std::string& name() const { return name_; }
383 bool MatchesName(NPIdentifier name) const { 357 bool MatchesName(NPIdentifier name) const {
384 return WebBindings::getStringIdentifier(name_.c_str()) == name; 358 return WebBindings::getStringIdentifier(name_.c_str()) == name;
385 } 359 }
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 NPObject* obj = 700 NPObject* obj =
727 WebBindings::createObject(instance->pluginNPP(), 701 WebBindings::createObject(instance->pluginNPP(),
728 &browser_plugin_message_class); 702 &browser_plugin_message_class);
729 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); 703 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj);
730 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); 704 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr();
731 705
732 method_bindings_.push_back(new BrowserPluginBindingAttach); 706 method_bindings_.push_back(new BrowserPluginBindingAttach);
733 method_bindings_.push_back(new BrowserPluginBindingAttachWindowTo); 707 method_bindings_.push_back(new BrowserPluginBindingAttachWindowTo);
734 method_bindings_.push_back(new BrowserPluginBindingGetInstanceID); 708 method_bindings_.push_back(new BrowserPluginBindingGetInstanceID);
735 method_bindings_.push_back(new BrowserPluginBindingGetGuestInstanceID); 709 method_bindings_.push_back(new BrowserPluginBindingGetGuestInstanceID);
736 method_bindings_.push_back(new BrowserPluginBindingSetPermission);
737 method_bindings_.push_back(new BrowserPluginBindingTrackObjectLifetime); 710 method_bindings_.push_back(new BrowserPluginBindingTrackObjectLifetime);
738 711
739 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); 712 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize);
740 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); 713 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow);
741 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); 714 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight);
742 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); 715 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth);
743 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); 716 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight);
744 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); 717 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth);
745 property_bindings_.push_back(new BrowserPluginPropertyBindingName); 718 property_bindings_.push_back(new BrowserPluginPropertyBindingName);
746 property_bindings_.push_back(new BrowserPluginPropertyBindingPartition); 719 property_bindings_.push_back(new BrowserPluginPropertyBindingPartition);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 for (PropertyBindingList::iterator iter = property_bindings_.begin(); 790 for (PropertyBindingList::iterator iter = property_bindings_.begin();
818 iter != property_bindings_.end(); 791 iter != property_bindings_.end();
819 ++iter) { 792 ++iter) {
820 if ((*iter)->MatchesName(name)) 793 if ((*iter)->MatchesName(name))
821 return (*iter)->GetProperty(this, result); 794 return (*iter)->GetProperty(this, result);
822 } 795 }
823 return false; 796 return false;
824 } 797 }
825 798
826 } // namespace content 799 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698