From 1c370c041ab3333d091efdfbbc814853934d574d Mon Sep 17 00:00:00 2001 From: "tc@google.com" Date: Fri, 3 Apr 2009 21:30:12 +0000 Subject: NULL check web_contents_ to prevent a crash. In the notification observer, web_contents_ can be set to NULL so check for a NULL web_contents_ in GetWindowTitle. All the other methods check web_contents_ before using it too. BUG=9672 Review URL: http://codereview.chromium.org/56205 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13113 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/jsmessage_box_handler_win.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'chrome/browser') diff --git a/chrome/browser/jsmessage_box_handler_win.cc b/chrome/browser/jsmessage_box_handler_win.cc index 847f7cf..5184dd6 100644 --- a/chrome/browser/jsmessage_box_handler_win.cc +++ b/chrome/browser/jsmessage_box_handler_win.cc @@ -84,7 +84,7 @@ int JavascriptMessageBoxHandler::GetDialogButtons() const { } std::wstring JavascriptMessageBoxHandler::GetWindowTitle() const { - if (!frame_url_.has_host()) + if (!frame_url_.has_host() || !web_contents_) return l10n_util::GetString(IDS_JAVASCRIPT_MESSAGEBOX_DEFAULT_TITLE); // We really only want the scheme, hostname, and port. @@ -189,10 +189,11 @@ views::View* JavascriptMessageBoxHandler::GetInitiallyFocusedView() { void JavascriptMessageBoxHandler::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { - bool web_contents_gone = false; if (!web_contents_) return; + bool web_contents_gone = false; + if (type == NotificationType::NAV_ENTRY_COMMITTED && Source(source).ptr() == web_contents_->controller()) web_contents_gone = true; -- cgit v1.1