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

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

Issue 2668753006: Special-case LocalDOMWindow for same-origin access in bindings. (Closed)
Patch Set: . Created 3 years, 10 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 target->domWindow(), reportingOption); 209 target->domWindow(), reportingOption);
210 } 210 }
211 211
212 bool BindingSecurity::shouldAllowAccessToDetachedWindow( 212 bool BindingSecurity::shouldAllowAccessToDetachedWindow(
213 const LocalDOMWindow* accessingWindow, 213 const LocalDOMWindow* accessingWindow,
214 const DOMWindow* target, 214 const DOMWindow* target,
215 ExceptionState& exceptionState) { 215 ExceptionState& exceptionState) {
216 CHECK(target && !target->frame()) 216 CHECK(target && !target->frame())
217 << "This version of shouldAllowAccessToFrame() must be used only for " 217 << "This version of shouldAllowAccessToFrame() must be used only for "
218 << "detached windows."; 218 << "detached windows.";
219 if (!target->document()) 219 if (!target->isLocalDOMWindow())
220 return false; 220 return false;
221 return canAccessFrame(accessingWindow, 221 Document* document = toLocalDOMWindow(target)->document();
dcheng 2017/02/01 07:22:59 I am considering moving SecurityContext to DOMWind
222 target->document()->getSecurityOrigin(), target, 222 if (!document)
223 return false;
224 return canAccessFrame(accessingWindow, document->getSecurityOrigin(), target,
223 exceptionState); 225 exceptionState);
224 } 226 }
225 227
226 bool BindingSecurity::shouldAllowNamedAccessTo(const DOMWindow* accessingWindow, 228 bool BindingSecurity::shouldAllowNamedAccessTo(const DOMWindow* accessingWindow,
227 const DOMWindow* targetWindow) { 229 const DOMWindow* targetWindow) {
228 const Frame* accessingFrame = accessingWindow->frame(); 230 const Frame* accessingFrame = accessingWindow->frame();
229 DCHECK(accessingFrame); 231 DCHECK(accessingFrame);
230 DCHECK(accessingFrame->securityContext()); 232 DCHECK(accessingFrame->securityContext());
231 const SecurityOrigin* accessingOrigin = 233 const SecurityOrigin* accessingOrigin =
232 accessingFrame->securityContext()->getSecurityOrigin(); 234 accessingFrame->securityContext()->getSecurityOrigin();
(...skipping 30 matching lines...) Expand all
263 // arguments, so the generated exception can be more descriptive. 265 // arguments, so the generated exception can be more descriptive.
264 ExceptionState exceptionState(isolate, ExceptionState::UnknownContext, 266 ExceptionState exceptionState(isolate, ExceptionState::UnknownContext,
265 nullptr, nullptr); 267 nullptr, nullptr);
266 exceptionState.throwSecurityError( 268 exceptionState.throwSecurityError(
267 targetWindow->sanitizedCrossDomainAccessErrorMessage( 269 targetWindow->sanitizedCrossDomainAccessErrorMessage(
268 currentDOMWindow(isolate)), 270 currentDOMWindow(isolate)),
269 targetWindow->crossDomainAccessErrorMessage(currentDOMWindow(isolate))); 271 targetWindow->crossDomainAccessErrorMessage(currentDOMWindow(isolate)));
270 } 272 }
271 273
272 } // namespace blink 274 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698