| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/tab_contents/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 is_showing_before_unload_dialog_(false), | 365 is_showing_before_unload_dialog_(false), |
| 366 renderer_preferences_(), | 366 renderer_preferences_(), |
| 367 opener_dom_ui_type_(DOMUIFactory::kNoDOMUI), | 367 opener_dom_ui_type_(DOMUIFactory::kNoDOMUI), |
| 368 language_state_(&controller_), | 368 language_state_(&controller_), |
| 369 closed_by_user_gesture_(false), | 369 closed_by_user_gesture_(false), |
| 370 minimum_zoom_percent_( | 370 minimum_zoom_percent_( |
| 371 static_cast<int>(WebKit::WebView::minTextSizeMultiplier * 100)), | 371 static_cast<int>(WebKit::WebView::minTextSizeMultiplier * 100)), |
| 372 maximum_zoom_percent_( | 372 maximum_zoom_percent_( |
| 373 static_cast<int>(WebKit::WebView::maxTextSizeMultiplier * 100)), | 373 static_cast<int>(WebKit::WebView::maxTextSizeMultiplier * 100)), |
| 374 temporary_zoom_settings_(false), | 374 temporary_zoom_settings_(false), |
| 375 content_restrictions_(0) { | 375 content_restrictions_(0), |
| 376 renderer_ran_out_of_memory_(false) { |
| 376 renderer_preferences_util::UpdateFromSystemSettings( | 377 renderer_preferences_util::UpdateFromSystemSettings( |
| 377 &renderer_preferences_, profile); | 378 &renderer_preferences_, profile); |
| 378 | 379 |
| 379 content_settings_delegate_.reset( | 380 content_settings_delegate_.reset( |
| 380 new TabSpecificContentSettings(this, profile)); | 381 new TabSpecificContentSettings(this, profile)); |
| 381 | 382 |
| 382 render_manager_.Init(profile, site_instance, routing_id); | 383 render_manager_.Init(profile, site_instance, routing_id); |
| 383 | 384 |
| 384 // We have the initial size of the view be based on the size of the passed in | 385 // We have the initial size of the view be based on the size of the passed in |
| 385 // tab contents (normally a tab from the same window). | 386 // tab contents (normally a tab from the same window). |
| (...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2478 } | 2479 } |
| 2479 | 2480 |
| 2480 SetIsLoading(false, NULL); | 2481 SetIsLoading(false, NULL); |
| 2481 NotifyDisconnected(); | 2482 NotifyDisconnected(); |
| 2482 SetIsCrashed(status, error_code); | 2483 SetIsCrashed(status, error_code); |
| 2483 | 2484 |
| 2484 // Remove all infobars. | 2485 // Remove all infobars. |
| 2485 for (int i = infobar_delegate_count() - 1; i >=0 ; --i) | 2486 for (int i = infobar_delegate_count() - 1; i >=0 ; --i) |
| 2486 RemoveInfoBar(GetInfoBarDelegateAt(i)); | 2487 RemoveInfoBar(GetInfoBarDelegateAt(i)); |
| 2487 | 2488 |
| 2489 // Restore OOM infobar. |
| 2490 if (renderer_ran_out_of_memory_) |
| 2491 OnJSOutOfMemory(); |
| 2492 |
| 2488 // Tell the view that we've crashed so it can prepare the sad tab page. | 2493 // Tell the view that we've crashed so it can prepare the sad tab page. |
| 2489 // Only do this if we're not in browser shutdown, so that TabContents | 2494 // Only do this if we're not in browser shutdown, so that TabContents |
| 2490 // objects that are not in a browser (e.g., HTML dialogs) and thus are | 2495 // objects that are not in a browser (e.g., HTML dialogs) and thus are |
| 2491 // visible do not flash a sad tab page. | 2496 // visible do not flash a sad tab page. |
| 2492 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) | 2497 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) |
| 2493 view_->OnTabCrashed(); | 2498 view_->OnTabCrashed(); |
| 2494 | 2499 |
| 2495 // Hide any visible hung renderer warning for this web contents' process. | 2500 // Hide any visible hung renderer warning for this web contents' process. |
| 2496 hung_renderer_dialog::HideForTabContents(this); | 2501 hung_renderer_dialog::HideForTabContents(this); |
| 2497 } | 2502 } |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3017 } | 3022 } |
| 3018 | 3023 |
| 3019 void TabContents::OnIgnoredUIEvent() { | 3024 void TabContents::OnIgnoredUIEvent() { |
| 3020 if (constrained_window_count()) { | 3025 if (constrained_window_count()) { |
| 3021 ConstrainedWindow* window = *constrained_window_begin(); | 3026 ConstrainedWindow* window = *constrained_window_begin(); |
| 3022 window->FocusConstrainedWindow(); | 3027 window->FocusConstrainedWindow(); |
| 3023 } | 3028 } |
| 3024 } | 3029 } |
| 3025 | 3030 |
| 3026 void TabContents::OnJSOutOfMemory() { | 3031 void TabContents::OnJSOutOfMemory() { |
| 3032 renderer_ran_out_of_memory_ = true; |
| 3027 AddInfoBar(new SimpleAlertInfoBarDelegate( | 3033 AddInfoBar(new SimpleAlertInfoBarDelegate( |
| 3028 this, l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), | 3034 this, l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), |
| 3029 NULL, true)); | 3035 NULL, true)); |
| 3030 } | 3036 } |
| 3031 | 3037 |
| 3032 void TabContents::OnCrossSiteResponse(int new_render_process_host_id, | 3038 void TabContents::OnCrossSiteResponse(int new_render_process_host_id, |
| 3033 int new_request_id) { | 3039 int new_request_id) { |
| 3034 // Allows the TabContents to react when a cross-site response is ready to be | 3040 // Allows the TabContents to react when a cross-site response is ready to be |
| 3035 // delivered to a pending RenderViewHost. We must first run the onunload | 3041 // delivered to a pending RenderViewHost. We must first run the onunload |
| 3036 // handler of the old RenderViewHost before we can allow it to proceed. | 3042 // handler of the old RenderViewHost before we can allow it to proceed. |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3208 case NotificationType::RENDER_WIDGET_HOST_DESTROYED: | 3214 case NotificationType::RENDER_WIDGET_HOST_DESTROYED: |
| 3209 view_->RenderWidgetHostDestroyed(Source<RenderWidgetHost>(source).ptr()); | 3215 view_->RenderWidgetHostDestroyed(Source<RenderWidgetHost>(source).ptr()); |
| 3210 break; | 3216 break; |
| 3211 | 3217 |
| 3212 case NotificationType::NAV_ENTRY_COMMITTED: { | 3218 case NotificationType::NAV_ENTRY_COMMITTED: { |
| 3213 DCHECK(&controller_ == Source<NavigationController>(source).ptr()); | 3219 DCHECK(&controller_ == Source<NavigationController>(source).ptr()); |
| 3214 | 3220 |
| 3215 NavigationController::LoadCommittedDetails& committed_details = | 3221 NavigationController::LoadCommittedDetails& committed_details = |
| 3216 *(Details<NavigationController::LoadCommittedDetails>(details).ptr()); | 3222 *(Details<NavigationController::LoadCommittedDetails>(details).ptr()); |
| 3217 ExpireInfoBars(committed_details); | 3223 ExpireInfoBars(committed_details); |
| 3224 |
| 3225 renderer_ran_out_of_memory_ = false; |
| 3218 break; | 3226 break; |
| 3219 } | 3227 } |
| 3220 | 3228 |
| 3221 #if defined(OS_LINUX) | 3229 #if defined(OS_LINUX) |
| 3222 case NotificationType::BROWSER_THEME_CHANGED: { | 3230 case NotificationType::BROWSER_THEME_CHANGED: { |
| 3223 renderer_preferences_util::UpdateFromSystemSettings( | 3231 renderer_preferences_util::UpdateFromSystemSettings( |
| 3224 &renderer_preferences_, profile()); | 3232 &renderer_preferences_, profile()); |
| 3225 render_view_host()->SyncRendererPrefs(); | 3233 render_view_host()->SyncRendererPrefs(); |
| 3226 break; | 3234 break; |
| 3227 } | 3235 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3338 } | 3346 } |
| 3339 | 3347 |
| 3340 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { | 3348 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { |
| 3341 render_manager_.SwapInRenderViewHost(rvh); | 3349 render_manager_.SwapInRenderViewHost(rvh); |
| 3342 } | 3350 } |
| 3343 | 3351 |
| 3344 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 3352 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 3345 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 3353 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 3346 rwh_view->SetSize(view()->GetContainerSize()); | 3354 rwh_view->SetSize(view()->GetContainerSize()); |
| 3347 } | 3355 } |
| OLD | NEW |