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

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

Issue 2877893002: Make UseCounter take a LocaFrame instead of any Frame (Closed)
Patch Set: Rebase Created 3 years, 7 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, 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2011 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // None of these need to be RefPtr because info and context are guaranteed 210 // None of these need to be RefPtr because info and context are guaranteed
211 // to hold on to them. 211 // to hold on to them.
212 DOMWindow* window = V8Window::toImpl(info.Holder()); 212 DOMWindow* window = V8Window::toImpl(info.Holder());
213 // TODO(yukishiino): The HTML spec specifies that we should use the 213 // TODO(yukishiino): The HTML spec specifies that we should use the
214 // Incumbent Realm instead of the Current Realm, but currently we don't have 214 // Incumbent Realm instead of the Current Realm, but currently we don't have
215 // a way to retrieve the Incumbent Realm. See also: 215 // a way to retrieve the Incumbent Realm. See also:
216 // https://html.spec.whatwg.org/multipage/comms.html#dom-window-postmessage 216 // https://html.spec.whatwg.org/multipage/comms.html#dom-window-postmessage
217 LocalDOMWindow* source = CurrentDOMWindow(info.GetIsolate()); 217 LocalDOMWindow* source = CurrentDOMWindow(info.GetIsolate());
218 218
219 DCHECK(window); 219 DCHECK(window);
220 UseCounter::Count(window->GetFrame(), UseCounter::kWindowPostMessage); 220 UseCounter::Count(source->GetFrame(), UseCounter::kWindowPostMessage);
221 221
222 // If called directly by WebCore we don't have a calling context. 222 // If called directly by WebCore we don't have a calling context.
223 if (!source) { 223 if (!source) {
224 exception_state.ThrowTypeError("No active calling context exists."); 224 exception_state.ThrowTypeError("No active calling context exists.");
225 return; 225 return;
226 } 226 }
227 227
228 // This function has variable arguments and can be: 228 // This function has variable arguments and can be:
229 // postMessage(message, targetOrigin) 229 // postMessage(message, targetOrigin)
230 // postMessage(message, targetOrigin, {sequence of transferrables}) 230 // postMessage(message, targetOrigin, {sequence of transferrables})
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 311
312 // Note that named access on WindowProxy is allowed in the cross-origin case. 312 // Note that named access on WindowProxy is allowed in the cross-origin case.
313 // 7.4.5 [[GetOwnProperty]] (P), step 6. 313 // 7.4.5 [[GetOwnProperty]] (P), step 6.
314 // https://html.spec.whatwg.org/multipage/browsers.html#windowproxy-getownprop erty 314 // https://html.spec.whatwg.org/multipage/browsers.html#windowproxy-getownprop erty
315 // 315 //
316 // 7.3.3 Named access on the Window object 316 // 7.3.3 Named access on the Window object
317 // The document-tree child browsing context name property set 317 // The document-tree child browsing context name property set
318 // https://html.spec.whatwg.org/multipage/browsers.html#document-tree-child-br owsing-context-name-property-set 318 // https://html.spec.whatwg.org/multipage/browsers.html#document-tree-child-br owsing-context-name-property-set
319 Frame* child = frame->Tree().ScopedChild(name); 319 Frame* child = frame->Tree().ScopedChild(name);
320 if (child) { 320 if (child) {
321 UseCounter::Count(window->GetFrame(), 321 UseCounter::Count(CurrentExecutionContext(info.GetIsolate()),
haraken 2017/05/15 03:40:45 This will work as expected because CurrentExecutio
dcheng 2017/05/15 04:04:02 I'm not sure I follow: I don't think CurrentExecut
haraken 2017/05/15 04:45:45 CurrentExecutionContext() returns nullptr for a re
dcheng 2017/05/15 04:57:30 Right, but CurrentExecutionContext() gets it from
322 UseCounter::kNamedAccessOnWindow_ChildBrowsingContext); 322 UseCounter::kNamedAccessOnWindow_ChildBrowsingContext);
323 323
324 // step 3. Remove each browsing context from childBrowsingContexts whose 324 // step 3. Remove each browsing context from childBrowsingContexts whose
325 // active document's origin is not same origin with activeDocument's origin 325 // active document's origin is not same origin with activeDocument's origin
326 // and whose browsing context name does not match the name of its browsing 326 // and whose browsing context name does not match the name of its browsing
327 // context container's name content attribute value. 327 // context container's name content attribute value.
328 if (BindingSecurity::ShouldAllowNamedAccessTo(window, child->DomWindow()) || 328 if (BindingSecurity::ShouldAllowNamedAccessTo(window, child->DomWindow()) ||
329 name == child->Owner()->BrowsingContextContainerName()) { 329 name == child->Owner()->BrowsingContextContainerName()) {
330 V8SetReturnValueFast(info, child->DomWindow(), window); 330 V8SetReturnValueFast(info, child->DomWindow(), window);
331 return; 331 return;
332 } 332 }
333 333
334 UseCounter::Count( 334 UseCounter::Count(
335 window->GetFrame(), 335 CurrentExecutionContext(info.GetIsolate()),
haraken 2017/05/15 03:40:45 Ditto.
336 UseCounter:: 336 UseCounter::
337 kNamedAccessOnWindow_ChildBrowsingContext_CrossOriginNameMismatch); 337 kNamedAccessOnWindow_ChildBrowsingContext_CrossOriginNameMismatch);
338 // In addition to the above spec'ed case, we return the child window 338 // In addition to the above spec'ed case, we return the child window
339 // regardless of step 3 due to crbug.com/701489 for the time being. 339 // regardless of step 3 due to crbug.com/701489 for the time being.
340 // TODO(yukishiino): Makes iframe.name update the browsing context name 340 // TODO(yukishiino): Makes iframe.name update the browsing context name
341 // appropriately and makes the new name available in the named access on 341 // appropriately and makes the new name available in the named access on
342 // window. Then, removes the following two lines. 342 // window. Then, removes the following two lines.
343 V8SetReturnValueFast(info, child->DomWindow(), window); 343 V8SetReturnValueFast(info, child->DomWindow(), window);
344 return; 344 return;
345 } 345 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 if (items->HasExactlyOneItem()) { 381 if (items->HasExactlyOneItem()) {
382 V8SetReturnValueFast(info, items->item(0), window); 382 V8SetReturnValueFast(info, items->item(0), window);
383 return; 383 return;
384 } 384 }
385 V8SetReturnValueFast(info, items, window); 385 V8SetReturnValueFast(info, items, window);
386 return; 386 return;
387 } 387 }
388 } 388 }
389 389
390 } // namespace blink 390 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698