OLD | NEW |
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/navigation_controller_impl.h" | 5 #include "content/browser/web_contents/navigation_controller_impl.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_number_conversions.h" // Temporary | 9 #include "base/string_number_conversions.h" // Temporary |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // remove "view-source:" from the beginning of the URL to get the URL that | 141 // remove "view-source:" from the beginning of the URL to get the URL that |
142 // will actually be loaded. This real URL won't be shown to the user, just | 142 // will actually be loaded. This real URL won't be shown to the user, just |
143 // used internally. | 143 // used internally. |
144 GURL loaded_url(url); | 144 GURL loaded_url(url); |
145 bool reverse_on_redirect = false; | 145 bool reverse_on_redirect = false; |
146 BrowserURLHandlerImpl::GetInstance()->RewriteURLIfNecessary( | 146 BrowserURLHandlerImpl::GetInstance()->RewriteURLIfNecessary( |
147 &loaded_url, browser_context, &reverse_on_redirect); | 147 &loaded_url, browser_context, &reverse_on_redirect); |
148 | 148 |
149 NavigationEntryImpl* entry = new NavigationEntryImpl( | 149 NavigationEntryImpl* entry = new NavigationEntryImpl( |
150 NULL, // The site instance for tabs is sent on navigation | 150 NULL, // The site instance for tabs is sent on navigation |
151 // (TabContents::GetSiteInstance). | 151 // (WebContents::GetSiteInstance). |
152 -1, | 152 -1, |
153 loaded_url, | 153 loaded_url, |
154 referrer, | 154 referrer, |
155 string16(), | 155 string16(), |
156 transition, | 156 transition, |
157 is_renderer_initiated); | 157 is_renderer_initiated); |
158 entry->SetVirtualURL(url); | 158 entry->SetVirtualURL(url); |
159 entry->set_user_typed_url(url); | 159 entry->set_user_typed_url(url); |
160 entry->set_update_virtual_url_with_url(reverse_on_redirect); | 160 entry->set_update_virtual_url_with_url(reverse_on_redirect); |
161 entry->set_extra_headers(extra_headers); | 161 entry->set_extra_headers(extra_headers); |
162 return entry; | 162 return entry; |
163 } | 163 } |
164 | 164 |
165 // static | 165 // static |
166 void NavigationController::DisablePromptOnRepost() { | 166 void NavigationController::DisablePromptOnRepost() { |
167 g_check_for_repost = false; | 167 g_check_for_repost = false; |
168 } | 168 } |
169 | 169 |
170 } // namespace content | 170 } // namespace content |
171 | 171 |
172 NavigationControllerImpl::NavigationControllerImpl( | 172 NavigationControllerImpl::NavigationControllerImpl( |
173 TabContents* contents, | 173 WebContentsImpl* web_contents, |
174 BrowserContext* browser_context, | 174 BrowserContext* browser_context, |
175 SessionStorageNamespaceImpl* session_storage_namespace) | 175 SessionStorageNamespaceImpl* session_storage_namespace) |
176 : browser_context_(browser_context), | 176 : browser_context_(browser_context), |
177 pending_entry_(NULL), | 177 pending_entry_(NULL), |
178 last_committed_entry_index_(-1), | 178 last_committed_entry_index_(-1), |
179 pending_entry_index_(-1), | 179 pending_entry_index_(-1), |
180 transient_entry_index_(-1), | 180 transient_entry_index_(-1), |
181 tab_contents_(contents), | 181 web_contents_(web_contents), |
182 max_restored_page_id_(-1), | 182 max_restored_page_id_(-1), |
183 ALLOW_THIS_IN_INITIALIZER_LIST(ssl_manager_(this)), | 183 ALLOW_THIS_IN_INITIALIZER_LIST(ssl_manager_(this)), |
184 needs_reload_(false), | 184 needs_reload_(false), |
185 session_storage_namespace_(session_storage_namespace), | 185 session_storage_namespace_(session_storage_namespace), |
186 pending_reload_(NO_RELOAD) { | 186 pending_reload_(NO_RELOAD) { |
187 DCHECK(browser_context_); | 187 DCHECK(browser_context_); |
188 if (!session_storage_namespace_) { | 188 if (!session_storage_namespace_) { |
189 session_storage_namespace_ = new SessionStorageNamespaceImpl( | 189 session_storage_namespace_ = new SessionStorageNamespaceImpl( |
190 static_cast<DOMStorageContextImpl*>( | 190 static_cast<DOMStorageContextImpl*>( |
191 BrowserContext::GetDOMStorageContext(browser_context_))); | 191 BrowserContext::GetDOMStorageContext(browser_context_))); |
192 } | 192 } |
193 } | 193 } |
194 | 194 |
195 NavigationControllerImpl::~NavigationControllerImpl() { | 195 NavigationControllerImpl::~NavigationControllerImpl() { |
196 DiscardNonCommittedEntriesInternal(); | 196 DiscardNonCommittedEntriesInternal(); |
197 | 197 |
198 content::NotificationService::current()->Notify( | 198 content::NotificationService::current()->Notify( |
199 content::NOTIFICATION_TAB_CLOSED, | 199 content::NOTIFICATION_TAB_CLOSED, |
200 content::Source<NavigationController>(this), | 200 content::Source<NavigationController>(this), |
201 content::NotificationService::NoDetails()); | 201 content::NotificationService::NoDetails()); |
202 } | 202 } |
203 | 203 |
204 WebContents* NavigationControllerImpl::GetWebContents() const { | 204 WebContents* NavigationControllerImpl::GetWebContents() const { |
205 return tab_contents_; | 205 return web_contents_; |
206 } | 206 } |
207 | 207 |
208 BrowserContext* NavigationControllerImpl::GetBrowserContext() const { | 208 BrowserContext* NavigationControllerImpl::GetBrowserContext() const { |
209 return browser_context_; | 209 return browser_context_; |
210 } | 210 } |
211 | 211 |
212 void NavigationControllerImpl::SetBrowserContext( | 212 void NavigationControllerImpl::SetBrowserContext( |
213 BrowserContext* browser_context) { | 213 BrowserContext* browser_context) { |
214 browser_context_ = browser_context; | 214 browser_context_ = browser_context; |
215 } | 215 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 GetEntryAtIndex(current_index)->GetHasPostData()) { | 260 GetEntryAtIndex(current_index)->GetHasPostData()) { |
261 // The user is asking to reload a page with POST data. Prompt to make sure | 261 // The user is asking to reload a page with POST data. Prompt to make sure |
262 // they really want to do this. If they do, the dialog will call us back | 262 // they really want to do this. If they do, the dialog will call us back |
263 // with check_for_repost = false. | 263 // with check_for_repost = false. |
264 content::NotificationService::current()->Notify( | 264 content::NotificationService::current()->Notify( |
265 content::NOTIFICATION_REPOST_WARNING_SHOWN, | 265 content::NOTIFICATION_REPOST_WARNING_SHOWN, |
266 content::Source<NavigationController>(this), | 266 content::Source<NavigationController>(this), |
267 content::NotificationService::NoDetails()); | 267 content::NotificationService::NoDetails()); |
268 | 268 |
269 pending_reload_ = reload_type; | 269 pending_reload_ = reload_type; |
270 tab_contents_->Activate(); | 270 web_contents_->Activate(); |
271 tab_contents_->GetDelegate()->ShowRepostFormWarningDialog(tab_contents_); | 271 web_contents_->GetDelegate()->ShowRepostFormWarningDialog(web_contents_); |
272 } else { | 272 } else { |
273 DiscardNonCommittedEntriesInternal(); | 273 DiscardNonCommittedEntriesInternal(); |
274 | 274 |
275 NavigationEntryImpl* entry = entries_[current_index].get(); | 275 NavigationEntryImpl* entry = entries_[current_index].get(); |
276 SiteInstanceImpl* site_instance = entry->site_instance(); | 276 SiteInstanceImpl* site_instance = entry->site_instance(); |
277 DCHECK(site_instance); | 277 DCHECK(site_instance); |
278 | 278 |
279 // If we are reloading an entry that no longer belongs to the current | 279 // If we are reloading an entry that no longer belongs to the current |
280 // site instance (for example, refreshing a page for just installed app), | 280 // site instance (for example, refreshing a page for just installed app), |
281 // the reload must happen in a new process. | 281 // the reload must happen in a new process. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 } | 398 } |
399 | 399 |
400 NavigationEntry* NavigationControllerImpl::GetLastCommittedEntry() const { | 400 NavigationEntry* NavigationControllerImpl::GetLastCommittedEntry() const { |
401 if (last_committed_entry_index_ == -1) | 401 if (last_committed_entry_index_ == -1) |
402 return NULL; | 402 return NULL; |
403 return entries_[last_committed_entry_index_].get(); | 403 return entries_[last_committed_entry_index_].get(); |
404 } | 404 } |
405 | 405 |
406 bool NavigationControllerImpl::CanViewSource() const { | 406 bool NavigationControllerImpl::CanViewSource() const { |
407 bool is_supported_mime_type = net::IsSupportedNonImageMimeType( | 407 bool is_supported_mime_type = net::IsSupportedNonImageMimeType( |
408 tab_contents_->GetContentsMimeType().c_str()); | 408 web_contents_->GetContentsMimeType().c_str()); |
409 NavigationEntry* active_entry = GetActiveEntry(); | 409 NavigationEntry* active_entry = GetActiveEntry(); |
410 return active_entry && !active_entry->IsViewSourceMode() && | 410 return active_entry && !active_entry->IsViewSourceMode() && |
411 is_supported_mime_type && !tab_contents_->GetInterstitialPage(); | 411 is_supported_mime_type && !web_contents_->GetInterstitialPage(); |
412 } | 412 } |
413 | 413 |
414 int NavigationControllerImpl::GetLastCommittedEntryIndex() const { | 414 int NavigationControllerImpl::GetLastCommittedEntryIndex() const { |
415 return last_committed_entry_index_; | 415 return last_committed_entry_index_; |
416 } | 416 } |
417 | 417 |
418 int NavigationControllerImpl::GetEntryCount() const { | 418 int NavigationControllerImpl::GetEntryCount() const { |
419 DCHECK(entries_.size() <= max_entry_count()); | 419 DCHECK(entries_.size() <= max_entry_count()); |
420 return static_cast<int>(entries_.size()); | 420 return static_cast<int>(entries_.size()); |
421 } | 421 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 | 545 |
546 void NavigationControllerImpl::AddTransientEntry(NavigationEntryImpl* entry) { | 546 void NavigationControllerImpl::AddTransientEntry(NavigationEntryImpl* entry) { |
547 // Discard any current transient entry, we can only have one at a time. | 547 // Discard any current transient entry, we can only have one at a time. |
548 int index = 0; | 548 int index = 0; |
549 if (last_committed_entry_index_ != -1) | 549 if (last_committed_entry_index_ != -1) |
550 index = last_committed_entry_index_ + 1; | 550 index = last_committed_entry_index_ + 1; |
551 DiscardTransientEntry(); | 551 DiscardTransientEntry(); |
552 entries_.insert( | 552 entries_.insert( |
553 entries_.begin() + index, linked_ptr<NavigationEntryImpl>(entry)); | 553 entries_.begin() + index, linked_ptr<NavigationEntryImpl>(entry)); |
554 transient_entry_index_ = index; | 554 transient_entry_index_ = index; |
555 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); | 555 web_contents_->NotifyNavigationStateChanged(kInvalidateAll); |
556 } | 556 } |
557 | 557 |
558 void NavigationControllerImpl::TransferURL( | 558 void NavigationControllerImpl::TransferURL( |
559 const GURL& url, | 559 const GURL& url, |
560 const content::Referrer& referrer, | 560 const content::Referrer& referrer, |
561 content::PageTransition transition, | 561 content::PageTransition transition, |
562 const std::string& extra_headers, | 562 const std::string& extra_headers, |
563 const GlobalRequestID& transferred_global_request_id, | 563 const GlobalRequestID& transferred_global_request_id, |
564 bool is_renderer_initiated) { | 564 bool is_renderer_initiated) { |
565 // The user initiated a load, we don't need to reload anymore. | 565 // The user initiated a load, we don't need to reload anymore. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 if (!RendererDidNavigateAutoSubframe(params)) | 662 if (!RendererDidNavigateAutoSubframe(params)) |
663 return false; | 663 return false; |
664 break; | 664 break; |
665 case content::NAVIGATION_TYPE_NAV_IGNORE: | 665 case content::NAVIGATION_TYPE_NAV_IGNORE: |
666 // If a pending navigation was in progress, this canceled it. We should | 666 // If a pending navigation was in progress, this canceled it. We should |
667 // discard it and make sure it is removed from the URL bar. After that, | 667 // discard it and make sure it is removed from the URL bar. After that, |
668 // there is nothing we can do with this navigation, so we just return to | 668 // there is nothing we can do with this navigation, so we just return to |
669 // the caller that nothing has happened. | 669 // the caller that nothing has happened. |
670 if (pending_entry_) { | 670 if (pending_entry_) { |
671 DiscardNonCommittedEntries(); | 671 DiscardNonCommittedEntries(); |
672 tab_contents_->NotifyNavigationStateChanged( | 672 web_contents_->NotifyNavigationStateChanged( |
673 content::INVALIDATE_TYPE_URL); | 673 content::INVALIDATE_TYPE_URL); |
674 } | 674 } |
675 return false; | 675 return false; |
676 default: | 676 default: |
677 NOTREACHED(); | 677 NOTREACHED(); |
678 } | 678 } |
679 | 679 |
680 // All committed entries should have nonempty content state so WebKit doesn't | 680 // All committed entries should have nonempty content state so WebKit doesn't |
681 // get confused when we go back to them (see the function for details). | 681 // get confused when we go back to them (see the function for details). |
682 DCHECK(!params.content_state.empty()); | 682 DCHECK(!params.content_state.empty()); |
683 NavigationEntryImpl* active_entry = | 683 NavigationEntryImpl* active_entry = |
684 NavigationEntryImpl::FromNavigationEntry(GetActiveEntry()); | 684 NavigationEntryImpl::FromNavigationEntry(GetActiveEntry()); |
685 active_entry->SetContentState(params.content_state); | 685 active_entry->SetContentState(params.content_state); |
686 | 686 |
687 // Once committed, we do not need to track if the entry was initiated by | 687 // Once committed, we do not need to track if the entry was initiated by |
688 // the renderer. | 688 // the renderer. |
689 active_entry->set_is_renderer_initiated(false); | 689 active_entry->set_is_renderer_initiated(false); |
690 | 690 |
691 // The active entry's SiteInstance should match our SiteInstance. | 691 // The active entry's SiteInstance should match our SiteInstance. |
692 DCHECK(active_entry->site_instance() == tab_contents_->GetSiteInstance()); | 692 DCHECK(active_entry->site_instance() == web_contents_->GetSiteInstance()); |
693 | 693 |
694 // Now prep the rest of the details for the notification and broadcast. | 694 // Now prep the rest of the details for the notification and broadcast. |
695 details->entry = active_entry; | 695 details->entry = active_entry; |
696 details->is_main_frame = | 696 details->is_main_frame = |
697 content::PageTransitionIsMainFrame(params.transition); | 697 content::PageTransitionIsMainFrame(params.transition); |
698 details->serialized_security_info = params.security_info; | 698 details->serialized_security_info = params.security_info; |
699 details->http_status_code = params.http_status_code; | 699 details->http_status_code = params.http_status_code; |
700 NotifyNavigationEntryCommitted(details); | 700 NotifyNavigationEntryCommitted(details); |
701 | 701 |
702 return true; | 702 return true; |
(...skipping 16 matching lines...) Expand all Loading... |
719 // could be invalid. This can also happen for a cross-site transition | 719 // could be invalid. This can also happen for a cross-site transition |
720 // that causes us to swap processes. Then the error page load will be in | 720 // that causes us to swap processes. Then the error page load will be in |
721 // a new process with no page IDs ever assigned (and hence a -1 value), | 721 // a new process with no page IDs ever assigned (and hence a -1 value), |
722 // yet the navigation controller still might have previous pages in its | 722 // yet the navigation controller still might have previous pages in its |
723 // list. | 723 // list. |
724 // | 724 // |
725 // In these cases, there's nothing we can do with them, so ignore. | 725 // In these cases, there's nothing we can do with them, so ignore. |
726 return content::NAVIGATION_TYPE_NAV_IGNORE; | 726 return content::NAVIGATION_TYPE_NAV_IGNORE; |
727 } | 727 } |
728 | 728 |
729 if (params.page_id > tab_contents_->GetMaxPageID()) { | 729 if (params.page_id > web_contents_->GetMaxPageID()) { |
730 // Greater page IDs than we've ever seen before are new pages. We may or may | 730 // Greater page IDs than we've ever seen before are new pages. We may or may |
731 // not have a pending entry for the page, and this may or may not be the | 731 // not have a pending entry for the page, and this may or may not be the |
732 // main frame. | 732 // main frame. |
733 if (content::PageTransitionIsMainFrame(params.transition)) | 733 if (content::PageTransitionIsMainFrame(params.transition)) |
734 return content::NAVIGATION_TYPE_NEW_PAGE; | 734 return content::NAVIGATION_TYPE_NEW_PAGE; |
735 | 735 |
736 // When this is a new subframe navigation, we should have a committed page | 736 // When this is a new subframe navigation, we should have a committed page |
737 // for which it's a suframe in. This may not be the case when an iframe is | 737 // for which it's a suframe in. This may not be the case when an iframe is |
738 // navigated on a popup navigated to about:blank (the iframe would be | 738 // navigated on a popup navigated to about:blank (the iframe would be |
739 // written into the popup by script on the main page). For these cases, | 739 // written into the popup by script on the main page). For these cases, |
740 // there isn't any navigation stuff we can do, so just ignore it. | 740 // there isn't any navigation stuff we can do, so just ignore it. |
741 if (!GetLastCommittedEntry()) | 741 if (!GetLastCommittedEntry()) |
742 return content::NAVIGATION_TYPE_NAV_IGNORE; | 742 return content::NAVIGATION_TYPE_NAV_IGNORE; |
743 | 743 |
744 // Valid subframe navigation. | 744 // Valid subframe navigation. |
745 return content::NAVIGATION_TYPE_NEW_SUBFRAME; | 745 return content::NAVIGATION_TYPE_NEW_SUBFRAME; |
746 } | 746 } |
747 | 747 |
748 // Now we know that the notification is for an existing page. Find that entry. | 748 // Now we know that the notification is for an existing page. Find that entry. |
749 int existing_entry_index = GetEntryIndexWithPageID( | 749 int existing_entry_index = GetEntryIndexWithPageID( |
750 tab_contents_->GetSiteInstance(), | 750 web_contents_->GetSiteInstance(), |
751 params.page_id); | 751 params.page_id); |
752 if (existing_entry_index == -1) { | 752 if (existing_entry_index == -1) { |
753 // The page was not found. It could have been pruned because of the limit on | 753 // The page was not found. It could have been pruned because of the limit on |
754 // back/forward entries (not likely since we'll usually tell it to navigate | 754 // back/forward entries (not likely since we'll usually tell it to navigate |
755 // to such entries). It could also mean that the renderer is smoking crack. | 755 // to such entries). It could also mean that the renderer is smoking crack. |
756 NOTREACHED(); | 756 NOTREACHED(); |
757 | 757 |
758 // Because the unknown entry has committed, we risk showing the wrong URL in | 758 // Because the unknown entry has committed, we risk showing the wrong URL in |
759 // release builds. Instead, we'll kill the renderer process to be safe. | 759 // release builds. Instead, we'll kill the renderer process to be safe. |
760 LOG(ERROR) << "terminating renderer for bad navigation: " << params.url; | 760 LOG(ERROR) << "terminating renderer for bad navigation: " << params.url; |
761 content::RecordAction(UserMetricsAction("BadMessageTerminate_NC")); | 761 content::RecordAction(UserMetricsAction("BadMessageTerminate_NC")); |
762 | 762 |
763 // Temporary code so we can get more information. Format: | 763 // Temporary code so we can get more information. Format: |
764 // http://url/foo.html#page1#max3#frame1#ids:2_Nx,1_1x,3_2 | 764 // http://url/foo.html#page1#max3#frame1#ids:2_Nx,1_1x,3_2 |
765 std::string temp = params.url.spec(); | 765 std::string temp = params.url.spec(); |
766 temp.append("#page"); | 766 temp.append("#page"); |
767 temp.append(base::IntToString(params.page_id)); | 767 temp.append(base::IntToString(params.page_id)); |
768 temp.append("#max"); | 768 temp.append("#max"); |
769 temp.append(base::IntToString(tab_contents_->GetMaxPageID())); | 769 temp.append(base::IntToString(web_contents_->GetMaxPageID())); |
770 temp.append("#frame"); | 770 temp.append("#frame"); |
771 temp.append(base::IntToString(params.frame_id)); | 771 temp.append(base::IntToString(params.frame_id)); |
772 temp.append("#ids"); | 772 temp.append("#ids"); |
773 for (int i = 0; i < static_cast<int>(entries_.size()); ++i) { | 773 for (int i = 0; i < static_cast<int>(entries_.size()); ++i) { |
774 // Append entry metadata (e.g., 3_7x): | 774 // Append entry metadata (e.g., 3_7x): |
775 // 3: page_id | 775 // 3: page_id |
776 // 7: SiteInstance ID, or N for null | 776 // 7: SiteInstance ID, or N for null |
777 // x: appended if not from the current SiteInstance | 777 // x: appended if not from the current SiteInstance |
778 temp.append(base::IntToString(entries_[i]->GetPageID())); | 778 temp.append(base::IntToString(entries_[i]->GetPageID())); |
779 temp.append("_"); | 779 temp.append("_"); |
780 if (entries_[i]->site_instance()) | 780 if (entries_[i]->site_instance()) |
781 temp.append(base::IntToString(entries_[i]->site_instance()->GetId())); | 781 temp.append(base::IntToString(entries_[i]->site_instance()->GetId())); |
782 else | 782 else |
783 temp.append("N"); | 783 temp.append("N"); |
784 if (entries_[i]->site_instance() != tab_contents_->GetSiteInstance()) | 784 if (entries_[i]->site_instance() != web_contents_->GetSiteInstance()) |
785 temp.append("x"); | 785 temp.append("x"); |
786 temp.append(","); | 786 temp.append(","); |
787 } | 787 } |
788 GURL url(temp); | 788 GURL url(temp); |
789 static_cast<RenderViewHostImpl*>( | 789 static_cast<RenderViewHostImpl*>( |
790 tab_contents_->GetRenderViewHost())->Send( | 790 web_contents_->GetRenderViewHost())->Send( |
791 new ViewMsg_TempCrashWithData(url)); | 791 new ViewMsg_TempCrashWithData(url)); |
792 return content::NAVIGATION_TYPE_NAV_IGNORE; | 792 return content::NAVIGATION_TYPE_NAV_IGNORE; |
793 } | 793 } |
794 NavigationEntryImpl* existing_entry = entries_[existing_entry_index].get(); | 794 NavigationEntryImpl* existing_entry = entries_[existing_entry_index].get(); |
795 | 795 |
796 if (!content::PageTransitionIsMainFrame(params.transition)) { | 796 if (!content::PageTransitionIsMainFrame(params.transition)) { |
797 // All manual subframes would get new IDs and were handled above, so we | 797 // All manual subframes would get new IDs and were handled above, so we |
798 // know this is auto. Since the current page was found in the navigation | 798 // know this is auto. Since the current page was found in the navigation |
799 // entry list, we're guaranteed to have a last committed entry. | 799 // entry list, we're guaranteed to have a last committed entry. |
800 DCHECK(GetLastCommittedEntry()); | 800 DCHECK(GetLastCommittedEntry()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 update_virtual_url = true; | 863 update_virtual_url = true; |
864 } | 864 } |
865 | 865 |
866 new_entry->SetURL(params.url); | 866 new_entry->SetURL(params.url); |
867 if (update_virtual_url) | 867 if (update_virtual_url) |
868 UpdateVirtualURLToURL(new_entry, params.url); | 868 UpdateVirtualURLToURL(new_entry, params.url); |
869 new_entry->SetReferrer(params.referrer); | 869 new_entry->SetReferrer(params.referrer); |
870 new_entry->SetPageID(params.page_id); | 870 new_entry->SetPageID(params.page_id); |
871 new_entry->SetTransitionType(params.transition); | 871 new_entry->SetTransitionType(params.transition); |
872 new_entry->set_site_instance( | 872 new_entry->set_site_instance( |
873 static_cast<SiteInstanceImpl*>(tab_contents_->GetSiteInstance())); | 873 static_cast<SiteInstanceImpl*>(web_contents_->GetSiteInstance())); |
874 new_entry->SetHasPostData(params.is_post); | 874 new_entry->SetHasPostData(params.is_post); |
875 new_entry->SetPostID(params.post_id); | 875 new_entry->SetPostID(params.post_id); |
876 | 876 |
877 InsertOrReplaceEntry(new_entry, *did_replace_entry); | 877 InsertOrReplaceEntry(new_entry, *did_replace_entry); |
878 } | 878 } |
879 | 879 |
880 void NavigationControllerImpl::RendererDidNavigateToExistingPage( | 880 void NavigationControllerImpl::RendererDidNavigateToExistingPage( |
881 const ViewHostMsg_FrameNavigate_Params& params) { | 881 const ViewHostMsg_FrameNavigate_Params& params) { |
882 // We should only get here for main frame navigations. | 882 // We should only get here for main frame navigations. |
883 DCHECK(content::PageTransitionIsMainFrame(params.transition)); | 883 DCHECK(content::PageTransitionIsMainFrame(params.transition)); |
884 | 884 |
885 // This is a back/forward navigation. The existing page for the ID is | 885 // This is a back/forward navigation. The existing page for the ID is |
886 // guaranteed to exist by ClassifyNavigation, and we just need to update it | 886 // guaranteed to exist by ClassifyNavigation, and we just need to update it |
887 // with new information from the renderer. | 887 // with new information from the renderer. |
888 int entry_index = GetEntryIndexWithPageID(tab_contents_->GetSiteInstance(), | 888 int entry_index = GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), |
889 params.page_id); | 889 params.page_id); |
890 DCHECK(entry_index >= 0 && | 890 DCHECK(entry_index >= 0 && |
891 entry_index < static_cast<int>(entries_.size())); | 891 entry_index < static_cast<int>(entries_.size())); |
892 NavigationEntryImpl* entry = entries_[entry_index].get(); | 892 NavigationEntryImpl* entry = entries_[entry_index].get(); |
893 | 893 |
894 // The URL may have changed due to redirects. The site instance will normally | 894 // The URL may have changed due to redirects. The site instance will normally |
895 // be the same except during session restore, when no site instance will be | 895 // be the same except during session restore, when no site instance will be |
896 // assigned. | 896 // assigned. |
897 entry->SetURL(params.url); | 897 entry->SetURL(params.url); |
898 if (entry->update_virtual_url_with_url()) | 898 if (entry->update_virtual_url_with_url()) |
899 UpdateVirtualURLToURL(entry, params.url); | 899 UpdateVirtualURLToURL(entry, params.url); |
900 DCHECK(entry->site_instance() == NULL || | 900 DCHECK(entry->site_instance() == NULL || |
901 entry->site_instance() == tab_contents_->GetSiteInstance()); | 901 entry->site_instance() == web_contents_->GetSiteInstance()); |
902 entry->set_site_instance( | 902 entry->set_site_instance( |
903 static_cast<SiteInstanceImpl*>(tab_contents_->GetSiteInstance())); | 903 static_cast<SiteInstanceImpl*>(web_contents_->GetSiteInstance())); |
904 | 904 |
905 entry->SetHasPostData(params.is_post); | 905 entry->SetHasPostData(params.is_post); |
906 entry->SetPostID(params.post_id); | 906 entry->SetPostID(params.post_id); |
907 | 907 |
908 // The entry we found in the list might be pending if the user hit | 908 // The entry we found in the list might be pending if the user hit |
909 // back/forward/reload. This load should commit it (since it's already in the | 909 // back/forward/reload. This load should commit it (since it's already in the |
910 // list, we can just discard the pending pointer). We should also discard the | 910 // list, we can just discard the pending pointer). We should also discard the |
911 // pending entry if it corresponds to a different navigation, since that one | 911 // pending entry if it corresponds to a different navigation, since that one |
912 // is now likely canceled. If it is not canceled, we will treat it as a new | 912 // is now likely canceled. If it is not canceled, we will treat it as a new |
913 // navigation when it arrives, which is also ok. | 913 // navigation when it arrives, which is also ok. |
914 // | 914 // |
915 // Note that we need to use the "internal" version since we don't want to | 915 // Note that we need to use the "internal" version since we don't want to |
916 // actually change any other state, just kill the pointer. | 916 // actually change any other state, just kill the pointer. |
917 if (pending_entry_) | 917 if (pending_entry_) |
918 DiscardNonCommittedEntriesInternal(); | 918 DiscardNonCommittedEntriesInternal(); |
919 | 919 |
920 // If a transient entry was removed, the indices might have changed, so we | 920 // If a transient entry was removed, the indices might have changed, so we |
921 // have to query the entry index again. | 921 // have to query the entry index again. |
922 last_committed_entry_index_ = | 922 last_committed_entry_index_ = |
923 GetEntryIndexWithPageID(tab_contents_->GetSiteInstance(), params.page_id); | 923 GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), params.page_id); |
924 } | 924 } |
925 | 925 |
926 void NavigationControllerImpl::RendererDidNavigateToSamePage( | 926 void NavigationControllerImpl::RendererDidNavigateToSamePage( |
927 const ViewHostMsg_FrameNavigate_Params& params) { | 927 const ViewHostMsg_FrameNavigate_Params& params) { |
928 // This mode implies we have a pending entry that's the same as an existing | 928 // This mode implies we have a pending entry that's the same as an existing |
929 // entry for this page ID. This entry is guaranteed to exist by | 929 // entry for this page ID. This entry is guaranteed to exist by |
930 // ClassifyNavigation. All we need to do is update the existing entry. | 930 // ClassifyNavigation. All we need to do is update the existing entry. |
931 NavigationEntryImpl* existing_entry = GetEntryWithPageID( | 931 NavigationEntryImpl* existing_entry = GetEntryWithPageID( |
932 tab_contents_->GetSiteInstance(), params.page_id); | 932 web_contents_->GetSiteInstance(), params.page_id); |
933 | 933 |
934 // We assign the entry's unique ID to be that of the new one. Since this is | 934 // We assign the entry's unique ID to be that of the new one. Since this is |
935 // always the result of a user action, we want to dismiss infobars, etc. like | 935 // always the result of a user action, we want to dismiss infobars, etc. like |
936 // a regular user-initiated navigation. | 936 // a regular user-initiated navigation. |
937 existing_entry->set_unique_id(pending_entry_->GetUniqueID()); | 937 existing_entry->set_unique_id(pending_entry_->GetUniqueID()); |
938 | 938 |
939 // The URL may have changed due to redirects. | 939 // The URL may have changed due to redirects. |
940 if (existing_entry->update_virtual_url_with_url()) | 940 if (existing_entry->update_virtual_url_with_url()) |
941 UpdateVirtualURLToURL(existing_entry, params.url); | 941 UpdateVirtualURLToURL(existing_entry, params.url); |
942 existing_entry->SetURL(params.url); | 942 existing_entry->SetURL(params.url); |
943 | 943 |
944 DiscardNonCommittedEntries(); | 944 DiscardNonCommittedEntries(); |
945 } | 945 } |
946 | 946 |
947 void NavigationControllerImpl::RendererDidNavigateInPage( | 947 void NavigationControllerImpl::RendererDidNavigateInPage( |
948 const ViewHostMsg_FrameNavigate_Params& params, bool* did_replace_entry) { | 948 const ViewHostMsg_FrameNavigate_Params& params, bool* did_replace_entry) { |
949 DCHECK(content::PageTransitionIsMainFrame(params.transition)) << | 949 DCHECK(content::PageTransitionIsMainFrame(params.transition)) << |
950 "WebKit should only tell us about in-page navs for the main frame."; | 950 "WebKit should only tell us about in-page navs for the main frame."; |
951 // We're guaranteed to have an entry for this one. | 951 // We're guaranteed to have an entry for this one. |
952 NavigationEntryImpl* existing_entry = GetEntryWithPageID( | 952 NavigationEntryImpl* existing_entry = GetEntryWithPageID( |
953 tab_contents_->GetSiteInstance(), params.page_id); | 953 web_contents_->GetSiteInstance(), params.page_id); |
954 | 954 |
955 // Reference fragment navigation. We're guaranteed to have the last_committed | 955 // Reference fragment navigation. We're guaranteed to have the last_committed |
956 // entry and it will be the same page as the new navigation (minus the | 956 // entry and it will be the same page as the new navigation (minus the |
957 // reference fragments, of course). We'll update the URL of the existing | 957 // reference fragments, of course). We'll update the URL of the existing |
958 // entry without pruning the forward history. | 958 // entry without pruning the forward history. |
959 existing_entry->SetURL(params.url); | 959 existing_entry->SetURL(params.url); |
960 if (existing_entry->update_virtual_url_with_url()) | 960 if (existing_entry->update_virtual_url_with_url()) |
961 UpdateVirtualURLToURL(existing_entry, params.url); | 961 UpdateVirtualURLToURL(existing_entry, params.url); |
962 | 962 |
963 // This replaces the existing entry since the page ID didn't change. | 963 // This replaces the existing entry since the page ID didn't change. |
964 *did_replace_entry = true; | 964 *did_replace_entry = true; |
965 | 965 |
966 if (pending_entry_) | 966 if (pending_entry_) |
967 DiscardNonCommittedEntriesInternal(); | 967 DiscardNonCommittedEntriesInternal(); |
968 | 968 |
969 // If a transient entry was removed, the indices might have changed, so we | 969 // If a transient entry was removed, the indices might have changed, so we |
970 // have to query the entry index again. | 970 // have to query the entry index again. |
971 last_committed_entry_index_ = | 971 last_committed_entry_index_ = |
972 GetEntryIndexWithPageID(tab_contents_->GetSiteInstance(), params.page_id); | 972 GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), params.page_id); |
973 } | 973 } |
974 | 974 |
975 void NavigationControllerImpl::RendererDidNavigateNewSubframe( | 975 void NavigationControllerImpl::RendererDidNavigateNewSubframe( |
976 const ViewHostMsg_FrameNavigate_Params& params) { | 976 const ViewHostMsg_FrameNavigate_Params& params) { |
977 if (content::PageTransitionStripQualifier(params.transition) == | 977 if (content::PageTransitionStripQualifier(params.transition) == |
978 content::PAGE_TRANSITION_AUTO_SUBFRAME) { | 978 content::PAGE_TRANSITION_AUTO_SUBFRAME) { |
979 // This is not user-initiated. Ignore. | 979 // This is not user-initiated. Ignore. |
980 return; | 980 return; |
981 } | 981 } |
982 | 982 |
(...skipping 12 matching lines...) Expand all Loading... |
995 bool NavigationControllerImpl::RendererDidNavigateAutoSubframe( | 995 bool NavigationControllerImpl::RendererDidNavigateAutoSubframe( |
996 const ViewHostMsg_FrameNavigate_Params& params) { | 996 const ViewHostMsg_FrameNavigate_Params& params) { |
997 // We're guaranteed to have a previously committed entry, and we now need to | 997 // We're guaranteed to have a previously committed entry, and we now need to |
998 // handle navigation inside of a subframe in it without creating a new entry. | 998 // handle navigation inside of a subframe in it without creating a new entry. |
999 DCHECK(GetLastCommittedEntry()); | 999 DCHECK(GetLastCommittedEntry()); |
1000 | 1000 |
1001 // Handle the case where we're navigating back/forward to a previous subframe | 1001 // Handle the case where we're navigating back/forward to a previous subframe |
1002 // navigation entry. This is case "2." in NAV_AUTO_SUBFRAME comment in the | 1002 // navigation entry. This is case "2." in NAV_AUTO_SUBFRAME comment in the |
1003 // header file. In case "1." this will be a NOP. | 1003 // header file. In case "1." this will be a NOP. |
1004 int entry_index = GetEntryIndexWithPageID( | 1004 int entry_index = GetEntryIndexWithPageID( |
1005 tab_contents_->GetSiteInstance(), | 1005 web_contents_->GetSiteInstance(), |
1006 params.page_id); | 1006 params.page_id); |
1007 if (entry_index < 0 || | 1007 if (entry_index < 0 || |
1008 entry_index >= static_cast<int>(entries_.size())) { | 1008 entry_index >= static_cast<int>(entries_.size())) { |
1009 NOTREACHED(); | 1009 NOTREACHED(); |
1010 return false; | 1010 return false; |
1011 } | 1011 } |
1012 | 1012 |
1013 // Update the current navigation entry in case we're going back/forward. | 1013 // Update the current navigation entry in case we're going back/forward. |
1014 if (entry_index != last_committed_entry_index_) { | 1014 if (entry_index != last_committed_entry_index_) { |
1015 last_committed_entry_index_ = entry_index; | 1015 last_committed_entry_index_ = entry_index; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 needs_reload_ = true; | 1047 needs_reload_ = true; |
1048 InsertEntriesFrom(source, source.GetEntryCount()); | 1048 InsertEntriesFrom(source, source.GetEntryCount()); |
1049 | 1049 |
1050 session_storage_namespace_ = source.session_storage_namespace_->Clone(); | 1050 session_storage_namespace_ = source.session_storage_namespace_->Clone(); |
1051 | 1051 |
1052 FinishRestore(source.last_committed_entry_index_, false); | 1052 FinishRestore(source.last_committed_entry_index_, false); |
1053 | 1053 |
1054 // Copy the max page id map from the old tab to the new tab. This ensures | 1054 // Copy the max page id map from the old tab to the new tab. This ensures |
1055 // that new and existing navigations in the tab's current SiteInstances | 1055 // that new and existing navigations in the tab's current SiteInstances |
1056 // are identified properly. | 1056 // are identified properly. |
1057 tab_contents_->CopyMaxPageIDsFrom(source.tab_contents()); | 1057 web_contents_->CopyMaxPageIDsFrom(source.web_contents()); |
1058 } | 1058 } |
1059 | 1059 |
1060 void NavigationControllerImpl::CopyStateFromAndPrune( | 1060 void NavigationControllerImpl::CopyStateFromAndPrune( |
1061 NavigationController* temp) { | 1061 NavigationController* temp) { |
1062 NavigationControllerImpl* source = | 1062 NavigationControllerImpl* source = |
1063 static_cast<NavigationControllerImpl*>(temp); | 1063 static_cast<NavigationControllerImpl*>(temp); |
1064 // The SiteInstance and page_id of the last committed entry needs to be | 1064 // The SiteInstance and page_id of the last committed entry needs to be |
1065 // remembered at this point, in case there is only one committed entry | 1065 // remembered at this point, in case there is only one committed entry |
1066 // and it is pruned. We use a scoped_refptr to ensure the SiteInstance | 1066 // and it is pruned. We use a scoped_refptr to ensure the SiteInstance |
1067 // can't be freed during this time period. | 1067 // can't be freed during this time period. |
1068 NavigationEntryImpl* last_committed = | 1068 NavigationEntryImpl* last_committed = |
1069 NavigationEntryImpl::FromNavigationEntry(GetLastCommittedEntry()); | 1069 NavigationEntryImpl::FromNavigationEntry(GetLastCommittedEntry()); |
1070 scoped_refptr<SiteInstance> site_instance( | 1070 scoped_refptr<SiteInstance> site_instance( |
1071 last_committed ? last_committed->site_instance() : NULL); | 1071 last_committed ? last_committed->site_instance() : NULL); |
1072 int32 minimum_page_id = last_committed ? last_committed->GetPageID() : -1; | 1072 int32 minimum_page_id = last_committed ? last_committed->GetPageID() : -1; |
1073 int32 max_page_id = last_committed ? | 1073 int32 max_page_id = last_committed ? |
1074 tab_contents_->GetMaxPageIDForSiteInstance(site_instance.get()) : -1; | 1074 web_contents_->GetMaxPageIDForSiteInstance(site_instance.get()) : -1; |
1075 | 1075 |
1076 // This code is intended for use when the last entry is the active entry. | 1076 // This code is intended for use when the last entry is the active entry. |
1077 DCHECK( | 1077 DCHECK( |
1078 (transient_entry_index_ != -1 && | 1078 (transient_entry_index_ != -1 && |
1079 transient_entry_index_ == GetEntryCount() - 1) || | 1079 transient_entry_index_ == GetEntryCount() - 1) || |
1080 (pending_entry_ && (pending_entry_index_ == -1 || | 1080 (pending_entry_ && (pending_entry_index_ == -1 || |
1081 pending_entry_index_ == GetEntryCount() - 1)) || | 1081 pending_entry_index_ == GetEntryCount() - 1)) || |
1082 (!pending_entry_ && last_committed_entry_index_ == GetEntryCount() - 1)); | 1082 (!pending_entry_ && last_committed_entry_index_ == GetEntryCount() - 1)); |
1083 | 1083 |
1084 // Remove all the entries leaving the active entry. | 1084 // Remove all the entries leaving the active entry. |
(...skipping 20 matching lines...) Expand all Loading... |
1105 if (pending_entry_index_ != -1) | 1105 if (pending_entry_index_ != -1) |
1106 pending_entry_index_ = GetEntryCount() - 1; | 1106 pending_entry_index_ = GetEntryCount() - 1; |
1107 if (transient_entry_index_ != -1) { | 1107 if (transient_entry_index_ != -1) { |
1108 // There's a transient entry. In this case we want the last committed to | 1108 // There's a transient entry. In this case we want the last committed to |
1109 // point to the previous entry. | 1109 // point to the previous entry. |
1110 transient_entry_index_ = GetEntryCount() - 1; | 1110 transient_entry_index_ = GetEntryCount() - 1; |
1111 if (last_committed_entry_index_ != -1) | 1111 if (last_committed_entry_index_ != -1) |
1112 last_committed_entry_index_--; | 1112 last_committed_entry_index_--; |
1113 } | 1113 } |
1114 | 1114 |
1115 tab_contents_->SetHistoryLengthAndPrune(site_instance.get(), | 1115 web_contents_->SetHistoryLengthAndPrune(site_instance.get(), |
1116 max_source_index, | 1116 max_source_index, |
1117 minimum_page_id); | 1117 minimum_page_id); |
1118 | 1118 |
1119 // Copy the max page id map from the old tab to the new tab. This ensures | 1119 // Copy the max page id map from the old tab to the new tab. This ensures |
1120 // that new and existing navigations in the tab's current SiteInstances | 1120 // that new and existing navigations in the tab's current SiteInstances |
1121 // are identified properly. | 1121 // are identified properly. |
1122 tab_contents_->CopyMaxPageIDsFrom(source->tab_contents()); | 1122 web_contents_->CopyMaxPageIDsFrom(source->web_contents()); |
1123 | 1123 |
1124 // If there is a last committed entry, be sure to include it in the new | 1124 // If there is a last committed entry, be sure to include it in the new |
1125 // max page ID map. | 1125 // max page ID map. |
1126 if (max_page_id > -1) { | 1126 if (max_page_id > -1) { |
1127 tab_contents_->UpdateMaxPageIDForSiteInstance(site_instance.get(), | 1127 web_contents_->UpdateMaxPageIDForSiteInstance(site_instance.get(), |
1128 max_page_id); | 1128 max_page_id); |
1129 } | 1129 } |
1130 } | 1130 } |
1131 | 1131 |
1132 void NavigationControllerImpl::PruneAllButActive() { | 1132 void NavigationControllerImpl::PruneAllButActive() { |
1133 if (transient_entry_index_ != -1) { | 1133 if (transient_entry_index_ != -1) { |
1134 // There is a transient entry. Prune up to it. | 1134 // There is a transient entry. Prune up to it. |
1135 DCHECK_EQ(GetEntryCount() - 1, transient_entry_index_); | 1135 DCHECK_EQ(GetEntryCount() - 1, transient_entry_index_); |
1136 entries_.erase(entries_.begin(), entries_.begin() + transient_entry_index_); | 1136 entries_.erase(entries_.begin(), entries_.begin() + transient_entry_index_); |
1137 transient_entry_index_ = 0; | 1137 transient_entry_index_ = 0; |
(...skipping 14 matching lines...) Expand all Loading... |
1152 entries_.erase(entries_.begin() + 1, entries_.end()); | 1152 entries_.erase(entries_.begin() + 1, entries_.end()); |
1153 pending_entry_index_ = 0; | 1153 pending_entry_index_ = 0; |
1154 last_committed_entry_index_ = 0; | 1154 last_committed_entry_index_ = 0; |
1155 } else { | 1155 } else { |
1156 // There is a pending_entry, but it's not in entries_. | 1156 // There is a pending_entry, but it's not in entries_. |
1157 pending_entry_index_ = -1; | 1157 pending_entry_index_ = -1; |
1158 last_committed_entry_index_ = -1; | 1158 last_committed_entry_index_ = -1; |
1159 entries_.clear(); | 1159 entries_.clear(); |
1160 } | 1160 } |
1161 | 1161 |
1162 if (tab_contents_->GetInterstitialPage()) { | 1162 if (web_contents_->GetInterstitialPage()) { |
1163 // Normally the interstitial page hides itself if the user doesn't proceeed. | 1163 // Normally the interstitial page hides itself if the user doesn't proceeed. |
1164 // This would result in showing a NavigationEntry we just removed. Set this | 1164 // This would result in showing a NavigationEntry we just removed. Set this |
1165 // so the interstitial triggers a reload if the user doesn't proceed. | 1165 // so the interstitial triggers a reload if the user doesn't proceed. |
1166 static_cast<InterstitialPageImpl*>(tab_contents_->GetInterstitialPage())-> | 1166 static_cast<InterstitialPageImpl*>(web_contents_->GetInterstitialPage())-> |
1167 set_reload_on_dont_proceed(true); | 1167 set_reload_on_dont_proceed(true); |
1168 } | 1168 } |
1169 } | 1169 } |
1170 | 1170 |
1171 void NavigationControllerImpl::SetMaxRestoredPageID(int32 max_id) { | 1171 void NavigationControllerImpl::SetMaxRestoredPageID(int32 max_id) { |
1172 max_restored_page_id_ = max_id; | 1172 max_restored_page_id_ = max_id; |
1173 } | 1173 } |
1174 | 1174 |
1175 int32 NavigationControllerImpl::GetMaxRestoredPageID() const { | 1175 int32 NavigationControllerImpl::GetMaxRestoredPageID() const { |
1176 return max_restored_page_id_; | 1176 return max_restored_page_id_; |
(...skipping 19 matching lines...) Expand all Loading... |
1196 last_committed_entry_index_--; | 1196 last_committed_entry_index_--; |
1197 } | 1197 } |
1198 | 1198 |
1199 void NavigationControllerImpl::DiscardNonCommittedEntries() { | 1199 void NavigationControllerImpl::DiscardNonCommittedEntries() { |
1200 bool transient = transient_entry_index_ != -1; | 1200 bool transient = transient_entry_index_ != -1; |
1201 DiscardNonCommittedEntriesInternal(); | 1201 DiscardNonCommittedEntriesInternal(); |
1202 | 1202 |
1203 // If there was a transient entry, invalidate everything so the new active | 1203 // If there was a transient entry, invalidate everything so the new active |
1204 // entry state is shown. | 1204 // entry state is shown. |
1205 if (transient) { | 1205 if (transient) { |
1206 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); | 1206 web_contents_->NotifyNavigationStateChanged(kInvalidateAll); |
1207 } | 1207 } |
1208 } | 1208 } |
1209 | 1209 |
1210 NavigationEntry* NavigationControllerImpl::GetPendingEntry() const { | 1210 NavigationEntry* NavigationControllerImpl::GetPendingEntry() const { |
1211 return pending_entry_; | 1211 return pending_entry_; |
1212 } | 1212 } |
1213 | 1213 |
1214 int NavigationControllerImpl::GetPendingEntryIndex() const { | 1214 int NavigationControllerImpl::GetPendingEntryIndex() const { |
1215 return pending_entry_index_; | 1215 return pending_entry_index_; |
1216 } | 1216 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1249 if (num_pruned > 0) // Only notify if we did prune something. | 1249 if (num_pruned > 0) // Only notify if we did prune something. |
1250 NotifyPrunedEntries(this, false, num_pruned); | 1250 NotifyPrunedEntries(this, false, num_pruned); |
1251 } | 1251 } |
1252 | 1252 |
1253 PruneOldestEntryIfFull(); | 1253 PruneOldestEntryIfFull(); |
1254 | 1254 |
1255 entries_.push_back(linked_ptr<NavigationEntryImpl>(entry)); | 1255 entries_.push_back(linked_ptr<NavigationEntryImpl>(entry)); |
1256 last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1; | 1256 last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1; |
1257 | 1257 |
1258 // This is a new page ID, so we need everybody to know about it. | 1258 // This is a new page ID, so we need everybody to know about it. |
1259 tab_contents_->UpdateMaxPageID(entry->GetPageID()); | 1259 web_contents_->UpdateMaxPageID(entry->GetPageID()); |
1260 } | 1260 } |
1261 | 1261 |
1262 void NavigationControllerImpl::PruneOldestEntryIfFull() { | 1262 void NavigationControllerImpl::PruneOldestEntryIfFull() { |
1263 if (entries_.size() >= max_entry_count()) { | 1263 if (entries_.size() >= max_entry_count()) { |
1264 DCHECK_EQ(max_entry_count(), entries_.size()); | 1264 DCHECK_EQ(max_entry_count(), entries_.size()); |
1265 DCHECK(last_committed_entry_index_ > 0); | 1265 DCHECK(last_committed_entry_index_ > 0); |
1266 RemoveEntryAtIndex(0); | 1266 RemoveEntryAtIndex(0); |
1267 NotifyPrunedEntries(this, true, 1); | 1267 NotifyPrunedEntries(this, true, 1); |
1268 } | 1268 } |
1269 } | 1269 } |
1270 | 1270 |
1271 void NavigationControllerImpl::NavigateToPendingEntry(ReloadType reload_type) { | 1271 void NavigationControllerImpl::NavigateToPendingEntry(ReloadType reload_type) { |
1272 needs_reload_ = false; | 1272 needs_reload_ = false; |
1273 | 1273 |
1274 // If we were navigating to a slow-to-commit page, and the user performs | 1274 // If we were navigating to a slow-to-commit page, and the user performs |
1275 // a session history navigation to the last committed page, RenderViewHost | 1275 // a session history navigation to the last committed page, RenderViewHost |
1276 // will force the throbber to start, but WebKit will essentially ignore the | 1276 // will force the throbber to start, but WebKit will essentially ignore the |
1277 // navigation, and won't send a message to stop the throbber. To prevent this | 1277 // navigation, and won't send a message to stop the throbber. To prevent this |
1278 // from happening, we drop the navigation here and stop the slow-to-commit | 1278 // from happening, we drop the navigation here and stop the slow-to-commit |
1279 // page from loading (which would normally happen during the navigation). | 1279 // page from loading (which would normally happen during the navigation). |
1280 if (pending_entry_index_ != -1 && | 1280 if (pending_entry_index_ != -1 && |
1281 pending_entry_index_ == last_committed_entry_index_ && | 1281 pending_entry_index_ == last_committed_entry_index_ && |
1282 (entries_[pending_entry_index_]->restore_type() == | 1282 (entries_[pending_entry_index_]->restore_type() == |
1283 NavigationEntryImpl::RESTORE_NONE) && | 1283 NavigationEntryImpl::RESTORE_NONE) && |
1284 (entries_[pending_entry_index_]->GetTransitionType() & | 1284 (entries_[pending_entry_index_]->GetTransitionType() & |
1285 content::PAGE_TRANSITION_FORWARD_BACK)) { | 1285 content::PAGE_TRANSITION_FORWARD_BACK)) { |
1286 tab_contents_->Stop(); | 1286 web_contents_->Stop(); |
1287 | 1287 |
1288 // If an interstitial page is showing, we want to close it to get back | 1288 // If an interstitial page is showing, we want to close it to get back |
1289 // to what was showing before. | 1289 // to what was showing before. |
1290 if (tab_contents_->GetInterstitialPage()) | 1290 if (web_contents_->GetInterstitialPage()) |
1291 tab_contents_->GetInterstitialPage()->DontProceed(); | 1291 web_contents_->GetInterstitialPage()->DontProceed(); |
1292 | 1292 |
1293 DiscardNonCommittedEntries(); | 1293 DiscardNonCommittedEntries(); |
1294 return; | 1294 return; |
1295 } | 1295 } |
1296 | 1296 |
1297 // If an interstitial page is showing, the previous renderer is blocked and | 1297 // If an interstitial page is showing, the previous renderer is blocked and |
1298 // cannot make new requests. Unblock (and disable) it to allow this | 1298 // cannot make new requests. Unblock (and disable) it to allow this |
1299 // navigation to succeed. The interstitial will stay visible until the | 1299 // navigation to succeed. The interstitial will stay visible until the |
1300 // resulting DidNavigate. | 1300 // resulting DidNavigate. |
1301 if (tab_contents_->GetInterstitialPage()) { | 1301 if (web_contents_->GetInterstitialPage()) { |
1302 static_cast<InterstitialPageImpl*>(tab_contents_->GetInterstitialPage())-> | 1302 static_cast<InterstitialPageImpl*>(web_contents_->GetInterstitialPage())-> |
1303 CancelForNavigation(); | 1303 CancelForNavigation(); |
1304 } | 1304 } |
1305 | 1305 |
1306 // For session history navigations only the pending_entry_index_ is set. | 1306 // For session history navigations only the pending_entry_index_ is set. |
1307 if (!pending_entry_) { | 1307 if (!pending_entry_) { |
1308 DCHECK_NE(pending_entry_index_, -1); | 1308 DCHECK_NE(pending_entry_index_, -1); |
1309 pending_entry_ = entries_[pending_entry_index_].get(); | 1309 pending_entry_ = entries_[pending_entry_index_].get(); |
1310 } | 1310 } |
1311 | 1311 |
1312 if (!tab_contents_->NavigateToPendingEntry(reload_type)) | 1312 if (!web_contents_->NavigateToPendingEntry(reload_type)) |
1313 DiscardNonCommittedEntries(); | 1313 DiscardNonCommittedEntries(); |
1314 | 1314 |
1315 // If the entry is being restored and doesn't have a SiteInstance yet, fill | 1315 // If the entry is being restored and doesn't have a SiteInstance yet, fill |
1316 // it in now that we know. This allows us to find the entry when it commits. | 1316 // it in now that we know. This allows us to find the entry when it commits. |
1317 // This works for browser-initiated navigations. We handle renderer-initiated | 1317 // This works for browser-initiated navigations. We handle renderer-initiated |
1318 // navigations to restored entries in TabContents::OnGoToEntryAtOffset. | 1318 // navigations to restored entries in WebContentsImpl::OnGoToEntryAtOffset. |
1319 if (pending_entry_ && !pending_entry_->site_instance() && | 1319 if (pending_entry_ && !pending_entry_->site_instance() && |
1320 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE) { | 1320 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE) { |
1321 pending_entry_->set_site_instance(static_cast<SiteInstanceImpl*>( | 1321 pending_entry_->set_site_instance(static_cast<SiteInstanceImpl*>( |
1322 tab_contents_->GetPendingSiteInstance())); | 1322 web_contents_->GetPendingSiteInstance())); |
1323 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE); | 1323 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE); |
1324 } | 1324 } |
1325 } | 1325 } |
1326 | 1326 |
1327 void NavigationControllerImpl::NotifyNavigationEntryCommitted( | 1327 void NavigationControllerImpl::NotifyNavigationEntryCommitted( |
1328 content::LoadCommittedDetails* details) { | 1328 content::LoadCommittedDetails* details) { |
1329 details->entry = GetActiveEntry(); | 1329 details->entry = GetActiveEntry(); |
1330 content::NotificationDetails notification_details = | 1330 content::NotificationDetails notification_details = |
1331 content::Details<content::LoadCommittedDetails>(details); | 1331 content::Details<content::LoadCommittedDetails>(details); |
1332 | 1332 |
1333 // We need to notify the ssl_manager_ before the tab_contents_ so the | 1333 // We need to notify the ssl_manager_ before the web_contents_ so the |
1334 // location bar will have up-to-date information about the security style | 1334 // location bar will have up-to-date information about the security style |
1335 // when it wants to draw. See http://crbug.com/11157 | 1335 // when it wants to draw. See http://crbug.com/11157 |
1336 ssl_manager_.DidCommitProvisionalLoad(notification_details); | 1336 ssl_manager_.DidCommitProvisionalLoad(notification_details); |
1337 | 1337 |
1338 // TODO(pkasting): http://b/1113079 Probably these explicit notification paths | 1338 // TODO(pkasting): http://b/1113079 Probably these explicit notification paths |
1339 // should be removed, and interested parties should just listen for the | 1339 // should be removed, and interested parties should just listen for the |
1340 // notification below instead. | 1340 // notification below instead. |
1341 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); | 1341 web_contents_->NotifyNavigationStateChanged(kInvalidateAll); |
1342 | 1342 |
1343 content::NotificationService::current()->Notify( | 1343 content::NotificationService::current()->Notify( |
1344 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 1344 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
1345 content::Source<NavigationController>(this), | 1345 content::Source<NavigationController>(this), |
1346 notification_details); | 1346 notification_details); |
1347 } | 1347 } |
1348 | 1348 |
1349 // static | 1349 // static |
1350 size_t NavigationControllerImpl::max_entry_count() { | 1350 size_t NavigationControllerImpl::max_entry_count() { |
1351 if (max_entry_count_for_testing_ != kMaxEntryCountForTestingNotSet) | 1351 if (max_entry_count_for_testing_ != kMaxEntryCountForTestingNotSet) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1432 for (int i = 0; i < max_index; i++) { | 1432 for (int i = 0; i < max_index; i++) { |
1433 // When cloning a tab, copy all entries except interstitial pages | 1433 // When cloning a tab, copy all entries except interstitial pages |
1434 if (source.entries_[i].get()->GetPageType() != | 1434 if (source.entries_[i].get()->GetPageType() != |
1435 content::PAGE_TYPE_INTERSTITIAL) { | 1435 content::PAGE_TYPE_INTERSTITIAL) { |
1436 entries_.insert(entries_.begin() + insert_index++, | 1436 entries_.insert(entries_.begin() + insert_index++, |
1437 linked_ptr<NavigationEntryImpl>( | 1437 linked_ptr<NavigationEntryImpl>( |
1438 new NavigationEntryImpl(*source.entries_[i]))); | 1438 new NavigationEntryImpl(*source.entries_[i]))); |
1439 } | 1439 } |
1440 } | 1440 } |
1441 } | 1441 } |
OLD | NEW |