From 4d409d77dfaa84a06547d3e0a45191cf803fbb9d Mon Sep 17 00:00:00 2001 From: "thakis@chromium.org" Date: Sat, 21 Nov 2009 07:44:29 +0000 Subject: Mac: Implement profile error dialog. The "active window" change was done for linux in http://codereview.chromium.org/147091 and might fix other problems too. Without this, BrowserList::GetLastActive() returns NULL in Browser::Observe(), which caused the new function not to be called. It looks something like http://imgur.com/6PHQm . BUG=26377 TEST= chmod -r ~/Library/Application\ Support/Chromium/Default/History* Then start chromium (release build, so that we survive some sqlite dchecks) and make sure it displays an error message (then chmod +r again) Review URL: http://codereview.chromium.org/418040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32738 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/cocoa/browser_window_cocoa.mm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index d7d19d5..2d48ebd 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "app/l10n_util_mac.h" #include "base/gfx/rect.h" #include "base/logging.h" #include "base/sys_string_conversions.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/bookmarks/bookmark_utils.h" +#include "chrome/browser/browser_list.h" #include "chrome/browser/cocoa/browser_window_cocoa.h" #import "chrome/browser/cocoa/browser_window_controller.h" #import "chrome/browser/cocoa/bug_report_window_controller.h" @@ -29,6 +31,8 @@ #include "chrome/common/pref_service.h" #include "chrome/common/temp_scaffolding_stubs.h" #include "chrome/browser/profile.h" +#include "grit/chromium_strings.h" +#include "grit/generated_resources.h" BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser, BrowserWindowController* controller, @@ -45,6 +49,14 @@ BrowserWindowCocoa::~BrowserWindowCocoa() { } void BrowserWindowCocoa::Show() { + // The Browser associated with this browser window must become the active + // browser at the time |Show()| is called. This is the natural behaviour under + // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:| + // until we return to the runloop. Therefore any calls to + // |BrowserList::GetLastActive()| (for example, in bookmark_util), will return + // the previous browser instead if we don't explicitly set it here. + BrowserList::SetLastActive(browser_); + [window_ makeKeyAndOrderFront:controller_]; } @@ -303,7 +315,12 @@ void BrowserWindowCocoa::ShowRepostFormWarningDialog( } void BrowserWindowCocoa::ShowProfileErrorDialog(int message_id) { - NOTIMPLEMENTED(); + scoped_nsobject alert([[NSAlert alloc] init]); + [alert addButtonWithTitle:l10n_util::GetNSStringWithFixup(IDS_OK)]; + [alert setMessageText:l10n_util::GetNSStringWithFixup(IDS_PRODUCT_NAME)]; + [alert setInformativeText:l10n_util::GetNSStringWithFixup(message_id)]; + [alert setAlertStyle:NSWarningAlertStyle]; + [alert runModal]; } void BrowserWindowCocoa::ShowThemeInstallBubble() { -- cgit v1.1