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

Side by Side Diff: src/isolate.cc

Issue 1410883006: Plumb accessing context through to access control callbacks (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/api.cc ('k') | src/objects.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project 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 "src/isolate.h" 5 #include "src/isolate.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <fstream> // NOLINT(readability/streams) 9 #include <fstream> // NOLINT(readability/streams)
10 #include <sstream> 10 #include <sstream>
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 if (receiver_context == native_context) return true; 805 if (receiver_context == native_context) return true;
806 806
807 if (Context::cast(receiver_context)->security_token() == 807 if (Context::cast(receiver_context)->security_token() ==
808 native_context->security_token()) 808 native_context->security_token())
809 return true; 809 return true;
810 } 810 }
811 } 811 }
812 812
813 HandleScope scope(this); 813 HandleScope scope(this);
814 Handle<Object> data; 814 Handle<Object> data;
815 v8::NamedSecurityCallback callback; 815 v8::AccessCheckCallback callback = nullptr;
816 v8::NamedSecurityCallback named_callback = nullptr;
816 { DisallowHeapAllocation no_gc; 817 { DisallowHeapAllocation no_gc;
817 AccessCheckInfo* access_check_info = GetAccessCheckInfo(this, receiver); 818 AccessCheckInfo* access_check_info = GetAccessCheckInfo(this, receiver);
818 if (!access_check_info) return false; 819 if (!access_check_info) return false;
819 Object* fun_obj = access_check_info->named_callback(); 820 Object* fun_obj = access_check_info->callback();
820 callback = v8::ToCData<v8::NamedSecurityCallback>(fun_obj); 821 callback = v8::ToCData<v8::AccessCheckCallback>(fun_obj);
821 if (!callback) return false; 822 if (!callback) {
822 data = handle(access_check_info->data(), this); 823 fun_obj = access_check_info->named_callback();
824 named_callback = v8::ToCData<v8::NamedSecurityCallback>(fun_obj);
825 if (!named_callback) return false;
826 data = handle(access_check_info->data(), this);
827 }
823 } 828 }
824 829
825 LOG(this, ApiSecurityCheck()); 830 LOG(this, ApiSecurityCheck());
826 831
827 { 832 {
828 SaveContext save(this);
829 set_context(accessing_context->native_context());
830
831 // Leaving JavaScript. 833 // Leaving JavaScript.
832 VMState<EXTERNAL> state(this); 834 VMState<EXTERNAL> state(this);
835 if (callback) {
836 return callback(v8::Utils::ToLocal(accessing_context),
837 v8::Utils::ToLocal(receiver));
838 }
833 Handle<Object> key = factory()->undefined_value(); 839 Handle<Object> key = factory()->undefined_value();
834 return callback(v8::Utils::ToLocal(receiver), v8::Utils::ToLocal(key), 840 return named_callback(v8::Utils::ToLocal(receiver), v8::Utils::ToLocal(key),
835 v8::ACCESS_HAS, v8::Utils::ToLocal(data)); 841 v8::ACCESS_HAS, v8::Utils::ToLocal(data));
836 } 842 }
837 } 843 }
838 844
839 845
840 const char* const Isolate::kStackOverflowMessage = 846 const char* const Isolate::kStackOverflowMessage =
841 "Uncaught RangeError: Maximum call stack size exceeded"; 847 "Uncaught RangeError: Maximum call stack size exceeded";
842 848
843 849
844 Object* Isolate::StackOverflow() { 850 Object* Isolate::StackOverflow() {
845 HandleScope scope(this); 851 HandleScope scope(this);
(...skipping 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after
2843 // Then check whether this scope intercepts. 2849 // Then check whether this scope intercepts.
2844 if ((flag & intercept_mask_)) { 2850 if ((flag & intercept_mask_)) {
2845 intercepted_flags_ |= flag; 2851 intercepted_flags_ |= flag;
2846 return true; 2852 return true;
2847 } 2853 }
2848 return false; 2854 return false;
2849 } 2855 }
2850 2856
2851 } // namespace internal 2857 } // namespace internal
2852 } // namespace v8 2858 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698