Skip to content

Commit

Permalink
Remove several unnecessary guest view owner WebContents accesses
Browse files Browse the repository at this point in the history
In each of these cases, accessing the owner RFH is enough.

Bug: 1261928
Change-Id: Ibe1cf569cdec580760e6a8752966df0c1240fdec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4843546
Commit-Queue: James Maclean <wjmaclean@chromium.org>
Auto-Submit: Kevin McNee <mcnee@chromium.org>
Reviewed-by: James Maclean <wjmaclean@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1192981}
  • Loading branch information
kjmcnee authored and Chromium LUCI CQ committed Sep 6, 2023
1 parent ca80b6f commit ec0f585
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool ContextMenuContentTypeWebView::SupportsGroup(int group) {
// For a list of places where <webview>/GuestViews are supported, see:
// https://goo.gl/xfJkwp.
if (!embedder_extension && web_view_guest_ &&
web_view_guest_->owner_web_contents()->GetWebUI()) {
web_view_guest_->owner_rfh()->GetMainFrame()->GetWebUI()) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion extensions/browser/guest_view/app_view/app_view_guest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void AppViewGuest::CompleteCreateWebContents(
const Extension* guest_extension,
std::unique_ptr<GuestViewBase> owned_this,
WebContentsCreatedCallback callback) {
if (!owner_web_contents()) {
if (!owner_rfh()) {
// The owner was destroyed before getting a response to the embedding
// request, so we can't proceed with creating a guest.
std::move(callback).Run(std::move(owned_this), nullptr);
Expand Down
7 changes: 3 additions & 4 deletions extensions/browser/guest_view/web_view/web_view_guest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,7 @@ int WebViewGuest::GetOrGenerateRulesRegistryID(int embedder_process_id,
void WebViewGuest::CreateWebContents(std::unique_ptr<GuestViewBase> owned_this,
const base::Value::Dict& create_params,
WebContentsCreatedCallback callback) {
RenderFrameHost* owner_render_frame_host =
owner_web_contents()->GetPrimaryMainFrame();
RenderFrameHost* owner_render_frame_host = owner_rfh();
RenderProcessHost* owner_render_process_host =
owner_render_frame_host->GetProcess();
DCHECK_EQ(browser_context(), owner_render_process_host->GetBrowserContext());
Expand Down Expand Up @@ -833,10 +832,10 @@ void WebViewGuest::DidFinishNavigation(
content::NavigationHandle* navigation_handle) {
if (navigation_handle->IsErrorPage() || !navigation_handle->HasCommitted()) {
// Suppress loadabort for "mailto" URLs.
// Also during destruction, owner_web_contents() is null so there's no point
// Also during destruction, the owner is null so there's no point
// trying to send the event.
if (!navigation_handle->GetURL().SchemeIs(url::kMailToScheme) &&
owner_web_contents()) {
owner_rfh()) {
// If a load is blocked, either by WebRequest or security checks, the
// navigation may or may not have committed. So if we don't see an error
// code, mark it as blocked.
Expand Down

0 comments on commit ec0f585

Please sign in to comment.