Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(849)

Side by Side Diff: content/browser/tab_contents/tab_contents.cc

Issue 9473001: Extract minimal RenderViewHost interface for embedders, leaving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 290 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
291 content::Source<WebContents>(this), 291 content::Source<WebContents>(this),
292 content::NotificationService::NoDetails()); 292 content::NotificationService::NoDetails());
293 293
294 // TODO(brettw) this should be moved to the view. 294 // TODO(brettw) this should be moved to the view.
295 #if defined(OS_WIN) && !defined(USE_AURA) 295 #if defined(OS_WIN) && !defined(USE_AURA)
296 // If we still have a window handle, destroy it. GetNativeView can return 296 // If we still have a window handle, destroy it. GetNativeView can return
297 // NULL if this contents was part of a window that closed. 297 // NULL if this contents was part of a window that closed.
298 if (GetNativeView()) { 298 if (GetNativeView()) {
299 RenderViewHost* host = GetRenderViewHost(); 299 RenderViewHost* host = GetRenderViewHost();
300 if (host && host->view()) 300 if (host && host->GetView())
301 RenderWidgetHostViewPort::FromRWHV(host->view())->WillWmDestroy(); 301 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy();
302 } 302 }
303 #endif 303 #endif
304 304
305 // OnCloseStarted isn't called in unit tests. 305 // OnCloseStarted isn't called in unit tests.
306 if (!tab_close_start_time_.is_null()) { 306 if (!tab_close_start_time_.is_null()) {
307 UMA_HISTOGRAM_TIMES("Tab.Close", 307 UMA_HISTOGRAM_TIMES("Tab.Close",
308 base::TimeTicks::Now() - tab_close_start_time_); 308 base::TimeTicks::Now() - tab_close_start_time_);
309 } 309 }
310 310
311 FOR_EACH_OBSERVER(WebContentsObserver, observers_, TabContentsDestroyed()); 311 FOR_EACH_OBSERVER(WebContentsObserver, observers_, TabContentsDestroyed());
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 // Accelerated video and animation are slower than regular when using a 438 // Accelerated video and animation are slower than regular when using a
439 // software 3d rasterizer. 3D CSS may also be too slow to be worthwhile. 439 // software 3d rasterizer. 3D CSS may also be too slow to be worthwhile.
440 if (gpu_data_manager->ShouldUseSoftwareRendering()) { 440 if (gpu_data_manager->ShouldUseSoftwareRendering()) {
441 prefs.accelerated_video_enabled = false; 441 prefs.accelerated_video_enabled = false;
442 prefs.accelerated_animation_enabled = false; 442 prefs.accelerated_animation_enabled = false;
443 prefs.accelerated_layers_enabled = false; 443 prefs.accelerated_layers_enabled = false;
444 } 444 }
445 } 445 }
446 446
447 if (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( 447 if (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
448 rvh->process()->GetID())) { 448 rvh->GetProcess()->GetID())) {
449 prefs.loads_images_automatically = true; 449 prefs.loads_images_automatically = true;
450 prefs.javascript_enabled = true; 450 prefs.javascript_enabled = true;
451 } 451 }
452 452
453 prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); 453 prefs.is_online = !net::NetworkChangeNotifier::IsOffline();
454 454
455 // Force accelerated compositing and 2d canvas off for chrome:, about: and 455 // Force accelerated compositing and 2d canvas off for chrome:, about: and
456 // chrome-devtools: pages (unless it's specifically allowed). 456 // chrome-devtools: pages (unless it's specifically allowed).
457 if ((url.SchemeIs(chrome::kChromeDevToolsScheme) || 457 if ((url.SchemeIs(chrome::kChromeDevToolsScheme) ||
458 url.SchemeIs(chrome::kChromeUIScheme) || 458 url.SchemeIs(chrome::kChromeUIScheme) ||
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 return; 591 return;
592 if (delegate_) 592 if (delegate_)
593 delegate_->Detach(this); 593 delegate_->Detach(this);
594 delegate_ = delegate; 594 delegate_ = delegate;
595 if (delegate_) 595 if (delegate_)
596 delegate_->Attach(this); 596 delegate_->Attach(this);
597 } 597 }
598 598
599 content::RenderProcessHost* TabContents::GetRenderProcessHost() const { 599 content::RenderProcessHost* TabContents::GetRenderProcessHost() const {
600 if (render_manager_.current_host()) 600 if (render_manager_.current_host())
601 return render_manager_.current_host()->process(); 601 return render_manager_.current_host()->GetProcess();
602 else 602 else
603 return NULL; 603 return NULL;
604 } 604 }
605 605
606 RenderViewHost* TabContents::GetRenderViewHost() const { 606 RenderViewHost* TabContents::GetRenderViewHost() const {
607 return render_manager_.current_host(); 607 return render_manager_.current_host();
608 } 608 }
609 609
610 RenderWidgetHostView* TabContents::GetRenderWidgetHostView() const { 610 RenderWidgetHostView* TabContents::GetRenderWidgetHostView() const {
611 return render_manager_.GetRenderWidgetHostView(); 611 return render_manager_.GetRenderWidgetHostView();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 SiteInstance* site_instance, int32 page_id) { 697 SiteInstance* site_instance, int32 page_id) {
698 if (GetMaxPageIDForSiteInstance(site_instance) < page_id) 698 if (GetMaxPageIDForSiteInstance(site_instance) < page_id)
699 max_page_ids_[site_instance->GetId()] = page_id; 699 max_page_ids_[site_instance->GetId()] = page_id;
700 } 700 }
701 701
702 void TabContents::CopyMaxPageIDsFrom(TabContents* tab_contents) { 702 void TabContents::CopyMaxPageIDsFrom(TabContents* tab_contents) {
703 max_page_ids_ = tab_contents->max_page_ids_; 703 max_page_ids_ = tab_contents->max_page_ids_;
704 } 704 }
705 705
706 SiteInstance* TabContents::GetSiteInstance() const { 706 SiteInstance* TabContents::GetSiteInstance() const {
707 return render_manager_.current_host()->site_instance(); 707 return render_manager_.current_host()->GetSiteInstance();
708 } 708 }
709 709
710 SiteInstance* TabContents::GetPendingSiteInstance() const { 710 SiteInstance* TabContents::GetPendingSiteInstance() const {
711 RenderViewHost* dest_rvh = render_manager_.pending_render_view_host() ? 711 RenderViewHost* dest_rvh = render_manager_.pending_render_view_host() ?
712 render_manager_.pending_render_view_host() : 712 render_manager_.pending_render_view_host() :
713 render_manager_.current_host(); 713 render_manager_.current_host();
714 return dest_rvh->site_instance(); 714 return dest_rvh->GetSiteInstance();
715 } 715 }
716 716
717 bool TabContents::IsLoading() const { 717 bool TabContents::IsLoading() const {
718 return is_loading_; 718 return is_loading_;
719 } 719 }
720 720
721 bool TabContents::IsWaitingForResponse() const { 721 bool TabContents::IsWaitingForResponse() const {
722 return waiting_for_response_; 722 return waiting_for_response_;
723 } 723 }
724 724
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 rwhv->SetActive(true); 788 rwhv->SetActive(true);
789 #endif 789 #endif
790 } 790 }
791 791
792 last_selected_time_ = base::TimeTicks::Now(); 792 last_selected_time_ = base::TimeTicks::Now();
793 793
794 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidBecomeSelected()); 794 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidBecomeSelected());
795 795
796 // The resize rect might have changed while this was inactive -- send the new 796 // The resize rect might have changed while this was inactive -- send the new
797 // one to make sure it's up to date. 797 // one to make sure it's up to date.
798 RenderViewHost* rvh = GetRenderViewHost(); 798 RenderViewHostImpl* rvh =
799 static_cast<RenderViewHostImpl*>(GetRenderViewHost());
799 if (rvh) { 800 if (rvh) {
800 rvh->ResizeRectChanged(GetRootWindowResizerRect()); 801 rvh->ResizeRectChanged(GetRootWindowResizerRect());
801 } 802 }
802 } 803 }
803 804
804 805
805 base::TimeTicks TabContents::GetLastSelectedTime() const { 806 base::TimeTicks TabContents::GetLastSelectedTime() const {
806 return last_selected_time_; 807 return last_selected_time_;
807 } 808 }
808 809
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 // here practically impossible to understand, this also means we end up 841 // here practically impossible to understand, this also means we end up
841 // calling TabContents::WasHidden() twice if callers call both versions of 842 // calling TabContents::WasHidden() twice if callers call both versions of
842 // HideContents() on a TabContents. 843 // HideContents() on a TabContents.
843 WasHidden(); 844 WasHidden();
844 } 845 }
845 846
846 bool TabContents::NeedToFireBeforeUnload() { 847 bool TabContents::NeedToFireBeforeUnload() {
847 // TODO(creis): Should we fire even for interstitial pages? 848 // TODO(creis): Should we fire even for interstitial pages?
848 return WillNotifyDisconnection() && 849 return WillNotifyDisconnection() &&
849 !ShowingInterstitialPage() && 850 !ShowingInterstitialPage() &&
850 !GetRenderViewHost()->SuddenTerminationAllowed(); 851 !static_cast<RenderViewHostImpl*>(
852 GetRenderViewHost())->SuddenTerminationAllowed();
851 } 853 }
852 854
853 void TabContents::Stop() { 855 void TabContents::Stop() {
854 render_manager_.Stop(); 856 render_manager_.Stop();
855 FOR_EACH_OBSERVER(WebContentsObserver, observers_, StopNavigation()); 857 FOR_EACH_OBSERVER(WebContentsObserver, observers_, StopNavigation());
856 } 858 }
857 859
858 WebContents* TabContents::Clone() { 860 WebContents* TabContents::Clone() {
859 // We create a new SiteInstance so that the new tab won't share processes 861 // We create a new SiteInstance so that the new tab won't share processes
860 // with the old one. This can be changed in the future if we need it to share 862 // with the old one. This can be changed in the future if we need it to share
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 } 1006 }
1005 1007
1006 bool TabContents::NavigateToEntry( 1008 bool TabContents::NavigateToEntry(
1007 const NavigationEntryImpl& entry, 1009 const NavigationEntryImpl& entry,
1008 NavigationController::ReloadType reload_type) { 1010 NavigationController::ReloadType reload_type) {
1009 // The renderer will reject IPC messages with URLs longer than 1011 // The renderer will reject IPC messages with URLs longer than
1010 // this limit, so don't attempt to navigate with a longer URL. 1012 // this limit, so don't attempt to navigate with a longer URL.
1011 if (entry.GetURL().spec().size() > content::kMaxURLChars) 1013 if (entry.GetURL().spec().size() > content::kMaxURLChars)
1012 return false; 1014 return false;
1013 1015
1014 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); 1016 RenderViewHostImpl* dest_render_view_host =
1017 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry));
1015 if (!dest_render_view_host) 1018 if (!dest_render_view_host)
1016 return false; // Unable to create the desired render view host. 1019 return false; // Unable to create the desired render view host.
1017 1020
1018 // For security, we should never send non-Web-UI URLs to a Web UI renderer. 1021 // For security, we should never send non-Web-UI URLs to a Web UI renderer.
1019 // Double check that here. 1022 // Double check that here.
1020 int enabled_bindings = dest_render_view_host->enabled_bindings(); 1023 int enabled_bindings = dest_render_view_host->GetEnabledBindings();
1021 WebUIControllerFactory* factory = 1024 WebUIControllerFactory* factory =
1022 content::GetContentClient()->browser()->GetWebUIControllerFactory(); 1025 content::GetContentClient()->browser()->GetWebUIControllerFactory();
1023 bool is_allowed_in_web_ui_renderer = 1026 bool is_allowed_in_web_ui_renderer =
1024 factory && 1027 factory &&
1025 factory->IsURLAcceptableForWebUI(GetBrowserContext(), entry.GetURL()); 1028 factory->IsURLAcceptableForWebUI(GetBrowserContext(), entry.GetURL());
1026 #if defined(OS_CHROMEOS) 1029 #if defined(OS_CHROMEOS)
1027 is_allowed_in_web_ui_renderer |= entry.GetURL().SchemeIs(chrome::kDataScheme); 1030 is_allowed_in_web_ui_renderer |= entry.GetURL().SchemeIs(chrome::kDataScheme);
1028 #endif 1031 #endif
1029 CHECK(!(enabled_bindings & content::BINDINGS_POLICY_WEB_UI) || 1032 CHECK(!(enabled_bindings & content::BINDINGS_POLICY_WEB_UI) ||
1030 is_allowed_in_web_ui_renderer); 1033 is_allowed_in_web_ui_renderer);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 void TabContents::SetHistoryLengthAndPrune( 1071 void TabContents::SetHistoryLengthAndPrune(
1069 const SiteInstance* site_instance, 1072 const SiteInstance* site_instance,
1070 int history_length, 1073 int history_length,
1071 int32 minimum_page_id) { 1074 int32 minimum_page_id) {
1072 // SetHistoryLengthAndPrune doesn't work when there are pending cross-site 1075 // SetHistoryLengthAndPrune doesn't work when there are pending cross-site
1073 // navigations. Callers should ensure that this is the case. 1076 // navigations. Callers should ensure that this is the case.
1074 if (render_manager_.pending_render_view_host()) { 1077 if (render_manager_.pending_render_view_host()) {
1075 NOTREACHED(); 1078 NOTREACHED();
1076 return; 1079 return;
1077 } 1080 }
1078 RenderViewHost* rvh = GetRenderViewHost(); 1081 RenderViewHostImpl* rvh = GetRenderViewHostImpl();
1079 if (!rvh) { 1082 if (!rvh) {
1080 NOTREACHED(); 1083 NOTREACHED();
1081 return; 1084 return;
1082 } 1085 }
1083 if (site_instance && rvh->site_instance() != site_instance) { 1086 if (site_instance && rvh->GetSiteInstance() != site_instance) {
1084 NOTREACHED(); 1087 NOTREACHED();
1085 return; 1088 return;
1086 } 1089 }
1087 rvh->Send(new ViewMsg_SetHistoryLengthAndPrune(rvh->routing_id(), 1090 rvh->Send(new ViewMsg_SetHistoryLengthAndPrune(rvh->GetRoutingID(),
1088 history_length, 1091 history_length,
1089 minimum_page_id)); 1092 minimum_page_id));
1090 } 1093 }
1091 1094
1092 void TabContents::FocusThroughTabTraversal(bool reverse) { 1095 void TabContents::FocusThroughTabTraversal(bool reverse) {
1093 if (ShowingInterstitialPage()) { 1096 if (ShowingInterstitialPage()) {
1094 render_manager_.interstitial_page()->FocusThroughTabTraversal(reverse); 1097 render_manager_.interstitial_page()->FocusThroughTabTraversal(reverse);
1095 return; 1098 return;
1096 } 1099 }
1097 GetRenderViewHost()->SetInitialFocus(reverse); 1100 GetRenderViewHostImpl()->SetInitialFocus(reverse);
1098 } 1101 }
1099 1102
1100 bool TabContents::ShowingInterstitialPage() const { 1103 bool TabContents::ShowingInterstitialPage() const {
1101 return render_manager_.interstitial_page() != NULL; 1104 return render_manager_.interstitial_page() != NULL;
1102 } 1105 }
1103 1106
1104 InterstitialPage* TabContents::GetInterstitialPage() const { 1107 InterstitialPage* TabContents::GetInterstitialPage() const {
1105 return render_manager_.interstitial_page(); 1108 return render_manager_.interstitial_page();
1106 } 1109 }
1107 1110
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 const std::string& TabContents::GetContentsMimeType() const { 1166 const std::string& TabContents::GetContentsMimeType() const {
1164 return contents_mime_type_; 1167 return contents_mime_type_;
1165 } 1168 }
1166 1169
1167 bool TabContents::WillNotifyDisconnection() const { 1170 bool TabContents::WillNotifyDisconnection() const {
1168 return notify_disconnection_; 1171 return notify_disconnection_;
1169 } 1172 }
1170 1173
1171 void TabContents::SetOverrideEncoding(const std::string& encoding) { 1174 void TabContents::SetOverrideEncoding(const std::string& encoding) {
1172 SetEncoding(encoding); 1175 SetEncoding(encoding);
1173 GetRenderViewHost()->Send(new ViewMsg_SetPageEncoding( 1176 GetRenderViewHostImpl()->Send(new ViewMsg_SetPageEncoding(
1174 GetRenderViewHost()->routing_id(), encoding)); 1177 GetRenderViewHost()->GetRoutingID(), encoding));
1175 } 1178 }
1176 1179
1177 void TabContents::ResetOverrideEncoding() { 1180 void TabContents::ResetOverrideEncoding() {
1178 encoding_.clear(); 1181 encoding_.clear();
1179 GetRenderViewHost()->Send(new ViewMsg_ResetPageEncodingToDefault( 1182 GetRenderViewHostImpl()->Send(new ViewMsg_ResetPageEncodingToDefault(
1180 GetRenderViewHost()->routing_id())); 1183 GetRenderViewHost()->GetRoutingID()));
1181 } 1184 }
1182 1185
1183 content::RendererPreferences* TabContents::GetMutableRendererPrefs() { 1186 content::RendererPreferences* TabContents::GetMutableRendererPrefs() {
1184 return &renderer_preferences_; 1187 return &renderer_preferences_;
1185 } 1188 }
1186 1189
1187 void TabContents::SetNewTabStartTime(const base::TimeTicks& time) { 1190 void TabContents::SetNewTabStartTime(const base::TimeTicks& time) {
1188 new_tab_start_time_ = time; 1191 new_tab_start_time_ = time;
1189 } 1192 }
1190 1193
(...skipping 13 matching lines...) Expand all
1204 if (delegate_ && delegate_->IsPopupOrPanel(this)) 1207 if (delegate_ && delegate_->IsPopupOrPanel(this))
1205 return false; 1208 return false;
1206 return true; 1209 return true;
1207 #else 1210 #else
1208 return true; 1211 return true;
1209 #endif 1212 #endif
1210 } 1213 }
1211 1214
1212 void TabContents::SystemDragEnded() { 1215 void TabContents::SystemDragEnded() {
1213 if (GetRenderViewHost()) 1216 if (GetRenderViewHost())
1214 GetRenderViewHost()->DragSourceSystemDragEnded(); 1217 GetRenderViewHostImpl()->DragSourceSystemDragEnded();
1215 if (delegate_) 1218 if (delegate_)
1216 delegate_->DragEnded(); 1219 delegate_->DragEnded();
1217 } 1220 }
1218 1221
1219 void TabContents::SetClosedByUserGesture(bool value) { 1222 void TabContents::SetClosedByUserGesture(bool value) {
1220 closed_by_user_gesture_ = value; 1223 closed_by_user_gesture_ = value;
1221 } 1224 }
1222 1225
1223 bool TabContents::GetClosedByUserGesture() const { 1226 bool TabContents::GetClosedByUserGesture() const {
1224 return closed_by_user_gesture_; 1227 return closed_by_user_gesture_;
1225 } 1228 }
1226 1229
1227 double TabContents::GetZoomLevel() const { 1230 double TabContents::GetZoomLevel() const {
1228 HostZoomMapImpl* zoom_map = static_cast<HostZoomMapImpl*>( 1231 HostZoomMapImpl* zoom_map = static_cast<HostZoomMapImpl*>(
1229 HostZoomMap::GetForBrowserContext(GetBrowserContext())); 1232 HostZoomMap::GetForBrowserContext(GetBrowserContext()));
1230 if (!zoom_map) 1233 if (!zoom_map)
1231 return 0; 1234 return 0;
1232 1235
1233 double zoom_level; 1236 double zoom_level;
1234 if (temporary_zoom_settings_) { 1237 if (temporary_zoom_settings_) {
1235 zoom_level = zoom_map->GetTemporaryZoomLevel( 1238 zoom_level = zoom_map->GetTemporaryZoomLevel(
1236 GetRenderProcessHost()->GetID(), GetRenderViewHost()->routing_id()); 1239 GetRenderProcessHost()->GetID(), GetRenderViewHost()->GetRoutingID());
1237 } else { 1240 } else {
1238 GURL url; 1241 GURL url;
1239 NavigationEntry* active_entry = GetController().GetActiveEntry(); 1242 NavigationEntry* active_entry = GetController().GetActiveEntry();
1240 // Since zoom map is updated using rewritten URL, use rewritten URL 1243 // Since zoom map is updated using rewritten URL, use rewritten URL
1241 // to get the zoom level. 1244 // to get the zoom level.
1242 url = active_entry ? active_entry->GetURL() : GURL::EmptyGURL(); 1245 url = active_entry ? active_entry->GetURL() : GURL::EmptyGURL();
1243 zoom_level = zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(url)); 1246 zoom_level = zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(url));
1244 } 1247 }
1245 return zoom_level; 1248 return zoom_level;
1246 } 1249 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 // -> Use committed Web UI. 1338 // -> Use committed Web UI.
1336 if (controller_.GetPendingEntry() && 1339 if (controller_.GetPendingEntry() &&
1337 (controller_.GetLastCommittedEntry() || 1340 (controller_.GetLastCommittedEntry() ||
1338 render_manager_.pending_web_ui())) 1341 render_manager_.pending_web_ui()))
1339 return render_manager_.pending_web_ui(); 1342 return render_manager_.pending_web_ui();
1340 return render_manager_.web_ui(); 1343 return render_manager_.web_ui();
1341 } 1344 }
1342 1345
1343 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { 1346 bool TabContents::GotResponseToLockMouseRequest(bool allowed) {
1344 return GetRenderViewHost() ? 1347 return GetRenderViewHost() ?
1345 GetRenderViewHost()->GotResponseToLockMouseRequest(allowed) : false; 1348 GetRenderViewHostImpl()->GotResponseToLockMouseRequest(allowed) : false;
1346 } 1349 }
1347 1350
1348 bool TabContents::FocusLocationBarByDefault() { 1351 bool TabContents::FocusLocationBarByDefault() {
1349 content::WebUI* web_ui = GetWebUIForCurrentState(); 1352 content::WebUI* web_ui = GetWebUIForCurrentState();
1350 if (web_ui) 1353 if (web_ui)
1351 return web_ui->ShouldFocusLocationBarByDefault(); 1354 return web_ui->ShouldFocusLocationBarByDefault();
1352 NavigationEntry* entry = controller_.GetActiveEntry(); 1355 NavigationEntry* entry = controller_.GetActiveEntry();
1353 if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)) 1356 if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL))
1354 return true; 1357 return true;
1355 return false; 1358 return false;
(...skipping 19 matching lines...) Expand all
1375 new WebIntentsDispatcherImpl(this, intent, intent_id); 1378 new WebIntentsDispatcherImpl(this, intent, intent_id);
1376 delegate_->WebIntentDispatch(this, intents_dispatcher); 1379 delegate_->WebIntentDispatch(this, intents_dispatcher);
1377 } 1380 }
1378 1381
1379 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, 1382 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id,
1380 bool is_main_frame, 1383 bool is_main_frame,
1381 const GURL& opener_url, 1384 const GURL& opener_url,
1382 const GURL& url) { 1385 const GURL& url) {
1383 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); 1386 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL);
1384 GURL validated_url(url); 1387 GURL validated_url(url);
1385 GetRenderViewHost()->FilterURL(ChildProcessSecurityPolicyImpl::GetInstance(), 1388 GetRenderViewHostImpl()->FilterURL(
1386 GetRenderProcessHost()->GetID(), &validated_url); 1389 ChildProcessSecurityPolicyImpl::GetInstance(),
1390 GetRenderProcessHost()->GetID(),
1391 &validated_url);
1387 1392
1388 RenderViewHost* rvh = 1393 RenderViewHost* rvh =
1389 render_manager_.pending_render_view_host() ? 1394 render_manager_.pending_render_view_host() ?
1390 render_manager_.pending_render_view_host() : GetRenderViewHost(); 1395 render_manager_.pending_render_view_host() : GetRenderViewHost();
1391 // Notify observers about the start of the provisional load. 1396 // Notify observers about the start of the provisional load.
1392 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 1397 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
1393 DidStartProvisionalLoadForFrame(frame_id, is_main_frame, 1398 DidStartProvisionalLoadForFrame(frame_id, is_main_frame,
1394 validated_url, is_error_page, rvh)); 1399 validated_url, is_error_page, rvh));
1395 1400
1396 if (is_main_frame) { 1401 if (is_main_frame) {
(...skipping 27 matching lines...) Expand all
1424 void TabContents::OnDidFailProvisionalLoadWithError( 1429 void TabContents::OnDidFailProvisionalLoadWithError(
1425 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) { 1430 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) {
1426 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() 1431 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec()
1427 << ", error_code: " << params.error_code 1432 << ", error_code: " << params.error_code
1428 << ", error_description: " << params.error_description 1433 << ", error_description: " << params.error_description
1429 << ", is_main_frame: " << params.is_main_frame 1434 << ", is_main_frame: " << params.is_main_frame
1430 << ", showing_repost_interstitial: " << 1435 << ", showing_repost_interstitial: " <<
1431 params.showing_repost_interstitial 1436 params.showing_repost_interstitial
1432 << ", frame_id: " << params.frame_id; 1437 << ", frame_id: " << params.frame_id;
1433 GURL validated_url(params.url); 1438 GURL validated_url(params.url);
1434 GetRenderViewHost()->FilterURL(ChildProcessSecurityPolicyImpl::GetInstance(), 1439 GetRenderViewHostImpl()->FilterURL(
1435 GetRenderProcessHost()->GetID(), &validated_url); 1440 ChildProcessSecurityPolicyImpl::GetInstance(),
1441 GetRenderProcessHost()->GetID(),
1442 &validated_url);
1436 1443
1437 if (net::ERR_ABORTED == params.error_code) { 1444 if (net::ERR_ABORTED == params.error_code) {
1438 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. 1445 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials.
1439 // This means that the interstitial won't be torn down properly, which is 1446 // This means that the interstitial won't be torn down properly, which is
1440 // bad. But if we have an interstitial, go back to another tab type, and 1447 // bad. But if we have an interstitial, go back to another tab type, and
1441 // then load the same interstitial again, we could end up getting the first 1448 // then load the same interstitial again, we could end up getting the first
1442 // interstitial's "failed" message (as a result of the cancel) when we're on 1449 // interstitial's "failed" message (as a result of the cancel) when we're on
1443 // the second one. 1450 // the second one.
1444 // 1451 //
1445 // We can't tell this apart, so we think we're tearing down the current page 1452 // 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
1643 int active_match_ordinal, 1650 int active_match_ordinal,
1644 bool final_update) { 1651 bool final_update) {
1645 delegate_->FindReply(this, request_id, number_of_matches, selection_rect, 1652 delegate_->FindReply(this, request_id, number_of_matches, selection_rect,
1646 active_match_ordinal, final_update); 1653 active_match_ordinal, final_update);
1647 // Send a notification to the renderer that we are ready to receive more 1654 // Send a notification to the renderer that we are ready to receive more
1648 // results from the scoping effort of the Find operation. The FindInPage 1655 // results from the scoping effort of the Find operation. The FindInPage
1649 // scoping is asynchronous and periodically sends results back up to the 1656 // scoping is asynchronous and periodically sends results back up to the
1650 // browser using IPC. In an effort to not spam the browser we have the 1657 // browser using IPC. In an effort to not spam the browser we have the
1651 // browser send an ACK for each FindReply message and have the renderer 1658 // browser send an ACK for each FindReply message and have the renderer
1652 // queue up the latest status message while waiting for this ACK. 1659 // queue up the latest status message while waiting for this ACK.
1653 GetRenderViewHost()->Send( 1660 GetRenderViewHostImpl()->Send(
1654 new ViewMsg_FindReplyACK(GetRenderViewHost()->routing_id())); 1661 new ViewMsg_FindReplyACK(GetRenderViewHost()->GetRoutingID()));
1655 } 1662 }
1656 1663
1657 void TabContents::OnCrashedPlugin(const FilePath& plugin_path) { 1664 void TabContents::OnCrashedPlugin(const FilePath& plugin_path) {
1658 delegate_->CrashedPlugin(this, plugin_path); 1665 delegate_->CrashedPlugin(this, plugin_path);
1659 } 1666 }
1660 1667
1661 void TabContents::OnAppCacheAccessed(const GURL& manifest_url, 1668 void TabContents::OnAppCacheAccessed(const GURL& manifest_url,
1662 bool blocked_by_policy) { 1669 bool blocked_by_policy) {
1663 // Notify observers about navigation. 1670 // Notify observers about navigation.
1664 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 1671 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 } 1762 }
1756 1763
1757 void TabContents::UpdateMaxPageIDIfNecessary(RenderViewHost* rvh) { 1764 void TabContents::UpdateMaxPageIDIfNecessary(RenderViewHost* rvh) {
1758 // If we are creating a RVH for a restored controller, then we need to make 1765 // If we are creating a RVH for a restored controller, then we need to make
1759 // sure the RenderView starts with a next_page_id_ larger than the number 1766 // sure the RenderView starts with a next_page_id_ larger than the number
1760 // of restored entries. This must be called before the RenderView starts 1767 // of restored entries. This must be called before the RenderView starts
1761 // navigating (to avoid a race between the browser updating max_page_id and 1768 // navigating (to avoid a race between the browser updating max_page_id and
1762 // the renderer updating next_page_id_). Because of this, we only call this 1769 // the renderer updating next_page_id_). Because of this, we only call this
1763 // from CreateRenderView and allow that to notify the RenderView for us. 1770 // from CreateRenderView and allow that to notify the RenderView for us.
1764 int max_restored_page_id = controller_.GetMaxRestoredPageID(); 1771 int max_restored_page_id = controller_.GetMaxRestoredPageID();
1765 if (max_restored_page_id > GetMaxPageIDForSiteInstance(rvh->site_instance())) 1772 if (max_restored_page_id >
1766 UpdateMaxPageIDForSiteInstance(rvh->site_instance(), max_restored_page_id); 1773 GetMaxPageIDForSiteInstance(rvh->GetSiteInstance()))
1774 UpdateMaxPageIDForSiteInstance(rvh->GetSiteInstance(),
1775 max_restored_page_id);
1767 } 1776 }
1768 1777
1769 bool TabContents::UpdateTitleForEntry(NavigationEntryImpl* entry, 1778 bool TabContents::UpdateTitleForEntry(NavigationEntryImpl* entry,
1770 const string16& title) { 1779 const string16& title) {
1771 // For file URLs without a title, use the pathname instead. In the case of a 1780 // For file URLs without a title, use the pathname instead. In the case of a
1772 // synthesized title, we don't want the update to count toward the "one set 1781 // synthesized title, we don't want the update to count toward the "one set
1773 // per page of the title to history." 1782 // per page of the title to history."
1774 string16 final_title; 1783 string16 final_title;
1775 bool explicit_set; 1784 bool explicit_set;
1776 if (entry && entry->GetURL().SchemeIsFile() && title.empty()) { 1785 if (entry && entry->GetURL().SchemeIsFile() && title.empty()) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 if (!entry) 1885 if (!entry)
1877 return; 1886 return;
1878 1887
1879 // When we're creating views, we're still doing initial setup, so we always 1888 // When we're creating views, we're still doing initial setup, so we always
1880 // use the pending Web UI rather than any possibly existing committed one. 1889 // use the pending Web UI rather than any possibly existing committed one.
1881 if (render_manager_.pending_web_ui()) 1890 if (render_manager_.pending_web_ui())
1882 render_manager_.pending_web_ui()->RenderViewCreated(render_view_host); 1891 render_manager_.pending_web_ui()->RenderViewCreated(render_view_host);
1883 1892
1884 if (entry->IsViewSourceMode()) { 1893 if (entry->IsViewSourceMode()) {
1885 // Put the renderer in view source mode. 1894 // Put the renderer in view source mode.
1886 render_view_host->Send( 1895 static_cast<RenderViewHostImpl*>(render_view_host)->Send(
1887 new ViewMsg_EnableViewSourceMode(render_view_host->routing_id())); 1896 new ViewMsg_EnableViewSourceMode(render_view_host->GetRoutingID()));
1888 } 1897 }
1889 1898
1890 GetView()->RenderViewCreated(render_view_host); 1899 GetView()->RenderViewCreated(render_view_host);
1891 1900
1892 FOR_EACH_OBSERVER( 1901 FOR_EACH_OBSERVER(
1893 WebContentsObserver, observers_, RenderViewCreated(render_view_host)); 1902 WebContentsObserver, observers_, RenderViewCreated(render_view_host));
1894 } 1903 }
1895 1904
1896 void TabContents::RenderViewReady(RenderViewHost* rvh) { 1905 void TabContents::RenderViewReady(RenderViewHost* rvh) {
1897 if (rvh != GetRenderViewHost()) { 1906 if (rvh != GetRenderViewHost()) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2013 // the swapped out RVHs. We don't expect to hear from any other RVHs. 2022 // the swapped out RVHs. We don't expect to hear from any other RVHs.
2014 DCHECK(rvh == GetRenderViewHost() || render_manager_.IsSwappedOut(rvh)); 2023 DCHECK(rvh == GetRenderViewHost() || render_manager_.IsSwappedOut(rvh));
2015 2024
2016 // We must be prepared to handle state updates for any page, these occur 2025 // We must be prepared to handle state updates for any page, these occur
2017 // when the user is scrolling and entering form data, as well as when we're 2026 // when the user is scrolling and entering form data, as well as when we're
2018 // leaving a page, in which case our state may have already been moved to 2027 // leaving a page, in which case our state may have already been moved to
2019 // the next page. The navigation controller will look up the appropriate 2028 // the next page. The navigation controller will look up the appropriate
2020 // NavigationEntry and update it when it is notified via the delegate. 2029 // NavigationEntry and update it when it is notified via the delegate.
2021 2030
2022 int entry_index = controller_.GetEntryIndexWithPageID( 2031 int entry_index = controller_.GetEntryIndexWithPageID(
2023 rvh->site_instance(), page_id); 2032 rvh->GetSiteInstance(), page_id);
2024 if (entry_index < 0) 2033 if (entry_index < 0)
2025 return; 2034 return;
2026 NavigationEntry* entry = controller_.GetEntryAtIndex(entry_index); 2035 NavigationEntry* entry = controller_.GetEntryAtIndex(entry_index);
2027 2036
2028 if (state == entry->GetContentState()) 2037 if (state == entry->GetContentState())
2029 return; // Nothing to update. 2038 return; // Nothing to update.
2030 entry->SetContentState(state); 2039 entry->SetContentState(state);
2031 controller_.NotifyEntryChanged(entry, entry_index); 2040 controller_.NotifyEntryChanged(entry, entry_index);
2032 } 2041 }
2033 2042
2034 void TabContents::UpdateTitle(RenderViewHost* rvh, 2043 void TabContents::UpdateTitle(RenderViewHost* rvh,
2035 int32 page_id, 2044 int32 page_id,
2036 const string16& title, 2045 const string16& title,
2037 base::i18n::TextDirection title_direction) { 2046 base::i18n::TextDirection title_direction) {
2038 // If we have a title, that's a pretty good indication that we've started 2047 // If we have a title, that's a pretty good indication that we've started
2039 // getting useful data. 2048 // getting useful data.
2040 SetNotWaitingForResponse(); 2049 SetNotWaitingForResponse();
2041 2050
2042 // Try to find the navigation entry, which might not be the current one. 2051 // Try to find the navigation entry, which might not be the current one.
2043 // For example, it might be from a pending RVH for the pending entry. 2052 // For example, it might be from a pending RVH for the pending entry.
2044 NavigationEntryImpl* entry = controller_.GetEntryWithPageID( 2053 NavigationEntryImpl* entry = controller_.GetEntryWithPageID(
2045 rvh->site_instance(), page_id); 2054 rvh->GetSiteInstance(), page_id);
2046 2055
2047 // We can handle title updates when we don't have an entry in 2056 // We can handle title updates when we don't have an entry in
2048 // UpdateTitleForEntry, but only if the update is from the current RVH. 2057 // UpdateTitleForEntry, but only if the update is from the current RVH.
2049 if (!entry && rvh != GetRenderViewHost()) 2058 if (!entry && rvh != GetRenderViewHost())
2050 return; 2059 return;
2051 2060
2052 // TODO(evan): make use of title_direction. 2061 // TODO(evan): make use of title_direction.
2053 // http://code.google.com/p/chromium/issues/detail?id=27094 2062 // http://code.google.com/p/chromium/issues/detail?id=27094
2054 if (!UpdateTitleForEntry(entry, title)) 2063 if (!UpdateTitleForEntry(entry, title))
2055 return; 2064 return;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2224 const string16& message, 2233 const string16& message,
2225 const string16& default_prompt, 2234 const string16& default_prompt,
2226 const GURL& frame_url, 2235 const GURL& frame_url,
2227 ui::JavascriptMessageType javascript_message_type, 2236 ui::JavascriptMessageType javascript_message_type,
2228 IPC::Message* reply_msg, 2237 IPC::Message* reply_msg,
2229 bool* did_suppress_message) { 2238 bool* did_suppress_message) {
2230 // Suppress JavaScript dialogs when requested. Also suppress messages when 2239 // Suppress JavaScript dialogs when requested. Also suppress messages when
2231 // showing an interstitial as it's shown over the previous page and we don't 2240 // showing an interstitial as it's shown over the previous page and we don't
2232 // want the hidden page's dialogs to interfere with the interstitial. 2241 // want the hidden page's dialogs to interfere with the interstitial.
2233 bool suppress_this_message = 2242 bool suppress_this_message =
2234 rvh->is_swapped_out() || 2243 static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() ||
2235 ShowingInterstitialPage() || 2244 ShowingInterstitialPage() ||
2236 !delegate_ || 2245 !delegate_ ||
2237 delegate_->ShouldSuppressDialogs() || 2246 delegate_->ShouldSuppressDialogs() ||
2238 !delegate_->GetJavaScriptDialogCreator(); 2247 !delegate_->GetJavaScriptDialogCreator();
2239 2248
2240 if (!suppress_this_message) { 2249 if (!suppress_this_message) {
2241 std::string accept_lang = content::GetContentClient()->browser()-> 2250 std::string accept_lang = content::GetContentClient()->browser()->
2242 GetAcceptLangs(GetBrowserContext()); 2251 GetAcceptLangs(GetBrowserContext());
2243 dialog_creator_ = delegate_->GetJavaScriptDialogCreator(); 2252 dialog_creator_ = delegate_->GetJavaScriptDialogCreator();
2244 dialog_creator_->RunJavaScriptDialog( 2253 dialog_creator_->RunJavaScriptDialog(
(...skipping 14 matching lines...) Expand all
2259 OnDialogClosed(rvh, reply_msg, false, string16()); 2268 OnDialogClosed(rvh, reply_msg, false, string16());
2260 } 2269 }
2261 2270
2262 *did_suppress_message = suppress_this_message; 2271 *did_suppress_message = suppress_this_message;
2263 } 2272 }
2264 2273
2265 void TabContents::RunBeforeUnloadConfirm(RenderViewHost* rvh, 2274 void TabContents::RunBeforeUnloadConfirm(RenderViewHost* rvh,
2266 const string16& message, 2275 const string16& message,
2267 bool is_reload, 2276 bool is_reload,
2268 IPC::Message* reply_msg) { 2277 IPC::Message* reply_msg) {
2278 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh);
2269 if (delegate_) 2279 if (delegate_)
2270 delegate_->WillRunBeforeUnloadConfirm(); 2280 delegate_->WillRunBeforeUnloadConfirm();
2271 2281
2272 bool suppress_this_message = 2282 bool suppress_this_message =
2273 rvh->is_swapped_out() || 2283 rvhi->is_swapped_out() ||
2274 !delegate_ || 2284 !delegate_ ||
2275 delegate_->ShouldSuppressDialogs() || 2285 delegate_->ShouldSuppressDialogs() ||
2276 !delegate_->GetJavaScriptDialogCreator(); 2286 !delegate_->GetJavaScriptDialogCreator();
2277 if (suppress_this_message) { 2287 if (suppress_this_message) {
2278 // The reply must be sent to the RVH that sent the request. 2288 // The reply must be sent to the RVH that sent the request.
2279 rvh->JavaScriptDialogClosed(reply_msg, true, string16()); 2289 rvhi->JavaScriptDialogClosed(reply_msg, true, string16());
2280 return; 2290 return;
2281 } 2291 }
2282 2292
2283 is_showing_before_unload_dialog_ = true; 2293 is_showing_before_unload_dialog_ = true;
2284 dialog_creator_ = delegate_->GetJavaScriptDialogCreator(); 2294 dialog_creator_ = delegate_->GetJavaScriptDialogCreator();
2285 dialog_creator_->RunBeforeUnloadDialog( 2295 dialog_creator_->RunBeforeUnloadDialog(
2286 this, message, is_reload, 2296 this, message, is_reload,
2287 base::Bind(&TabContents::OnDialogClosed, base::Unretained(this), rvh, 2297 base::Bind(&TabContents::OnDialogClosed, base::Unretained(this), rvh,
2288 reply_msg)); 2298 reply_msg));
2289 } 2299 }
(...skipping 15 matching lines...) Expand all
2305 // Notify observers. 2315 // Notify observers.
2306 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetIgnoredUIEvent()); 2316 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetIgnoredUIEvent());
2307 } 2317 }
2308 2318
2309 void TabContents::RendererUnresponsive(RenderViewHost* rvh, 2319 void TabContents::RendererUnresponsive(RenderViewHost* rvh,
2310 bool is_during_unload) { 2320 bool is_during_unload) {
2311 // Don't show hung renderer dialog for a swapped out RVH. 2321 // Don't show hung renderer dialog for a swapped out RVH.
2312 if (rvh != GetRenderViewHost()) 2322 if (rvh != GetRenderViewHost())
2313 return; 2323 return;
2314 2324
2325 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh);
2326
2315 // Ignore renderer unresponsive event if debugger is attached to the tab 2327 // Ignore renderer unresponsive event if debugger is attached to the tab
2316 // since the event may be a result of the renderer sitting on a breakpoint. 2328 // since the event may be a result of the renderer sitting on a breakpoint.
2317 // See http://crbug.com/65458 2329 // See http://crbug.com/65458
2318 DevToolsAgentHost* agent = 2330 DevToolsAgentHost* agent =
2319 content::DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh); 2331 content::DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh);
2320 if (agent && 2332 if (agent &&
2321 DevToolsManagerImpl::GetInstance()->GetDevToolsClientHostFor(agent)) 2333 DevToolsManagerImpl::GetInstance()->GetDevToolsClientHostFor(agent))
2322 return; 2334 return;
2323 2335
2324 if (is_during_unload) { 2336 if (is_during_unload) {
2325 // Hang occurred while firing the beforeunload/unload handler. 2337 // Hang occurred while firing the beforeunload/unload handler.
2326 // Pretend the handler fired so tab closing continues as if it had. 2338 // Pretend the handler fired so tab closing continues as if it had.
2327 rvh->set_sudden_termination_allowed(true); 2339 rvhi->set_sudden_termination_allowed(true);
2328 2340
2329 if (!render_manager_.ShouldCloseTabOnUnresponsiveRenderer()) 2341 if (!render_manager_.ShouldCloseTabOnUnresponsiveRenderer())
2330 return; 2342 return;
2331 2343
2332 // If the tab hangs in the beforeunload/unload handler there's really 2344 // If the tab hangs in the beforeunload/unload handler there's really
2333 // nothing we can do to recover. Pretend the unload listeners have 2345 // nothing we can do to recover. Pretend the unload listeners have
2334 // all fired and close the tab. If the hang is in the beforeunload handler 2346 // all fired and close the tab. If the hang is in the beforeunload handler
2335 // then the user will not have the option of cancelling the close. 2347 // then the user will not have the option of cancelling the close.
2336 Close(rvh); 2348 Close(rvh);
2337 return; 2349 return;
2338 } 2350 }
2339 2351
2340 if (!GetRenderViewHost() || !GetRenderViewHost()->IsRenderViewLive()) 2352 if (!GetRenderViewHostImpl() || !GetRenderViewHostImpl()->IsRenderViewLive())
2341 return; 2353 return;
2342 2354
2343 if (delegate_) 2355 if (delegate_)
2344 delegate_->RendererUnresponsive(this); 2356 delegate_->RendererUnresponsive(this);
2345 } 2357 }
2346 2358
2347 void TabContents::RendererResponsive(RenderViewHost* render_view_host) { 2359 void TabContents::RendererResponsive(RenderViewHost* render_view_host) {
2348 if (delegate_) 2360 if (delegate_)
2349 delegate_->RendererResponsive(this); 2361 delegate_->RendererResponsive(this);
2350 } 2362 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2423 // Can be NULL during tests. 2435 // Can be NULL during tests.
2424 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host); 2436 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host);
2425 2437
2426 // Now that the RenderView has been created, we need to tell it its size. 2438 // Now that the RenderView has been created, we need to tell it its size.
2427 if (rwh_view) 2439 if (rwh_view)
2428 rwh_view->SetSize(view_->GetContainerSize()); 2440 rwh_view->SetSize(view_->GetContainerSize());
2429 2441
2430 // Make sure we use the correct starting page_id in the new RenderView. 2442 // Make sure we use the correct starting page_id in the new RenderView.
2431 UpdateMaxPageIDIfNecessary(render_view_host); 2443 UpdateMaxPageIDIfNecessary(render_view_host);
2432 int32 max_page_id = 2444 int32 max_page_id =
2433 GetMaxPageIDForSiteInstance(render_view_host->site_instance()); 2445 GetMaxPageIDForSiteInstance(render_view_host->GetSiteInstance());
2434 2446
2435 if (!render_view_host->CreateRenderView(string16(), max_page_id)) 2447 if (!static_cast<RenderViewHostImpl*>(
2448 render_view_host)->CreateRenderView(string16(), max_page_id))
2436 return false; 2449 return false;
2437 2450
2438 #if defined(OS_LINUX) || defined(OS_OPENBSD) 2451 #if defined(OS_LINUX) || defined(OS_OPENBSD)
2439 // Force a ViewMsg_Resize to be sent, needed to make plugins show up on 2452 // Force a ViewMsg_Resize to be sent, needed to make plugins show up on
2440 // linux. See crbug.com/83941. 2453 // linux. See crbug.com/83941.
2441 if (rwh_view) { 2454 if (rwh_view) {
2442 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) 2455 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost())
2443 render_widget_host->WasResized(); 2456 render_widget_host->WasResized();
2444 } 2457 }
2445 #endif 2458 #endif
2446 2459
2447 return true; 2460 return true;
2448 } 2461 }
2449 2462
2450 void TabContents::OnDialogClosed(RenderViewHost* rvh, 2463 void TabContents::OnDialogClosed(RenderViewHost* rvh,
2451 IPC::Message* reply_msg, 2464 IPC::Message* reply_msg,
2452 bool success, 2465 bool success,
2453 const string16& user_input) { 2466 const string16& user_input) {
2454 if (is_showing_before_unload_dialog_ && !success) { 2467 if (is_showing_before_unload_dialog_ && !success) {
2455 // If a beforeunload dialog is canceled, we need to stop the throbber from 2468 // If a beforeunload dialog is canceled, we need to stop the throbber from
2456 // spinning, since we forced it to start spinning in Navigate. 2469 // spinning, since we forced it to start spinning in Navigate.
2457 DidStopLoading(); 2470 DidStopLoading();
2458 2471
2459 tab_close_start_time_ = base::TimeTicks(); 2472 tab_close_start_time_ = base::TimeTicks();
2460 } 2473 }
2461 is_showing_before_unload_dialog_ = false; 2474 is_showing_before_unload_dialog_ = false;
2462 rvh->JavaScriptDialogClosed(reply_msg, success, user_input); 2475 static_cast<RenderViewHostImpl*>(
2476 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input);
2463 } 2477 }
2464 2478
2465 void TabContents::SetEncoding(const std::string& encoding) { 2479 void TabContents::SetEncoding(const std::string& encoding) {
2466 encoding_ = content::GetContentClient()->browser()-> 2480 encoding_ = content::GetContentClient()->browser()->
2467 GetCanonicalEncodingNameByAliasName(encoding); 2481 GetCanonicalEncodingNameByAliasName(encoding);
2468 } 2482 }
2469 2483
2470 void TabContents::SaveURL(const GURL& url, 2484 void TabContents::SaveURL(const GURL& url,
2471 const GURL& referrer, 2485 const GURL& referrer,
2472 bool is_main_frame) { 2486 bool is_main_frame) {
(...skipping 16 matching lines...) Expand all
2489 save_info, 2503 save_info,
2490 this); 2504 this);
2491 } 2505 }
2492 2506
2493 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { 2507 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
2494 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); 2508 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh);
2495 // Can be NULL during tests. 2509 // Can be NULL during tests.
2496 if (rwh_view) 2510 if (rwh_view)
2497 rwh_view->SetSize(GetView()->GetContainerSize()); 2511 rwh_view->SetSize(GetView()->GetContainerSize());
2498 } 2512 }
2513
2514 RenderViewHostImpl* TabContents::GetRenderViewHostImpl() {
2515 return static_cast<RenderViewHostImpl*>(GetRenderViewHost());
2516 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/tab_contents.h ('k') | content/browser/tab_contents/tab_contents_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698