Skip to content

Commit

Permalink
Portals: Attach TabHelpers when a Portal is created.
Browse files Browse the repository at this point in the history
This CL adds a notification via WebContentsDelegate that
notifies the embedder that a new portal WebContents was created.

The chrome/ embedder then uses this notification in order to
attach TabHelpers to the newly created WebContents.

Bug: 865565

Change-Id: I3e39883a5869832e6e59be9db7ea9e88ab18cd64
Reviewed-on: https://chromium-review.googlesource.com/1197143
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Lucas Gadani <lfg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592498}
  • Loading branch information
lucasgadani authored and Commit Bot committed Sep 19, 2018
1 parent b6a59f2 commit e289a91
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions chrome/browser/ui/browser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,10 @@ void Browser::WebContentsCreated(WebContents* source_contents,
task_manager::WebContentsTags::CreateForTabContents(new_contents);
}

void Browser::PortalWebContentsCreated(WebContents* portal_web_contents) {
TabHelpers::AttachTabHelpers(portal_web_contents);
}

void Browser::RendererUnresponsive(
WebContents* source,
content::RenderWidgetHost* render_widget_host,
Expand Down
2 changes: 2 additions & 0 deletions chrome/browser/ui/browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,8 @@ class Browser : public TabStripModelObserver,
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents) override;
void PortalWebContentsCreated(
content::WebContents* portal_web_contents) override;
void RendererUnresponsive(
content::WebContents* source,
content::RenderWidgetHost* render_widget_host,
Expand Down
4 changes: 4 additions & 0 deletions content/browser/portal/portal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/content_switches.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "third_party/blink/public/common/features.h"
Expand Down Expand Up @@ -53,6 +54,9 @@ void Portal::Init(
WebContents::FromRenderFrameHost(owner_render_frame_host_)
->GetBrowserContext());
portal_contents_ = WebContents::Create(params);
WebContents::FromRenderFrameHost(owner_render_frame_host_)
->GetDelegate()
->PortalWebContentsCreated(portal_contents_.get());
}

void Portal::Navigate(const GURL& url) {
Expand Down
3 changes: 3 additions & 0 deletions content/public/browser/web_contents_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ class CONTENT_EXPORT WebContentsDelegate {
const GURL& target_url,
WebContents* new_contents) {}

// Notifies the embedder that a Portal WebContents was created.
virtual void PortalWebContentsCreated(WebContents* portal_web_contents) {}

// Notification that one of the frames in the WebContents is hung. |source| is
// the WebContents that is hung, and |render_widget_host| is the
// RenderWidgetHost that, while routing events to it, discovered the hang.
Expand Down

0 comments on commit e289a91

Please sign in to comment.