| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tab_contents/tab_contents.h" | 5 #include "content/browser/tab_contents/tab_contents.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "content/browser/intents/web_intents_dispatcher_impl.h" | 21 #include "content/browser/intents/web_intents_dispatcher_impl.h" |
| 22 #include "content/browser/load_from_memory_cache_details.h" | 22 #include "content/browser/load_from_memory_cache_details.h" |
| 23 #include "content/browser/load_notification_details.h" | 23 #include "content/browser/load_notification_details.h" |
| 24 #include "content/browser/renderer_host/render_process_host_impl.h" | 24 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 25 #include "content/browser/renderer_host/render_view_host.h" | 25 #include "content/browser/renderer_host/render_view_host.h" |
| 26 #include "content/browser/renderer_host/render_widget_host_view.h" | 26 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 27 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 27 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 28 #include "content/browser/renderer_host/resource_request_details.h" | 28 #include "content/browser/renderer_host/resource_request_details.h" |
| 29 #include "content/browser/site_instance.h" | 29 #include "content/browser/site_instance.h" |
| 30 #include "content/browser/tab_contents/interstitial_page.h" | 30 #include "content/browser/tab_contents/interstitial_page.h" |
| 31 #include "content/browser/tab_contents/navigation_entry.h" | 31 #include "content/browser/tab_contents/navigation_entry_impl.h" |
| 32 #include "content/browser/tab_contents/provisional_load_details.h" | 32 #include "content/browser/tab_contents/provisional_load_details.h" |
| 33 #include "content/browser/tab_contents/tab_contents_view.h" | 33 #include "content/browser/tab_contents/tab_contents_view.h" |
| 34 #include "content/browser/tab_contents/title_updated_details.h" | 34 #include "content/browser/tab_contents/title_updated_details.h" |
| 35 #include "content/browser/webui/web_ui_factory.h" | 35 #include "content/browser/webui/web_ui_factory.h" |
| 36 #include "content/common/intents_messages.h" | 36 #include "content/common/intents_messages.h" |
| 37 #include "content/common/view_messages.h" | 37 #include "content/common/view_messages.h" |
| 38 #include "content/public/browser/browser_context.h" | 38 #include "content/public/browser/browser_context.h" |
| 39 #include "content/public/browser/content_browser_client.h" | 39 #include "content/public/browser/content_browser_client.h" |
| 40 #include "content/public/browser/devtools_agent_host_registry.h" | 40 #include "content/public/browser/devtools_agent_host_registry.h" |
| 41 #include "content/public/browser/download_manager.h" | 41 #include "content/public/browser/download_manager.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // In this case the old RVH has been swapped out but the new one has not | 105 // In this case the old RVH has been swapped out but the new one has not |
| 106 // replaced it, yet. Therefore, we cancel the pending RVH and skip the unloading | 106 // replaced it, yet. Therefore, we cancel the pending RVH and skip the unloading |
| 107 // of the old RVH. | 107 // of the old RVH. |
| 108 | 108 |
| 109 using content::DevToolsAgentHost; | 109 using content::DevToolsAgentHost; |
| 110 using content::DevToolsAgentHostRegistry; | 110 using content::DevToolsAgentHostRegistry; |
| 111 using content::DevToolsManagerImpl; | 111 using content::DevToolsManagerImpl; |
| 112 using content::DownloadItem; | 112 using content::DownloadItem; |
| 113 using content::DownloadManager; | 113 using content::DownloadManager; |
| 114 using content::GlobalRequestID; | 114 using content::GlobalRequestID; |
| 115 using content::NavigationEntry; |
| 116 using content::NavigationEntryImpl; |
| 115 using content::OpenURLParams; | 117 using content::OpenURLParams; |
| 116 using content::SSLStatus; | 118 using content::SSLStatus; |
| 117 using content::UserMetricsAction; | 119 using content::UserMetricsAction; |
| 118 using content::WebContents; | 120 using content::WebContents; |
| 119 using content::WebContentsObserver; | 121 using content::WebContentsObserver; |
| 120 | 122 |
| 121 namespace { | 123 namespace { |
| 122 | 124 |
| 123 // Amount of time we wait between when a key event is received and the renderer | 125 // Amount of time we wait between when a key event is received and the renderer |
| 124 // is queried for its state and pushed to the NavigationEntry. | 126 // is queried for its state and pushed to the NavigationEntry. |
| 125 const int kQueryStateDelay = 5000; | 127 const int kQueryStateDelay = 5000; |
| 126 | 128 |
| 127 const int kSyncWaitDelay = 40; | 129 const int kSyncWaitDelay = 40; |
| 128 | 130 |
| 129 static const char kDotGoogleDotCom[] = ".google.com"; | 131 static const char kDotGoogleDotCom[] = ".google.com"; |
| 130 | 132 |
| 131 #if defined(OS_WIN) | 133 #if defined(OS_WIN) |
| 132 | 134 |
| 133 BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { | 135 BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { |
| 134 // Note: erase is required to properly paint some widgets borders. This can | 136 // Note: erase is required to properly paint some widgets borders. This can |
| 135 // be seen with textfields. | 137 // be seen with textfields. |
| 136 InvalidateRect(hwnd, NULL, TRUE); | 138 InvalidateRect(hwnd, NULL, TRUE); |
| 137 return TRUE; | 139 return TRUE; |
| 138 } | 140 } |
| 139 #endif | 141 #endif |
| 140 | 142 |
| 141 ViewMsg_Navigate_Type::Value GetNavigationType( | 143 ViewMsg_Navigate_Type::Value GetNavigationType( |
| 142 content::BrowserContext* browser_context, const NavigationEntry& entry, | 144 content::BrowserContext* browser_context, const NavigationEntryImpl& entry, |
| 143 NavigationController::ReloadType reload_type) { | 145 NavigationController::ReloadType reload_type) { |
| 144 switch (reload_type) { | 146 switch (reload_type) { |
| 145 case NavigationController::RELOAD: | 147 case NavigationController::RELOAD: |
| 146 return ViewMsg_Navigate_Type::RELOAD; | 148 return ViewMsg_Navigate_Type::RELOAD; |
| 147 case NavigationController::RELOAD_IGNORING_CACHE: | 149 case NavigationController::RELOAD_IGNORING_CACHE: |
| 148 return ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; | 150 return ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; |
| 149 case NavigationController::NO_RELOAD: | 151 case NavigationController::NO_RELOAD: |
| 150 break; // Fall through to rest of function. | 152 break; // Fall through to rest of function. |
| 151 } | 153 } |
| 152 | 154 |
| 153 if (entry.restore_type() == NavigationEntry::RESTORE_LAST_SESSION && | 155 if (entry.restore_type() == NavigationEntryImpl::RESTORE_LAST_SESSION && |
| 154 browser_context->DidLastSessionExitCleanly()) | 156 browser_context->DidLastSessionExitCleanly()) |
| 155 return ViewMsg_Navigate_Type::RESTORE; | 157 return ViewMsg_Navigate_Type::RESTORE; |
| 156 | 158 |
| 157 return ViewMsg_Navigate_Type::NORMAL; | 159 return ViewMsg_Navigate_Type::NORMAL; |
| 158 } | 160 } |
| 159 | 161 |
| 160 void MakeNavigateParams(const NavigationEntry& entry, | 162 void MakeNavigateParams(const NavigationEntryImpl& entry, |
| 161 const NavigationController& controller, | 163 const NavigationController& controller, |
| 162 content::WebContentsDelegate* delegate, | 164 content::WebContentsDelegate* delegate, |
| 163 NavigationController::ReloadType reload_type, | 165 NavigationController::ReloadType reload_type, |
| 164 ViewMsg_Navigate_Params* params) { | 166 ViewMsg_Navigate_Params* params) { |
| 165 params->page_id = entry.GetPageID(); | 167 params->page_id = entry.GetPageID(); |
| 166 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); | 168 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); |
| 167 params->current_history_list_offset = controller.last_committed_entry_index(); | 169 params->current_history_list_offset = controller.last_committed_entry_index(); |
| 168 params->current_history_list_length = controller.entry_count(); | 170 params->current_history_list_length = controller.entry_count(); |
| 169 params->url = entry.GetURL(); | 171 params->url = entry.GetURL(); |
| 170 params->referrer = entry.GetReferrer(); | 172 params->referrer = entry.GetReferrer(); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 void TabContents::SetViewType(content::ViewType type) { | 367 void TabContents::SetViewType(content::ViewType type) { |
| 366 view_type_ = type; | 368 view_type_ = type; |
| 367 } | 369 } |
| 368 | 370 |
| 369 content::ViewType TabContents::GetViewType() const { | 371 content::ViewType TabContents::GetViewType() const { |
| 370 return view_type_; | 372 return view_type_; |
| 371 } | 373 } |
| 372 | 374 |
| 373 const GURL& TabContents::GetURL() const { | 375 const GURL& TabContents::GetURL() const { |
| 374 // We may not have a navigation entry yet | 376 // We may not have a navigation entry yet |
| 375 content::NavigationEntry* entry = controller_.GetActiveEntry(); | 377 NavigationEntry* entry = controller_.GetActiveEntry(); |
| 376 return entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); | 378 return entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); |
| 377 } | 379 } |
| 378 | 380 |
| 379 | 381 |
| 380 const base::PropertyBag* TabContents::GetPropertyBag() const { | 382 const base::PropertyBag* TabContents::GetPropertyBag() const { |
| 381 return &property_bag_; | 383 return &property_bag_; |
| 382 } | 384 } |
| 383 | 385 |
| 384 base::PropertyBag* TabContents::GetPropertyBag() { | 386 base::PropertyBag* TabContents::GetPropertyBag() { |
| 385 return &property_bag_; | 387 return &property_bag_; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 : render_manager_.pending_web_ui(); | 426 : render_manager_.pending_web_ui(); |
| 425 } | 427 } |
| 426 | 428 |
| 427 WebUI* TabContents::GetCommittedWebUI() const { | 429 WebUI* TabContents::GetCommittedWebUI() const { |
| 428 return render_manager_.web_ui(); | 430 return render_manager_.web_ui(); |
| 429 } | 431 } |
| 430 | 432 |
| 431 const string16& TabContents::GetTitle() const { | 433 const string16& TabContents::GetTitle() const { |
| 432 // Transient entries take precedence. They are used for interstitial pages | 434 // Transient entries take precedence. They are used for interstitial pages |
| 433 // that are shown on top of existing pages. | 435 // that are shown on top of existing pages. |
| 434 content::NavigationEntry* entry = controller_.GetTransientEntry(); | 436 NavigationEntry* entry = controller_.GetTransientEntry(); |
| 435 std::string accept_languages = | 437 std::string accept_languages = |
| 436 content::GetContentClient()->browser()->GetAcceptLangs( | 438 content::GetContentClient()->browser()->GetAcceptLangs( |
| 437 GetBrowserContext()); | 439 GetBrowserContext()); |
| 438 if (entry) { | 440 if (entry) { |
| 439 return entry->GetTitleForDisplay(accept_languages); | 441 return entry->GetTitleForDisplay(accept_languages); |
| 440 } | 442 } |
| 441 WebUI* our_web_ui = render_manager_.pending_web_ui() ? | 443 WebUI* our_web_ui = render_manager_.pending_web_ui() ? |
| 442 render_manager_.pending_web_ui() : render_manager_.web_ui(); | 444 render_manager_.pending_web_ui() : render_manager_.web_ui(); |
| 443 if (our_web_ui) { | 445 if (our_web_ui) { |
| 444 // Don't override the title in view source mode. | 446 // Don't override the title in view source mode. |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 // Notify observers. | 774 // Notify observers. |
| 773 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 775 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 774 DidOpenURL(params.url, params.referrer, | 776 DidOpenURL(params.url, params.referrer, |
| 775 params.disposition, params.transition)); | 777 params.disposition, params.transition)); |
| 776 return new_contents; | 778 return new_contents; |
| 777 } | 779 } |
| 778 | 780 |
| 779 bool TabContents::NavigateToPendingEntry( | 781 bool TabContents::NavigateToPendingEntry( |
| 780 NavigationController::ReloadType reload_type) { | 782 NavigationController::ReloadType reload_type) { |
| 781 return NavigateToEntry( | 783 return NavigateToEntry( |
| 782 *NavigationEntry::FromNavigationEntry(controller_.GetPendingEntry()), | 784 *NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry()), |
| 783 reload_type); | 785 reload_type); |
| 784 } | 786 } |
| 785 | 787 |
| 786 bool TabContents::NavigateToEntry( | 788 bool TabContents::NavigateToEntry( |
| 787 const NavigationEntry& entry, | 789 const NavigationEntryImpl& entry, |
| 788 NavigationController::ReloadType reload_type) { | 790 NavigationController::ReloadType reload_type) { |
| 789 // The renderer will reject IPC messages with URLs longer than | 791 // The renderer will reject IPC messages with URLs longer than |
| 790 // this limit, so don't attempt to navigate with a longer URL. | 792 // this limit, so don't attempt to navigate with a longer URL. |
| 791 if (entry.GetURL().spec().size() > content::kMaxURLChars) | 793 if (entry.GetURL().spec().size() > content::kMaxURLChars) |
| 792 return false; | 794 return false; |
| 793 | 795 |
| 794 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); | 796 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); |
| 795 if (!dest_render_view_host) | 797 if (!dest_render_view_host) |
| 796 return false; // Unable to create the desired render view host. | 798 return false; // Unable to create the desired render view host. |
| 797 | 799 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 bool TabContents::SavePage(const FilePath& main_file, const FilePath& dir_path, | 912 bool TabContents::SavePage(const FilePath& main_file, const FilePath& dir_path, |
| 911 SavePackage::SavePackageType save_type) { | 913 SavePackage::SavePackageType save_type) { |
| 912 // Stop the page from navigating. | 914 // Stop the page from navigating. |
| 913 Stop(); | 915 Stop(); |
| 914 | 916 |
| 915 save_package_ = new SavePackage(this, save_type, main_file, dir_path); | 917 save_package_ = new SavePackage(this, save_type, main_file, dir_path); |
| 916 return save_package_->Init(); | 918 return save_package_->Init(); |
| 917 } | 919 } |
| 918 | 920 |
| 919 bool TabContents::IsActiveEntry(int32 page_id) { | 921 bool TabContents::IsActiveEntry(int32 page_id) { |
| 920 NavigationEntry* active_entry = | 922 NavigationEntryImpl* active_entry = |
| 921 NavigationEntry::FromNavigationEntry(controller_.GetActiveEntry()); | 923 NavigationEntryImpl::FromNavigationEntry(controller_.GetActiveEntry()); |
| 922 return (active_entry != NULL && | 924 return (active_entry != NULL && |
| 923 active_entry->site_instance() == GetSiteInstance() && | 925 active_entry->site_instance() == GetSiteInstance() && |
| 924 active_entry->GetPageID() == page_id); | 926 active_entry->GetPageID() == page_id); |
| 925 } | 927 } |
| 926 | 928 |
| 927 const std::string& TabContents::GetContentsMimeType() const { | 929 const std::string& TabContents::GetContentsMimeType() const { |
| 928 return contents_mime_type_; | 930 return contents_mime_type_; |
| 929 } | 931 } |
| 930 | 932 |
| 931 bool TabContents::WillNotifyDisconnection() const { | 933 bool TabContents::WillNotifyDisconnection() const { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 HostZoomMap* zoom_map = GetBrowserContext()->GetHostZoomMap(); | 994 HostZoomMap* zoom_map = GetBrowserContext()->GetHostZoomMap(); |
| 993 if (!zoom_map) | 995 if (!zoom_map) |
| 994 return 0; | 996 return 0; |
| 995 | 997 |
| 996 double zoom_level; | 998 double zoom_level; |
| 997 if (temporary_zoom_settings_) { | 999 if (temporary_zoom_settings_) { |
| 998 zoom_level = zoom_map->GetTemporaryZoomLevel( | 1000 zoom_level = zoom_map->GetTemporaryZoomLevel( |
| 999 GetRenderProcessHost()->GetID(), GetRenderViewHost()->routing_id()); | 1001 GetRenderProcessHost()->GetID(), GetRenderViewHost()->routing_id()); |
| 1000 } else { | 1002 } else { |
| 1001 GURL url; | 1003 GURL url; |
| 1002 content::NavigationEntry* active_entry = GetController().GetActiveEntry(); | 1004 NavigationEntry* active_entry = GetController().GetActiveEntry(); |
| 1003 // Since zoom map is updated using rewritten URL, use rewritten URL | 1005 // Since zoom map is updated using rewritten URL, use rewritten URL |
| 1004 // to get the zoom level. | 1006 // to get the zoom level. |
| 1005 url = active_entry ? active_entry->GetURL() : GURL::EmptyGURL(); | 1007 url = active_entry ? active_entry->GetURL() : GURL::EmptyGURL(); |
| 1006 zoom_level = zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(url)); | 1008 zoom_level = zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(url)); |
| 1007 } | 1009 } |
| 1008 return zoom_level; | 1010 return zoom_level; |
| 1009 } | 1011 } |
| 1010 | 1012 |
| 1011 int TabContents::GetZoomPercent(bool* enable_increment, | 1013 int TabContents::GetZoomPercent(bool* enable_increment, |
| 1012 bool* enable_decrement) { | 1014 bool* enable_decrement) { |
| 1013 *enable_decrement = *enable_increment = false; | 1015 *enable_decrement = *enable_increment = false; |
| 1014 // Calculate the zoom percent from the factor. Round up to the nearest whole | 1016 // Calculate the zoom percent from the factor. Round up to the nearest whole |
| 1015 // number. | 1017 // number. |
| 1016 int percent = static_cast<int>( | 1018 int percent = static_cast<int>( |
| 1017 WebKit::WebView::zoomLevelToZoomFactor(GetZoomLevel()) * 100 + 0.5); | 1019 WebKit::WebView::zoomLevelToZoomFactor(GetZoomLevel()) * 100 + 0.5); |
| 1018 *enable_decrement = percent > minimum_zoom_percent_; | 1020 *enable_decrement = percent > minimum_zoom_percent_; |
| 1019 *enable_increment = percent < maximum_zoom_percent_; | 1021 *enable_increment = percent < maximum_zoom_percent_; |
| 1020 return percent; | 1022 return percent; |
| 1021 } | 1023 } |
| 1022 | 1024 |
| 1023 void TabContents::ViewSource() { | 1025 void TabContents::ViewSource() { |
| 1024 if (!delegate_) | 1026 if (!delegate_) |
| 1025 return; | 1027 return; |
| 1026 | 1028 |
| 1027 content::NavigationEntry* active_entry = GetController().GetActiveEntry(); | 1029 NavigationEntry* active_entry = GetController().GetActiveEntry(); |
| 1028 if (!active_entry) | 1030 if (!active_entry) |
| 1029 return; | 1031 return; |
| 1030 | 1032 |
| 1031 delegate_->ViewSourceForTab(this, active_entry->GetURL()); | 1033 delegate_->ViewSourceForTab(this, active_entry->GetURL()); |
| 1032 } | 1034 } |
| 1033 | 1035 |
| 1034 void TabContents::ViewFrameSource(const GURL& url, | 1036 void TabContents::ViewFrameSource(const GURL& url, |
| 1035 const std::string& content_state) { | 1037 const std::string& content_state) { |
| 1036 if (!delegate_) | 1038 if (!delegate_) |
| 1037 return; | 1039 return; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 | 1100 |
| 1099 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { | 1101 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { |
| 1100 return GetRenderViewHost() ? | 1102 return GetRenderViewHost() ? |
| 1101 GetRenderViewHost()->GotResponseToLockMouseRequest(allowed) : false; | 1103 GetRenderViewHost()->GotResponseToLockMouseRequest(allowed) : false; |
| 1102 } | 1104 } |
| 1103 | 1105 |
| 1104 bool TabContents::FocusLocationBarByDefault() { | 1106 bool TabContents::FocusLocationBarByDefault() { |
| 1105 WebUI* web_ui = GetWebUIForCurrentState(); | 1107 WebUI* web_ui = GetWebUIForCurrentState(); |
| 1106 if (web_ui) | 1108 if (web_ui) |
| 1107 return web_ui->focus_location_bar_by_default(); | 1109 return web_ui->focus_location_bar_by_default(); |
| 1108 content::NavigationEntry* entry = controller_.GetActiveEntry(); | 1110 NavigationEntry* entry = controller_.GetActiveEntry(); |
| 1109 if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)) | 1111 if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)) |
| 1110 return true; | 1112 return true; |
| 1111 return false; | 1113 return false; |
| 1112 } | 1114 } |
| 1113 | 1115 |
| 1114 void TabContents::SetFocusToLocationBar(bool select_all) { | 1116 void TabContents::SetFocusToLocationBar(bool select_all) { |
| 1115 if (delegate_) | 1117 if (delegate_) |
| 1116 delegate_->SetFocusToLocationBar(select_all); | 1118 delegate_->SetFocusToLocationBar(select_all); |
| 1117 } | 1119 } |
| 1118 | 1120 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 } | 1158 } |
| 1157 } | 1159 } |
| 1158 | 1160 |
| 1159 void TabContents::OnDidRedirectProvisionalLoad(int32 page_id, | 1161 void TabContents::OnDidRedirectProvisionalLoad(int32 page_id, |
| 1160 const GURL& opener_url, | 1162 const GURL& opener_url, |
| 1161 const GURL& source_url, | 1163 const GURL& source_url, |
| 1162 const GURL& target_url) { | 1164 const GURL& target_url) { |
| 1163 // TODO(creis): Remove this method and have the pre-rendering code listen to | 1165 // TODO(creis): Remove this method and have the pre-rendering code listen to |
| 1164 // the ResourceDispatcherHost's RESOURCE_RECEIVED_REDIRECT notification | 1166 // the ResourceDispatcherHost's RESOURCE_RECEIVED_REDIRECT notification |
| 1165 // instead. See http://crbug.com/78512. | 1167 // instead. See http://crbug.com/78512. |
| 1166 content::NavigationEntry* entry; | 1168 NavigationEntry* entry; |
| 1167 if (page_id == -1) | 1169 if (page_id == -1) |
| 1168 entry = controller_.GetPendingEntry(); | 1170 entry = controller_.GetPendingEntry(); |
| 1169 else | 1171 else |
| 1170 entry = controller_.GetEntryWithPageID(GetSiteInstance(), page_id); | 1172 entry = controller_.GetEntryWithPageID(GetSiteInstance(), page_id); |
| 1171 if (!entry || entry->GetURL() != source_url) | 1173 if (!entry || entry->GetURL() != source_url) |
| 1172 return; | 1174 return; |
| 1173 | 1175 |
| 1174 // Notify observers about the provisional change in the main frame URL. | 1176 // Notify observers about the provisional change in the main frame URL. |
| 1175 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1177 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 1176 ProvisionalChangeToMainFrameUrl(target_url, | 1178 ProvisionalChangeToMainFrameUrl(target_url, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1322 error_code, error_description)); | 1324 error_code, error_description)); |
| 1323 } | 1325 } |
| 1324 | 1326 |
| 1325 void TabContents::OnUpdateContentRestrictions(int restrictions) { | 1327 void TabContents::OnUpdateContentRestrictions(int restrictions) { |
| 1326 content_restrictions_ = restrictions; | 1328 content_restrictions_ = restrictions; |
| 1327 delegate_->ContentRestrictionsChanged(this); | 1329 delegate_->ContentRestrictionsChanged(this); |
| 1328 } | 1330 } |
| 1329 | 1331 |
| 1330 void TabContents::OnGoToEntryAtOffset(int offset) { | 1332 void TabContents::OnGoToEntryAtOffset(int offset) { |
| 1331 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) { | 1333 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) { |
| 1332 NavigationEntry* entry = NavigationEntry::FromNavigationEntry( | 1334 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( |
| 1333 controller_.GetEntryAtOffset(offset)); | 1335 controller_.GetEntryAtOffset(offset)); |
| 1334 if (!entry) | 1336 if (!entry) |
| 1335 return; | 1337 return; |
| 1336 // Note that we don't call NavigationController::GotToOffset() as we don't | 1338 // Note that we don't call NavigationController::GotToOffset() as we don't |
| 1337 // want to create a pending navigation entry (it might end up lingering | 1339 // want to create a pending navigation entry (it might end up lingering |
| 1338 // http://crbug.com/51680). | 1340 // http://crbug.com/51680). |
| 1339 entry->SetTransitionType( | 1341 entry->SetTransitionType( |
| 1340 content::PageTransitionFromInt( | 1342 content::PageTransitionFromInt( |
| 1341 entry->GetTransitionType() | | 1343 entry->GetTransitionType() | |
| 1342 content::PAGE_TRANSITION_FORWARD_BACK)); | 1344 content::PAGE_TRANSITION_FORWARD_BACK)); |
| 1343 NavigateToEntry(*entry, NavigationController::NO_RELOAD); | 1345 NavigateToEntry(*entry, NavigationController::NO_RELOAD); |
| 1344 | 1346 |
| 1345 // If the entry is being restored and doesn't have a SiteInstance yet, fill | 1347 // If the entry is being restored and doesn't have a SiteInstance yet, fill |
| 1346 // it in now that we know. This allows us to find the entry when it commits. | 1348 // it in now that we know. This allows us to find the entry when it commits. |
| 1347 if (!entry->site_instance() && | 1349 if (!entry->site_instance() && |
| 1348 entry->restore_type() != NavigationEntry::RESTORE_NONE) { | 1350 entry->restore_type() != NavigationEntryImpl::RESTORE_NONE) { |
| 1349 entry->set_site_instance(GetPendingSiteInstance()); | 1351 entry->set_site_instance(GetPendingSiteInstance()); |
| 1350 } | 1352 } |
| 1351 } | 1353 } |
| 1352 } | 1354 } |
| 1353 | 1355 |
| 1354 void TabContents::OnUpdateZoomLimits(int minimum_percent, | 1356 void TabContents::OnUpdateZoomLimits(int minimum_percent, |
| 1355 int maximum_percent, | 1357 int maximum_percent, |
| 1356 bool remember) { | 1358 bool remember) { |
| 1357 minimum_zoom_percent_ = minimum_percent; | 1359 minimum_zoom_percent_ = minimum_percent; |
| 1358 maximum_zoom_percent_ = maximum_percent; | 1360 maximum_zoom_percent_ = maximum_percent; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1502 // sure the RenderView starts with a next_page_id_ larger than the number | 1504 // sure the RenderView starts with a next_page_id_ larger than the number |
| 1503 // of restored entries. This must be called before the RenderView starts | 1505 // of restored entries. This must be called before the RenderView starts |
| 1504 // navigating (to avoid a race between the browser updating max_page_id and | 1506 // navigating (to avoid a race between the browser updating max_page_id and |
| 1505 // the renderer updating next_page_id_). Because of this, we only call this | 1507 // the renderer updating next_page_id_). Because of this, we only call this |
| 1506 // from CreateRenderView and allow that to notify the RenderView for us. | 1508 // from CreateRenderView and allow that to notify the RenderView for us. |
| 1507 int max_restored_page_id = controller_.max_restored_page_id(); | 1509 int max_restored_page_id = controller_.max_restored_page_id(); |
| 1508 if (max_restored_page_id > GetMaxPageIDForSiteInstance(rvh->site_instance())) | 1510 if (max_restored_page_id > GetMaxPageIDForSiteInstance(rvh->site_instance())) |
| 1509 UpdateMaxPageIDForSiteInstance(rvh->site_instance(), max_restored_page_id); | 1511 UpdateMaxPageIDForSiteInstance(rvh->site_instance(), max_restored_page_id); |
| 1510 } | 1512 } |
| 1511 | 1513 |
| 1512 bool TabContents::UpdateTitleForEntry(NavigationEntry* entry, | 1514 bool TabContents::UpdateTitleForEntry(NavigationEntryImpl* entry, |
| 1513 const string16& title) { | 1515 const string16& title) { |
| 1514 // For file URLs without a title, use the pathname instead. In the case of a | 1516 // For file URLs without a title, use the pathname instead. In the case of a |
| 1515 // synthesized title, we don't want the update to count toward the "one set | 1517 // synthesized title, we don't want the update to count toward the "one set |
| 1516 // per page of the title to history." | 1518 // per page of the title to history." |
| 1517 string16 final_title; | 1519 string16 final_title; |
| 1518 bool explicit_set; | 1520 bool explicit_set; |
| 1519 if (entry && entry->GetURL().SchemeIsFile() && title.empty()) { | 1521 if (entry && entry->GetURL().SchemeIsFile() && title.empty()) { |
| 1520 final_title = UTF8ToUTF16(entry->GetURL().ExtractFileName()); | 1522 final_title = UTF8ToUTF16(entry->GetURL().ExtractFileName()); |
| 1521 explicit_set = false; // Don't count synthetic titles toward the set limit. | 1523 explicit_set = false; // Don't count synthetic titles toward the set limit. |
| 1522 } else { | 1524 } else { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1606 | 1608 |
| 1607 content::ViewType TabContents::GetRenderViewType() const { | 1609 content::ViewType TabContents::GetRenderViewType() const { |
| 1608 return view_type_; | 1610 return view_type_; |
| 1609 } | 1611 } |
| 1610 | 1612 |
| 1611 void TabContents::RenderViewCreated(RenderViewHost* render_view_host) { | 1613 void TabContents::RenderViewCreated(RenderViewHost* render_view_host) { |
| 1612 content::NotificationService::current()->Notify( | 1614 content::NotificationService::current()->Notify( |
| 1613 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, | 1615 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, |
| 1614 content::Source<TabContents>(this), | 1616 content::Source<TabContents>(this), |
| 1615 content::Details<RenderViewHost>(render_view_host)); | 1617 content::Details<RenderViewHost>(render_view_host)); |
| 1616 content::NavigationEntry* entry = controller_.GetActiveEntry(); | 1618 NavigationEntry* entry = controller_.GetActiveEntry(); |
| 1617 if (!entry) | 1619 if (!entry) |
| 1618 return; | 1620 return; |
| 1619 | 1621 |
| 1620 // When we're creating views, we're still doing initial setup, so we always | 1622 // When we're creating views, we're still doing initial setup, so we always |
| 1621 // use the pending Web UI rather than any possibly existing committed one. | 1623 // use the pending Web UI rather than any possibly existing committed one. |
| 1622 if (render_manager_.pending_web_ui()) | 1624 if (render_manager_.pending_web_ui()) |
| 1623 render_manager_.pending_web_ui()->RenderViewCreated(render_view_host); | 1625 render_manager_.pending_web_ui()->RenderViewCreated(render_view_host); |
| 1624 | 1626 |
| 1625 if (entry->IsViewSourceMode()) { | 1627 if (entry->IsViewSourceMode()) { |
| 1626 // Put the renderer in view source mode. | 1628 // Put the renderer in view source mode. |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1753 // We must be prepared to handle state updates for any page, these occur | 1755 // We must be prepared to handle state updates for any page, these occur |
| 1754 // when the user is scrolling and entering form data, as well as when we're | 1756 // when the user is scrolling and entering form data, as well as when we're |
| 1755 // leaving a page, in which case our state may have already been moved to | 1757 // leaving a page, in which case our state may have already been moved to |
| 1756 // the next page. The navigation controller will look up the appropriate | 1758 // the next page. The navigation controller will look up the appropriate |
| 1757 // NavigationEntry and update it when it is notified via the delegate. | 1759 // NavigationEntry and update it when it is notified via the delegate. |
| 1758 | 1760 |
| 1759 int entry_index = controller_.GetEntryIndexWithPageID( | 1761 int entry_index = controller_.GetEntryIndexWithPageID( |
| 1760 rvh->site_instance(), page_id); | 1762 rvh->site_instance(), page_id); |
| 1761 if (entry_index < 0) | 1763 if (entry_index < 0) |
| 1762 return; | 1764 return; |
| 1763 content::NavigationEntry* entry = controller_.GetEntryAtIndex(entry_index); | 1765 NavigationEntry* entry = controller_.GetEntryAtIndex(entry_index); |
| 1764 | 1766 |
| 1765 if (state == entry->GetContentState()) | 1767 if (state == entry->GetContentState()) |
| 1766 return; // Nothing to update. | 1768 return; // Nothing to update. |
| 1767 entry->SetContentState(state); | 1769 entry->SetContentState(state); |
| 1768 controller_.NotifyEntryChanged(entry, entry_index); | 1770 controller_.NotifyEntryChanged(entry, entry_index); |
| 1769 } | 1771 } |
| 1770 | 1772 |
| 1771 void TabContents::UpdateTitle(RenderViewHost* rvh, | 1773 void TabContents::UpdateTitle(RenderViewHost* rvh, |
| 1772 int32 page_id, | 1774 int32 page_id, |
| 1773 const string16& title, | 1775 const string16& title, |
| 1774 base::i18n::TextDirection title_direction) { | 1776 base::i18n::TextDirection title_direction) { |
| 1775 // If we have a title, that's a pretty good indication that we've started | 1777 // If we have a title, that's a pretty good indication that we've started |
| 1776 // getting useful data. | 1778 // getting useful data. |
| 1777 SetNotWaitingForResponse(); | 1779 SetNotWaitingForResponse(); |
| 1778 | 1780 |
| 1779 DCHECK(rvh == GetRenderViewHost()); | 1781 DCHECK(rvh == GetRenderViewHost()); |
| 1780 NavigationEntry* entry = controller_.GetEntryWithPageID(rvh->site_instance(), | 1782 NavigationEntryImpl* entry = controller_.GetEntryWithPageID( |
| 1781 page_id); | 1783 rvh->site_instance(), page_id); |
| 1782 | 1784 |
| 1783 // TODO(evan): make use of title_direction. | 1785 // TODO(evan): make use of title_direction. |
| 1784 // http://code.google.com/p/chromium/issues/detail?id=27094 | 1786 // http://code.google.com/p/chromium/issues/detail?id=27094 |
| 1785 if (!UpdateTitleForEntry(entry, title)) | 1787 if (!UpdateTitleForEntry(entry, title)) |
| 1786 return; | 1788 return; |
| 1787 | 1789 |
| 1788 // Broadcast notifications when the UI should be updated. | 1790 // Broadcast notifications when the UI should be updated. |
| 1789 if (entry == controller_.GetEntryAtOffset(0)) | 1791 if (entry == controller_.GetEntryAtOffset(0)) |
| 1790 NotifyNavigationStateChanged(INVALIDATE_TITLE); | 1792 NotifyNavigationStateChanged(INVALIDATE_TITLE); |
| 1791 } | 1793 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1846 delegate_->ContentRestrictionsChanged(this); | 1848 delegate_->ContentRestrictionsChanged(this); |
| 1847 } | 1849 } |
| 1848 | 1850 |
| 1849 // Notify observers about navigation. | 1851 // Notify observers about navigation. |
| 1850 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidStartLoading()); | 1852 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidStartLoading()); |
| 1851 } | 1853 } |
| 1852 | 1854 |
| 1853 void TabContents::DidStopLoading() { | 1855 void TabContents::DidStopLoading() { |
| 1854 scoped_ptr<LoadNotificationDetails> details; | 1856 scoped_ptr<LoadNotificationDetails> details; |
| 1855 | 1857 |
| 1856 content::NavigationEntry* entry = controller_.GetActiveEntry(); | 1858 NavigationEntry* entry = controller_.GetActiveEntry(); |
| 1857 // An entry may not exist for a stop when loading an initial blank page or | 1859 // An entry may not exist for a stop when loading an initial blank page or |
| 1858 // if an iframe injected by script into a blank page finishes loading. | 1860 // if an iframe injected by script into a blank page finishes loading. |
| 1859 if (entry) { | 1861 if (entry) { |
| 1860 base::TimeDelta elapsed = base::TimeTicks::Now() - current_load_start_; | 1862 base::TimeDelta elapsed = base::TimeTicks::Now() - current_load_start_; |
| 1861 | 1863 |
| 1862 details.reset(new LoadNotificationDetails( | 1864 details.reset(new LoadNotificationDetails( |
| 1863 entry->GetVirtualURL(), | 1865 entry->GetVirtualURL(), |
| 1864 entry->GetTransitionType(), | 1866 entry->GetTransitionType(), |
| 1865 elapsed, | 1867 elapsed, |
| 1866 &controller_, | 1868 &controller_, |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2156 } | 2158 } |
| 2157 | 2159 |
| 2158 NavigationController& TabContents::GetControllerForRenderManager() { | 2160 NavigationController& TabContents::GetControllerForRenderManager() { |
| 2159 return GetController(); | 2161 return GetController(); |
| 2160 } | 2162 } |
| 2161 | 2163 |
| 2162 WebUI* TabContents::CreateWebUIForRenderManager(const GURL& url) { | 2164 WebUI* TabContents::CreateWebUIForRenderManager(const GURL& url) { |
| 2163 return content::WebUIFactory::Get()->CreateWebUIForURL(this, url); | 2165 return content::WebUIFactory::Get()->CreateWebUIForURL(this, url); |
| 2164 } | 2166 } |
| 2165 | 2167 |
| 2166 content::NavigationEntry* | 2168 NavigationEntry* |
| 2167 TabContents::GetLastCommittedNavigationEntryForRenderManager() { | 2169 TabContents::GetLastCommittedNavigationEntryForRenderManager() { |
| 2168 return controller_.GetLastCommittedEntry(); | 2170 return controller_.GetLastCommittedEntry(); |
| 2169 } | 2171 } |
| 2170 | 2172 |
| 2171 bool TabContents::CreateRenderViewForRenderManager( | 2173 bool TabContents::CreateRenderViewForRenderManager( |
| 2172 RenderViewHost* render_view_host) { | 2174 RenderViewHost* render_view_host) { |
| 2173 // Can be NULL during tests. | 2175 // Can be NULL during tests. |
| 2174 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host); | 2176 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host); |
| 2175 | 2177 |
| 2176 // Now that the RenderView has been created, we need to tell it its size. | 2178 // Now that the RenderView has been created, we need to tell it its size. |
| 2177 if (rwh_view) | 2179 if (rwh_view) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2223 encoding_ = content::GetContentClient()->browser()-> | 2225 encoding_ = content::GetContentClient()->browser()-> |
| 2224 GetCanonicalEncodingNameByAliasName(encoding); | 2226 GetCanonicalEncodingNameByAliasName(encoding); |
| 2225 } | 2227 } |
| 2226 | 2228 |
| 2227 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2229 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 2228 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); | 2230 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); |
| 2229 // Can be NULL during tests. | 2231 // Can be NULL during tests. |
| 2230 if (rwh_view) | 2232 if (rwh_view) |
| 2231 rwh_view->SetSize(GetView()->GetContainerSize()); | 2233 rwh_view->SetSize(GetView()->GetContainerSize()); |
| 2232 } | 2234 } |
| OLD | NEW |