OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 | 432 |
433 // Accelerated video and animation are slower than regular when using a | 433 // Accelerated video and animation are slower than regular when using a |
434 // software 3d rasterizer. | 434 // software 3d rasterizer. |
435 if (gpu_data_manager->ShouldUseSoftwareRendering()) { | 435 if (gpu_data_manager->ShouldUseSoftwareRendering()) { |
436 prefs.accelerated_video_enabled = false; | 436 prefs.accelerated_video_enabled = false; |
437 prefs.accelerated_animation_enabled = false; | 437 prefs.accelerated_animation_enabled = false; |
438 } | 438 } |
439 } | 439 } |
440 | 440 |
441 if (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( | 441 if (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( |
442 rvh->process()->GetID())) { | 442 rvh->GetProcess()->GetID())) { |
443 prefs.loads_images_automatically = true; | 443 prefs.loads_images_automatically = true; |
444 prefs.javascript_enabled = true; | 444 prefs.javascript_enabled = true; |
445 } | 445 } |
446 | 446 |
447 prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); | 447 prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); |
448 | 448 |
449 // Force accelerated compositing and 2d canvas off for chrome:, about: and | 449 // Force accelerated compositing and 2d canvas off for chrome:, about: and |
450 // chrome-devtools: pages (unless it's specifically allowed). | 450 // chrome-devtools: pages (unless it's specifically allowed). |
451 if ((url.SchemeIs(chrome::kChromeDevToolsScheme) || | 451 if ((url.SchemeIs(chrome::kChromeDevToolsScheme) || |
452 url.SchemeIs(chrome::kChromeUIScheme) || | 452 url.SchemeIs(chrome::kChromeUIScheme) || |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 return; | 578 return; |
579 if (delegate_) | 579 if (delegate_) |
580 delegate_->Detach(this); | 580 delegate_->Detach(this); |
581 delegate_ = delegate; | 581 delegate_ = delegate; |
582 if (delegate_) | 582 if (delegate_) |
583 delegate_->Attach(this); | 583 delegate_->Attach(this); |
584 } | 584 } |
585 | 585 |
586 content::RenderProcessHost* TabContents::GetRenderProcessHost() const { | 586 content::RenderProcessHost* TabContents::GetRenderProcessHost() const { |
587 if (render_manager_.current_host()) | 587 if (render_manager_.current_host()) |
588 return render_manager_.current_host()->process(); | 588 return render_manager_.current_host()->GetProcess(); |
589 else | 589 else |
590 return NULL; | 590 return NULL; |
591 } | 591 } |
592 | 592 |
593 RenderViewHost* TabContents::GetRenderViewHost() const { | 593 RenderViewHost* TabContents::GetRenderViewHost() const { |
594 return render_manager_.current_host(); | 594 return render_manager_.current_host(); |
595 } | 595 } |
596 | 596 |
597 RenderWidgetHostView* TabContents::GetRenderWidgetHostView() const { | 597 RenderWidgetHostView* TabContents::GetRenderWidgetHostView() const { |
598 return render_manager_.GetRenderWidgetHostView(); | 598 return render_manager_.GetRenderWidgetHostView(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 SiteInstance* site_instance, int32 page_id) { | 684 SiteInstance* site_instance, int32 page_id) { |
685 if (GetMaxPageIDForSiteInstance(site_instance) < page_id) | 685 if (GetMaxPageIDForSiteInstance(site_instance) < page_id) |
686 max_page_ids_[site_instance->GetId()] = page_id; | 686 max_page_ids_[site_instance->GetId()] = page_id; |
687 } | 687 } |
688 | 688 |
689 void TabContents::CopyMaxPageIDsFrom(TabContents* tab_contents) { | 689 void TabContents::CopyMaxPageIDsFrom(TabContents* tab_contents) { |
690 max_page_ids_ = tab_contents->max_page_ids_; | 690 max_page_ids_ = tab_contents->max_page_ids_; |
691 } | 691 } |
692 | 692 |
693 SiteInstance* TabContents::GetSiteInstance() const { | 693 SiteInstance* TabContents::GetSiteInstance() const { |
694 return render_manager_.current_host()->site_instance(); | 694 return render_manager_.current_host()->GetSiteInstance(); |
695 } | 695 } |
696 | 696 |
697 SiteInstance* TabContents::GetPendingSiteInstance() const { | 697 SiteInstance* TabContents::GetPendingSiteInstance() const { |
698 RenderViewHost* dest_rvh = render_manager_.pending_render_view_host() ? | 698 RenderViewHost* dest_rvh = render_manager_.pending_render_view_host() ? |
699 render_manager_.pending_render_view_host() : | 699 render_manager_.pending_render_view_host() : |
700 render_manager_.current_host(); | 700 render_manager_.current_host(); |
701 return dest_rvh->site_instance(); | 701 return dest_rvh->GetSiteInstance(); |
702 } | 702 } |
703 | 703 |
704 bool TabContents::IsLoading() const { | 704 bool TabContents::IsLoading() const { |
705 return is_loading_; | 705 return is_loading_; |
706 } | 706 } |
707 | 707 |
708 bool TabContents::IsWaitingForResponse() const { | 708 bool TabContents::IsWaitingForResponse() const { |
709 return waiting_for_response_; | 709 return waiting_for_response_; |
710 } | 710 } |
711 | 711 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 rwhv->SetActive(true); | 775 rwhv->SetActive(true); |
776 #endif | 776 #endif |
777 } | 777 } |
778 | 778 |
779 last_selected_time_ = base::TimeTicks::Now(); | 779 last_selected_time_ = base::TimeTicks::Now(); |
780 | 780 |
781 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidBecomeSelected()); | 781 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidBecomeSelected()); |
782 | 782 |
783 // The resize rect might have changed while this was inactive -- send the new | 783 // The resize rect might have changed while this was inactive -- send the new |
784 // one to make sure it's up to date. | 784 // one to make sure it's up to date. |
785 RenderViewHost* rvh = GetRenderViewHost(); | 785 RenderViewHostImpl* rvh = |
| 786 static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
786 if (rvh) { | 787 if (rvh) { |
787 rvh->ResizeRectChanged(GetRootWindowResizerRect()); | 788 rvh->ResizeRectChanged(GetRootWindowResizerRect()); |
788 } | 789 } |
789 } | 790 } |
790 | 791 |
791 | 792 |
792 base::TimeTicks TabContents::GetLastSelectedTime() const { | 793 base::TimeTicks TabContents::GetLastSelectedTime() const { |
793 return last_selected_time_; | 794 return last_selected_time_; |
794 } | 795 } |
795 | 796 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 // here practically impossible to understand, this also means we end up | 828 // here practically impossible to understand, this also means we end up |
828 // calling TabContents::WasHidden() twice if callers call both versions of | 829 // calling TabContents::WasHidden() twice if callers call both versions of |
829 // HideContents() on a TabContents. | 830 // HideContents() on a TabContents. |
830 WasHidden(); | 831 WasHidden(); |
831 } | 832 } |
832 | 833 |
833 bool TabContents::NeedToFireBeforeUnload() { | 834 bool TabContents::NeedToFireBeforeUnload() { |
834 // TODO(creis): Should we fire even for interstitial pages? | 835 // TODO(creis): Should we fire even for interstitial pages? |
835 return WillNotifyDisconnection() && | 836 return WillNotifyDisconnection() && |
836 !ShowingInterstitialPage() && | 837 !ShowingInterstitialPage() && |
837 !GetRenderViewHost()->SuddenTerminationAllowed(); | 838 !static_cast<RenderViewHostImpl*>( |
| 839 GetRenderViewHost())->SuddenTerminationAllowed(); |
838 } | 840 } |
839 | 841 |
840 void TabContents::Stop() { | 842 void TabContents::Stop() { |
841 render_manager_.Stop(); | 843 render_manager_.Stop(); |
842 FOR_EACH_OBSERVER(WebContentsObserver, observers_, StopNavigation()); | 844 FOR_EACH_OBSERVER(WebContentsObserver, observers_, StopNavigation()); |
843 } | 845 } |
844 | 846 |
845 WebContents* TabContents::Clone() { | 847 WebContents* TabContents::Clone() { |
846 // We create a new SiteInstance so that the new tab won't share processes | 848 // We create a new SiteInstance so that the new tab won't share processes |
847 // with the old one. This can be changed in the future if we need it to share | 849 // with the old one. This can be changed in the future if we need it to share |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 } | 988 } |
987 | 989 |
988 bool TabContents::NavigateToEntry( | 990 bool TabContents::NavigateToEntry( |
989 const NavigationEntryImpl& entry, | 991 const NavigationEntryImpl& entry, |
990 NavigationController::ReloadType reload_type) { | 992 NavigationController::ReloadType reload_type) { |
991 // The renderer will reject IPC messages with URLs longer than | 993 // The renderer will reject IPC messages with URLs longer than |
992 // this limit, so don't attempt to navigate with a longer URL. | 994 // this limit, so don't attempt to navigate with a longer URL. |
993 if (entry.GetURL().spec().size() > content::kMaxURLChars) | 995 if (entry.GetURL().spec().size() > content::kMaxURLChars) |
994 return false; | 996 return false; |
995 | 997 |
996 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); | 998 RenderViewHostImpl* dest_render_view_host = |
| 999 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry)); |
997 if (!dest_render_view_host) | 1000 if (!dest_render_view_host) |
998 return false; // Unable to create the desired render view host. | 1001 return false; // Unable to create the desired render view host. |
999 | 1002 |
1000 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 1003 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
1001 // Double check that here. | 1004 // Double check that here. |
1002 int enabled_bindings = dest_render_view_host->enabled_bindings(); | 1005 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); |
1003 WebUIControllerFactory* factory = | 1006 WebUIControllerFactory* factory = |
1004 content::GetContentClient()->browser()->GetWebUIControllerFactory(); | 1007 content::GetContentClient()->browser()->GetWebUIControllerFactory(); |
1005 bool is_allowed_in_web_ui_renderer = | 1008 bool is_allowed_in_web_ui_renderer = |
1006 factory && | 1009 factory && |
1007 factory->IsURLAcceptableForWebUI(GetBrowserContext(), entry.GetURL()); | 1010 factory->IsURLAcceptableForWebUI(GetBrowserContext(), entry.GetURL()); |
1008 #if defined(OS_CHROMEOS) | 1011 #if defined(OS_CHROMEOS) |
1009 is_allowed_in_web_ui_renderer |= entry.GetURL().SchemeIs(chrome::kDataScheme); | 1012 is_allowed_in_web_ui_renderer |= entry.GetURL().SchemeIs(chrome::kDataScheme); |
1010 #endif | 1013 #endif |
1011 CHECK(!(enabled_bindings & content::BINDINGS_POLICY_WEB_UI) || | 1014 CHECK(!(enabled_bindings & content::BINDINGS_POLICY_WEB_UI) || |
1012 is_allowed_in_web_ui_renderer); | 1015 is_allowed_in_web_ui_renderer); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 void TabContents::SetHistoryLengthAndPrune( | 1053 void TabContents::SetHistoryLengthAndPrune( |
1051 const SiteInstance* site_instance, | 1054 const SiteInstance* site_instance, |
1052 int history_length, | 1055 int history_length, |
1053 int32 minimum_page_id) { | 1056 int32 minimum_page_id) { |
1054 // SetHistoryLengthAndPrune doesn't work when there are pending cross-site | 1057 // SetHistoryLengthAndPrune doesn't work when there are pending cross-site |
1055 // navigations. Callers should ensure that this is the case. | 1058 // navigations. Callers should ensure that this is the case. |
1056 if (render_manager_.pending_render_view_host()) { | 1059 if (render_manager_.pending_render_view_host()) { |
1057 NOTREACHED(); | 1060 NOTREACHED(); |
1058 return; | 1061 return; |
1059 } | 1062 } |
1060 RenderViewHost* rvh = GetRenderViewHost(); | 1063 RenderViewHostImpl* rvh = GetRenderViewHostImpl(); |
1061 if (!rvh) { | 1064 if (!rvh) { |
1062 NOTREACHED(); | 1065 NOTREACHED(); |
1063 return; | 1066 return; |
1064 } | 1067 } |
1065 if (site_instance && rvh->site_instance() != site_instance) { | 1068 if (site_instance && rvh->GetSiteInstance() != site_instance) { |
1066 NOTREACHED(); | 1069 NOTREACHED(); |
1067 return; | 1070 return; |
1068 } | 1071 } |
1069 rvh->Send(new ViewMsg_SetHistoryLengthAndPrune(rvh->routing_id(), | 1072 rvh->Send(new ViewMsg_SetHistoryLengthAndPrune(rvh->GetRoutingID(), |
1070 history_length, | 1073 history_length, |
1071 minimum_page_id)); | 1074 minimum_page_id)); |
1072 } | 1075 } |
1073 | 1076 |
1074 void TabContents::FocusThroughTabTraversal(bool reverse) { | 1077 void TabContents::FocusThroughTabTraversal(bool reverse) { |
1075 if (ShowingInterstitialPage()) { | 1078 if (ShowingInterstitialPage()) { |
1076 render_manager_.interstitial_page()->FocusThroughTabTraversal(reverse); | 1079 render_manager_.interstitial_page()->FocusThroughTabTraversal(reverse); |
1077 return; | 1080 return; |
1078 } | 1081 } |
1079 GetRenderViewHost()->SetInitialFocus(reverse); | 1082 GetRenderViewHostImpl()->SetInitialFocus(reverse); |
1080 } | 1083 } |
1081 | 1084 |
1082 bool TabContents::ShowingInterstitialPage() const { | 1085 bool TabContents::ShowingInterstitialPage() const { |
1083 return render_manager_.interstitial_page() != NULL; | 1086 return render_manager_.interstitial_page() != NULL; |
1084 } | 1087 } |
1085 | 1088 |
1086 InterstitialPage* TabContents::GetInterstitialPage() const { | 1089 InterstitialPage* TabContents::GetInterstitialPage() const { |
1087 return render_manager_.interstitial_page(); | 1090 return render_manager_.interstitial_page(); |
1088 } | 1091 } |
1089 | 1092 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 const std::string& TabContents::GetContentsMimeType() const { | 1142 const std::string& TabContents::GetContentsMimeType() const { |
1140 return contents_mime_type_; | 1143 return contents_mime_type_; |
1141 } | 1144 } |
1142 | 1145 |
1143 bool TabContents::WillNotifyDisconnection() const { | 1146 bool TabContents::WillNotifyDisconnection() const { |
1144 return notify_disconnection_; | 1147 return notify_disconnection_; |
1145 } | 1148 } |
1146 | 1149 |
1147 void TabContents::SetOverrideEncoding(const std::string& encoding) { | 1150 void TabContents::SetOverrideEncoding(const std::string& encoding) { |
1148 SetEncoding(encoding); | 1151 SetEncoding(encoding); |
1149 GetRenderViewHost()->Send(new ViewMsg_SetPageEncoding( | 1152 GetRenderViewHostImpl()->Send(new ViewMsg_SetPageEncoding( |
1150 GetRenderViewHost()->routing_id(), encoding)); | 1153 GetRenderViewHost()->GetRoutingID(), encoding)); |
1151 } | 1154 } |
1152 | 1155 |
1153 void TabContents::ResetOverrideEncoding() { | 1156 void TabContents::ResetOverrideEncoding() { |
1154 encoding_.clear(); | 1157 encoding_.clear(); |
1155 GetRenderViewHost()->Send(new ViewMsg_ResetPageEncodingToDefault( | 1158 GetRenderViewHostImpl()->Send(new ViewMsg_ResetPageEncodingToDefault( |
1156 GetRenderViewHost()->routing_id())); | 1159 GetRenderViewHost()->GetRoutingID())); |
1157 } | 1160 } |
1158 | 1161 |
1159 content::RendererPreferences* TabContents::GetMutableRendererPrefs() { | 1162 content::RendererPreferences* TabContents::GetMutableRendererPrefs() { |
1160 return &renderer_preferences_; | 1163 return &renderer_preferences_; |
1161 } | 1164 } |
1162 | 1165 |
1163 void TabContents::SetNewTabStartTime(const base::TimeTicks& time) { | 1166 void TabContents::SetNewTabStartTime(const base::TimeTicks& time) { |
1164 new_tab_start_time_ = time; | 1167 new_tab_start_time_ = time; |
1165 } | 1168 } |
1166 | 1169 |
(...skipping 13 matching lines...) Expand all Loading... |
1180 if (delegate_ && delegate_->IsPopupOrPanel(this)) | 1183 if (delegate_ && delegate_->IsPopupOrPanel(this)) |
1181 return false; | 1184 return false; |
1182 return true; | 1185 return true; |
1183 #else | 1186 #else |
1184 return true; | 1187 return true; |
1185 #endif | 1188 #endif |
1186 } | 1189 } |
1187 | 1190 |
1188 void TabContents::SystemDragEnded() { | 1191 void TabContents::SystemDragEnded() { |
1189 if (GetRenderViewHost()) | 1192 if (GetRenderViewHost()) |
1190 GetRenderViewHost()->DragSourceSystemDragEnded(); | 1193 GetRenderViewHostImpl()->DragSourceSystemDragEnded(); |
1191 if (delegate_) | 1194 if (delegate_) |
1192 delegate_->DragEnded(); | 1195 delegate_->DragEnded(); |
1193 } | 1196 } |
1194 | 1197 |
1195 void TabContents::SetClosedByUserGesture(bool value) { | 1198 void TabContents::SetClosedByUserGesture(bool value) { |
1196 closed_by_user_gesture_ = value; | 1199 closed_by_user_gesture_ = value; |
1197 } | 1200 } |
1198 | 1201 |
1199 bool TabContents::GetClosedByUserGesture() const { | 1202 bool TabContents::GetClosedByUserGesture() const { |
1200 return closed_by_user_gesture_; | 1203 return closed_by_user_gesture_; |
1201 } | 1204 } |
1202 | 1205 |
1203 double TabContents::GetZoomLevel() const { | 1206 double TabContents::GetZoomLevel() const { |
1204 HostZoomMapImpl* zoom_map = static_cast<HostZoomMapImpl*>( | 1207 HostZoomMapImpl* zoom_map = static_cast<HostZoomMapImpl*>( |
1205 HostZoomMap::GetForBrowserContext(GetBrowserContext())); | 1208 HostZoomMap::GetForBrowserContext(GetBrowserContext())); |
1206 if (!zoom_map) | 1209 if (!zoom_map) |
1207 return 0; | 1210 return 0; |
1208 | 1211 |
1209 double zoom_level; | 1212 double zoom_level; |
1210 if (temporary_zoom_settings_) { | 1213 if (temporary_zoom_settings_) { |
1211 zoom_level = zoom_map->GetTemporaryZoomLevel( | 1214 zoom_level = zoom_map->GetTemporaryZoomLevel( |
1212 GetRenderProcessHost()->GetID(), GetRenderViewHost()->routing_id()); | 1215 GetRenderProcessHost()->GetID(), GetRenderViewHost()->GetRoutingID()); |
1213 } else { | 1216 } else { |
1214 GURL url; | 1217 GURL url; |
1215 NavigationEntry* active_entry = GetController().GetActiveEntry(); | 1218 NavigationEntry* active_entry = GetController().GetActiveEntry(); |
1216 // Since zoom map is updated using rewritten URL, use rewritten URL | 1219 // Since zoom map is updated using rewritten URL, use rewritten URL |
1217 // to get the zoom level. | 1220 // to get the zoom level. |
1218 url = active_entry ? active_entry->GetURL() : GURL::EmptyGURL(); | 1221 url = active_entry ? active_entry->GetURL() : GURL::EmptyGURL(); |
1219 zoom_level = zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(url)); | 1222 zoom_level = zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(url)); |
1220 } | 1223 } |
1221 return zoom_level; | 1224 return zoom_level; |
1222 } | 1225 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 // -> Use committed Web UI. | 1314 // -> Use committed Web UI. |
1312 if (controller_.GetPendingEntry() && | 1315 if (controller_.GetPendingEntry() && |
1313 (controller_.GetLastCommittedEntry() || | 1316 (controller_.GetLastCommittedEntry() || |
1314 render_manager_.pending_web_ui())) | 1317 render_manager_.pending_web_ui())) |
1315 return render_manager_.pending_web_ui(); | 1318 return render_manager_.pending_web_ui(); |
1316 return render_manager_.web_ui(); | 1319 return render_manager_.web_ui(); |
1317 } | 1320 } |
1318 | 1321 |
1319 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { | 1322 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { |
1320 return GetRenderViewHost() ? | 1323 return GetRenderViewHost() ? |
1321 GetRenderViewHost()->GotResponseToLockMouseRequest(allowed) : false; | 1324 GetRenderViewHostImpl()->GotResponseToLockMouseRequest(allowed) : false; |
1322 } | 1325 } |
1323 | 1326 |
1324 bool TabContents::FocusLocationBarByDefault() { | 1327 bool TabContents::FocusLocationBarByDefault() { |
1325 content::WebUI* web_ui = GetWebUIForCurrentState(); | 1328 content::WebUI* web_ui = GetWebUIForCurrentState(); |
1326 if (web_ui) | 1329 if (web_ui) |
1327 return web_ui->ShouldFocusLocationBarByDefault(); | 1330 return web_ui->ShouldFocusLocationBarByDefault(); |
1328 NavigationEntry* entry = controller_.GetActiveEntry(); | 1331 NavigationEntry* entry = controller_.GetActiveEntry(); |
1329 if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)) | 1332 if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)) |
1330 return true; | 1333 return true; |
1331 return false; | 1334 return false; |
(...skipping 19 matching lines...) Expand all Loading... |
1351 new WebIntentsDispatcherImpl(this, intent, intent_id); | 1354 new WebIntentsDispatcherImpl(this, intent, intent_id); |
1352 delegate_->WebIntentDispatch(this, intents_dispatcher); | 1355 delegate_->WebIntentDispatch(this, intents_dispatcher); |
1353 } | 1356 } |
1354 | 1357 |
1355 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, | 1358 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, |
1356 bool is_main_frame, | 1359 bool is_main_frame, |
1357 const GURL& opener_url, | 1360 const GURL& opener_url, |
1358 const GURL& url) { | 1361 const GURL& url) { |
1359 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); | 1362 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); |
1360 GURL validated_url(url); | 1363 GURL validated_url(url); |
1361 GetRenderViewHost()->FilterURL(ChildProcessSecurityPolicyImpl::GetInstance(), | 1364 GetRenderViewHostImpl()->FilterURL( |
1362 GetRenderProcessHost()->GetID(), &validated_url); | 1365 ChildProcessSecurityPolicyImpl::GetInstance(), |
| 1366 GetRenderProcessHost()->GetID(), |
| 1367 &validated_url); |
1363 | 1368 |
1364 RenderViewHost* rvh = | 1369 RenderViewHost* rvh = |
1365 render_manager_.pending_render_view_host() ? | 1370 render_manager_.pending_render_view_host() ? |
1366 render_manager_.pending_render_view_host() : GetRenderViewHost(); | 1371 render_manager_.pending_render_view_host() : GetRenderViewHost(); |
1367 // Notify observers about the start of the provisional load. | 1372 // Notify observers about the start of the provisional load. |
1368 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1373 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
1369 DidStartProvisionalLoadForFrame(frame_id, is_main_frame, | 1374 DidStartProvisionalLoadForFrame(frame_id, is_main_frame, |
1370 validated_url, is_error_page, rvh)); | 1375 validated_url, is_error_page, rvh)); |
1371 | 1376 |
1372 if (is_main_frame) { | 1377 if (is_main_frame) { |
(...skipping 27 matching lines...) Expand all Loading... |
1400 void TabContents::OnDidFailProvisionalLoadWithError( | 1405 void TabContents::OnDidFailProvisionalLoadWithError( |
1401 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) { | 1406 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) { |
1402 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() | 1407 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() |
1403 << ", error_code: " << params.error_code | 1408 << ", error_code: " << params.error_code |
1404 << ", error_description: " << params.error_description | 1409 << ", error_description: " << params.error_description |
1405 << ", is_main_frame: " << params.is_main_frame | 1410 << ", is_main_frame: " << params.is_main_frame |
1406 << ", showing_repost_interstitial: " << | 1411 << ", showing_repost_interstitial: " << |
1407 params.showing_repost_interstitial | 1412 params.showing_repost_interstitial |
1408 << ", frame_id: " << params.frame_id; | 1413 << ", frame_id: " << params.frame_id; |
1409 GURL validated_url(params.url); | 1414 GURL validated_url(params.url); |
1410 GetRenderViewHost()->FilterURL(ChildProcessSecurityPolicyImpl::GetInstance(), | 1415 GetRenderViewHostImpl()->FilterURL( |
1411 GetRenderProcessHost()->GetID(), &validated_url); | 1416 ChildProcessSecurityPolicyImpl::GetInstance(), |
| 1417 GetRenderProcessHost()->GetID(), |
| 1418 &validated_url); |
1412 | 1419 |
1413 if (net::ERR_ABORTED == params.error_code) { | 1420 if (net::ERR_ABORTED == params.error_code) { |
1414 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. | 1421 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. |
1415 // This means that the interstitial won't be torn down properly, which is | 1422 // This means that the interstitial won't be torn down properly, which is |
1416 // bad. But if we have an interstitial, go back to another tab type, and | 1423 // bad. But if we have an interstitial, go back to another tab type, and |
1417 // then load the same interstitial again, we could end up getting the first | 1424 // then load the same interstitial again, we could end up getting the first |
1418 // interstitial's "failed" message (as a result of the cancel) when we're on | 1425 // interstitial's "failed" message (as a result of the cancel) when we're on |
1419 // the second one. | 1426 // the second one. |
1420 // | 1427 // |
1421 // We can't tell this apart, so we think we're tearing down the current page | 1428 // We can't tell this apart, so we think we're tearing down the current page |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1619 int active_match_ordinal, | 1626 int active_match_ordinal, |
1620 bool final_update) { | 1627 bool final_update) { |
1621 delegate_->FindReply(this, request_id, number_of_matches, selection_rect, | 1628 delegate_->FindReply(this, request_id, number_of_matches, selection_rect, |
1622 active_match_ordinal, final_update); | 1629 active_match_ordinal, final_update); |
1623 // Send a notification to the renderer that we are ready to receive more | 1630 // Send a notification to the renderer that we are ready to receive more |
1624 // results from the scoping effort of the Find operation. The FindInPage | 1631 // results from the scoping effort of the Find operation. The FindInPage |
1625 // scoping is asynchronous and periodically sends results back up to the | 1632 // scoping is asynchronous and periodically sends results back up to the |
1626 // browser using IPC. In an effort to not spam the browser we have the | 1633 // browser using IPC. In an effort to not spam the browser we have the |
1627 // browser send an ACK for each FindReply message and have the renderer | 1634 // browser send an ACK for each FindReply message and have the renderer |
1628 // queue up the latest status message while waiting for this ACK. | 1635 // queue up the latest status message while waiting for this ACK. |
1629 GetRenderViewHost()->Send( | 1636 GetRenderViewHostImpl()->Send( |
1630 new ViewMsg_FindReplyACK(GetRenderViewHost()->routing_id())); | 1637 new ViewMsg_FindReplyACK(GetRenderViewHost()->GetRoutingID())); |
1631 } | 1638 } |
1632 | 1639 |
1633 void TabContents::OnCrashedPlugin(const FilePath& plugin_path) { | 1640 void TabContents::OnCrashedPlugin(const FilePath& plugin_path) { |
1634 delegate_->CrashedPlugin(this, plugin_path); | 1641 delegate_->CrashedPlugin(this, plugin_path); |
1635 } | 1642 } |
1636 | 1643 |
1637 void TabContents::OnAppCacheAccessed(const GURL& manifest_url, | 1644 void TabContents::OnAppCacheAccessed(const GURL& manifest_url, |
1638 bool blocked_by_policy) { | 1645 bool blocked_by_policy) { |
1639 // Notify observers about navigation. | 1646 // Notify observers about navigation. |
1640 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1647 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 } | 1738 } |
1732 | 1739 |
1733 void TabContents::UpdateMaxPageIDIfNecessary(RenderViewHost* rvh) { | 1740 void TabContents::UpdateMaxPageIDIfNecessary(RenderViewHost* rvh) { |
1734 // If we are creating a RVH for a restored controller, then we need to make | 1741 // If we are creating a RVH for a restored controller, then we need to make |
1735 // sure the RenderView starts with a next_page_id_ larger than the number | 1742 // sure the RenderView starts with a next_page_id_ larger than the number |
1736 // of restored entries. This must be called before the RenderView starts | 1743 // of restored entries. This must be called before the RenderView starts |
1737 // navigating (to avoid a race between the browser updating max_page_id and | 1744 // navigating (to avoid a race between the browser updating max_page_id and |
1738 // the renderer updating next_page_id_). Because of this, we only call this | 1745 // the renderer updating next_page_id_). Because of this, we only call this |
1739 // from CreateRenderView and allow that to notify the RenderView for us. | 1746 // from CreateRenderView and allow that to notify the RenderView for us. |
1740 int max_restored_page_id = controller_.GetMaxRestoredPageID(); | 1747 int max_restored_page_id = controller_.GetMaxRestoredPageID(); |
1741 if (max_restored_page_id > GetMaxPageIDForSiteInstance(rvh->site_instance())) | 1748 if (max_restored_page_id > |
1742 UpdateMaxPageIDForSiteInstance(rvh->site_instance(), max_restored_page_id); | 1749 GetMaxPageIDForSiteInstance(rvh->GetSiteInstance())) |
| 1750 UpdateMaxPageIDForSiteInstance(rvh->GetSiteInstance(), |
| 1751 max_restored_page_id); |
1743 } | 1752 } |
1744 | 1753 |
1745 bool TabContents::UpdateTitleForEntry(NavigationEntryImpl* entry, | 1754 bool TabContents::UpdateTitleForEntry(NavigationEntryImpl* entry, |
1746 const string16& title) { | 1755 const string16& title) { |
1747 // For file URLs without a title, use the pathname instead. In the case of a | 1756 // For file URLs without a title, use the pathname instead. In the case of a |
1748 // synthesized title, we don't want the update to count toward the "one set | 1757 // synthesized title, we don't want the update to count toward the "one set |
1749 // per page of the title to history." | 1758 // per page of the title to history." |
1750 string16 final_title; | 1759 string16 final_title; |
1751 bool explicit_set; | 1760 bool explicit_set; |
1752 if (entry && entry->GetURL().SchemeIsFile() && title.empty()) { | 1761 if (entry && entry->GetURL().SchemeIsFile() && title.empty()) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1852 if (!entry) | 1861 if (!entry) |
1853 return; | 1862 return; |
1854 | 1863 |
1855 // When we're creating views, we're still doing initial setup, so we always | 1864 // When we're creating views, we're still doing initial setup, so we always |
1856 // use the pending Web UI rather than any possibly existing committed one. | 1865 // use the pending Web UI rather than any possibly existing committed one. |
1857 if (render_manager_.pending_web_ui()) | 1866 if (render_manager_.pending_web_ui()) |
1858 render_manager_.pending_web_ui()->RenderViewCreated(render_view_host); | 1867 render_manager_.pending_web_ui()->RenderViewCreated(render_view_host); |
1859 | 1868 |
1860 if (entry->IsViewSourceMode()) { | 1869 if (entry->IsViewSourceMode()) { |
1861 // Put the renderer in view source mode. | 1870 // Put the renderer in view source mode. |
1862 render_view_host->Send( | 1871 static_cast<RenderViewHostImpl*>(render_view_host)->Send( |
1863 new ViewMsg_EnableViewSourceMode(render_view_host->routing_id())); | 1872 new ViewMsg_EnableViewSourceMode(render_view_host->GetRoutingID())); |
1864 } | 1873 } |
1865 | 1874 |
1866 GetView()->RenderViewCreated(render_view_host); | 1875 GetView()->RenderViewCreated(render_view_host); |
1867 | 1876 |
1868 FOR_EACH_OBSERVER( | 1877 FOR_EACH_OBSERVER( |
1869 WebContentsObserver, observers_, RenderViewCreated(render_view_host)); | 1878 WebContentsObserver, observers_, RenderViewCreated(render_view_host)); |
1870 } | 1879 } |
1871 | 1880 |
1872 void TabContents::RenderViewReady(RenderViewHost* rvh) { | 1881 void TabContents::RenderViewReady(RenderViewHost* rvh) { |
1873 if (rvh != GetRenderViewHost()) { | 1882 if (rvh != GetRenderViewHost()) { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1989 // the swapped out RVHs. We don't expect to hear from any other RVHs. | 1998 // the swapped out RVHs. We don't expect to hear from any other RVHs. |
1990 DCHECK(rvh == GetRenderViewHost() || render_manager_.IsSwappedOut(rvh)); | 1999 DCHECK(rvh == GetRenderViewHost() || render_manager_.IsSwappedOut(rvh)); |
1991 | 2000 |
1992 // We must be prepared to handle state updates for any page, these occur | 2001 // We must be prepared to handle state updates for any page, these occur |
1993 // when the user is scrolling and entering form data, as well as when we're | 2002 // when the user is scrolling and entering form data, as well as when we're |
1994 // leaving a page, in which case our state may have already been moved to | 2003 // leaving a page, in which case our state may have already been moved to |
1995 // the next page. The navigation controller will look up the appropriate | 2004 // the next page. The navigation controller will look up the appropriate |
1996 // NavigationEntry and update it when it is notified via the delegate. | 2005 // NavigationEntry and update it when it is notified via the delegate. |
1997 | 2006 |
1998 int entry_index = controller_.GetEntryIndexWithPageID( | 2007 int entry_index = controller_.GetEntryIndexWithPageID( |
1999 rvh->site_instance(), page_id); | 2008 rvh->GetSiteInstance(), page_id); |
2000 if (entry_index < 0) | 2009 if (entry_index < 0) |
2001 return; | 2010 return; |
2002 NavigationEntry* entry = controller_.GetEntryAtIndex(entry_index); | 2011 NavigationEntry* entry = controller_.GetEntryAtIndex(entry_index); |
2003 | 2012 |
2004 if (state == entry->GetContentState()) | 2013 if (state == entry->GetContentState()) |
2005 return; // Nothing to update. | 2014 return; // Nothing to update. |
2006 entry->SetContentState(state); | 2015 entry->SetContentState(state); |
2007 controller_.NotifyEntryChanged(entry, entry_index); | 2016 controller_.NotifyEntryChanged(entry, entry_index); |
2008 } | 2017 } |
2009 | 2018 |
2010 void TabContents::UpdateTitle(RenderViewHost* rvh, | 2019 void TabContents::UpdateTitle(RenderViewHost* rvh, |
2011 int32 page_id, | 2020 int32 page_id, |
2012 const string16& title, | 2021 const string16& title, |
2013 base::i18n::TextDirection title_direction) { | 2022 base::i18n::TextDirection title_direction) { |
2014 // If we have a title, that's a pretty good indication that we've started | 2023 // If we have a title, that's a pretty good indication that we've started |
2015 // getting useful data. | 2024 // getting useful data. |
2016 SetNotWaitingForResponse(); | 2025 SetNotWaitingForResponse(); |
2017 | 2026 |
2018 // Try to find the navigation entry, which might not be the current one. | 2027 // Try to find the navigation entry, which might not be the current one. |
2019 // For example, it might be from a pending RVH for the pending entry. | 2028 // For example, it might be from a pending RVH for the pending entry. |
2020 NavigationEntryImpl* entry = controller_.GetEntryWithPageID( | 2029 NavigationEntryImpl* entry = controller_.GetEntryWithPageID( |
2021 rvh->site_instance(), page_id); | 2030 rvh->GetSiteInstance(), page_id); |
2022 | 2031 |
2023 // We can handle title updates when we don't have an entry in | 2032 // We can handle title updates when we don't have an entry in |
2024 // UpdateTitleForEntry, but only if the update is from the current RVH. | 2033 // UpdateTitleForEntry, but only if the update is from the current RVH. |
2025 if (!entry && rvh != GetRenderViewHost()) | 2034 if (!entry && rvh != GetRenderViewHost()) |
2026 return; | 2035 return; |
2027 | 2036 |
2028 // TODO(evan): make use of title_direction. | 2037 // TODO(evan): make use of title_direction. |
2029 // http://code.google.com/p/chromium/issues/detail?id=27094 | 2038 // http://code.google.com/p/chromium/issues/detail?id=27094 |
2030 if (!UpdateTitleForEntry(entry, title)) | 2039 if (!UpdateTitleForEntry(entry, title)) |
2031 return; | 2040 return; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2200 const string16& message, | 2209 const string16& message, |
2201 const string16& default_prompt, | 2210 const string16& default_prompt, |
2202 const GURL& frame_url, | 2211 const GURL& frame_url, |
2203 ui::JavascriptMessageType javascript_message_type, | 2212 ui::JavascriptMessageType javascript_message_type, |
2204 IPC::Message* reply_msg, | 2213 IPC::Message* reply_msg, |
2205 bool* did_suppress_message) { | 2214 bool* did_suppress_message) { |
2206 // Suppress JavaScript dialogs when requested. Also suppress messages when | 2215 // Suppress JavaScript dialogs when requested. Also suppress messages when |
2207 // showing an interstitial as it's shown over the previous page and we don't | 2216 // showing an interstitial as it's shown over the previous page and we don't |
2208 // want the hidden page's dialogs to interfere with the interstitial. | 2217 // want the hidden page's dialogs to interfere with the interstitial. |
2209 bool suppress_this_message = | 2218 bool suppress_this_message = |
2210 rvh->is_swapped_out() || | 2219 static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() || |
2211 ShowingInterstitialPage() || | 2220 ShowingInterstitialPage() || |
2212 !delegate_ || | 2221 !delegate_ || |
2213 delegate_->ShouldSuppressDialogs() || | 2222 delegate_->ShouldSuppressDialogs() || |
2214 !delegate_->GetJavaScriptDialogCreator(); | 2223 !delegate_->GetJavaScriptDialogCreator(); |
2215 | 2224 |
2216 if (!suppress_this_message) { | 2225 if (!suppress_this_message) { |
2217 content::JavaScriptDialogCreator::TitleType title_type; | 2226 content::JavaScriptDialogCreator::TitleType title_type; |
2218 string16 title; | 2227 string16 title; |
2219 | 2228 |
2220 if (!frame_url.has_host()) { | 2229 if (!frame_url.has_host()) { |
(...skipping 20 matching lines...) Expand all Loading... |
2241 // pressed "Cancel". | 2250 // pressed "Cancel". |
2242 OnDialogClosed(rvh, reply_msg, false, string16()); | 2251 OnDialogClosed(rvh, reply_msg, false, string16()); |
2243 } | 2252 } |
2244 | 2253 |
2245 *did_suppress_message = suppress_this_message; | 2254 *did_suppress_message = suppress_this_message; |
2246 } | 2255 } |
2247 | 2256 |
2248 void TabContents::RunBeforeUnloadConfirm(RenderViewHost* rvh, | 2257 void TabContents::RunBeforeUnloadConfirm(RenderViewHost* rvh, |
2249 const string16& message, | 2258 const string16& message, |
2250 IPC::Message* reply_msg) { | 2259 IPC::Message* reply_msg) { |
| 2260 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); |
2251 if (delegate_) | 2261 if (delegate_) |
2252 delegate_->WillRunBeforeUnloadConfirm(); | 2262 delegate_->WillRunBeforeUnloadConfirm(); |
2253 | 2263 |
2254 bool suppress_this_message = | 2264 bool suppress_this_message = |
2255 rvh->is_swapped_out() || | 2265 rvhi->is_swapped_out() || |
2256 !delegate_ || | 2266 !delegate_ || |
2257 delegate_->ShouldSuppressDialogs() || | 2267 delegate_->ShouldSuppressDialogs() || |
2258 !delegate_->GetJavaScriptDialogCreator(); | 2268 !delegate_->GetJavaScriptDialogCreator(); |
2259 if (suppress_this_message) { | 2269 if (suppress_this_message) { |
2260 // The reply must be sent to the RVH that sent the request. | 2270 // The reply must be sent to the RVH that sent the request. |
2261 rvh->JavaScriptDialogClosed(reply_msg, true, string16()); | 2271 rvhi->JavaScriptDialogClosed(reply_msg, true, string16()); |
2262 return; | 2272 return; |
2263 } | 2273 } |
2264 | 2274 |
2265 is_showing_before_unload_dialog_ = true; | 2275 is_showing_before_unload_dialog_ = true; |
2266 dialog_creator_ = delegate_->GetJavaScriptDialogCreator(); | 2276 dialog_creator_ = delegate_->GetJavaScriptDialogCreator(); |
2267 dialog_creator_->RunBeforeUnloadDialog( | 2277 dialog_creator_->RunBeforeUnloadDialog( |
2268 this, message, | 2278 this, message, |
2269 base::Bind(&TabContents::OnDialogClosed, base::Unretained(this), rvh, | 2279 base::Bind(&TabContents::OnDialogClosed, base::Unretained(this), rvh, |
2270 reply_msg)); | 2280 reply_msg)); |
2271 } | 2281 } |
(...skipping 15 matching lines...) Expand all Loading... |
2287 // Notify observers. | 2297 // Notify observers. |
2288 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetIgnoredUIEvent()); | 2298 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetIgnoredUIEvent()); |
2289 } | 2299 } |
2290 | 2300 |
2291 void TabContents::RendererUnresponsive(RenderViewHost* rvh, | 2301 void TabContents::RendererUnresponsive(RenderViewHost* rvh, |
2292 bool is_during_unload) { | 2302 bool is_during_unload) { |
2293 // Don't show hung renderer dialog for a swapped out RVH. | 2303 // Don't show hung renderer dialog for a swapped out RVH. |
2294 if (rvh != GetRenderViewHost()) | 2304 if (rvh != GetRenderViewHost()) |
2295 return; | 2305 return; |
2296 | 2306 |
| 2307 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); |
| 2308 |
2297 // Ignore renderer unresponsive event if debugger is attached to the tab | 2309 // Ignore renderer unresponsive event if debugger is attached to the tab |
2298 // since the event may be a result of the renderer sitting on a breakpoint. | 2310 // since the event may be a result of the renderer sitting on a breakpoint. |
2299 // See http://crbug.com/65458 | 2311 // See http://crbug.com/65458 |
2300 DevToolsAgentHost* agent = | 2312 DevToolsAgentHost* agent = |
2301 content::DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh); | 2313 content::DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh); |
2302 if (agent && | 2314 if (agent && |
2303 DevToolsManagerImpl::GetInstance()->GetDevToolsClientHostFor(agent)) | 2315 DevToolsManagerImpl::GetInstance()->GetDevToolsClientHostFor(agent)) |
2304 return; | 2316 return; |
2305 | 2317 |
2306 if (is_during_unload) { | 2318 if (is_during_unload) { |
2307 // Hang occurred while firing the beforeunload/unload handler. | 2319 // Hang occurred while firing the beforeunload/unload handler. |
2308 // Pretend the handler fired so tab closing continues as if it had. | 2320 // Pretend the handler fired so tab closing continues as if it had. |
2309 rvh->set_sudden_termination_allowed(true); | 2321 rvhi->set_sudden_termination_allowed(true); |
2310 | 2322 |
2311 if (!render_manager_.ShouldCloseTabOnUnresponsiveRenderer()) | 2323 if (!render_manager_.ShouldCloseTabOnUnresponsiveRenderer()) |
2312 return; | 2324 return; |
2313 | 2325 |
2314 // If the tab hangs in the beforeunload/unload handler there's really | 2326 // If the tab hangs in the beforeunload/unload handler there's really |
2315 // nothing we can do to recover. Pretend the unload listeners have | 2327 // nothing we can do to recover. Pretend the unload listeners have |
2316 // all fired and close the tab. If the hang is in the beforeunload handler | 2328 // all fired and close the tab. If the hang is in the beforeunload handler |
2317 // then the user will not have the option of cancelling the close. | 2329 // then the user will not have the option of cancelling the close. |
2318 Close(rvh); | 2330 Close(rvh); |
2319 return; | 2331 return; |
2320 } | 2332 } |
2321 | 2333 |
2322 if (!GetRenderViewHost() || !GetRenderViewHost()->IsRenderViewLive()) | 2334 if (!GetRenderViewHostImpl() || !GetRenderViewHostImpl()->IsRenderViewLive()) |
2323 return; | 2335 return; |
2324 | 2336 |
2325 if (delegate_) | 2337 if (delegate_) |
2326 delegate_->RendererUnresponsive(this); | 2338 delegate_->RendererUnresponsive(this); |
2327 } | 2339 } |
2328 | 2340 |
2329 void TabContents::RendererResponsive(RenderViewHost* render_view_host) { | 2341 void TabContents::RendererResponsive(RenderViewHost* render_view_host) { |
2330 if (delegate_) | 2342 if (delegate_) |
2331 delegate_->RendererResponsive(this); | 2343 delegate_->RendererResponsive(this); |
2332 } | 2344 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2405 // Can be NULL during tests. | 2417 // Can be NULL during tests. |
2406 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host); | 2418 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host); |
2407 | 2419 |
2408 // Now that the RenderView has been created, we need to tell it its size. | 2420 // Now that the RenderView has been created, we need to tell it its size. |
2409 if (rwh_view) | 2421 if (rwh_view) |
2410 rwh_view->SetSize(view_->GetContainerSize()); | 2422 rwh_view->SetSize(view_->GetContainerSize()); |
2411 | 2423 |
2412 // Make sure we use the correct starting page_id in the new RenderView. | 2424 // Make sure we use the correct starting page_id in the new RenderView. |
2413 UpdateMaxPageIDIfNecessary(render_view_host); | 2425 UpdateMaxPageIDIfNecessary(render_view_host); |
2414 int32 max_page_id = | 2426 int32 max_page_id = |
2415 GetMaxPageIDForSiteInstance(render_view_host->site_instance()); | 2427 GetMaxPageIDForSiteInstance(render_view_host->GetSiteInstance()); |
2416 | 2428 |
2417 if (!render_view_host->CreateRenderView(string16(), max_page_id)) | 2429 if (!static_cast<RenderViewHostImpl*>( |
| 2430 render_view_host)->CreateRenderView(string16(), max_page_id)) |
2418 return false; | 2431 return false; |
2419 | 2432 |
2420 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 2433 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
2421 // Force a ViewMsg_Resize to be sent, needed to make plugins show up on | 2434 // Force a ViewMsg_Resize to be sent, needed to make plugins show up on |
2422 // linux. See crbug.com/83941. | 2435 // linux. See crbug.com/83941. |
2423 if (rwh_view) { | 2436 if (rwh_view) { |
2424 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) | 2437 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) |
2425 render_widget_host->WasResized(); | 2438 render_widget_host->WasResized(); |
2426 } | 2439 } |
2427 #endif | 2440 #endif |
2428 | 2441 |
2429 return true; | 2442 return true; |
2430 } | 2443 } |
2431 | 2444 |
2432 void TabContents::OnDialogClosed(RenderViewHost* rvh, | 2445 void TabContents::OnDialogClosed(RenderViewHost* rvh, |
2433 IPC::Message* reply_msg, | 2446 IPC::Message* reply_msg, |
2434 bool success, | 2447 bool success, |
2435 const string16& user_input) { | 2448 const string16& user_input) { |
2436 if (is_showing_before_unload_dialog_ && !success) { | 2449 if (is_showing_before_unload_dialog_ && !success) { |
2437 // If a beforeunload dialog is canceled, we need to stop the throbber from | 2450 // If a beforeunload dialog is canceled, we need to stop the throbber from |
2438 // spinning, since we forced it to start spinning in Navigate. | 2451 // spinning, since we forced it to start spinning in Navigate. |
2439 DidStopLoading(); | 2452 DidStopLoading(); |
2440 | 2453 |
2441 tab_close_start_time_ = base::TimeTicks(); | 2454 tab_close_start_time_ = base::TimeTicks(); |
2442 } | 2455 } |
2443 is_showing_before_unload_dialog_ = false; | 2456 is_showing_before_unload_dialog_ = false; |
2444 rvh->JavaScriptDialogClosed(reply_msg, success, user_input); | 2457 static_cast<RenderViewHostImpl*>( |
| 2458 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); |
2445 } | 2459 } |
2446 | 2460 |
2447 void TabContents::SetEncoding(const std::string& encoding) { | 2461 void TabContents::SetEncoding(const std::string& encoding) { |
2448 encoding_ = content::GetContentClient()->browser()-> | 2462 encoding_ = content::GetContentClient()->browser()-> |
2449 GetCanonicalEncodingNameByAliasName(encoding); | 2463 GetCanonicalEncodingNameByAliasName(encoding); |
2450 } | 2464 } |
2451 | 2465 |
2452 void TabContents::SaveURL(const GURL& url, | 2466 void TabContents::SaveURL(const GURL& url, |
2453 const GURL& referrer, | 2467 const GURL& referrer, |
2454 bool is_main_frame) { | 2468 bool is_main_frame) { |
(...skipping 16 matching lines...) Expand all Loading... |
2471 save_info, | 2485 save_info, |
2472 this); | 2486 this); |
2473 } | 2487 } |
2474 | 2488 |
2475 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2489 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2476 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); | 2490 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); |
2477 // Can be NULL during tests. | 2491 // Can be NULL during tests. |
2478 if (rwh_view) | 2492 if (rwh_view) |
2479 rwh_view->SetSize(GetView()->GetContainerSize()); | 2493 rwh_view->SetSize(GetView()->GetContainerSize()); |
2480 } | 2494 } |
| 2495 |
| 2496 RenderViewHostImpl* TabContents::GetRenderViewHostImpl() { |
| 2497 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
| 2498 } |
OLD | NEW |