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

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

Issue 5172009: This adds some plumbing for propagating the reason for a renderer's death (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Upload after sync for proper diffs Created 10 years 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) 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
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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 } 759 }
759 760
760 void TabContents::AddNavigationObserver(WebNavigationObserver* observer) { 761 void TabContents::AddNavigationObserver(WebNavigationObserver* observer) {
761 web_navigation_observers_.AddObserver(observer); 762 web_navigation_observers_.AddObserver(observer);
762 } 763 }
763 764
764 void TabContents::RemoveNavigationObserver(WebNavigationObserver* observer) { 765 void TabContents::RemoveNavigationObserver(WebNavigationObserver* observer) {
765 web_navigation_observers_.RemoveObserver(observer); 766 web_navigation_observers_.RemoveObserver(observer);
766 } 767 }
767 768
768 void TabContents::SetIsCrashed(bool state) { 769 void TabContents::SetIsCrashed(base::TerminationStatus status, int error_code) {
769 if (state == is_crashed_) 770 if (status == crashed_status_)
770 return; 771 return;
771 772
772 is_crashed_ = state; 773 crashed_status_ = status;
774 crashed_error_code_ = error_code;
773 NotifyNavigationStateChanged(INVALIDATE_TAB); 775 NotifyNavigationStateChanged(INVALIDATE_TAB);
774 } 776 }
775 777
776 void TabContents::PageActionStateChanged() { 778 void TabContents::PageActionStateChanged() {
777 NotifyNavigationStateChanged(TabContents::INVALIDATE_PAGE_ACTIONS); 779 NotifyNavigationStateChanged(TabContents::INVALIDATE_PAGE_ACTIONS);
778 } 780 }
779 781
780 void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) { 782 void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) {
781 if (delegate_) 783 if (delegate_)
782 delegate_->NavigationStateChanged(this, changed_flags); 784 delegate_->NavigationStateChanged(this, changed_flags);
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after
2388 2390
2389 void TabContents::RenderViewReady(RenderViewHost* rvh) { 2391 void TabContents::RenderViewReady(RenderViewHost* rvh) {
2390 if (rvh != render_view_host()) { 2392 if (rvh != render_view_host()) {
2391 // Don't notify the world, since this came from a renderer in the 2393 // Don't notify the world, since this came from a renderer in the
2392 // background. 2394 // background.
2393 return; 2395 return;
2394 } 2396 }
2395 2397
2396 NotifyConnected(); 2398 NotifyConnected();
2397 bool was_crashed = is_crashed(); 2399 bool was_crashed = is_crashed();
2398 SetIsCrashed(false); 2400 SetIsCrashed(base::TERMINATION_STATUS_STILL_RUNNING, 0);
2399 2401
2400 // Restore the focus to the tab (otherwise the focus will be on the top 2402 // Restore the focus to the tab (otherwise the focus will be on the top
2401 // window). 2403 // window).
2402 if (was_crashed && !FocusLocationBarByDefault() && 2404 if (was_crashed && !FocusLocationBarByDefault() &&
2403 (!delegate_ || delegate_->ShouldFocusPageAfterCrash())) { 2405 (!delegate_ || delegate_->ShouldFocusPageAfterCrash())) {
2404 Focus(); 2406 Focus();
2405 } 2407 }
2406 } 2408 }
2407 2409
2408 void TabContents::RenderViewGone(RenderViewHost* rvh) { 2410 void TabContents::RenderViewGone(RenderViewHost* rvh,
2411 base::TerminationStatus status,
2412 int error_code) {
2409 // Ask the print preview if this renderer was valuable. 2413 // Ask the print preview if this renderer was valuable.
2410 if (!printing_->OnRenderViewGone(rvh)) 2414 if (!printing_->OnRenderViewGone(rvh))
2411 return; 2415 return;
2412 if (rvh != render_view_host()) { 2416 if (rvh != render_view_host()) {
2413 // The pending page's RenderViewHost is gone. 2417 // The pending page's RenderViewHost is gone.
2414 return; 2418 return;
2415 } 2419 }
2416 2420
2417 SetIsLoading(false, NULL); 2421 SetIsLoading(false, NULL);
2418 NotifyDisconnected(); 2422 NotifyDisconnected();
2419 SetIsCrashed(true); 2423 SetIsCrashed(status, error_code);
2420 2424
2421 // Remove all infobars. 2425 // Remove all infobars.
2422 for (int i = infobar_delegate_count() - 1; i >=0 ; --i) 2426 for (int i = infobar_delegate_count() - 1; i >=0 ; --i)
2423 RemoveInfoBar(GetInfoBarDelegateAt(i)); 2427 RemoveInfoBar(GetInfoBarDelegateAt(i));
2424 2428
2425 // Tell the view that we've crashed so it can prepare the sad tab page. 2429 // Tell the view that we've crashed so it can prepare the sad tab page.
2426 // Only do this if we're not in browser shutdown, so that TabContents 2430 // Only do this if we're not in browser shutdown, so that TabContents
2427 // objects that are not in a browser (e.g., HTML dialogs) and thus are 2431 // objects that are not in a browser (e.g., HTML dialogs) and thus are
2428 // visible do not flash a sad tab page. 2432 // visible do not flash a sad tab page.
2429 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) 2433 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID)
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
3028 delegate()->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); 3032 delegate()->BeforeUnloadFired(this, proceed, proceed_to_fire_unload);
3029 } 3033 }
3030 3034
3031 void TabContents::DidStartLoadingFromRenderManager( 3035 void TabContents::DidStartLoadingFromRenderManager(
3032 RenderViewHost* render_view_host) { 3036 RenderViewHost* render_view_host) {
3033 DidStartLoading(); 3037 DidStartLoading();
3034 } 3038 }
3035 3039
3036 void TabContents::RenderViewGoneFromRenderManager( 3040 void TabContents::RenderViewGoneFromRenderManager(
3037 RenderViewHost* render_view_host) { 3041 RenderViewHost* render_view_host) {
3038 RenderViewGone(render_view_host); 3042 DCHECK(crashed_status_ != base::TERMINATION_STATUS_STILL_RUNNING);
3043 RenderViewGone(render_view_host, crashed_status_, crashed_error_code_);
3039 } 3044 }
3040 3045
3041 void TabContents::UpdateRenderViewSizeForRenderManager() { 3046 void TabContents::UpdateRenderViewSizeForRenderManager() {
3042 // TODO(brettw) this is a hack. See TabContentsView::SizeContents. 3047 // TODO(brettw) this is a hack. See TabContentsView::SizeContents.
3043 gfx::Size size = view_->GetContainerSize(); 3048 gfx::Size size = view_->GetContainerSize();
3044 // 0x0 isn't a valid window size (minimal window size is 1x1) but it may be 3049 // 0x0 isn't a valid window size (minimal window size is 1x1) but it may be
3045 // here during container initialization and normal window size will be set 3050 // here during container initialization and normal window size will be set
3046 // later. In case of tab duplication this resizing to 0x0 prevents setting 3051 // later. In case of tab duplication this resizing to 0x0 prevents setting
3047 // normal size later so just ignore it. 3052 // normal size later so just ignore it.
3048 if (!size.IsEmpty()) 3053 if (!size.IsEmpty())
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
3236 } 3241 }
3237 3242
3238 void TabContents::set_encoding(const std::string& encoding) { 3243 void TabContents::set_encoding(const std::string& encoding) {
3239 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); 3244 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding);
3240 } 3245 }
3241 3246
3242 void TabContents::SetAppIcon(const SkBitmap& app_icon) { 3247 void TabContents::SetAppIcon(const SkBitmap& app_icon) {
3243 app_icon_ = app_icon; 3248 app_icon_ = app_icon;
3244 NotifyNavigationStateChanged(INVALIDATE_TITLE); 3249 NotifyNavigationStateChanged(INVALIDATE_TITLE);
3245 } 3250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698