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

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: Addressed jam@'s comments 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 const NPVariant* args, 320 const NPVariant* args,
321 NPVariant* result) OVERRIDE { 321 NPVariant* result) OVERRIDE {
322 bindings->instance()->TrackObjectLifetime(args, IntFromNPVariant(args[1])); 322 bindings->instance()->TrackObjectLifetime(args, IntFromNPVariant(args[1]));
323 return true; 323 return true;
324 } 324 }
325 325
326 private: 326 private:
327 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingTrackObjectLifetime); 327 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingTrackObjectLifetime);
328 }; 328 };
329 329
330 // Note: This is a method that is used internally by the <webview> shim only.
331 // This should not be exposed to developers.
332 class BrowserPluginBindingSetPermission : public BrowserPluginMethodBinding {
333 public:
334 BrowserPluginBindingSetPermission()
335 : BrowserPluginMethodBinding(
336 browser_plugin::kMethodInternalSetPermission, 3) {
337 }
338
339 virtual bool Invoke(BrowserPluginBindings* bindings,
340 const NPVariant* args,
341 NPVariant* result) OVERRIDE {
342 int request_id = IntFromNPVariant(args[0]);
343 bool allow = NPVARIANT_TO_BOOLEAN(args[1]);
344 std::string user_input = StringFromNPVariant(args[2]);
345 bool request_was_pending =
346 bindings->instance()->RespondPermissionIfRequestIsPending(
347 request_id, allow, user_input);
348 BOOLEAN_TO_NPVARIANT(request_was_pending, *result);
349 return true;
350 }
351
352 private:
353 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingSetPermission);
354 };
355
356 // BrowserPluginPropertyBinding ------------------------------------------------ 330 // BrowserPluginPropertyBinding ------------------------------------------------
357 331
358 class BrowserPluginPropertyBinding { 332 class BrowserPluginPropertyBinding {
359 public: 333 public:
360 explicit BrowserPluginPropertyBinding(const char name[]) : name_(name) {} 334 explicit BrowserPluginPropertyBinding(const char name[]) : name_(name) {}
361 virtual ~BrowserPluginPropertyBinding() {} 335 virtual ~BrowserPluginPropertyBinding() {}
362 const std::string& name() const { return name_; } 336 const std::string& name() const { return name_; }
363 bool MatchesName(NPIdentifier name) const { 337 bool MatchesName(NPIdentifier name) const {
364 return WebBindings::getStringIdentifier(name_.c_str()) == name; 338 return WebBindings::getStringIdentifier(name_.c_str()) == name;
365 } 339 }
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 weak_ptr_factory_(this) { 679 weak_ptr_factory_(this) {
706 NPObject* obj = 680 NPObject* obj =
707 WebBindings::createObject(instance->pluginNPP(), 681 WebBindings::createObject(instance->pluginNPP(),
708 &browser_plugin_message_class); 682 &browser_plugin_message_class);
709 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj); 683 np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj);
710 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr(); 684 np_object_->message_channel = weak_ptr_factory_.GetWeakPtr();
711 685
712 method_bindings_.push_back(new BrowserPluginBindingAttach); 686 method_bindings_.push_back(new BrowserPluginBindingAttach);
713 method_bindings_.push_back(new BrowserPluginBindingAttachWindowTo); 687 method_bindings_.push_back(new BrowserPluginBindingAttachWindowTo);
714 method_bindings_.push_back(new BrowserPluginBindingGetGuestInstanceID); 688 method_bindings_.push_back(new BrowserPluginBindingGetGuestInstanceID);
715 method_bindings_.push_back(new BrowserPluginBindingSetPermission);
716 method_bindings_.push_back(new BrowserPluginBindingTrackObjectLifetime); 689 method_bindings_.push_back(new BrowserPluginBindingTrackObjectLifetime);
717 690
718 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize); 691 property_bindings_.push_back(new BrowserPluginPropertyBindingAutoSize);
719 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow); 692 property_bindings_.push_back(new BrowserPluginPropertyBindingContentWindow);
720 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight); 693 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxHeight);
721 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); 694 property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth);
722 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); 695 property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight);
723 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); 696 property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth);
724 property_bindings_.push_back(new BrowserPluginPropertyBindingName); 697 property_bindings_.push_back(new BrowserPluginPropertyBindingName);
725 property_bindings_.push_back(new BrowserPluginPropertyBindingPartition); 698 property_bindings_.push_back(new BrowserPluginPropertyBindingPartition);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 for (PropertyBindingList::iterator iter = property_bindings_.begin(); 769 for (PropertyBindingList::iterator iter = property_bindings_.begin();
797 iter != property_bindings_.end(); 770 iter != property_bindings_.end();
798 ++iter) { 771 ++iter) {
799 if ((*iter)->MatchesName(name)) 772 if ((*iter)->MatchesName(name))
800 return (*iter)->GetProperty(this, result); 773 return (*iter)->GetProperty(this, result);
801 } 774 }
802 return false; 775 return false;
803 } 776 }
804 777
805 } // namespace content 778 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698