Skip to content

Commit

Permalink
browser: Rename two message box functions to more accurate names.
Browse files Browse the repository at this point in the history
This is a follow up to r132847.

R=msw@chromium.org
TBR=sky@chromium.org

Review URL: https://chromiumcodereview.appspot.com/10164019

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133396 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
tfarina@chromium.org committed Apr 23, 2012
1 parent f2ad6f5 commit 5c61cc9
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 88 deletions.
8 changes: 4 additions & 4 deletions chrome/browser/bookmarks/bookmark_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ bool ShouldOpenAll(gfx::NativeWindow parent,
if (child_count < bookmark_utils::num_urls_before_prompting)
return true;

string16 message = l10n_util::GetStringFUTF16(
const string16 title = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
const string16 message = l10n_util::GetStringFUTF16(
IDS_BOOKMARK_BAR_SHOULD_OPEN_ALL,
base::IntToString16(child_count));
string16 title = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
return browser::ShowYesNoBox(parent, title, message);
return browser::ShowQuestionMessageBox(parent, title, message);
}

// Comparison function that compares based on date modified of the two nodes.
Expand Down Expand Up @@ -725,7 +725,7 @@ bool NodeHasURLs(const BookmarkNode* node) {
bool ConfirmDeleteBookmarkNode(const BookmarkNode* node,
gfx::NativeWindow window) {
DCHECK(node && node->is_folder() && !node->empty());
return browser::ShowYesNoBox(window,
return browser::ShowQuestionMessageBox(window,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
l10n_util::GetStringFUTF16Int(IDS_BOOKMARK_EDITOR_CONFIRM_DELETE,
ChildURLCountTotal(node)));
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chrome_browser_main_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void WarnAboutMinimumSystemRequirements() {
const string16 title = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
const string16 message =
l10n_util::GetStringUTF16(IDS_UNSUPPORTED_OS_PRE_WIN_XP);
browser::ShowErrorBox(NULL, title, message);
browser::ShowWarningMessageBox(NULL, title, message);
}
}

Expand All @@ -114,7 +114,7 @@ int AskForUninstallConfirmation() {
void ShowCloseBrowserFirstMessageBox() {
const string16 title = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
const string16 message = l10n_util::GetStringUTF16(IDS_UNINSTALL_CLOSE_APP);
browser::ShowErrorBox(NULL, title, message);
browser::ShowWarningMessageBox(NULL, title, message);
}

int DoUninstallTasks(bool chrome_still_running) {
Expand Down
7 changes: 3 additions & 4 deletions chrome/browser/chromeos/extensions/file_manager_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/extensions/file_browser_handler.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/file_browser_handler.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/plugin_service.h"
Expand Down Expand Up @@ -534,13 +534,12 @@ void ViewFile(const FilePath& path) {
if (!TryOpeningFileBrowser(profile, path) &&
!TryViewingFile(profile, path)) {
Browser* browser = Browser::GetOrCreateTabbedBrowser(profile);
browser::ShowErrorBox(
browser::ShowWarningMessageBox(
browser->window()->GetNativeHandle(),
l10n_util::GetStringFUTF16(
IDS_FILE_BROWSER_ERROR_VIEWING_FILE_TITLE,
UTF8ToUTF16(path.BaseName().value())),
l10n_util::GetStringUTF16(
IDS_FILE_BROWSER_ERROR_VIEWING_FILE));
l10n_util::GetStringUTF16(IDS_FILE_BROWSER_ERROR_VIEWING_FILE));
}
}

Expand Down
7 changes: 3 additions & 4 deletions chrome/browser/extensions/extension_error_reporter.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -56,9 +56,8 @@ void ExtensionErrorReporter::ReportError(const string16& message,
LOG(ERROR) << "Extension error: " << message;

if (enable_noisy_errors_ && be_noisy) {
browser::ShowErrorBox(NULL,
UTF8ToUTF16("Extension error"),
message);
browser::ShowWarningMessageBox(NULL, ASCIIToUTF16("Extension error"),
message);
}
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/extension_install_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ void ExtensionInstallUI::OnInstallFailure(const string16& error) {
return;

Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
browser::ShowErrorBox(
browser::ShowWarningMessageBox(
browser ? browser->window()->GetNativeHandle() : NULL,
l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_FAILURE_TITLE),
error);
Expand Down
9 changes: 5 additions & 4 deletions chrome/browser/hang_monitor/hung_plugin_action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ bool HungPluginAction::OnHungWindowDetected(HWND hung_window,
NOTREACHED() << "Terminated a hung plugin process.";
*action = HungWindowNotification::HUNG_WINDOW_TERMINATE_PROCESS;
} else {
string16 msg = l10n_util::GetStringFUTF16(IDS_BROWSER_HANGMONITOR,
plugin_name);
string16 title = l10n_util::GetStringUTF16(IDS_BROWSER_HANGMONITOR_TITLE);
const string16 title = l10n_util::GetStringUTF16(
IDS_BROWSER_HANGMONITOR_TITLE);
const string16 message = l10n_util::GetStringFUTF16(
IDS_BROWSER_HANGMONITOR, plugin_name);
// Before displaying the message box, invoke SendMessageCallback on the
// hung window. If the callback ever hits, the window is not hung anymore
// and we can dismiss the message box.
Expand All @@ -112,7 +113,7 @@ bool HungPluginAction::OnHungWindowDetected(HWND hung_window,
HungWindowResponseCallback,
reinterpret_cast<ULONG_PTR>(this));
current_hung_plugin_window_ = hung_window;
if (browser::ShowYesNoBox(NULL, title, msg)) {
if (browser::ShowQuestionMessageBox(NULL, title, message)) {
*action = HungWindowNotification::HUNG_WINDOW_TERMINATE_PROCESS;
} else {
// If the user choses to ignore the hung window warning, the
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/pepper_gtalk_message_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ void PepperGtalkMessageFilter::OnTalkGetPermission(uint32 plugin_dispatcher_id,

bool user_response = false;
#if defined(USE_ASH)
string16 title = l10n_util::GetStringUTF16(
const string16 title = l10n_util::GetStringUTF16(
IDS_GTALK_SCREEN_SHARE_DIALOG_TITLE);
string16 message = l10n_util::GetStringUTF16(
const string16 message = l10n_util::GetStringUTF16(
IDS_GTALK_SCREEN_SHARE_DIALOG_MESSAGE);

aura::Window* parent = ash::Shell::GetInstance()->GetContainer(
ash::internal::kShellWindowId_SystemModalContainer);
user_response = browser::ShowYesNoBox(parent, title, message);
user_response = browser::ShowQuestionMessageBox(parent, title, message);
#else
NOTIMPLEMENTED();
#endif
Expand Down
7 changes: 4 additions & 3 deletions chrome/browser/process_singleton_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,10 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() {

// If there is a visible browser window, ask the user before killing it.
if (visible_window) {
string16 text = l10n_util::GetStringUTF16(IDS_BROWSER_HUNGBROWSER_MESSAGE);
string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
if (!browser::ShowYesNoBox(NULL, caption, text)) {
const string16 title = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
const string16 message = l10n_util::GetStringUTF16(
IDS_BROWSER_HUNGBROWSER_MESSAGE);
if (!browser::ShowQuestionMessageBox(NULL, title, message)) {
// The user denied. Quit silently.
return PROCESS_NOTIFIED;
}
Expand Down
26 changes: 13 additions & 13 deletions chrome/browser/simple_message_box.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand All @@ -11,19 +11,19 @@

namespace browser {

// Pops up an error box with an OK button. If |parent| is non-null, the box
// will be modal on it. (On Mac, it is always app-modal.) Generally speaking,
// this function should not be used for much. Infobars are preferred.
void ShowErrorBox(gfx::NativeWindow parent,
const string16& title,
const string16& message);
// Shows a warning message box with an OK button. If |parent| is non-null,
// the box will be modal on it. (On Mac, it is always app-modal.) Generally
// speaking, this function should not be used for much. Infobars are preferred.
void ShowWarningMessageBox(gfx::NativeWindow parent,
const string16& title,
const string16& message);

// Pops up a dialog box with two buttons (Yes/No), with the default button of
// Yes. If |parent| is non-null, the box will be modal on it. (On Mac, it is
// always app-modal.) Returns true if the Yes button was chosen.
bool ShowYesNoBox(gfx::NativeWindow parent,
const string16& title,
const string16& message);
// Shows a question message box with two buttons (Yes/No), with the default
// button of Yes. If |parent| is non-null, the box will be modal on it. (On Mac,
// it is always app-modal.) Returns true if the Yes button was chosen.
bool ShowQuestionMessageBox(gfx::NativeWindow parent,
const string16& title,
const string16& message);

} // namespace browser

Expand Down
14 changes: 7 additions & 7 deletions chrome/browser/ui/cocoa/simple_message_box_mac.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand All @@ -12,9 +12,9 @@

namespace browser {

void ShowErrorBox(gfx::NativeWindow parent,
const string16& title,
const string16& message) {
void ShowWarningMessageBox(gfx::NativeWindow parent,
const string16& title,
const string16& message) {
// Ignore the title; it's the window title on other platforms and ignorable.
NSAlert* alert = [[[NSAlert alloc] init] autorelease];
[alert addButtonWithTitle:l10n_util::GetNSString(IDS_OK)];
Expand All @@ -23,9 +23,9 @@ void ShowErrorBox(gfx::NativeWindow parent,
[alert runModal];
}

bool ShowYesNoBox(gfx::NativeWindow parent,
const string16& title,
const string16& message) {
bool ShowQuestionMessageBox(gfx::NativeWindow parent,
const string16& title,
const string16& message) {
// Ignore the title; it's the window title on other platforms and ignorable.
NSAlert* alert = [[[NSAlert alloc] init] autorelease];
[alert setMessageText:base::SysUTF16ToNSString(message)];
Expand Down
12 changes: 6 additions & 6 deletions chrome/browser/ui/gtk/simple_message_box_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ void HandleOnResponseDialog(GtkWidget* widget, int response, void* user_data) {

namespace browser {

void ShowErrorBox(gfx::NativeWindow parent,
const string16& title,
const string16& message) {
void ShowWarningMessageBox(gfx::NativeWindow parent,
const string16& title,
const string16& message) {
GtkWidget* dialog = gtk_message_dialog_new(parent,
GTK_DIALOG_MODAL,
GTK_MESSAGE_WARNING,
Expand All @@ -60,9 +60,9 @@ void ShowErrorBox(gfx::NativeWindow parent,
gtk_util::ShowDialog(dialog);
}

bool ShowYesNoBox(gfx::NativeWindow parent,
const string16& title,
const string16& message) {
bool ShowQuestionMessageBox(gfx::NativeWindow parent,
const string16& title,
const string16& message) {
GtkWidget* dialog = gtk_message_dialog_new(parent,
GTK_DIALOG_MODAL,
GTK_MESSAGE_QUESTION,
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/profile_error_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void ShowProfileErrorDialog(int message_id) {
// Parent the dialog to the current browser. During startup there may be no
// browser.
Browser* browser = BrowserList::GetLastActive();
browser::ShowErrorBox(
browser::ShowWarningMessageBox(
browser ? browser->window()->GetNativeHandle() : NULL,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
l10n_util::GetStringUTF16(message_id));
Expand Down
38 changes: 20 additions & 18 deletions chrome/browser/ui/views/simple_message_box_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@

namespace browser {

void ShowErrorBox(gfx::NativeWindow parent,
const string16& title,
const string16& message) {
SimpleMessageBoxViews::ShowErrorBox(parent, title, message);
void ShowWarningMessageBox(gfx::NativeWindow parent,
const string16& title,
const string16& message) {
SimpleMessageBoxViews::ShowWarningMessageBox(parent, title, message);
}

bool ShowYesNoBox(gfx::NativeWindow parent,
const string16& title,
const string16& message) {
return SimpleMessageBoxViews::ShowYesNoBox(parent, title, message);
bool ShowQuestionMessageBox(gfx::NativeWindow parent,
const string16& title,
const string16& message) {
return SimpleMessageBoxViews::ShowQuestionMessageBox(parent, title, message);
}

} // namespace browser
Expand All @@ -40,22 +40,24 @@ bool ShowYesNoBox(gfx::NativeWindow parent,
// SimpleMessageBoxViews, public:

// static
void SimpleMessageBoxViews::ShowErrorBox(gfx::NativeWindow parent_window,
const string16& title,
const string16& message) {
void SimpleMessageBoxViews::ShowWarningMessageBox(
gfx::NativeWindow parent_window,
const string16& title,
const string16& message) {
// This is a reference counted object so it is given an initial increment
// in the constructor with a corresponding decrement in DeleteDelegate().
new SimpleMessageBoxViews(parent_window, DIALOG_ERROR, title, message);
new SimpleMessageBoxViews(parent_window, DIALOG_TYPE_WARNING, title, message);
}

bool SimpleMessageBoxViews::ShowYesNoBox(gfx::NativeWindow parent_window,
const string16& title,
const string16& message) {
bool SimpleMessageBoxViews::ShowQuestionMessageBox(
gfx::NativeWindow parent_window,
const string16& title,
const string16& message) {
// This is a reference counted object so it is given an initial increment
// in the constructor plus an extra one below to ensure the dialog persists
// until we retrieve the user response..
scoped_refptr<SimpleMessageBoxViews> dialog =
new SimpleMessageBoxViews(parent_window, DIALOG_YES_NO, title, message);
scoped_refptr<SimpleMessageBoxViews> dialog = new SimpleMessageBoxViews(
parent_window, DIALOG_TYPE_QUESTION, title, message);

// Make sure Chrome doesn't attempt to shut down with the dialog up.
g_browser_process->AddRefModule();
Expand All @@ -79,7 +81,7 @@ bool SimpleMessageBoxViews::ShowYesNoBox(gfx::NativeWindow parent_window,
// SimpleMessageBoxViews, private:

int SimpleMessageBoxViews::GetDialogButtons() const {
if (dialog_type_ == DIALOG_ERROR)
if (dialog_type_ == DIALOG_TYPE_WARNING)
return ui::DIALOG_BUTTON_OK;
return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
}
Expand Down
16 changes: 8 additions & 8 deletions chrome/browser/ui/views/simple_message_box_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class SimpleMessageBoxViews : public views::DialogDelegate,
public MessageLoop::Dispatcher,
public base::RefCounted<SimpleMessageBoxViews> {
public:
static void ShowErrorBox(gfx::NativeWindow parent_window,
const string16& title,
const string16& message);
static bool ShowYesNoBox(gfx::NativeWindow parent_window,
const string16& title,
const string16& message);
static void ShowWarningMessageBox(gfx::NativeWindow parent_window,
const string16& title,
const string16& message);
static bool ShowQuestionMessageBox(gfx::NativeWindow parent_window,
const string16& title,
const string16& message);

// Returns true if the Accept button was clicked.
bool accepted() const { return disposition_ == DISPOSITION_OK; }
Expand All @@ -42,8 +42,8 @@ class SimpleMessageBoxViews : public views::DialogDelegate,
};

enum DialogType {
DIALOG_ERROR,
DIALOG_YES_NO,
DIALOG_TYPE_WARNING,
DIALOG_TYPE_QUESTION,
};

// Overridden from views::DialogDelegate:
Expand Down
19 changes: 9 additions & 10 deletions chrome/browser/ui/views/simple_message_box_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@

namespace browser {

void ShowErrorBox(gfx::NativeWindow parent,
const string16& title,
const string16& message) {
UINT flags = MB_OK | MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST;
void ShowWarningMessageBox(gfx::NativeWindow parent,
const string16& title,
const string16& message) {
const UINT flags = MB_OK | MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST;
ui::MessageBox(parent, message, title, flags);
}

bool ShowYesNoBox(gfx::NativeWindow parent,
const string16& title,
const string16& message) {
UINT flags = MB_YESNO | MB_ICONWARNING | MB_SETFOREGROUND;
int result = ui::MessageBox(parent, message, title, flags);
return result == IDYES;
bool ShowQuestionMessageBox(gfx::NativeWindow parent,
const string16& title,
const string16& message) {
const UINT flags = MB_YESNO | MB_ICONWARNING | MB_SETFOREGROUND;
return ui::MessageBox(parent, message, title, flags) == IDYES;
}

} // namespace browser

0 comments on commit 5c61cc9

Please sign in to comment.