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