| Index: content/browser/web_contents/web_contents_impl.cc
|
| diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
|
| index a43b70fd2aa5d780678d3b90cc18fb668716b21f..e3a7edf4073996bd05eccd99c9c543142f9f1571 100644
|
| --- a/content/browser/web_contents/web_contents_impl.cc
|
| +++ b/content/browser/web_contents/web_contents_impl.cc
|
| @@ -374,6 +374,10 @@ WebContentsImpl::WebContentsImpl(
|
| fullscreen_widget_routing_id_(MSG_ROUTING_NONE) {
|
| for (size_t i = 0; i < g_created_callbacks.Get().size(); i++)
|
| g_created_callbacks.Get().at(i).Run(this);
|
| + frame_tree_.SetFrameRemoveListener(
|
| + base::Bind(&WebContentsImpl::OnFrameRemoved,
|
| + base::Unretained(this)));
|
| +
|
| }
|
|
|
| WebContentsImpl::~WebContentsImpl() {
|
| @@ -718,8 +722,6 @@ bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host,
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog,
|
| OnOpenDateTimeDialog)
|
| #endif
|
| - IPC_MESSAGE_HANDLER(ViewHostMsg_FrameAttached, OnFrameAttached)
|
| - IPC_MESSAGE_HANDLER(ViewHostMsg_FrameDetached, OnFrameDetached)
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_MediaNotification, OnMediaNotification)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP_EX()
|
| @@ -1013,26 +1015,23 @@ uint64 WebContentsImpl::GetUploadPosition() const {
|
| }
|
|
|
| std::set<GURL> WebContentsImpl::GetSitesInTab() const {
|
| - BrowserContext* browser_context = GetBrowserContext();
|
| std::set<GURL> sites;
|
| - if (!frame_tree_root_.get())
|
| - return sites;
|
| -
|
| - // Iterates over the FrameTreeNodes to find each unique site URL that is
|
| - // currently committed.
|
| - FrameTreeNode* node = NULL;
|
| - std::queue<FrameTreeNode*> queue;
|
| - queue.push(frame_tree_root_.get());
|
| -
|
| - while (!queue.empty()) {
|
| - node = queue.front();
|
| - queue.pop();
|
| - sites.insert(SiteInstance::GetSiteForURL(browser_context,
|
| - node->current_url()));
|
| -
|
| - for (size_t i = 0; i < node->child_count(); ++i)
|
| - queue.push(node->child_at(i));
|
| - }
|
| + // TODO(ajwong): Why don't people just dump these at the top of most .cc
|
| + // files??
|
| + using base::Bind;
|
| + using base::Unretained;
|
| +
|
| + // TODO(ajwong): Using a local class like this almost certainly won't compile
|
| + // on MSVC or some bot. Hoist it up to file-local function.
|
| + struct Foo {
|
| + static bool Do(BrowserContext* context, std::set<GURL>* s,
|
| + FrameTreeNode* node) {
|
| + s->insert(SiteInstance::GetSiteForURL(context, node->current_url()));
|
| + return true;
|
| + }
|
| + };
|
| + frame_tree_.ForEach(Bind(&Foo::Do, Unretained(GetBrowserContext()),
|
| + Unretained(&sites)));
|
|
|
| return sites;
|
| }
|
| @@ -1706,6 +1705,10 @@ SessionStorageNamespace* WebContentsImpl::GetSessionStorageNamespace(
|
| return controller_.GetSessionStorageNamespace(instance);
|
| }
|
|
|
| +FrameTree* WebContentsImpl::GetFrameTree() {
|
| + return &frame_tree_;
|
| +}
|
| +
|
| void WebContentsImpl::DidSendScreenRects(RenderWidgetHostImpl* rwh) {
|
| if (browser_plugin_embedder_)
|
| browser_plugin_embedder_->DidSendScreenRects();
|
| @@ -2600,52 +2603,6 @@ void WebContentsImpl::OnUpdateFaviconURL(
|
| DidUpdateFaviconURL(page_id, candidates));
|
| }
|
|
|
| -FrameTreeNode* WebContentsImpl::FindFrameTreeNodeByID(int64 frame_id) {
|
| - // TODO(nasko): Remove this check once we move to creating the root node
|
| - // through RenderFrameHost creation.
|
| - if (!frame_tree_root_.get())
|
| - return NULL;
|
| -
|
| - FrameTreeNode* node = NULL;
|
| - std::queue<FrameTreeNode*> queue;
|
| - queue.push(frame_tree_root_.get());
|
| -
|
| - while (!queue.empty()) {
|
| - node = queue.front();
|
| - queue.pop();
|
| - if (node->frame_id() == frame_id)
|
| - return node;
|
| -
|
| - for (size_t i = 0; i < node->child_count(); ++i)
|
| - queue.push(node->child_at(i));
|
| - }
|
| -
|
| - return NULL;
|
| -}
|
| -
|
| -void WebContentsImpl::OnFrameAttached(
|
| - int64 parent_frame_id,
|
| - int64 frame_id,
|
| - const std::string& frame_name) {
|
| - FrameTreeNode* parent = FindFrameTreeNodeByID(parent_frame_id);
|
| - if (!parent)
|
| - return;
|
| -
|
| - FrameTreeNode* node = new FrameTreeNode(frame_id, frame_name);
|
| - parent->AddChild(node);
|
| -}
|
| -
|
| -void WebContentsImpl::OnFrameDetached(int64 parent_frame_id, int64 frame_id) {
|
| - FOR_EACH_OBSERVER(WebContentsObserver, observers_,
|
| - FrameDetached(message_source_, frame_id));
|
| -
|
| - FrameTreeNode* parent = FindFrameTreeNodeByID(parent_frame_id);
|
| - if (!parent)
|
| - return;
|
| -
|
| - parent->RemoveChild(frame_id);
|
| -}
|
| -
|
| void WebContentsImpl::OnMediaNotification(int64 player_cookie,
|
| bool has_video,
|
| bool has_audio,
|
| @@ -3015,12 +2972,10 @@ void WebContentsImpl::DidGetRedirectForResourceRequest(
|
| void WebContentsImpl::DidNavigate(
|
| RenderViewHost* rvh,
|
| const ViewHostMsg_FrameNavigate_Params& params) {
|
| - // If we don't have a frame tree root yet, this is the first navigation in
|
| - // using the current RenderViewHost, so we need to create it with the proper
|
| - // frame id.
|
| - if (!frame_tree_root_.get()) {
|
| + if (frame_tree_.IsFirstNavigation()) {
|
| + // First navigation should be a main frame navigation.
|
| DCHECK(PageTransitionIsMainFrame(params.transition));
|
| - frame_tree_root_.reset(new FrameTreeNode(params.frame_id, std::string()));
|
| + frame_tree_.OnFirstNavigation(params.frame_id);
|
| }
|
|
|
| if (PageTransitionIsMainFrame(params.transition)) {
|
| @@ -3036,10 +2991,6 @@ void WebContentsImpl::DidNavigate(
|
| render_manager_.DidNavigateMainFrame(rvh);
|
| }
|
|
|
| - // We expect to have a valid frame tree root node at all times when
|
| - // navigating.
|
| - DCHECK(frame_tree_root_.get());
|
| -
|
| // Update the site of the SiteInstance if it doesn't have one yet, unless
|
| // assigning a site is not necessary for this URL. In that case, the
|
| // SiteInstance can still be considered unused until a navigation to a real
|
| @@ -3066,9 +3017,7 @@ void WebContentsImpl::DidNavigate(
|
| // For now, keep track of each frame's URL in its FrameTreeNode. This lets
|
| // us estimate our process count for implementing OOP iframes.
|
| // TODO(creis): Remove this when we track which pages commit in each frame.
|
| - FrameTreeNode* node = FindFrameTreeNodeByID(params.frame_id);
|
| - if (node)
|
| - node->set_current_url(params.url);
|
| + frame_tree_.SetFrameUrl(params.frame_id, params.url);
|
|
|
| // Send notification about committed provisional loads. This notification is
|
| // different from the NAV_ENTRY_COMMITTED notification which doesn't include
|
| @@ -3640,24 +3589,6 @@ void WebContentsImpl::NotifySwappedFromRenderManager(RenderViewHost* rvh) {
|
| view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent());
|
|
|
| view_->RenderViewSwappedIn(render_manager_.current_host());
|
| -
|
| - FrameTreeNode* root = NULL;
|
| - RenderViewHostImpl* new_rvh = static_cast<RenderViewHostImpl*>(
|
| - render_manager_.current_host());
|
| -
|
| - // We are doing a cross-site navigation and swapping processes. Since frame
|
| - // ids are unique to a process, we need to recreate the frame tree with the
|
| - // proper main frame id.
|
| - // Note that it is possible for this method to be called before the new RVH
|
| - // has committed a navigation (if RenderViewHostManager short-circuits the
|
| - // CommitPending call because the current RVH is dead). In that case, we
|
| - // haven't heard a valid frame id to use to initialize the root node, so clear
|
| - // out the root node and the first subsequent navigation message will set it
|
| - // correctly.
|
| - if (new_rvh->main_frame_id() != -1)
|
| - root = new FrameTreeNode(new_rvh->main_frame_id(), std::string());
|
| -
|
| - frame_tree_root_.reset(root);
|
| }
|
|
|
| int WebContentsImpl::CreateOpenerRenderViewsForRenderManager(
|
| @@ -3831,4 +3762,9 @@ gfx::Size WebContentsImpl::GetSizeForNewRenderView() const {
|
| return size;
|
| }
|
|
|
| +void WebContentsImpl::OnFrameRemoved(int64 frame_id) {
|
| + FOR_EACH_OBSERVER(WebContentsObserver, observers_,
|
| + FrameDetached(message_source_, frame_id));
|
| +}
|
| +
|
| } // namespace content
|
|
|