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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/BindingSecurity.cpp

Issue 2058133002: Fix DevTools support of worklets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comments Created 4 years, 5 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 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, const LocalDOMWi ndow* accessingWindow, const Location* target, SecurityReportingOption reporting Option) 125 bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, const LocalDOMWi ndow* accessingWindow, const Location* target, SecurityReportingOption reporting Option)
126 { 126 {
127 ASSERT(target); 127 ASSERT(target);
128 const Frame* frame = target->frame(); 128 const Frame* frame = target->frame();
129 if (!frame || !frame->securityContext()) 129 if (!frame || !frame->securityContext())
130 return false; 130 return false;
131 return canAccessFrame(isolate, accessingWindow, frame->securityContext()->ge tSecurityOrigin(), frame->domWindow(), reportingOption); 131 return canAccessFrame(isolate, accessingWindow, frame->securityContext()->ge tSecurityOrigin(), frame->domWindow(), reportingOption);
132 } 132 }
133 133
134 bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, const LocalDOMWi ndow* accessingWindow, const MainThreadWorkletGlobalScope* target, SecurityRepor tingOption reportingOption) 134 bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, v8::Local<v8::Co ntext> context, const ExecutionContext* executionContext, const MainThreadWorkle tGlobalScope* workletGlobalScope, SecurityReportingOption reportingOption)
135 { 135 {
136 ASSERT(target); 136 DCHECK(executionContext);
137 const Frame* frame = target->frame(); 137 DOMWindow* domWindow = toDOMWindow(context);
138 if (!frame || !frame->securityContext()) 138 if (executionContext->isMainThreadWorkletGlobalScope()) {
139 Frame* callingFrame = toMainThreadWorkletGlobalScope(executionContext)-> frame();
140 domWindow = callingFrame ? callingFrame->domWindow() : nullptr;
141 }
142
143 DCHECK(workletGlobalScope);
144 const Frame* workletGlobalScopeFrame = workletGlobalScope->frame();
145 if (!workletGlobalScopeFrame || !workletGlobalScopeFrame->securityContext())
139 return false; 146 return false;
140 return canAccessFrame(isolate, accessingWindow, frame->securityContext()->ge tSecurityOrigin(), frame->domWindow(), reportingOption); 147
148 return domWindow && canAccessFrame(isolate, toLocalDOMWindow(domWindow), wor kletGlobalScopeFrame->securityContext()->getSecurityOrigin(), workletGlobalScope Frame->domWindow(), reportingOption);
149 }
150
151 bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, v8::Local<v8::Co ntext> calling, v8::Local<v8::Context> target, SecurityReportingOption reporting Option)
152 {
153 ExecutionContext* targetExecutionContext = toExecutionContext(target);
154 DCHECK(targetExecutionContext);
155
156 ExecutionContext* callingExecutionContext = toExecutionContext(calling);
157 DCHECK(callingExecutionContext);
158
159 if (targetExecutionContext->isMainThreadWorkletGlobalScope())
160 return shouldAllowAccessTo(isolate, calling, callingExecutionContext, to MainThreadWorkletGlobalScope(targetExecutionContext), DoNotReportSecurityError);
161
162 if (callingExecutionContext->isMainThreadWorkletGlobalScope())
163 return shouldAllowAccessTo(isolate, target, targetExecutionContext, toMa inThreadWorkletGlobalScope(callingExecutionContext), DoNotReportSecurityError);
164
165 DOMWindow* window = toDOMWindow(target);
166 return window && shouldAllowAccessTo(isolate, toLocalDOMWindow(toDOMWindow(c alling)), window, DoNotReportSecurityError);
141 } 167 }
142 168
143 bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, const LocalDOMWi ndow* accessingWindow, const Node* target, ExceptionState& exceptionState) 169 bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, const LocalDOMWi ndow* accessingWindow, const Node* target, ExceptionState& exceptionState)
144 { 170 {
145 if (!target) 171 if (!target)
146 return false; 172 return false;
147 return canAccessFrame(isolate, accessingWindow, target->document().getSecuri tyOrigin(), target->document().domWindow(), exceptionState); 173 return canAccessFrame(isolate, accessingWindow, target->document().getSecuri tyOrigin(), target->document().domWindow(), exceptionState);
148 } 174 }
149 175
150 bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, const LocalDOMWi ndow* accessingWindow, const Node* target, SecurityReportingOption reportingOpti on) 176 bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, const LocalDOMWi ndow* accessingWindow, const Node* target, SecurityReportingOption reportingOpti on)
151 { 177 {
152 if (!target) 178 if (!target)
153 return false; 179 return false;
154 return canAccessFrame(isolate, accessingWindow, target->document().getSecuri tyOrigin(), target->document().domWindow(), reportingOption); 180 return canAccessFrame(isolate, accessingWindow, target->document().getSecuri tyOrigin(), target->document().domWindow(), reportingOption);
155 } 181 }
156 182
157 bool BindingSecurity::shouldAllowAccessToFrame(v8::Isolate* isolate, const Local DOMWindow* accessingWindow, const Frame* target, SecurityReportingOption reporti ngOption) 183 bool BindingSecurity::shouldAllowAccessToFrame(v8::Isolate* isolate, const Local DOMWindow* accessingWindow, const Frame* target, SecurityReportingOption reporti ngOption)
158 { 184 {
159 if (!target || !target->securityContext()) 185 if (!target || !target->securityContext())
160 return false; 186 return false;
161 return canAccessFrame(isolate, accessingWindow, target->securityContext()->g etSecurityOrigin(), target->domWindow(), reportingOption); 187 return canAccessFrame(isolate, accessingWindow, target->securityContext()->g etSecurityOrigin(), target->domWindow(), reportingOption);
162 } 188 }
163 189
164 } // namespace blink 190 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698