Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Unified Diff: chrome/browser/views/confirm_message_box_dialog.h

Issue 243054: Change ConfirmMessageBoxDialog to just be a native view (it was only windows ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/resources/locale_settings_zh-TW.xtb ('k') | chrome/browser/views/confirm_message_box_dialog.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/confirm_message_box_dialog.h
===================================================================
--- chrome/browser/views/confirm_message_box_dialog.h (revision 27503)
+++ chrome/browser/views/confirm_message_box_dialog.h (working copy)
@@ -9,25 +9,39 @@
#include "base/basictypes.h"
#include "base/gfx/native_widget_types.h"
-#include "base/message_loop.h"
+#include "views/controls/label.h"
#include "views/window/dialog_delegate.h"
-class MessageBoxView;
+// An interface the confirm dialog uses to notify its clients (observers) when
+// the user makes a decision to confirm or cancel. Only one method will be
+// invoked per use (i.e per invocation of ConfirmMessageBoxDialog::Run).
+class ConfirmMessageBoxObserver {
+ public:
+ // The user explicitly confirmed by clicking "OK".
+ virtual void OnConfirmMessageAccept() = 0;
+ // The user chose not to confirm either by clicking "Cancel" or by closing
+ // the dialog.
+ virtual void OnConfirmMessageCancel() {}
+};
class ConfirmMessageBoxDialog : public views::DialogDelegate,
- public MessageLoopForUI::Dispatcher {
+ public views::View {
public:
- // The method blocks while the dialog is showing, and returns the the value
- // of the user choice, if the user click in Yes button it returns true,
- // otherwise false
- static bool Run(gfx::NativeWindow parent,
+ // The method presents a modal confirmation dialog to the user with the title
+ // |window_title| and message |message_text|. |observer| will be notified
+ // when the user makes a decision or closes the dialog. Note that this class
+ // guarantees it will call one of the observer's methods, so it is the
+ // caller's responsibility to ensure |observer| lives until one of the
+ // methods is invoked; it can be deleted thereafter from this class' point
+ // of view. |parent| specifies where to insert the view into the hierarchy
+ // and effectively assumes ownership of the dialog.
+ static void Run(gfx::NativeWindow parent,
+ ConfirmMessageBoxObserver* observer,
const std::wstring& message_text,
const std::wstring& window_title);
- virtual ~ConfirmMessageBoxDialog();
+ virtual ~ConfirmMessageBoxDialog() {}
- bool accepted() const { return accepted_; }
-
// views::DialogDelegate implementation.
virtual int GetDialogButtons() const;
virtual std::wstring GetWindowTitle() const;
@@ -38,32 +52,26 @@
// views::WindowDelegate implementation.
virtual bool IsModal() const { return true; }
- virtual views::View* GetContentsView();
- virtual void DeleteDelegate();
+ virtual views::View* GetContentsView() { return this; }
- // MessageLoop::Dispatcher implementation.
- virtual bool Dispatch(const MSG& msg);
+ // views::View implementation.
+ virtual void Layout();
+ virtual gfx::Size GetPreferredSize();
private:
- ConfirmMessageBoxDialog(gfx::NativeWindow parent,
+ ConfirmMessageBoxDialog(ConfirmMessageBoxObserver* observer,
const std::wstring& message_text,
const std::wstring& window_title);
// The message which will be shown to user.
- std::wstring message_text_;
+ views::Label* message_label_;
// This is the Title bar text.
std::wstring window_title_;
- MessageBoxView* message_box_view_;
+ // The observer to notify of acceptance or cancellation.
+ ConfirmMessageBoxObserver* observer_;
- // Returns true if the user clicks in Yes button, otherwise false
- bool accepted_;
-
- // Used to keep track of whether or not to block the message loop (still
- // waiting for the user to dismiss the dialog).
- bool is_blocking_;
-
DISALLOW_COPY_AND_ASSIGN(ConfirmMessageBoxDialog);
};
« no previous file with comments | « chrome/app/resources/locale_settings_zh-TW.xtb ('k') | chrome/browser/views/confirm_message_box_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698