diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-07 02:43:47 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-07 02:43:47 +0000 |
commit | 269f86de339fdf6e9e539c7350a1035ae78fddf7 (patch) | |
tree | a01853c7b2e36dc4d830fff87fe173a8ee3418b1 /ui | |
parent | 857ecf3fa1b779a9238c881a96001a9adf440b08 (diff) | |
download | chromium_src-269f86de339fdf6e9e539c7350a1035ae78fddf7.zip chromium_src-269f86de339fdf6e9e539c7350a1035ae78fddf7.tar.gz chromium_src-269f86de339fdf6e9e539c7350a1035ae78fddf7.tar.bz2 |
views: Add an Options enum to MessageBoxView control.
R=sky@chromium.org
TBR=jam@chromium.org
Review URL: http://codereview.chromium.org/8553001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113331 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/javascript_message_type.h | 21 | ||||
-rw-r--r-- | ui/base/message_box_flags.h | 54 | ||||
-rw-r--r-- | ui/ui.gyp | 2 | ||||
-rw-r--r-- | ui/views/controls/message_box_view.cc | 15 | ||||
-rw-r--r-- | ui/views/controls/message_box_view.h | 12 | ||||
-rw-r--r-- | ui/views/examples/message_box_example.cc | 2 |
6 files changed, 39 insertions, 67 deletions
diff --git a/ui/base/javascript_message_type.h b/ui/base/javascript_message_type.h new file mode 100644 index 0000000..03e1a83 --- /dev/null +++ b/ui/base/javascript_message_type.h @@ -0,0 +1,21 @@ +// Copyright (c) 2011 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. + +#ifndef UI_BASE_JAVASCRIPT_MESSAGE_TYPE_H_ +#define UI_BASE_JAVASCRIPT_MESSAGE_TYPE_H_ +#pragma once + +#include "ui/base/ui_export.h" + +namespace ui { + +enum UI_EXPORT JavascriptMessageType { + JAVASCRIPT_MESSAGE_TYPE_ALERT, + JAVASCRIPT_MESSAGE_TYPE_CONFIRM, + JAVASCRIPT_MESSAGE_TYPE_PROMPT +}; + +} // namespace ui + +#endif // UI_BASE_JAVASCRIPT_MESSAGE_TYPE_H_ diff --git a/ui/base/message_box_flags.h b/ui/base/message_box_flags.h deleted file mode 100644 index 207a97c..0000000 --- a/ui/base/message_box_flags.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef UI_BASE_MESSAGE_BOX_FLAGS_H_ -#define UI_BASE_MESSAGE_BOX_FLAGS_H_ -#pragma once - -#include "base/basictypes.h" - -namespace ui { - -// This class contains flags used to communicate the type of message box -// to show. E.g., the renderer can request the browser to show a -// javascript alert or a javascript confirm message. -class MessageBoxFlags { - public: - static const int kFlagHasOKButton = 0x1; - static const int kFlagHasCancelButton = 0x2; - static const int kFlagHasPromptField = 0x4; - static const int kFlagHasMessage = 0x8; - - // The following flag is used to indicate whether the message's alignment - // should be autodetected or inherited from Chrome UI. Callers should pass - // the correct flag based on the origin of the message. If the message is - // from a web page (such as the JavaScript alert message), its alignment and - // directionality are based on the first character with strong directionality - // in the message. Chrome UI strings are localized string and therefore they - // should have the same alignment and directionality as those of the Chrome - // UI. For example, in RTL locales, even though some strings might begin with - // an English character, they should still be right aligned and be displayed - // Right-To-Left. - // - // TODO(xji): If the message is from a web page, then the message - // directionality should be determined based on the directionality of the web - // page. Please refer to http://crbug.com/7166 for more information. - static const int kAutoDetectAlignment = 0x10; - - static const int kIsConfirmMessageBox = kFlagHasMessage | - kFlagHasOKButton | - kFlagHasCancelButton; - static const int kIsJavascriptAlert = kFlagHasOKButton | kFlagHasMessage; - static const int kIsJavascriptConfirm = kIsJavascriptAlert | - kFlagHasCancelButton; - static const int kIsJavascriptPrompt = kIsJavascriptConfirm | - kFlagHasPromptField; - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(MessageBoxFlags); -}; - -} // namespace ui - -#endif // UI_BASE_MESSAGE_BOX_FLAGS_H_ @@ -144,6 +144,7 @@ 'base/ime/text_input_client.cc', 'base/ime/text_input_client.h', 'base/ime/text_input_type.h', + 'base/javascript_message_type.h', 'base/keycodes/keyboard_code_conversion.cc', 'base/keycodes/keyboard_code_conversion.h', 'base/keycodes/keyboard_code_conversion_gtk.cc', @@ -165,7 +166,6 @@ 'base/l10n/l10n_util_posix.cc', 'base/l10n/l10n_util_win.cc', 'base/l10n/l10n_util_win.h', - 'base/message_box_flags.h', 'base/message_box_win.cc', 'base/message_box_win.h', 'base/models/button_menu_item_model.cc', diff --git a/ui/views/controls/message_box_view.cc b/ui/views/controls/message_box_view.cc index 1c27627..6ce3217 100644 --- a/ui/views/controls/message_box_view.cc +++ b/ui/views/controls/message_box_view.cc @@ -10,7 +10,6 @@ #include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/scoped_clipboard_writer.h" -#include "ui/base/message_box_flags.h" #include "ui/views/controls/button/checkbox.h" #include "ui/views/controls/image_view.h" #include "ui/views/controls/label.h" @@ -28,7 +27,7 @@ namespace views { /////////////////////////////////////////////////////////////////////////////// // MessageBoxView, public: -MessageBoxView::MessageBoxView(int dialog_flags, +MessageBoxView::MessageBoxView(int options, const string16& message, const string16& default_prompt, int message_width) @@ -37,10 +36,10 @@ MessageBoxView::MessageBoxView(int dialog_flags, icon_(NULL), checkbox_(NULL), message_width_(message_width) { - Init(dialog_flags, default_prompt); + Init(options, default_prompt); } -MessageBoxView::MessageBoxView(int dialog_flags, +MessageBoxView::MessageBoxView(int options, const string16& message, const string16& default_prompt) : message_label_(new Label(message)), @@ -48,7 +47,7 @@ MessageBoxView::MessageBoxView(int dialog_flags, icon_(NULL), checkbox_(NULL), message_width_(kDefaultMessageWidth) { - Init(dialog_flags, default_prompt); + Init(options, default_prompt); } MessageBoxView::~MessageBoxView() {} @@ -125,11 +124,11 @@ bool MessageBoxView::AcceleratorPressed(const ui::Accelerator& accelerator) { /////////////////////////////////////////////////////////////////////////////// // MessageBoxView, private: -void MessageBoxView::Init(int dialog_flags, +void MessageBoxView::Init(int options, const string16& default_prompt) { message_label_->SetMultiLine(true); message_label_->SetAllowCharacterBreak(true); - if (dialog_flags & ui::MessageBoxFlags::kAutoDetectAlignment) { + if (options & DETECT_ALIGNMENT) { // Determine the alignment and directionality based on the first character // with strong directionality. base::i18n::TextDirection direction = @@ -149,7 +148,7 @@ void MessageBoxView::Init(int dialog_flags, message_label_->SetHorizontalAlignment(Label::ALIGN_LEFT); } - if (dialog_flags & ui::MessageBoxFlags::kFlagHasPromptField) { + if (options & HAS_PROMPT_FIELD) { prompt_field_ = new Textfield; prompt_field_->SetText(default_prompt); } diff --git a/ui/views/controls/message_box_view.h b/ui/views/controls/message_box_view.h index cd81e40..8df16bc 100644 --- a/ui/views/controls/message_box_view.h +++ b/ui/views/controls/message_box_view.h @@ -23,12 +23,18 @@ class Textfield; // and Cancel buttons. class VIEWS_EXPORT MessageBoxView : public View { public: - MessageBoxView(int dialog_flags, + enum Options { + NO_OPTIONS = 0, + DETECT_ALIGNMENT = 1 << 0, + HAS_PROMPT_FIELD = 1 << 1, + }; + + MessageBoxView(int options, const string16& message, const string16& default_prompt, int message_width); - MessageBoxView(int dialog_flags, + MessageBoxView(int options, const string16& message, const string16& default_prompt); @@ -70,7 +76,7 @@ class VIEWS_EXPORT MessageBoxView : public View { private: // Sets up the layout manager and initializes the prompt field. This should // only be called once, from the constructor. - void Init(int dialog_flags, const string16& default_prompt); + void Init(int options, const string16& default_prompt); // Sets up the layout manager based on currently initialized views. Should be // called when a view is initialized or changed. diff --git a/ui/views/examples/message_box_example.cc b/ui/views/examples/message_box_example.cc index 3bb6eb7..c718077 100644 --- a/ui/views/examples/message_box_example.cc +++ b/ui/views/examples/message_box_example.cc @@ -20,7 +20,7 @@ MessageBoxExample::~MessageBoxExample() { void MessageBoxExample::CreateExampleView(View* container) { message_box_view_ = new MessageBoxView( - 0, + views::MessageBoxView::NO_OPTIONS, ASCIIToUTF16("Message Box Message"), ASCIIToUTF16("Default Prompt")); status_ = new TextButton(this, ASCIIToUTF16("Show Status")); |