summaryrefslogtreecommitdiffstats
path: root/chrome/browser/task_manager.cc
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-20 20:38:26 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-20 20:38:26 +0000
commit065566b96e3aca9a6ac1288b64dd47eda305cc8a (patch)
tree6850f13e0d0cc63b4efdd42701cd5425ac07b742 /chrome/browser/task_manager.cc
parent4139a98bb67d3044fdb28f9da171cba1691b141d (diff)
downloadchromium_src-065566b96e3aca9a6ac1288b64dd47eda305cc8a.zip
chromium_src-065566b96e3aca9a6ac1288b64dd47eda305cc8a.tar.gz
chromium_src-065566b96e3aca9a6ac1288b64dd47eda305cc8a.tar.bz2
Mac: Don't crash on "Stats for nerds" link if no browser window is open.
BUG=32659 TEST=see bug Review URL: http://codereview.chromium.org/554023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36666 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/task_manager.cc')
-rw-r--r--chrome/browser/task_manager.cc39
1 files changed, 27 insertions, 12 deletions
diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc
index 2c6c281..a3b671f 100644
--- a/chrome/browser/task_manager.cc
+++ b/chrome/browser/task_manager.cc
@@ -13,9 +13,11 @@
#include "base/string_util.h"
#include "base/thread.h"
#include "chrome/browser/browser_list.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/net/url_request_tracking.h"
+#include "chrome/browser/profile_manager.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "chrome/browser/tab_contents/tab_contents.h"
@@ -905,17 +907,30 @@ TaskManager* TaskManager::GetInstance() {
void TaskManager::OpenAboutMemory() {
Browser* browser = BrowserList::GetLastActive();
- DCHECK(browser);
- browser->OpenURL(GURL(chrome::kAboutMemoryURL), GURL(), NEW_FOREGROUND_TAB,
- PageTransition::LINK);
- // In case the browser window is minimzed, show it. If this is an application
- // or popup, we can only have one tab, hence we need to process this in a
- // tabbed browser window. Currently, |browser| is pointing to the application,
- // popup window. Therefore, we have to retrieve the last active tab again,
- // since a new window has been used.
- if (browser->type() & Browser::TYPE_APP_POPUP) {
- browser = BrowserList::GetLastActive();
- DCHECK(browser);
+
+ if (!browser) {
+ // On OS X, the task manager can be open without any open browser windows.
+ if (!g_browser_process ||
+ !g_browser_process->profile_manager() ||
+ g_browser_process->profile_manager()->begin() ==
+ g_browser_process->profile_manager()->end())
+ return;
+ browser = Browser::Create(*g_browser_process->profile_manager()->begin());
+ browser->OpenURL(GURL(chrome::kAboutMemoryURL), GURL(), NEW_WINDOW,
+ PageTransition::LINK);
+ } else {
+ browser->OpenURL(GURL(chrome::kAboutMemoryURL), GURL(), NEW_FOREGROUND_TAB,
+ PageTransition::LINK);
+
+ // In case the browser window is minimzed, show it. If this is an
+ // application or popup, we can only have one tab, hence we need to process
+ // this in a tabbed browser window. Currently, |browser| is pointing to the
+ // application, popup window. Therefore, we have to retrieve the last
+ // active tab again, since a new window has been used.
+ if (browser->type() & Browser::TYPE_APP_POPUP) {
+ browser = BrowserList::GetLastActive();
+ DCHECK(browser);
+ }
+ browser->window()->Show();
}
- browser->window()->Show();
}