Commit 9433a2df authored by arthursonzogni's avatar arthursonzogni Committed by Commit Bot

[COOP] access reporting: Remove "isolate" argument.

I was suggested the "isolate" argument of ReportCoopAccess could be
determined by the DomWindow instance itself:
https://chromium-review.googlesource.com/c/chromium/src/+/2339353/4

This patch removes it from the ReportCoopAccess method and updates the
callers.

Bug: 1090273
Change-Id: I0286f13ea8700c419728f89f706baf71bb0f0642
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2346569
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarCamille Lamy <clamy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796842}
parent 703febc0
...@@ -65,11 +65,9 @@ namespace blink { ...@@ -65,11 +65,9 @@ namespace blink {
template <typename CallbackInfo> template <typename CallbackInfo>
static void LocationAttributeGet(const CallbackInfo& info) { static void LocationAttributeGet(const CallbackInfo& info) {
v8::Isolate* isolate = info.GetIsolate();
v8::Local<v8::Object> holder = info.Holder(); v8::Local<v8::Object> holder = info.Holder();
DOMWindow* window = V8Window::ToImpl(holder); DOMWindow* window = V8Window::ToImpl(holder);
window->ReportCoopAccess(isolate, "location"); window->ReportCoopAccess("location");
Location* location = window->location(); Location* location = window->location();
DCHECK(location); DCHECK(location);
...@@ -77,6 +75,7 @@ static void LocationAttributeGet(const CallbackInfo& info) { ...@@ -77,6 +75,7 @@ static void LocationAttributeGet(const CallbackInfo& info) {
if (DOMDataStore::SetReturnValue(info.GetReturnValue(), location)) if (DOMDataStore::SetReturnValue(info.GetReturnValue(), location))
return; return;
v8::Isolate* isolate = info.GetIsolate();
v8::Local<v8::Value> wrapper; v8::Local<v8::Value> wrapper;
// Note that this check is gated on whether or not |window| is remote, not // Note that this check is gated on whether or not |window| is remote, not
...@@ -141,9 +140,8 @@ void V8Window::FrameElementAttributeGetterCustom( ...@@ -141,9 +140,8 @@ void V8Window::FrameElementAttributeGetterCustom(
template <typename CallbackInfo> template <typename CallbackInfo>
static void OpenerAttributeSet(v8::Local<v8::Value> value, static void OpenerAttributeSet(v8::Local<v8::Value> value,
const CallbackInfo& info) { const CallbackInfo& info) {
v8::Isolate* isolate = info.GetIsolate();
DOMWindow* impl = V8Window::ToImpl(info.Holder()); DOMWindow* impl = V8Window::ToImpl(info.Holder());
impl->ReportCoopAccess(isolate, "opener"); impl->ReportCoopAccess("opener");
if (!impl->GetFrame()) if (!impl->GetFrame())
return; return;
...@@ -157,6 +155,7 @@ static void OpenerAttributeSet(v8::Local<v8::Value> value, ...@@ -157,6 +155,7 @@ static void OpenerAttributeSet(v8::Local<v8::Value> value,
To<LocalFrame>(impl->GetFrame())->Loader().SetOpener(nullptr); To<LocalFrame>(impl->GetFrame())->Loader().SetOpener(nullptr);
} }
v8::Isolate* isolate = info.GetIsolate();
// Delete the accessor from the inner object. // Delete the accessor from the inner object.
if (info.Holder() if (info.Holder()
->Delete(isolate->GetCurrentContext(), ->Delete(isolate->GetCurrentContext(),
...@@ -210,7 +209,7 @@ void V8Window::NamedPropertyGetterCustom( ...@@ -210,7 +209,7 @@ void V8Window::NamedPropertyGetterCustom(
// https://html.spec.whatwg.org/C/#document-tree-child-browsing-context-name-property-set // https://html.spec.whatwg.org/C/#document-tree-child-browsing-context-name-property-set
Frame* child = frame->Tree().ScopedChild(name); Frame* child = frame->Tree().ScopedChild(name);
if (child) { if (child) {
window->ReportCoopAccess(info.GetIsolate(), "named"); window->ReportCoopAccess("named");
UseCounter::Count(CurrentExecutionContext(info.GetIsolate()), UseCounter::Count(CurrentExecutionContext(info.GetIsolate()),
WebFeature::kNamedAccessOnWindow_ChildBrowsingContext); WebFeature::kNamedAccessOnWindow_ChildBrowsingContext);
...@@ -271,7 +270,7 @@ void V8Window::NamedPropertyGetterCustom( ...@@ -271,7 +270,7 @@ void V8Window::NamedPropertyGetterCustom(
if (!has_named_item && !has_id_item) if (!has_named_item && !has_id_item)
return; return;
window->ReportCoopAccess(info.GetIsolate(), "named"); window->ReportCoopAccess("named");
if (!has_named_item && has_id_item && if (!has_named_item && has_id_item &&
!doc->ContainsMultipleElementsWithId(name)) { !doc->ContainsMultipleElementsWithId(name)) {
......
...@@ -70,7 +70,7 @@ const v8::FunctionCallbackInfo<v8::Value>& info ...@@ -70,7 +70,7 @@ const v8::FunctionCallbackInfo<v8::Value>& info
{% endif %}{# not attribute.is_static #} {% endif %}{# not attribute.is_static #}
{% if interface_name == "Window" and attribute.has_cross_origin_getter %} {% if interface_name == "Window" and attribute.has_cross_origin_getter %}
impl->ReportCoopAccess(info.GetIsolate(), "{{attribute.name}}"); impl->ReportCoopAccess("{{attribute.name}}");
{% endif %} {% endif %}
{% if attribute.cached_attribute_validation_method %} {% if attribute.cached_attribute_validation_method %}
......
...@@ -55,7 +55,7 @@ static void {{method.camel_case_name}}{{method.overload_index}}Method{{world_suf ...@@ -55,7 +55,7 @@ static void {{method.camel_case_name}}{{method.overload_index}}Method{{world_suf
{% endif %}{# not method.is_static #} {% endif %}{# not method.is_static #}
{% if interface_name == "Window" and method.is_cross_origin %} {% if interface_name == "Window" and method.is_cross_origin %}
impl->ReportCoopAccess(info.GetIsolate(), "{{method.name}}"); impl->ReportCoopAccess("{{method.name}}");
{% endif %} {% endif %}
{# Security checks #} {# Security checks #}
......
...@@ -166,7 +166,7 @@ void DOMWindow::postMessage(v8::Isolate* isolate, ...@@ -166,7 +166,7 @@ void DOMWindow::postMessage(v8::Isolate* isolate,
} }
DOMWindow* DOMWindow::AnonymousIndexedGetter(uint32_t index) { DOMWindow* DOMWindow::AnonymousIndexedGetter(uint32_t index) {
ReportCoopAccess(window_proxy_manager_->GetIsolate(), "indexed"); ReportCoopAccess("indexed");
if (!GetFrame()) if (!GetFrame())
return nullptr; return nullptr;
...@@ -450,11 +450,11 @@ void DOMWindow::InstallCoopAccessMonitor( ...@@ -450,11 +450,11 @@ void DOMWindow::InstallCoopAccessMonitor(
// Check if the accessing context would be able to access this window if COOP // Check if the accessing context would be able to access this window if COOP
// was enforced. If this isn't a report is sent. // was enforced. If this isn't a report is sent.
void DOMWindow::ReportCoopAccess(v8::Isolate* isolate, void DOMWindow::ReportCoopAccess(const char* property_name) {
const char* property_name) {
if (coop_access_monitor_.IsEmpty()) // Fast early return. Very likely true. if (coop_access_monitor_.IsEmpty()) // Fast early return. Very likely true.
return; return;
v8::Isolate* isolate = window_proxy_manager_->GetIsolate();
LocalDOMWindow* accessing_window = IncumbentDOMWindow(isolate); LocalDOMWindow* accessing_window = IncumbentDOMWindow(isolate);
LocalFrame* accessing_frame = accessing_window->GetFrame(); LocalFrame* accessing_frame = accessing_window->GetFrame();
......
...@@ -147,7 +147,7 @@ class CORE_EXPORT DOMWindow : public EventTargetWithInlineData { ...@@ -147,7 +147,7 @@ class CORE_EXPORT DOMWindow : public EventTargetWithInlineData {
// //
// This function must be called when accessing any attributes and methods // This function must be called when accessing any attributes and methods
// marked as "CrossOrigin" in the window.idl. // marked as "CrossOrigin" in the window.idl.
void ReportCoopAccess(v8::Isolate* isolate, const char* property_name); void ReportCoopAccess(const char* property_name);
protected: protected:
explicit DOMWindow(Frame&); explicit DOMWindow(Frame&);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment