| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 break; // Fall through to rest of function. | 220 break; // Fall through to rest of function. |
| 221 } | 221 } |
| 222 | 222 |
| 223 if (entry.restore_type() == NavigationEntry::RESTORE_LAST_SESSION && | 223 if (entry.restore_type() == NavigationEntry::RESTORE_LAST_SESSION && |
| 224 profile->DidLastSessionExitCleanly()) | 224 profile->DidLastSessionExitCleanly()) |
| 225 return ViewMsg_Navigate_Params::RESTORE; | 225 return ViewMsg_Navigate_Params::RESTORE; |
| 226 | 226 |
| 227 return ViewMsg_Navigate_Params::NORMAL; | 227 return ViewMsg_Navigate_Params::NORMAL; |
| 228 } | 228 } |
| 229 | 229 |
| 230 void MakeNavigateParams(const NavigationEntry& entry, | 230 void MakeNavigateParams(const NavigationController& controller, |
| 231 const NavigationController& controller, | |
| 232 NavigationController::ReloadType reload_type, | 231 NavigationController::ReloadType reload_type, |
| 233 ViewMsg_Navigate_Params* params) { | 232 ViewMsg_Navigate_Params* params) { |
| 233 const NavigationEntry& entry = *controller.pending_entry(); |
| 234 params->page_id = entry.page_id(); | 234 params->page_id = entry.page_id(); |
| 235 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); | 235 params->pending_history_list_offset = controller.pending_entry_index(); |
| 236 params->current_history_list_offset = controller.last_committed_entry_index(); | 236 params->current_history_list_offset = controller.last_committed_entry_index(); |
| 237 params->current_history_list_length = controller.entry_count(); | 237 params->current_history_list_length = controller.entry_count(); |
| 238 params->url = entry.url(); | 238 params->url = entry.url(); |
| 239 params->referrer = entry.referrer(); | 239 params->referrer = entry.referrer(); |
| 240 params->transition = entry.transition_type(); | 240 params->transition = entry.transition_type(); |
| 241 params->state = entry.content_state(); | 241 params->state = entry.content_state(); |
| 242 params->navigation_type = | 242 params->navigation_type = |
| 243 GetNavigationType(controller.profile(), entry, reload_type); | 243 GetNavigationType(controller.profile(), entry, reload_type); |
| 244 params->request_time = base::Time::Now(); | 244 params->request_time = base::Time::Now(); |
| 245 } | 245 } |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 | 842 |
| 843 void TabContents::OpenURL(const GURL& url, const GURL& referrer, | 843 void TabContents::OpenURL(const GURL& url, const GURL& referrer, |
| 844 WindowOpenDisposition disposition, | 844 WindowOpenDisposition disposition, |
| 845 PageTransition::Type transition) { | 845 PageTransition::Type transition) { |
| 846 if (delegate_) | 846 if (delegate_) |
| 847 delegate_->OpenURLFromTab(this, url, referrer, disposition, transition); | 847 delegate_->OpenURLFromTab(this, url, referrer, disposition, transition); |
| 848 } | 848 } |
| 849 | 849 |
| 850 bool TabContents::NavigateToPendingEntry( | 850 bool TabContents::NavigateToPendingEntry( |
| 851 NavigationController::ReloadType reload_type) { | 851 NavigationController::ReloadType reload_type) { |
| 852 return NavigateToEntry(*controller_.pending_entry(), reload_type); | 852 const NavigationEntry& entry = *controller_.pending_entry(); |
| 853 } | |
| 854 | 853 |
| 855 bool TabContents::NavigateToEntry( | |
| 856 const NavigationEntry& entry, | |
| 857 NavigationController::ReloadType reload_type) { | |
| 858 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); | 854 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); |
| 859 if (!dest_render_view_host) | 855 if (!dest_render_view_host) |
| 860 return false; // Unable to create the desired render view host. | 856 return false; // Unable to create the desired render view host. |
| 861 | 857 |
| 862 if (delegate_ && delegate_->ShouldEnablePreferredSizeNotifications()) { | 858 if (delegate_ && delegate_->ShouldEnablePreferredSizeNotifications()) { |
| 863 dest_render_view_host->EnablePreferredSizeChangedMode( | 859 dest_render_view_host->EnablePreferredSizeChangedMode( |
| 864 kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); | 860 kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); |
| 865 } | 861 } |
| 866 | 862 |
| 867 // For security, we should never send non-DOM-UI URLs (other than about:blank) | 863 // For security, we should never send non-DOM-UI URLs (other than about:blank) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 879 devtools_manager->OnNavigatingToPendingEntry(render_view_host(), | 875 devtools_manager->OnNavigatingToPendingEntry(render_view_host(), |
| 880 dest_render_view_host, | 876 dest_render_view_host, |
| 881 entry.url()); | 877 entry.url()); |
| 882 } | 878 } |
| 883 | 879 |
| 884 // Used for page load time metrics. | 880 // Used for page load time metrics. |
| 885 current_load_start_ = base::TimeTicks::Now(); | 881 current_load_start_ = base::TimeTicks::Now(); |
| 886 | 882 |
| 887 // Navigate in the desired RenderViewHost. | 883 // Navigate in the desired RenderViewHost. |
| 888 ViewMsg_Navigate_Params navigate_params; | 884 ViewMsg_Navigate_Params navigate_params; |
| 889 MakeNavigateParams(entry, controller_, reload_type, &navigate_params); | 885 MakeNavigateParams(controller_, reload_type, &navigate_params); |
| 890 dest_render_view_host->Navigate(navigate_params); | 886 dest_render_view_host->Navigate(navigate_params); |
| 891 | 887 |
| 892 if (entry.page_id() == -1) { | 888 if (entry.page_id() == -1) { |
| 893 // HACK!! This code suppresses javascript: URLs from being added to | 889 // HACK!! This code suppresses javascript: URLs from being added to |
| 894 // session history, which is what we want to do for javascript: URLs that | 890 // session history, which is what we want to do for javascript: URLs that |
| 895 // do not generate content. What we really need is a message from the | 891 // do not generate content. What we really need is a message from the |
| 896 // renderer telling us that a new page was not created. The same message | 892 // renderer telling us that a new page was not created. The same message |
| 897 // could be used for mailto: URLs and the like. | 893 // could be used for mailto: URLs and the like. |
| 898 if (entry.url().SchemeIs(chrome::kJavaScriptScheme)) | 894 if (entry.url().SchemeIs(chrome::kJavaScriptScheme)) |
| 899 return false; | 895 return false; |
| (...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1991 last_search_result_ = FindNotificationDetails(request_id, number_of_matches, | 1987 last_search_result_ = FindNotificationDetails(request_id, number_of_matches, |
| 1992 selection, active_match_ordinal, | 1988 selection, active_match_ordinal, |
| 1993 final_update); | 1989 final_update); |
| 1994 NotificationService::current()->Notify( | 1990 NotificationService::current()->Notify( |
| 1995 NotificationType::FIND_RESULT_AVAILABLE, | 1991 NotificationType::FIND_RESULT_AVAILABLE, |
| 1996 Source<TabContents>(this), | 1992 Source<TabContents>(this), |
| 1997 Details<FindNotificationDetails>(&last_search_result_)); | 1993 Details<FindNotificationDetails>(&last_search_result_)); |
| 1998 } | 1994 } |
| 1999 | 1995 |
| 2000 void TabContents::GoToEntryAtOffset(int offset) { | 1996 void TabContents::GoToEntryAtOffset(int offset) { |
| 2001 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) { | 1997 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) |
| 2002 NavigationEntry* entry = controller_.GetEntryAtOffset(offset); | 1998 controller_.GoToOffset(offset); |
| 2003 if (!entry) | |
| 2004 return; | |
| 2005 // Note that we don't call NavigationController::GotToOffset() as we don't | |
| 2006 // want to create a pending navigation entry (it might end up lingering | |
| 2007 // http://crbug.com/51680). | |
| 2008 NavigateToEntry(*entry, NavigationController::NO_RELOAD); | |
| 2009 } | |
| 2010 } | 1999 } |
| 2011 | 2000 |
| 2012 void TabContents::OnMissingPluginStatus(int status) { | 2001 void TabContents::OnMissingPluginStatus(int status) { |
| 2013 #if defined(OS_WIN) | 2002 #if defined(OS_WIN) |
| 2014 // TODO(PORT): pull in when plug-ins work | 2003 // TODO(PORT): pull in when plug-ins work |
| 2015 GetPluginInstaller()->OnMissingPluginStatus(status); | 2004 GetPluginInstaller()->OnMissingPluginStatus(status); |
| 2016 #endif | 2005 #endif |
| 2017 } | 2006 } |
| 2018 | 2007 |
| 2019 void TabContents::OnCrashedPlugin(const FilePath& plugin_path) { | 2008 void TabContents::OnCrashedPlugin(const FilePath& plugin_path) { |
| (...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3239 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save)); | 3228 AddInfoBar(new SavePasswordInfoBarDelegate(this, form_to_save)); |
| 3240 } | 3229 } |
| 3241 | 3230 |
| 3242 Profile* TabContents::GetProfileForPasswordManager() { | 3231 Profile* TabContents::GetProfileForPasswordManager() { |
| 3243 return profile(); | 3232 return profile(); |
| 3244 } | 3233 } |
| 3245 | 3234 |
| 3246 bool TabContents::DidLastPageLoadEncounterSSLErrors() { | 3235 bool TabContents::DidLastPageLoadEncounterSSLErrors() { |
| 3247 return controller().ssl_manager()->ProcessedSSLErrorFromRequest(); | 3236 return controller().ssl_manager()->ProcessedSSLErrorFromRequest(); |
| 3248 } | 3237 } |
| OLD | NEW |