OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/tab_contents/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.h" |
6 | 6 |
7 #if defined(OS_CHROMEOS) | 7 #if defined(OS_CHROMEOS) |
8 // For GdkScreen | 8 // For GdkScreen |
9 #include <gdk/gdk.h> | 9 #include <gdk/gdk.h> |
10 #endif // defined(OS_CHROMEOS) | 10 #endif // defined(OS_CHROMEOS) |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 break; // Fall through to rest of function. | 217 break; // Fall through to rest of function. |
218 } | 218 } |
219 | 219 |
220 if (entry.restore_type() == NavigationEntry::RESTORE_LAST_SESSION && | 220 if (entry.restore_type() == NavigationEntry::RESTORE_LAST_SESSION && |
221 profile->DidLastSessionExitCleanly()) | 221 profile->DidLastSessionExitCleanly()) |
222 return ViewMsg_Navigate_Params::RESTORE; | 222 return ViewMsg_Navigate_Params::RESTORE; |
223 | 223 |
224 return ViewMsg_Navigate_Params::NORMAL; | 224 return ViewMsg_Navigate_Params::NORMAL; |
225 } | 225 } |
226 | 226 |
227 void MakeNavigateParams(const NavigationController& controller, | 227 void MakeNavigateParams(const NavigationEntry& entry, |
| 228 const NavigationController& controller, |
228 NavigationController::ReloadType reload_type, | 229 NavigationController::ReloadType reload_type, |
229 ViewMsg_Navigate_Params* params) { | 230 ViewMsg_Navigate_Params* params) { |
230 const NavigationEntry& entry = *controller.pending_entry(); | |
231 params->page_id = entry.page_id(); | 231 params->page_id = entry.page_id(); |
232 params->pending_history_list_offset = controller.pending_entry_index(); | 232 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); |
233 params->current_history_list_offset = controller.last_committed_entry_index(); | 233 params->current_history_list_offset = controller.last_committed_entry_index(); |
234 params->current_history_list_length = controller.entry_count(); | 234 params->current_history_list_length = controller.entry_count(); |
235 params->url = entry.url(); | 235 params->url = entry.url(); |
236 params->referrer = entry.referrer(); | 236 params->referrer = entry.referrer(); |
237 params->transition = entry.transition_type(); | 237 params->transition = entry.transition_type(); |
238 params->state = entry.content_state(); | 238 params->state = entry.content_state(); |
239 params->navigation_type = | 239 params->navigation_type = |
240 GetNavigationType(controller.profile(), entry, reload_type); | 240 GetNavigationType(controller.profile(), entry, reload_type); |
241 params->request_time = base::Time::Now(); | 241 params->request_time = base::Time::Now(); |
242 } | 242 } |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 | 837 |
838 void TabContents::OpenURL(const GURL& url, const GURL& referrer, | 838 void TabContents::OpenURL(const GURL& url, const GURL& referrer, |
839 WindowOpenDisposition disposition, | 839 WindowOpenDisposition disposition, |
840 PageTransition::Type transition) { | 840 PageTransition::Type transition) { |
841 if (delegate_) | 841 if (delegate_) |
842 delegate_->OpenURLFromTab(this, url, referrer, disposition, transition); | 842 delegate_->OpenURLFromTab(this, url, referrer, disposition, transition); |
843 } | 843 } |
844 | 844 |
845 bool TabContents::NavigateToPendingEntry( | 845 bool TabContents::NavigateToPendingEntry( |
846 NavigationController::ReloadType reload_type) { | 846 NavigationController::ReloadType reload_type) { |
847 const NavigationEntry& entry = *controller_.pending_entry(); | 847 return NavigateToEntry(*controller_.pending_entry(), reload_type); |
| 848 } |
848 | 849 |
| 850 bool TabContents::NavigateToEntry( |
| 851 const NavigationEntry& entry, |
| 852 NavigationController::ReloadType reload_type) { |
849 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); | 853 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); |
850 if (!dest_render_view_host) | 854 if (!dest_render_view_host) |
851 return false; // Unable to create the desired render view host. | 855 return false; // Unable to create the desired render view host. |
852 | 856 |
853 if (delegate_ && delegate_->ShouldEnablePreferredSizeNotifications()) { | 857 if (delegate_ && delegate_->ShouldEnablePreferredSizeNotifications()) { |
854 dest_render_view_host->EnablePreferredSizeChangedMode( | 858 dest_render_view_host->EnablePreferredSizeChangedMode( |
855 kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); | 859 kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); |
856 } | 860 } |
857 | 861 |
858 // For security, we should never send non-DOM-UI URLs (other than about:blank) | 862 // For security, we should never send non-DOM-UI URLs (other than about:blank) |
(...skipping 11 matching lines...) Expand all Loading... |
870 devtools_manager->OnNavigatingToPendingEntry(render_view_host(), | 874 devtools_manager->OnNavigatingToPendingEntry(render_view_host(), |
871 dest_render_view_host, | 875 dest_render_view_host, |
872 entry.url()); | 876 entry.url()); |
873 } | 877 } |
874 | 878 |
875 // Used for page load time metrics. | 879 // Used for page load time metrics. |
876 current_load_start_ = base::TimeTicks::Now(); | 880 current_load_start_ = base::TimeTicks::Now(); |
877 | 881 |
878 // Navigate in the desired RenderViewHost. | 882 // Navigate in the desired RenderViewHost. |
879 ViewMsg_Navigate_Params navigate_params; | 883 ViewMsg_Navigate_Params navigate_params; |
880 MakeNavigateParams(controller_, reload_type, &navigate_params); | 884 MakeNavigateParams(entry, controller_, reload_type, &navigate_params); |
881 dest_render_view_host->Navigate(navigate_params); | 885 dest_render_view_host->Navigate(navigate_params); |
882 | 886 |
883 if (entry.page_id() == -1) { | 887 if (entry.page_id() == -1) { |
884 // HACK!! This code suppresses javascript: URLs from being added to | 888 // HACK!! This code suppresses javascript: URLs from being added to |
885 // session history, which is what we want to do for javascript: URLs that | 889 // session history, which is what we want to do for javascript: URLs that |
886 // do not generate content. What we really need is a message from the | 890 // do not generate content. What we really need is a message from the |
887 // renderer telling us that a new page was not created. The same message | 891 // renderer telling us that a new page was not created. The same message |
888 // could be used for mailto: URLs and the like. | 892 // could be used for mailto: URLs and the like. |
889 if (entry.url().SchemeIs(chrome::kJavaScriptScheme)) | 893 if (entry.url().SchemeIs(chrome::kJavaScriptScheme)) |
890 return false; | 894 return false; |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1977 last_search_result_ = FindNotificationDetails(request_id, number_of_matches, | 1981 last_search_result_ = FindNotificationDetails(request_id, number_of_matches, |
1978 selection, active_match_ordinal, | 1982 selection, active_match_ordinal, |
1979 final_update); | 1983 final_update); |
1980 NotificationService::current()->Notify( | 1984 NotificationService::current()->Notify( |
1981 NotificationType::FIND_RESULT_AVAILABLE, | 1985 NotificationType::FIND_RESULT_AVAILABLE, |
1982 Source<TabContents>(this), | 1986 Source<TabContents>(this), |
1983 Details<FindNotificationDetails>(&last_search_result_)); | 1987 Details<FindNotificationDetails>(&last_search_result_)); |
1984 } | 1988 } |
1985 | 1989 |
1986 void TabContents::GoToEntryAtOffset(int offset) { | 1990 void TabContents::GoToEntryAtOffset(int offset) { |
1987 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) | 1991 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) { |
1988 controller_.GoToOffset(offset); | 1992 NavigationEntry* entry = controller_.GetEntryAtOffset(offset); |
| 1993 if (!entry) |
| 1994 return; |
| 1995 // Note that we don't call NavigationController::GotToOffset() as we don't |
| 1996 // want to create a pending navigation entry (it might end up lingering |
| 1997 // http://crbug.com/51680). |
| 1998 NavigateToEntry(*entry, NavigationController::NO_RELOAD); |
| 1999 } |
1989 } | 2000 } |
1990 | 2001 |
1991 void TabContents::OnMissingPluginStatus(int status) { | 2002 void TabContents::OnMissingPluginStatus(int status) { |
1992 #if defined(OS_WIN) | 2003 #if defined(OS_WIN) |
1993 // TODO(PORT): pull in when plug-ins work | 2004 // TODO(PORT): pull in when plug-ins work |
1994 GetPluginInstaller()->OnMissingPluginStatus(status); | 2005 GetPluginInstaller()->OnMissingPluginStatus(status); |
1995 #endif | 2006 #endif |
1996 } | 2007 } |
1997 | 2008 |
1998 void TabContents::OnCrashedPlugin(const FilePath& plugin_path) { | 2009 void TabContents::OnCrashedPlugin(const FilePath& plugin_path) { |
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3245 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save)); | 3256 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save)); |
3246 } | 3257 } |
3247 | 3258 |
3248 Profile* TabContents::GetProfileForPasswordManager() { | 3259 Profile* TabContents::GetProfileForPasswordManager() { |
3249 return profile(); | 3260 return profile(); |
3250 } | 3261 } |
3251 | 3262 |
3252 bool TabContents::DidLastPageLoadEncounterSSLErrors() { | 3263 bool TabContents::DidLastPageLoadEncounterSSLErrors() { |
3253 return controller().ssl_manager()->ProcessedSSLErrorFromRequest(); | 3264 return controller().ssl_manager()->ProcessedSSLErrorFromRequest(); |
3254 } | 3265 } |
OLD | NEW |