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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 registrar_(), | 329 registrar_(), |
330 ALLOW_THIS_IN_INITIALIZER_LIST(printing_( | 330 ALLOW_THIS_IN_INITIALIZER_LIST(printing_( |
331 new printing::PrintViewManager(*this))), | 331 new printing::PrintViewManager(*this))), |
332 save_package_(), | 332 save_package_(), |
333 autocomplete_history_manager_(), | 333 autocomplete_history_manager_(), |
334 autofill_manager_(), | 334 autofill_manager_(), |
335 plugin_installer_(), | 335 plugin_installer_(), |
336 bookmark_drag_(NULL), | 336 bookmark_drag_(NULL), |
337 ALLOW_THIS_IN_INITIALIZER_LIST(fav_icon_helper_(this)), | 337 ALLOW_THIS_IN_INITIALIZER_LIST(fav_icon_helper_(this)), |
338 is_loading_(false), | 338 is_loading_(false), |
339 is_crashed_(false), | 339 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 340 crashed_error_code_(0), |
340 waiting_for_response_(false), | 341 waiting_for_response_(false), |
341 max_page_id_(-1), | 342 max_page_id_(-1), |
342 current_load_start_(), | 343 current_load_start_(), |
343 load_state_(net::LOAD_STATE_IDLE), | 344 load_state_(net::LOAD_STATE_IDLE), |
344 load_state_host_(), | 345 load_state_host_(), |
345 upload_size_(0), | 346 upload_size_(0), |
346 upload_position_(0), | 347 upload_position_(0), |
347 received_page_title_(false), | 348 received_page_title_(false), |
348 is_starred_(false), | 349 is_starred_(false), |
349 contents_mime_type_(), | 350 contents_mime_type_(), |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 } | 761 } |
761 | 762 |
762 void TabContents::AddNavigationObserver(WebNavigationObserver* observer) { | 763 void TabContents::AddNavigationObserver(WebNavigationObserver* observer) { |
763 web_navigation_observers_.AddObserver(observer); | 764 web_navigation_observers_.AddObserver(observer); |
764 } | 765 } |
765 | 766 |
766 void TabContents::RemoveNavigationObserver(WebNavigationObserver* observer) { | 767 void TabContents::RemoveNavigationObserver(WebNavigationObserver* observer) { |
767 web_navigation_observers_.RemoveObserver(observer); | 768 web_navigation_observers_.RemoveObserver(observer); |
768 } | 769 } |
769 | 770 |
770 void TabContents::SetIsCrashed(bool state) { | 771 void TabContents::SetIsCrashed(base::TerminationStatus status, int error_code) { |
771 if (state == is_crashed_) | 772 if (status == crashed_status_) |
772 return; | 773 return; |
773 | 774 |
774 is_crashed_ = state; | 775 crashed_status_ = status; |
| 776 crashed_error_code_ = error_code; |
775 NotifyNavigationStateChanged(INVALIDATE_TAB); | 777 NotifyNavigationStateChanged(INVALIDATE_TAB); |
776 } | 778 } |
777 | 779 |
778 void TabContents::PageActionStateChanged() { | 780 void TabContents::PageActionStateChanged() { |
779 NotifyNavigationStateChanged(TabContents::INVALIDATE_PAGE_ACTIONS); | 781 NotifyNavigationStateChanged(TabContents::INVALIDATE_PAGE_ACTIONS); |
780 } | 782 } |
781 | 783 |
782 void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) { | 784 void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) { |
783 if (delegate_) | 785 if (delegate_) |
784 delegate_->NavigationStateChanged(this, changed_flags); | 786 delegate_->NavigationStateChanged(this, changed_flags); |
(...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2401 | 2403 |
2402 void TabContents::RenderViewReady(RenderViewHost* rvh) { | 2404 void TabContents::RenderViewReady(RenderViewHost* rvh) { |
2403 if (rvh != render_view_host()) { | 2405 if (rvh != render_view_host()) { |
2404 // Don't notify the world, since this came from a renderer in the | 2406 // Don't notify the world, since this came from a renderer in the |
2405 // background. | 2407 // background. |
2406 return; | 2408 return; |
2407 } | 2409 } |
2408 | 2410 |
2409 NotifyConnected(); | 2411 NotifyConnected(); |
2410 bool was_crashed = is_crashed(); | 2412 bool was_crashed = is_crashed(); |
2411 SetIsCrashed(false); | 2413 SetIsCrashed(base::TERMINATION_STATUS_STILL_RUNNING, 0); |
2412 | 2414 |
2413 // Restore the focus to the tab (otherwise the focus will be on the top | 2415 // Restore the focus to the tab (otherwise the focus will be on the top |
2414 // window). | 2416 // window). |
2415 if (was_crashed && !FocusLocationBarByDefault() && | 2417 if (was_crashed && !FocusLocationBarByDefault() && |
2416 (!delegate_ || delegate_->ShouldFocusPageAfterCrash())) { | 2418 (!delegate_ || delegate_->ShouldFocusPageAfterCrash())) { |
2417 Focus(); | 2419 Focus(); |
2418 } | 2420 } |
2419 } | 2421 } |
2420 | 2422 |
2421 void TabContents::RenderViewGone(RenderViewHost* rvh) { | 2423 void TabContents::RenderViewGone(RenderViewHost* rvh, |
| 2424 base::TerminationStatus status, |
| 2425 int error_code) { |
2422 // Ask the print preview if this renderer was valuable. | 2426 // Ask the print preview if this renderer was valuable. |
2423 if (!printing_->OnRenderViewGone(rvh)) | 2427 if (!printing_->OnRenderViewGone(rvh)) |
2424 return; | 2428 return; |
2425 if (rvh != render_view_host()) { | 2429 if (rvh != render_view_host()) { |
2426 // The pending page's RenderViewHost is gone. | 2430 // The pending page's RenderViewHost is gone. |
2427 return; | 2431 return; |
2428 } | 2432 } |
2429 | 2433 |
2430 SetIsLoading(false, NULL); | 2434 SetIsLoading(false, NULL); |
2431 NotifyDisconnected(); | 2435 NotifyDisconnected(); |
2432 SetIsCrashed(true); | 2436 SetIsCrashed(status, error_code); |
2433 | 2437 |
2434 // Remove all infobars. | 2438 // Remove all infobars. |
2435 for (int i = infobar_delegate_count() - 1; i >=0 ; --i) | 2439 for (int i = infobar_delegate_count() - 1; i >=0 ; --i) |
2436 RemoveInfoBar(GetInfoBarDelegateAt(i)); | 2440 RemoveInfoBar(GetInfoBarDelegateAt(i)); |
2437 | 2441 |
2438 // Tell the view that we've crashed so it can prepare the sad tab page. | 2442 // Tell the view that we've crashed so it can prepare the sad tab page. |
2439 // Only do this if we're not in browser shutdown, so that TabContents | 2443 // Only do this if we're not in browser shutdown, so that TabContents |
2440 // objects that are not in a browser (e.g., HTML dialogs) and thus are | 2444 // objects that are not in a browser (e.g., HTML dialogs) and thus are |
2441 // visible do not flash a sad tab page. | 2445 // visible do not flash a sad tab page. |
2442 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) | 2446 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3065 delegate()->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); | 3069 delegate()->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); |
3066 } | 3070 } |
3067 | 3071 |
3068 void TabContents::DidStartLoadingFromRenderManager( | 3072 void TabContents::DidStartLoadingFromRenderManager( |
3069 RenderViewHost* render_view_host) { | 3073 RenderViewHost* render_view_host) { |
3070 DidStartLoading(); | 3074 DidStartLoading(); |
3071 } | 3075 } |
3072 | 3076 |
3073 void TabContents::RenderViewGoneFromRenderManager( | 3077 void TabContents::RenderViewGoneFromRenderManager( |
3074 RenderViewHost* render_view_host) { | 3078 RenderViewHost* render_view_host) { |
3075 RenderViewGone(render_view_host); | 3079 DCHECK(crashed_status_ != base::TERMINATION_STATUS_STILL_RUNNING); |
| 3080 RenderViewGone(render_view_host, crashed_status_, crashed_error_code_); |
3076 } | 3081 } |
3077 | 3082 |
3078 void TabContents::UpdateRenderViewSizeForRenderManager() { | 3083 void TabContents::UpdateRenderViewSizeForRenderManager() { |
3079 // TODO(brettw) this is a hack. See TabContentsView::SizeContents. | 3084 // TODO(brettw) this is a hack. See TabContentsView::SizeContents. |
3080 gfx::Size size = view_->GetContainerSize(); | 3085 gfx::Size size = view_->GetContainerSize(); |
3081 // 0x0 isn't a valid window size (minimal window size is 1x1) but it may be | 3086 // 0x0 isn't a valid window size (minimal window size is 1x1) but it may be |
3082 // here during container initialization and normal window size will be set | 3087 // here during container initialization and normal window size will be set |
3083 // later. In case of tab duplication this resizing to 0x0 prevents setting | 3088 // later. In case of tab duplication this resizing to 0x0 prevents setting |
3084 // normal size later so just ignore it. | 3089 // normal size later so just ignore it. |
3085 if (!size.IsEmpty()) | 3090 if (!size.IsEmpty()) |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3282 } | 3287 } |
3283 | 3288 |
3284 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { | 3289 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { |
3285 render_manager_.SwapInRenderViewHost(rvh); | 3290 render_manager_.SwapInRenderViewHost(rvh); |
3286 } | 3291 } |
3287 | 3292 |
3288 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 3293 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
3289 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 3294 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
3290 rwh_view->SetSize(view()->GetContainerSize()); | 3295 rwh_view->SetSize(view()->GetContainerSize()); |
3291 } | 3296 } |
OLD | NEW |