From 608b1eb1811d270ee031a1a734a2b24344d2d8f2 Mon Sep 17 00:00:00 2001 From: "finnur@google.com" Date: Wed, 13 Aug 2008 03:11:19 +0000 Subject: When I added some new tests in automated_ui_tests I flushed out a crash in the IDC handler for ViewSource. If Navigate is not called before ViewSource we get a crash when trying to use the output from GetLastCommittedEntry(). To facilitate automatic testing We should instead just check it for null and only do something if a URL is available to us. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@779 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/browser_commands.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'chrome') diff --git a/chrome/browser/browser_commands.cc b/chrome/browser/browser_commands.cc index 9492c71..e0e14e1 100644 --- a/chrome/browser/browser_commands.cc +++ b/chrome/browser/browser_commands.cc @@ -494,11 +494,12 @@ void Browser::ExecuteCommand(int id) { UserMetrics::RecordAction(L"ViewSource", profile_); TabContents* current_tab = GetSelectedTabContents(); - DCHECK(current_tab->controller()->GetLastCommittedEntry()); - GURL url("view-source:" + - current_tab->controller()->GetLastCommittedEntry()->GetURL().spec()); - - AddTabWithURL(url, PageTransition::LINK, true, NULL); + NavigationEntry* entry = + current_tab->controller()->GetLastCommittedEntry(); + if (entry) { + GURL url("view-source:" + entry->GetURL().spec()); + AddTabWithURL(url, PageTransition::LINK, true, NULL); + } break; } -- cgit v1.1