| 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 registrar_(), | 327 registrar_(), |
| 328 ALLOW_THIS_IN_INITIALIZER_LIST(printing_( | 328 ALLOW_THIS_IN_INITIALIZER_LIST(printing_( |
| 329 new printing::PrintViewManager(*this))), | 329 new printing::PrintViewManager(*this))), |
| 330 save_package_(), | 330 save_package_(), |
| 331 autocomplete_history_manager_(), | 331 autocomplete_history_manager_(), |
| 332 autofill_manager_(), | 332 autofill_manager_(), |
| 333 plugin_installer_(), | 333 plugin_installer_(), |
| 334 bookmark_drag_(NULL), | 334 bookmark_drag_(NULL), |
| 335 ALLOW_THIS_IN_INITIALIZER_LIST(fav_icon_helper_(this)), | 335 ALLOW_THIS_IN_INITIALIZER_LIST(fav_icon_helper_(this)), |
| 336 is_loading_(false), | 336 is_loading_(false), |
| 337 is_crashed_(false), | 337 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 338 crashed_error_code_(0), |
| 338 waiting_for_response_(false), | 339 waiting_for_response_(false), |
| 339 max_page_id_(-1), | 340 max_page_id_(-1), |
| 340 current_load_start_(), | 341 current_load_start_(), |
| 341 load_state_(net::LOAD_STATE_IDLE), | 342 load_state_(net::LOAD_STATE_IDLE), |
| 342 load_state_host_(), | 343 load_state_host_(), |
| 343 upload_size_(0), | 344 upload_size_(0), |
| 344 upload_position_(0), | 345 upload_position_(0), |
| 345 received_page_title_(false), | 346 received_page_title_(false), |
| 346 is_starred_(false), | 347 is_starred_(false), |
| 347 contents_mime_type_(), | 348 contents_mime_type_(), |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 } | 768 } |
| 768 | 769 |
| 769 void TabContents::AddNavigationObserver(WebNavigationObserver* observer) { | 770 void TabContents::AddNavigationObserver(WebNavigationObserver* observer) { |
| 770 web_navigation_observers_.AddObserver(observer); | 771 web_navigation_observers_.AddObserver(observer); |
| 771 } | 772 } |
| 772 | 773 |
| 773 void TabContents::RemoveNavigationObserver(WebNavigationObserver* observer) { | 774 void TabContents::RemoveNavigationObserver(WebNavigationObserver* observer) { |
| 774 web_navigation_observers_.RemoveObserver(observer); | 775 web_navigation_observers_.RemoveObserver(observer); |
| 775 } | 776 } |
| 776 | 777 |
| 777 void TabContents::SetIsCrashed(bool state) { | 778 void TabContents::SetIsCrashed(base::TerminationStatus status, int error_code) { |
| 778 if (state == is_crashed_) | 779 if (status == crashed_status_) |
| 779 return; | 780 return; |
| 780 | 781 |
| 781 is_crashed_ = state; | 782 crashed_status_ = status; |
| 783 crashed_error_code_ = error_code; |
| 782 NotifyNavigationStateChanged(INVALIDATE_TAB); | 784 NotifyNavigationStateChanged(INVALIDATE_TAB); |
| 783 } | 785 } |
| 784 | 786 |
| 785 void TabContents::PageActionStateChanged() { | 787 void TabContents::PageActionStateChanged() { |
| 786 NotifyNavigationStateChanged(TabContents::INVALIDATE_PAGE_ACTIONS); | 788 NotifyNavigationStateChanged(TabContents::INVALIDATE_PAGE_ACTIONS); |
| 787 } | 789 } |
| 788 | 790 |
| 789 void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) { | 791 void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) { |
| 790 if (delegate_) | 792 if (delegate_) |
| 791 delegate_->NavigationStateChanged(this, changed_flags); | 793 delegate_->NavigationStateChanged(this, changed_flags); |
| (...skipping 1604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2396 | 2398 |
| 2397 void TabContents::RenderViewReady(RenderViewHost* rvh) { | 2399 void TabContents::RenderViewReady(RenderViewHost* rvh) { |
| 2398 if (rvh != render_view_host()) { | 2400 if (rvh != render_view_host()) { |
| 2399 // Don't notify the world, since this came from a renderer in the | 2401 // Don't notify the world, since this came from a renderer in the |
| 2400 // background. | 2402 // background. |
| 2401 return; | 2403 return; |
| 2402 } | 2404 } |
| 2403 | 2405 |
| 2404 NotifyConnected(); | 2406 NotifyConnected(); |
| 2405 bool was_crashed = is_crashed(); | 2407 bool was_crashed = is_crashed(); |
| 2406 SetIsCrashed(false); | 2408 SetIsCrashed(base::TERMINATION_STATUS_STILL_RUNNING, 0); |
| 2407 | 2409 |
| 2408 // Restore the focus to the tab (otherwise the focus will be on the top | 2410 // Restore the focus to the tab (otherwise the focus will be on the top |
| 2409 // window). | 2411 // window). |
| 2410 if (was_crashed && !FocusLocationBarByDefault() && | 2412 if (was_crashed && !FocusLocationBarByDefault() && |
| 2411 (!delegate_ || delegate_->ShouldFocusPageAfterCrash())) { | 2413 (!delegate_ || delegate_->ShouldFocusPageAfterCrash())) { |
| 2412 Focus(); | 2414 Focus(); |
| 2413 } | 2415 } |
| 2414 } | 2416 } |
| 2415 | 2417 |
| 2416 void TabContents::RenderViewGone(RenderViewHost* rvh) { | 2418 void TabContents::RenderViewGone(RenderViewHost* rvh, |
| 2419 base::TerminationStatus status, |
| 2420 int error_code) { |
| 2417 // Ask the print preview if this renderer was valuable. | 2421 // Ask the print preview if this renderer was valuable. |
| 2418 if (!printing_->OnRenderViewGone(rvh)) | 2422 if (!printing_->OnRenderViewGone(rvh)) |
| 2419 return; | 2423 return; |
| 2420 if (rvh != render_view_host()) { | 2424 if (rvh != render_view_host()) { |
| 2421 // The pending page's RenderViewHost is gone. | 2425 // The pending page's RenderViewHost is gone. |
| 2422 return; | 2426 return; |
| 2423 } | 2427 } |
| 2424 | 2428 |
| 2425 SetIsLoading(false, NULL); | 2429 SetIsLoading(false, NULL); |
| 2426 NotifyDisconnected(); | 2430 NotifyDisconnected(); |
| 2427 SetIsCrashed(true); | 2431 SetIsCrashed(status, error_code); |
| 2428 | 2432 |
| 2429 // Remove all infobars. | 2433 // Remove all infobars. |
| 2430 for (int i = infobar_delegate_count() - 1; i >=0 ; --i) | 2434 for (int i = infobar_delegate_count() - 1; i >=0 ; --i) |
| 2431 RemoveInfoBar(GetInfoBarDelegateAt(i)); | 2435 RemoveInfoBar(GetInfoBarDelegateAt(i)); |
| 2432 | 2436 |
| 2433 // Tell the view that we've crashed so it can prepare the sad tab page. | 2437 // Tell the view that we've crashed so it can prepare the sad tab page. |
| 2434 // Only do this if we're not in browser shutdown, so that TabContents | 2438 // Only do this if we're not in browser shutdown, so that TabContents |
| 2435 // objects that are not in a browser (e.g., HTML dialogs) and thus are | 2439 // objects that are not in a browser (e.g., HTML dialogs) and thus are |
| 2436 // visible do not flash a sad tab page. | 2440 // visible do not flash a sad tab page. |
| 2437 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) | 2441 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3036 delegate()->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); | 3040 delegate()->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); |
| 3037 } | 3041 } |
| 3038 | 3042 |
| 3039 void TabContents::DidStartLoadingFromRenderManager( | 3043 void TabContents::DidStartLoadingFromRenderManager( |
| 3040 RenderViewHost* render_view_host) { | 3044 RenderViewHost* render_view_host) { |
| 3041 DidStartLoading(); | 3045 DidStartLoading(); |
| 3042 } | 3046 } |
| 3043 | 3047 |
| 3044 void TabContents::RenderViewGoneFromRenderManager( | 3048 void TabContents::RenderViewGoneFromRenderManager( |
| 3045 RenderViewHost* render_view_host) { | 3049 RenderViewHost* render_view_host) { |
| 3046 RenderViewGone(render_view_host); | 3050 DCHECK(crashed_status_ != base::TERMINATION_STATUS_STILL_RUNNING); |
| 3051 RenderViewGone(render_view_host, crashed_status_, crashed_error_code_); |
| 3047 } | 3052 } |
| 3048 | 3053 |
| 3049 void TabContents::UpdateRenderViewSizeForRenderManager() { | 3054 void TabContents::UpdateRenderViewSizeForRenderManager() { |
| 3050 // TODO(brettw) this is a hack. See TabContentsView::SizeContents. | 3055 // TODO(brettw) this is a hack. See TabContentsView::SizeContents. |
| 3051 gfx::Size size = view_->GetContainerSize(); | 3056 gfx::Size size = view_->GetContainerSize(); |
| 3052 // 0x0 isn't a valid window size (minimal window size is 1x1) but it may be | 3057 // 0x0 isn't a valid window size (minimal window size is 1x1) but it may be |
| 3053 // here during container initialization and normal window size will be set | 3058 // here during container initialization and normal window size will be set |
| 3054 // later. In case of tab duplication this resizing to 0x0 prevents setting | 3059 // later. In case of tab duplication this resizing to 0x0 prevents setting |
| 3055 // normal size later so just ignore it. | 3060 // normal size later so just ignore it. |
| 3056 if (!size.IsEmpty()) | 3061 if (!size.IsEmpty()) |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3245 } | 3250 } |
| 3246 | 3251 |
| 3247 void TabContents::set_encoding(const std::string& encoding) { | 3252 void TabContents::set_encoding(const std::string& encoding) { |
| 3248 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); | 3253 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); |
| 3249 } | 3254 } |
| 3250 | 3255 |
| 3251 void TabContents::SetAppIcon(const SkBitmap& app_icon) { | 3256 void TabContents::SetAppIcon(const SkBitmap& app_icon) { |
| 3252 app_icon_ = app_icon; | 3257 app_icon_ = app_icon; |
| 3253 NotifyNavigationStateChanged(INVALIDATE_TITLE); | 3258 NotifyNavigationStateChanged(INVALIDATE_TITLE); |
| 3254 } | 3259 } |
| OLD | NEW |