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

Side by Side Diff: extensions/renderer/api_binding.cc

Issue 2821793003: [Extensions Bindings] Apply per-context restrictions to events (Closed)
Patch Set: . Created 3 years, 8 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
« no previous file with comments | « no previous file | extensions/renderer/api_binding_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "extensions/renderer/api_binding.h" 5 #include "extensions/renderer/api_binding.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // TODO(devlin): enums should always be exposed, but there may be events that 304 // TODO(devlin): enums should always be exposed, but there may be events that
305 // are restricted. Investigate. 305 // are restricted. Investigate.
306 for (const auto& key_value : methods_) { 306 for (const auto& key_value : methods_) {
307 if (!is_available.Run(key_value.second->full_name)) { 307 if (!is_available.Run(key_value.second->full_name)) {
308 v8::Maybe<bool> success = object->Delete( 308 v8::Maybe<bool> success = object->Delete(
309 context, gin::StringToSymbol(isolate, key_value.first)); 309 context, gin::StringToSymbol(isolate, key_value.first));
310 CHECK(success.IsJust()); 310 CHECK(success.IsJust());
311 CHECK(success.FromJust()); 311 CHECK(success.FromJust());
312 } 312 }
313 } 313 }
314 for (const auto& event : events_) {
315 if (!is_available.Run(event->full_name)) {
316 v8::Maybe<bool> success = object->Delete(
317 context, gin::StringToSymbol(isolate, event->exposed_name));
318 CHECK(success.IsJust());
319 CHECK(success.FromJust());
320 }
321 }
314 322
315 return object; 323 return object;
316 } 324 }
317 325
318 void APIBinding::InitializeTemplate(v8::Isolate* isolate) { 326 void APIBinding::InitializeTemplate(v8::Isolate* isolate) {
319 DCHECK(object_template_.IsEmpty()); 327 DCHECK(object_template_.IsEmpty());
320 v8::Local<v8::ObjectTemplate> object_template = 328 v8::Local<v8::ObjectTemplate> object_template =
321 v8::ObjectTemplate::New(isolate); 329 v8::ObjectTemplate::New(isolate);
322 330
323 for (const auto& key_value : methods_) { 331 for (const auto& key_value : methods_) {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 arguments->ThrowTypeError("Invalid invocation"); 568 arguments->ThrowTypeError("Invalid invocation");
561 return; 569 return;
562 } 570 }
563 571
564 request_handler_->StartRequest(context, name, std::move(converted_arguments), 572 request_handler_->StartRequest(context, name, std::move(converted_arguments),
565 callback, custom_callback, 573 callback, custom_callback,
566 binding::RequestThread::UI); 574 binding::RequestThread::UI);
567 } 575 }
568 576
569 } // namespace extensions 577 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | extensions/renderer/api_binding_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698