Commit 7d82a11c authored by Nate Chapin's avatar Nate Chapin Committed by Commit Bot

Make WebDocument's use of Document::GetExecutionContext() safe

There are 4 places Document::GetExecutionContext() is currently
invoked in WebDocument:
* GetSecurityOrigin() is the only one of the 4 that null-checks it.
* OutgoingReferrer() is unused and can be removed.
* GetReferrerPolicy() has a single use that can easily be adjusted so
  that it can be removed.
* IsSecureContext() needs a null-check.

Bug: 1121726
Change-Id: I0f65a56909e4bc1a5ee6aee30e0e59c8c698b434
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2375704
Commit-Queue: Kentaro Hara <haraken@chromium.org>
Auto-Submit: Nate Chapin <japhet@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801618}
parent a114706d
...@@ -104,8 +104,6 @@ class WebDocument : public WebNode { ...@@ -104,8 +104,6 @@ class WebDocument : public WebNode {
BLINK_EXPORT WebURL CompleteURL(const WebString&) const; BLINK_EXPORT WebURL CompleteURL(const WebString&) const;
BLINK_EXPORT WebElement GetElementById(const WebString&) const; BLINK_EXPORT WebElement GetElementById(const WebString&) const;
BLINK_EXPORT WebElement FocusedElement() const; BLINK_EXPORT WebElement FocusedElement() const;
BLINK_EXPORT network::mojom::ReferrerPolicy GetReferrerPolicy() const;
BLINK_EXPORT WebString OutgoingReferrer();
// Inserts the given CSS source code as a style sheet in the document. // Inserts the given CSS source code as a style sheet in the document.
BLINK_EXPORT WebStyleSheetKey InsertStyleSheet( BLINK_EXPORT WebStyleSheetKey InsertStyleSheet(
......
...@@ -93,7 +93,9 @@ WebSecurityOrigin WebDocument::GetSecurityOrigin() const { ...@@ -93,7 +93,9 @@ WebSecurityOrigin WebDocument::GetSecurityOrigin() const {
bool WebDocument::IsSecureContext() const { bool WebDocument::IsSecureContext() const {
const Document* document = ConstUnwrap<Document>(); const Document* document = ConstUnwrap<Document>();
return document && document->GetExecutionContext()->IsSecureContext(); ExecutionContext* context =
document ? document->GetExecutionContext() : nullptr;
return context && context->IsSecureContext();
} }
WebString WebDocument::Encoding() const { WebString WebDocument::Encoding() const {
...@@ -235,15 +237,6 @@ void WebDocument::WatchCSSSelectors(const WebVector<WebString>& web_selectors) { ...@@ -235,15 +237,6 @@ void WebDocument::WatchCSSSelectors(const WebVector<WebString>& web_selectors) {
CSSSelectorWatch::From(*document).WatchCSSSelectors(selectors); CSSSelectorWatch::From(*document).WatchCSSSelectors(selectors);
} }
network::mojom::ReferrerPolicy WebDocument::GetReferrerPolicy() const {
return ConstUnwrap<Document>()->GetExecutionContext()->GetReferrerPolicy();
}
WebString WebDocument::OutgoingReferrer() {
return WebString(
Unwrap<Document>()->GetExecutionContext()->OutgoingReferrer());
}
WebVector<WebDraggableRegion> WebDocument::DraggableRegions() const { WebVector<WebDraggableRegion> WebDocument::DraggableRegions() const {
WebVector<WebDraggableRegion> draggable_regions; WebVector<WebDraggableRegion> draggable_regions;
const Document* document = ConstUnwrap<Document>(); const Document* document = ConstUnwrap<Document>();
......
...@@ -238,9 +238,7 @@ void ChromeClientImpl::StartDragging(LocalFrame* frame, ...@@ -238,9 +238,7 @@ void ChromeClientImpl::StartDragging(LocalFrame* frame,
const SkBitmap& drag_image, const SkBitmap& drag_image,
const gfx::Point& drag_image_offset) { const gfx::Point& drag_image_offset) {
WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(frame); WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(frame);
WebDragData drag = drag_data; web_frame->LocalRootFrameWidget()->StartDragging(drag_data, mask, drag_image,
drag.SetReferrerPolicy(web_frame->GetDocument().GetReferrerPolicy());
web_frame->LocalRootFrameWidget()->StartDragging(drag, mask, drag_image,
drag_image_offset); drag_image_offset);
} }
......
...@@ -1334,6 +1334,7 @@ void DragController::DoSystemDrag(DragImage* image, ...@@ -1334,6 +1334,7 @@ void DragController::DoSystemDrag(DragImage* image,
IntSize offset_size(adjusted_event_pos - adjusted_drag_location); IntSize offset_size(adjusted_event_pos - adjusted_drag_location);
gfx::Point offset_point(offset_size.Width(), offset_size.Height()); gfx::Point offset_point(offset_size.Width(), offset_size.Height());
WebDragData drag_data = data_transfer->GetDataObject()->ToWebDragData(); WebDragData drag_data = data_transfer->GetDataObject()->ToWebDragData();
drag_data.SetReferrerPolicy(drag_initiator_->GetReferrerPolicy());
WebDragOperationsMask drag_operation_mask = WebDragOperationsMask drag_operation_mask =
static_cast<WebDragOperationsMask>(data_transfer->SourceOperation()); static_cast<WebDragOperationsMask>(data_transfer->SourceOperation());
SkBitmap drag_image; SkBitmap drag_image;
......
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