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 NavigationEntry& entry, | 227 void MakeNavigateParams(const NavigationController& controller, |
228 const NavigationController& controller, | |
229 NavigationController::ReloadType reload_type, | 228 NavigationController::ReloadType reload_type, |
230 ViewMsg_Navigate_Params* params) { | 229 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.GetIndexOfEntry(&entry); | 232 params->pending_history_list_offset = controller.pending_entry_index(); |
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 return NavigateToEntry(*controller_.pending_entry(), reload_type); | 847 const NavigationEntry& entry = *controller_.pending_entry(); |
848 } | |
849 | 848 |
850 bool TabContents::NavigateToEntry( | |
851 const NavigationEntry& entry, | |
852 NavigationController::ReloadType reload_type) { | |
853 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); | 849 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); |
854 if (!dest_render_view_host) | 850 if (!dest_render_view_host) |
855 return false; // Unable to create the desired render view host. | 851 return false; // Unable to create the desired render view host. |
856 | 852 |
857 if (delegate_ && delegate_->ShouldEnablePreferredSizeNotifications()) { | 853 if (delegate_ && delegate_->ShouldEnablePreferredSizeNotifications()) { |
858 dest_render_view_host->EnablePreferredSizeChangedMode( | 854 dest_render_view_host->EnablePreferredSizeChangedMode( |
859 kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); | 855 kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); |
860 } | 856 } |
861 | 857 |
862 // For security, we should never send non-DOM-UI URLs (other than about:blank) | 858 // For security, we should never send non-DOM-UI URLs (other than about:blank) |
(...skipping 11 matching lines...) Expand all Loading... |
874 devtools_manager->OnNavigatingToPendingEntry(render_view_host(), | 870 devtools_manager->OnNavigatingToPendingEntry(render_view_host(), |
875 dest_render_view_host, | 871 dest_render_view_host, |
876 entry.url()); | 872 entry.url()); |
877 } | 873 } |
878 | 874 |
879 // Used for page load time metrics. | 875 // Used for page load time metrics. |
880 current_load_start_ = base::TimeTicks::Now(); | 876 current_load_start_ = base::TimeTicks::Now(); |
881 | 877 |
882 // Navigate in the desired RenderViewHost. | 878 // Navigate in the desired RenderViewHost. |
883 ViewMsg_Navigate_Params navigate_params; | 879 ViewMsg_Navigate_Params navigate_params; |
884 MakeNavigateParams(entry, controller_, reload_type, &navigate_params); | 880 MakeNavigateParams(controller_, reload_type, &navigate_params); |
885 dest_render_view_host->Navigate(navigate_params); | 881 dest_render_view_host->Navigate(navigate_params); |
886 | 882 |
887 if (entry.page_id() == -1) { | 883 if (entry.page_id() == -1) { |
888 // HACK!! This code suppresses javascript: URLs from being added to | 884 // HACK!! This code suppresses javascript: URLs from being added to |
889 // session history, which is what we want to do for javascript: URLs that | 885 // session history, which is what we want to do for javascript: URLs that |
890 // do not generate content. What we really need is a message from the | 886 // do not generate content. What we really need is a message from the |
891 // renderer telling us that a new page was not created. The same message | 887 // renderer telling us that a new page was not created. The same message |
892 // could be used for mailto: URLs and the like. | 888 // could be used for mailto: URLs and the like. |
893 if (entry.url().SchemeIs(chrome::kJavaScriptScheme)) | 889 if (entry.url().SchemeIs(chrome::kJavaScriptScheme)) |
894 return false; | 890 return false; |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1981 last_search_result_ = FindNotificationDetails(request_id, number_of_matches, | 1977 last_search_result_ = FindNotificationDetails(request_id, number_of_matches, |
1982 selection, active_match_ordinal, | 1978 selection, active_match_ordinal, |
1983 final_update); | 1979 final_update); |
1984 NotificationService::current()->Notify( | 1980 NotificationService::current()->Notify( |
1985 NotificationType::FIND_RESULT_AVAILABLE, | 1981 NotificationType::FIND_RESULT_AVAILABLE, |
1986 Source<TabContents>(this), | 1982 Source<TabContents>(this), |
1987 Details<FindNotificationDetails>(&last_search_result_)); | 1983 Details<FindNotificationDetails>(&last_search_result_)); |
1988 } | 1984 } |
1989 | 1985 |
1990 void TabContents::GoToEntryAtOffset(int offset) { | 1986 void TabContents::GoToEntryAtOffset(int offset) { |
1991 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) { | 1987 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) |
1992 NavigationEntry* entry = controller_.GetEntryAtOffset(offset); | 1988 controller_.GoToOffset(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 } | |
2000 } | 1989 } |
2001 | 1990 |
2002 void TabContents::OnMissingPluginStatus(int status) { | 1991 void TabContents::OnMissingPluginStatus(int status) { |
2003 #if defined(OS_WIN) | 1992 #if defined(OS_WIN) |
2004 // TODO(PORT): pull in when plug-ins work | 1993 // TODO(PORT): pull in when plug-ins work |
2005 GetPluginInstaller()->OnMissingPluginStatus(status); | 1994 GetPluginInstaller()->OnMissingPluginStatus(status); |
2006 #endif | 1995 #endif |
2007 } | 1996 } |
2008 | 1997 |
2009 void TabContents::OnCrashedPlugin(const FilePath& plugin_path) { | 1998 void TabContents::OnCrashedPlugin(const FilePath& plugin_path) { |
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3254 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save)); | 3243 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save)); |
3255 } | 3244 } |
3256 | 3245 |
3257 Profile* TabContents::GetProfileForPasswordManager() { | 3246 Profile* TabContents::GetProfileForPasswordManager() { |
3258 return profile(); | 3247 return profile(); |
3259 } | 3248 } |
3260 | 3249 |
3261 bool TabContents::DidLastPageLoadEncounterSSLErrors() { | 3250 bool TabContents::DidLastPageLoadEncounterSSLErrors() { |
3262 return controller().ssl_manager()->ProcessedSSLErrorFromRequest(); | 3251 return controller().ssl_manager()->ProcessedSSLErrorFromRequest(); |
3263 } | 3252 } |
OLD | NEW |