| 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 #include "app/gfx/text_elider.h" | 7 #include "app/gfx/text_elider.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 break; // Fall through to rest of function. | 197 break; // Fall through to rest of function. |
| 198 } | 198 } |
| 199 | 199 |
| 200 if (entry.restore_type() == NavigationEntry::RESTORE_LAST_SESSION && | 200 if (entry.restore_type() == NavigationEntry::RESTORE_LAST_SESSION && |
| 201 profile->DidLastSessionExitCleanly()) | 201 profile->DidLastSessionExitCleanly()) |
| 202 return ViewMsg_Navigate_Params::RESTORE; | 202 return ViewMsg_Navigate_Params::RESTORE; |
| 203 | 203 |
| 204 return ViewMsg_Navigate_Params::NORMAL; | 204 return ViewMsg_Navigate_Params::NORMAL; |
| 205 } | 205 } |
| 206 | 206 |
| 207 void MakeNavigateParams(Profile* profile, const NavigationEntry& entry, | 207 void MakeNavigateParams(const NavigationController& controller, |
| 208 NavigationController::ReloadType reload_type, | 208 NavigationController::ReloadType reload_type, |
| 209 ViewMsg_Navigate_Params* params) { | 209 ViewMsg_Navigate_Params* params) { |
| 210 const NavigationEntry& entry = *controller.pending_entry(); |
| 210 params->page_id = entry.page_id(); | 211 params->page_id = entry.page_id(); |
| 212 params->pending_history_list_offset = controller.pending_entry_index(); |
| 213 params->current_history_list_offset = controller.last_committed_entry_index(); |
| 214 params->current_history_list_length = controller.entry_count(); |
| 211 params->url = entry.url(); | 215 params->url = entry.url(); |
| 212 params->referrer = entry.referrer(); | 216 params->referrer = entry.referrer(); |
| 213 params->transition = entry.transition_type(); | 217 params->transition = entry.transition_type(); |
| 214 params->state = entry.content_state(); | 218 params->state = entry.content_state(); |
| 215 params->navigation_type = GetNavigationType(profile, entry, reload_type); | 219 params->navigation_type = |
| 220 GetNavigationType(controller.profile(), entry, reload_type); |
| 216 params->request_time = base::Time::Now(); | 221 params->request_time = base::Time::Now(); |
| 217 } | 222 } |
| 218 | 223 |
| 219 } // namespace | 224 } // namespace |
| 220 | 225 |
| 221 // ----------------------------------------------------------------------------- | 226 // ----------------------------------------------------------------------------- |
| 222 | 227 |
| 223 // static | 228 // static |
| 224 int TabContents::find_request_id_counter_ = -1; | 229 int TabContents::find_request_id_counter_ = -1; |
| 225 | 230 |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 NavigationController::ReloadType reload_type) { | 724 NavigationController::ReloadType reload_type) { |
| 720 const NavigationEntry& entry = *controller_.pending_entry(); | 725 const NavigationEntry& entry = *controller_.pending_entry(); |
| 721 | 726 |
| 722 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); | 727 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); |
| 723 if (!dest_render_view_host) | 728 if (!dest_render_view_host) |
| 724 return false; // Unable to create the desired render view host. | 729 return false; // Unable to create the desired render view host. |
| 725 | 730 |
| 726 // Tell DevTools agent that it is attached prior to the navigation. | 731 // Tell DevTools agent that it is attached prior to the navigation. |
| 727 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | 732 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); |
| 728 if (devtools_manager) { // NULL in unit tests. | 733 if (devtools_manager) { // NULL in unit tests. |
| 729 devtools_manager->OnNavigatingToPendingEntry( | 734 devtools_manager->OnNavigatingToPendingEntry(render_view_host(), |
| 730 render_view_host(), | 735 dest_render_view_host, |
| 731 dest_render_view_host, | 736 entry.url()); |
| 732 controller_.pending_entry()->url()); | |
| 733 } | 737 } |
| 734 | 738 |
| 735 // Used for page load time metrics. | 739 // Used for page load time metrics. |
| 736 current_load_start_ = base::TimeTicks::Now(); | 740 current_load_start_ = base::TimeTicks::Now(); |
| 737 | 741 |
| 738 // Navigate in the desired RenderViewHost. | 742 // Navigate in the desired RenderViewHost. |
| 739 ViewMsg_Navigate_Params navigate_params; | 743 ViewMsg_Navigate_Params navigate_params; |
| 740 MakeNavigateParams(profile(), entry, reload_type, &navigate_params); | 744 MakeNavigateParams(controller_, reload_type, &navigate_params); |
| 741 dest_render_view_host->Navigate(navigate_params); | 745 dest_render_view_host->Navigate(navigate_params); |
| 742 | 746 |
| 743 if (entry.page_id() == -1) { | 747 if (entry.page_id() == -1) { |
| 744 // HACK!! This code suppresses javascript: URLs from being added to | 748 // HACK!! This code suppresses javascript: URLs from being added to |
| 745 // session history, which is what we want to do for javascript: URLs that | 749 // session history, which is what we want to do for javascript: URLs that |
| 746 // do not generate content. What we really need is a message from the | 750 // do not generate content. What we really need is a message from the |
| 747 // renderer telling us that a new page was not created. The same message | 751 // renderer telling us that a new page was not created. The same message |
| 748 // could be used for mailto: URLs and the like. | 752 // could be used for mailto: URLs and the like. |
| 749 if (entry.url().SchemeIs(chrome::kJavaScriptScheme)) | 753 if (entry.url().SchemeIs(chrome::kJavaScriptScheme)) |
| 750 return false; | 754 return false; |
| (...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1787 NotificationType::FIND_RESULT_AVAILABLE, | 1791 NotificationType::FIND_RESULT_AVAILABLE, |
| 1788 Source<TabContents>(this), | 1792 Source<TabContents>(this), |
| 1789 Details<FindNotificationDetails>(&last_search_result_)); | 1793 Details<FindNotificationDetails>(&last_search_result_)); |
| 1790 } | 1794 } |
| 1791 | 1795 |
| 1792 void TabContents::GoToEntryAtOffset(int offset) { | 1796 void TabContents::GoToEntryAtOffset(int offset) { |
| 1793 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) | 1797 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) |
| 1794 controller_.GoToOffset(offset); | 1798 controller_.GoToOffset(offset); |
| 1795 } | 1799 } |
| 1796 | 1800 |
| 1797 void TabContents::GetHistoryListCount(int* back_list_count, | |
| 1798 int* forward_list_count) { | |
| 1799 int current_index = controller_.last_committed_entry_index(); | |
| 1800 *back_list_count = current_index; | |
| 1801 *forward_list_count = controller_.entry_count() - current_index - 1; | |
| 1802 } | |
| 1803 | |
| 1804 void TabContents::OnMissingPluginStatus(int status) { | 1801 void TabContents::OnMissingPluginStatus(int status) { |
| 1805 #if defined(OS_WIN) | 1802 #if defined(OS_WIN) |
| 1806 // TODO(PORT): pull in when plug-ins work | 1803 // TODO(PORT): pull in when plug-ins work |
| 1807 GetPluginInstaller()->OnMissingPluginStatus(status); | 1804 GetPluginInstaller()->OnMissingPluginStatus(status); |
| 1808 #endif | 1805 #endif |
| 1809 } | 1806 } |
| 1810 | 1807 |
| 1811 void TabContents::OnCrashedPlugin(const FilePath& plugin_path) { | 1808 void TabContents::OnCrashedPlugin(const FilePath& plugin_path) { |
| 1812 DCHECK(!plugin_path.value().empty()); | 1809 DCHECK(!plugin_path.value().empty()); |
| 1813 | 1810 |
| (...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2872 } | 2869 } |
| 2873 | 2870 |
| 2874 void TabContents::set_encoding(const std::string& encoding) { | 2871 void TabContents::set_encoding(const std::string& encoding) { |
| 2875 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); | 2872 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); |
| 2876 } | 2873 } |
| 2877 | 2874 |
| 2878 void TabContents::SetAppIcon(const SkBitmap& app_icon) { | 2875 void TabContents::SetAppIcon(const SkBitmap& app_icon) { |
| 2879 app_icon_ = app_icon; | 2876 app_icon_ = app_icon; |
| 2880 NotifyNavigationStateChanged(INVALIDATE_TITLE); | 2877 NotifyNavigationStateChanged(INVALIDATE_TITLE); |
| 2881 } | 2878 } |
| OLD | NEW |