| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 is_showing_before_unload_dialog_(false), | 385 is_showing_before_unload_dialog_(false), |
| 386 renderer_preferences_(), | 386 renderer_preferences_(), |
| 387 opener_dom_ui_type_(DOMUIFactory::kNoDOMUI), | 387 opener_dom_ui_type_(DOMUIFactory::kNoDOMUI), |
| 388 language_state_(&controller_), | 388 language_state_(&controller_), |
| 389 closed_by_user_gesture_(false), | 389 closed_by_user_gesture_(false), |
| 390 minimum_zoom_percent_( | 390 minimum_zoom_percent_( |
| 391 static_cast<int>(WebKit::WebView::minTextSizeMultiplier * 100)), | 391 static_cast<int>(WebKit::WebView::minTextSizeMultiplier * 100)), |
| 392 maximum_zoom_percent_( | 392 maximum_zoom_percent_( |
| 393 static_cast<int>(WebKit::WebView::maxTextSizeMultiplier * 100)), | 393 static_cast<int>(WebKit::WebView::maxTextSizeMultiplier * 100)), |
| 394 temporary_zoom_settings_(false), | 394 temporary_zoom_settings_(false), |
| 395 content_restrictions_(0) { | 395 content_restrictions_(0), |
| 396 render_process_ran_out_of_memory_(false) { |
| 396 renderer_preferences_util::UpdateFromSystemSettings( | 397 renderer_preferences_util::UpdateFromSystemSettings( |
| 397 &renderer_preferences_, profile); | 398 &renderer_preferences_, profile); |
| 398 | 399 |
| 399 content_settings_delegate_.reset( | 400 content_settings_delegate_.reset( |
| 400 new TabSpecificContentSettings(this, profile)); | 401 new TabSpecificContentSettings(this, profile)); |
| 401 | 402 |
| 402 render_manager_.Init(profile, site_instance, routing_id); | 403 render_manager_.Init(profile, site_instance, routing_id); |
| 403 | 404 |
| 404 // We have the initial size of the view be based on the size of the passed in | 405 // We have the initial size of the view be based on the size of the passed in |
| 405 // tab contents (normally a tab from the same window). | 406 // tab contents (normally a tab from the same window). |
| (...skipping 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2532 } | 2533 } |
| 2533 | 2534 |
| 2534 SetIsLoading(false, NULL); | 2535 SetIsLoading(false, NULL); |
| 2535 NotifyDisconnected(); | 2536 NotifyDisconnected(); |
| 2536 SetIsCrashed(status, error_code); | 2537 SetIsCrashed(status, error_code); |
| 2537 | 2538 |
| 2538 // Remove all infobars. | 2539 // Remove all infobars. |
| 2539 for (int i = infobar_delegate_count() - 1; i >=0 ; --i) | 2540 for (int i = infobar_delegate_count() - 1; i >=0 ; --i) |
| 2540 RemoveInfoBar(GetInfoBarDelegateAt(i)); | 2541 RemoveInfoBar(GetInfoBarDelegateAt(i)); |
| 2541 | 2542 |
| 2543 // Restore OOM infobar. |
| 2544 if (render_process_ran_out_of_memory_) |
| 2545 OnJSOutOfMemory(); |
| 2546 |
| 2542 // Tell the view that we've crashed so it can prepare the sad tab page. | 2547 // Tell the view that we've crashed so it can prepare the sad tab page. |
| 2543 // Only do this if we're not in browser shutdown, so that TabContents | 2548 // Only do this if we're not in browser shutdown, so that TabContents |
| 2544 // objects that are not in a browser (e.g., HTML dialogs) and thus are | 2549 // objects that are not in a browser (e.g., HTML dialogs) and thus are |
| 2545 // visible do not flash a sad tab page. | 2550 // visible do not flash a sad tab page. |
| 2546 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) | 2551 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) |
| 2547 view_->OnTabCrashed(status, error_code); | 2552 view_->OnTabCrashed(status, error_code); |
| 2548 | 2553 |
| 2549 // Hide any visible hung renderer warning for this web contents' process. | 2554 // Hide any visible hung renderer warning for this web contents' process. |
| 2550 hung_renderer_dialog::HideForTabContents(this); | 2555 hung_renderer_dialog::HideForTabContents(this); |
| 2551 } | 2556 } |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3058 } | 3063 } |
| 3059 | 3064 |
| 3060 void TabContents::OnIgnoredUIEvent() { | 3065 void TabContents::OnIgnoredUIEvent() { |
| 3061 if (constrained_window_count()) { | 3066 if (constrained_window_count()) { |
| 3062 ConstrainedWindow* window = *constrained_window_begin(); | 3067 ConstrainedWindow* window = *constrained_window_begin(); |
| 3063 window->FocusConstrainedWindow(); | 3068 window->FocusConstrainedWindow(); |
| 3064 } | 3069 } |
| 3065 } | 3070 } |
| 3066 | 3071 |
| 3067 void TabContents::OnJSOutOfMemory() { | 3072 void TabContents::OnJSOutOfMemory() { |
| 3073 render_process_ran_out_of_memory_ = true; |
| 3068 AddInfoBar(new SimpleAlertInfoBarDelegate( | 3074 AddInfoBar(new SimpleAlertInfoBarDelegate( |
| 3069 this, l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), | 3075 this, l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), |
| 3070 NULL, true)); | 3076 NULL, true)); |
| 3071 } | 3077 } |
| 3072 | 3078 |
| 3073 void TabContents::OnCrossSiteResponse(int new_render_process_host_id, | 3079 void TabContents::OnCrossSiteResponse(int new_render_process_host_id, |
| 3074 int new_request_id) { | 3080 int new_request_id) { |
| 3075 // Allows the TabContents to react when a cross-site response is ready to be | 3081 // Allows the TabContents to react when a cross-site response is ready to be |
| 3076 // delivered to a pending RenderViewHost. We must first run the onunload | 3082 // delivered to a pending RenderViewHost. We must first run the onunload |
| 3077 // handler of the old RenderViewHost before we can allow it to proceed. | 3083 // 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... |
| 3249 case NotificationType::RENDER_WIDGET_HOST_DESTROYED: | 3255 case NotificationType::RENDER_WIDGET_HOST_DESTROYED: |
| 3250 view_->RenderWidgetHostDestroyed(Source<RenderWidgetHost>(source).ptr()); | 3256 view_->RenderWidgetHostDestroyed(Source<RenderWidgetHost>(source).ptr()); |
| 3251 break; | 3257 break; |
| 3252 | 3258 |
| 3253 case NotificationType::NAV_ENTRY_COMMITTED: { | 3259 case NotificationType::NAV_ENTRY_COMMITTED: { |
| 3254 DCHECK(&controller_ == Source<NavigationController>(source).ptr()); | 3260 DCHECK(&controller_ == Source<NavigationController>(source).ptr()); |
| 3255 | 3261 |
| 3256 NavigationController::LoadCommittedDetails& committed_details = | 3262 NavigationController::LoadCommittedDetails& committed_details = |
| 3257 *(Details<NavigationController::LoadCommittedDetails>(details).ptr()); | 3263 *(Details<NavigationController::LoadCommittedDetails>(details).ptr()); |
| 3258 ExpireInfoBars(committed_details); | 3264 ExpireInfoBars(committed_details); |
| 3265 |
| 3266 render_process_ran_out_of_memory_ = false; |
| 3259 break; | 3267 break; |
| 3260 } | 3268 } |
| 3261 | 3269 |
| 3262 #if defined(OS_LINUX) | 3270 #if defined(OS_LINUX) |
| 3263 case NotificationType::BROWSER_THEME_CHANGED: { | 3271 case NotificationType::BROWSER_THEME_CHANGED: { |
| 3264 renderer_preferences_util::UpdateFromSystemSettings( | 3272 renderer_preferences_util::UpdateFromSystemSettings( |
| 3265 &renderer_preferences_, profile()); | 3273 &renderer_preferences_, profile()); |
| 3266 render_view_host()->SyncRendererPrefs(); | 3274 render_view_host()->SyncRendererPrefs(); |
| 3267 break; | 3275 break; |
| 3268 } | 3276 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3378 } | 3386 } |
| 3379 | 3387 |
| 3380 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { | 3388 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { |
| 3381 render_manager_.SwapInRenderViewHost(rvh); | 3389 render_manager_.SwapInRenderViewHost(rvh); |
| 3382 } | 3390 } |
| 3383 | 3391 |
| 3384 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 3392 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 3385 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 3393 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 3386 rwh_view->SetSize(view()->GetContainerSize()); | 3394 rwh_view->SetSize(view()->GetContainerSize()); |
| 3387 } | 3395 } |
| OLD | NEW |