OLD | NEW |
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 Loading... |
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, const v8::Local<
v8::Context>& calling, const ExecutionContext* callingExecutionContext, const Ma
inThreadWorkletGlobalScope* workletGlobalScope, SecurityReportingOption reportin
gOption) |
135 { | 135 { |
136 ASSERT(target); | 136 DCHECK(callingExecutionContext); |
137 const Frame* frame = target->frame(); | 137 DOMWindow* callingDomWindow = toDOMWindow(calling); |
138 if (!frame || !frame->securityContext()) | 138 if (callingExecutionContext->isMainThreadWorkletGlobalScope()) { |
| 139 Frame* callingFrame = toMainThreadWorkletGlobalScope(callingExecutionCon
text)->frame(); |
| 140 callingDomWindow = 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 canAccessFrame(isolate, toLocalDOMWindow(callingDomWindow), workletGl
obalScopeFrame->securityContext()->getSecurityOrigin(), workletGlobalScopeFrame-
>domWindow(), reportingOption); |
141 } | 149 } |
142 | 150 |
143 bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, const LocalDOMWi
ndow* accessingWindow, const Node* target, ExceptionState& exceptionState) | 151 bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, const LocalDOMWi
ndow* accessingWindow, const Node* target, ExceptionState& exceptionState) |
144 { | 152 { |
145 if (!target) | 153 if (!target) |
146 return false; | 154 return false; |
147 return canAccessFrame(isolate, accessingWindow, target->document().getSecuri
tyOrigin(), target->document().domWindow(), exceptionState); | 155 return canAccessFrame(isolate, accessingWindow, target->document().getSecuri
tyOrigin(), target->document().domWindow(), exceptionState); |
148 } | 156 } |
149 | 157 |
150 bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, const LocalDOMWi
ndow* accessingWindow, const Node* target, SecurityReportingOption reportingOpti
on) | 158 bool BindingSecurity::shouldAllowAccessTo(v8::Isolate* isolate, const LocalDOMWi
ndow* accessingWindow, const Node* target, SecurityReportingOption reportingOpti
on) |
151 { | 159 { |
152 if (!target) | 160 if (!target) |
153 return false; | 161 return false; |
154 return canAccessFrame(isolate, accessingWindow, target->document().getSecuri
tyOrigin(), target->document().domWindow(), reportingOption); | 162 return canAccessFrame(isolate, accessingWindow, target->document().getSecuri
tyOrigin(), target->document().domWindow(), reportingOption); |
155 } | 163 } |
156 | 164 |
157 bool BindingSecurity::shouldAllowAccessToFrame(v8::Isolate* isolate, const Local
DOMWindow* accessingWindow, const Frame* target, SecurityReportingOption reporti
ngOption) | 165 bool BindingSecurity::shouldAllowAccessToFrame(v8::Isolate* isolate, const Local
DOMWindow* accessingWindow, const Frame* target, SecurityReportingOption reporti
ngOption) |
158 { | 166 { |
159 if (!target || !target->securityContext()) | 167 if (!target || !target->securityContext()) |
160 return false; | 168 return false; |
161 return canAccessFrame(isolate, accessingWindow, target->securityContext()->g
etSecurityOrigin(), target->domWindow(), reportingOption); | 169 return canAccessFrame(isolate, accessingWindow, target->securityContext()->g
etSecurityOrigin(), target->domWindow(), reportingOption); |
162 } | 170 } |
163 | 171 |
| 172 bool BindingSecurity::callingContextCanAccessContext(v8::Isolate* isolate, const
v8::Local<v8::Context>& calling, const v8::Local<v8::Context>& target, Security
ReportingOption reportingOption) |
| 173 { |
| 174 ExecutionContext* targetExecutionContext = toExecutionContext(target); |
| 175 DCHECK(targetExecutionContext); |
| 176 |
| 177 if (targetExecutionContext->isWorkerGlobalScope()) { |
| 178 // worker's isolate contains only a single worker, so any access is allo
wed. |
| 179 return true; |
| 180 } |
| 181 |
| 182 ExecutionContext* callingExecutionContext = toExecutionContext(calling); |
| 183 DCHECK(callingExecutionContext); |
| 184 |
| 185 if (targetExecutionContext->isMainThreadWorkletGlobalScope()) |
| 186 return shouldAllowAccessTo(isolate, calling, callingExecutionContext, to
MainThreadWorkletGlobalScope(targetExecutionContext), reportingOption); |
| 187 |
| 188 |
| 189 if (callingExecutionContext->isMainThreadWorkletGlobalScope()) |
| 190 return shouldAllowAccessTo(isolate, target, targetExecutionContext, toMa
inThreadWorkletGlobalScope(callingExecutionContext), reportingOption); |
| 191 |
| 192 DOMWindow* window = toDOMWindow(target); |
| 193 return window && shouldAllowAccessTo(isolate, toLocalDOMWindow(toDOMWindow(c
alling)), window, DoNotReportSecurityError); |
| 194 } |
| 195 |
164 } // namespace blink | 196 } // namespace blink |
OLD | NEW |