Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 1258273006: Remove page id from title and state updating. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@switch
Patch Set: comment nit Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 4316 matching lines...) Expand 10 before | Expand all | Expand 10 after
4327 FOR_EACH_OBSERVER(WebContentsObserver, 4327 FOR_EACH_OBSERVER(WebContentsObserver,
4328 observers_, 4328 observers_,
4329 RenderProcessGone(GetCrashedStatus())); 4329 RenderProcessGone(GetCrashedStatus()));
4330 } 4330 }
4331 4331
4332 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { 4332 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) {
4333 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh)); 4333 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh));
4334 } 4334 }
4335 4335
4336 void WebContentsImpl::UpdateState(RenderViewHost* rvh, 4336 void WebContentsImpl::UpdateState(RenderViewHost* rvh,
4337 int32_t page_id,
4338 const PageState& page_state) { 4337 const PageState& page_state) {
4339 DCHECK(!SiteIsolationPolicy::UseSubframeNavigationEntries()); 4338 DCHECK(!SiteIsolationPolicy::UseSubframeNavigationEntries());
4340 4339
4341 // Ensure that this state update comes from a RenderViewHost that belongs to 4340 // Ensure that this state update comes from a RenderViewHost that belongs to
4342 // this WebContents. 4341 // this WebContents.
4343 // TODO(nasko): This should go through RenderFrameHost. 4342 // TODO(nasko): This should go through RenderFrameHost.
4344 if (rvh->GetDelegate()->GetAsWebContents() != this) 4343 if (rvh->GetDelegate()->GetAsWebContents() != this)
4345 return; 4344 return;
4346 4345
4347 // We must be prepared to handle state updates for any page. They occur 4346 if (!rvh->GetMainFrame()) {
4348 // when the user is scrolling and entering form data, as well as when we're 4347 // When UseSubframeNavigationEntries is turned off, state updates only come
4349 // leaving a page, in which case our state may have already been moved to 4348 // in on main frames. When UseSubframeNavigationEntries is turned on,
4350 // the next page. The navigation controller will look up the appropriate 4349 // UpdateStateForFrame() should have been called rather than this function.
4351 // NavigationEntry and update it when it is notified via the delegate. 4350 NOTREACHED();
4352 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh);
4353 NavigationEntryImpl* entry = controller_.GetEntryWithPageID(
4354 rvhi->GetSiteInstance(), page_id);
4355 if (!entry)
4356 return; 4351 return;
4352 }
4357 4353
4358 // Sanity check that ensures nav_entry_id and page_id point to the same 4354 NavigationEntryImpl* entry = controller_.GetEntryWithUniqueID(
4359 // navigation entry. 4355 static_cast<RenderFrameHostImpl*>(rvh->GetMainFrame())->nav_entry_id());
4360 if (rvhi->GetMainFrame()) {
4361 NavigationEntryImpl* new_entry = controller_.GetEntryWithUniqueID(
4362 static_cast<RenderFrameHostImpl*>(rvhi->GetMainFrame())
4363 ->nav_entry_id());
4364
4365 DCHECK_EQ(entry, new_entry);
4366 }
4367 4356
4368 if (page_state == entry->GetPageState()) 4357 if (page_state == entry->GetPageState())
4369 return; // Nothing to update. 4358 return; // Nothing to update.
4370 entry->SetPageState(page_state); 4359 entry->SetPageState(page_state);
4371 controller_.NotifyEntryChanged(entry); 4360 controller_.NotifyEntryChanged(entry);
4372 } 4361 }
4373 4362
4374 void WebContentsImpl::UpdateTargetURL(RenderViewHost* render_view_host, 4363 void WebContentsImpl::UpdateTargetURL(RenderViewHost* render_view_host,
4375 const GURL& url) { 4364 const GURL& url) {
4376 if (fullscreen_widget_routing_id_ != MSG_ROUTING_NONE) { 4365 if (fullscreen_widget_routing_id_ != MSG_ROUTING_NONE) {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
4580 exploded_state.top.item_sequence_number != 4569 exploded_state.top.item_sequence_number !=
4581 frame_entry->item_sequence_number()) { 4570 frame_entry->item_sequence_number()) {
4582 return; 4571 return;
4583 } 4572 }
4584 4573
4585 frame_entry->SetPageState(page_state); 4574 frame_entry->SetPageState(page_state);
4586 controller_.NotifyEntryChanged(entry); 4575 controller_.NotifyEntryChanged(entry);
4587 } 4576 }
4588 4577
4589 void WebContentsImpl::UpdateTitle(RenderFrameHost* render_frame_host, 4578 void WebContentsImpl::UpdateTitle(RenderFrameHost* render_frame_host,
4590 int32_t page_id,
4591 const base::string16& title, 4579 const base::string16& title,
4592 base::i18n::TextDirection title_direction) { 4580 base::i18n::TextDirection title_direction) {
4593 // If we have a title, that's a pretty good indication that we've started 4581 // If we have a title, that's a pretty good indication that we've started
4594 // getting useful data. 4582 // getting useful data.
4595 SetNotWaitingForResponse(); 4583 SetNotWaitingForResponse();
4596 4584
4597 // Try to find the navigation entry, which might not be the current one. 4585 // Try to find the navigation entry, which might not be the current one.
4598 // For example, it might be from a recently swapped out RFH. 4586 // For example, it might be from a recently swapped out RFH.
4599 NavigationEntryImpl* entry = controller_.GetEntryWithPageID( 4587 NavigationEntryImpl* entry = controller_.GetEntryWithUniqueID(
4600 render_frame_host->GetSiteInstance(), page_id);
4601
4602 NavigationEntryImpl* new_entry = controller_.GetEntryWithUniqueID(
4603 static_cast<RenderFrameHostImpl*>(render_frame_host)->nav_entry_id()); 4588 static_cast<RenderFrameHostImpl*>(render_frame_host)->nav_entry_id());
4604 if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) {
4605 // In out-of-process iframe enabled modes, page_id can't keep track of
4606 // navigations in other processes, so we must use nav_entry_id.
4607 // TODO(creis): Switch to use this as the default.
4608 entry = new_entry;
4609 }
4610 // (In modes that have no out-of-process iframes, nav_entry_id and page_id
4611 // will usually agree on which entry to update, but may disagree if commits
4612 // from a previous RFH have been ignored, resetting the RFH's nav_entry_id.)
4613 4589
4614 // We can handle title updates when we don't have an entry in 4590 // We can handle title updates when we don't have an entry in
4615 // UpdateTitleForEntry, but only if the update is from the current RVH. 4591 // UpdateTitleForEntry, but only if the update is from the current RVH.
4616 // TODO(avi): Change to make decisions based on the RenderFrameHost. 4592 // TODO(avi): Change to make decisions based on the RenderFrameHost.
4617 if (!entry && render_frame_host != GetMainFrame()) 4593 if (!entry && render_frame_host != GetMainFrame())
4618 return; 4594 return;
4619 4595
4620 // TODO(evan): make use of title_direction. 4596 // TODO(evan): make use of title_direction.
4621 // http://code.google.com/p/chromium/issues/detail?id=27094 4597 // http://code.google.com/p/chromium/issues/detail?id=27094
4622 UpdateTitleForEntry(entry, title); 4598 UpdateTitleForEntry(entry, title);
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
5255 dialog_manager_ = dialog_manager; 5231 dialog_manager_ = dialog_manager;
5256 } 5232 }
5257 5233
5258 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { 5234 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) {
5259 auto it = binding_sets_.find(interface_name); 5235 auto it = binding_sets_.find(interface_name);
5260 if (it != binding_sets_.end()) 5236 if (it != binding_sets_.end())
5261 binding_sets_.erase(it); 5237 binding_sets_.erase(it);
5262 } 5238 }
5263 5239
5264 } // namespace content 5240 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698