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

Side by Side 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, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_VIEWS_CONFIRM_MESSAGE_BOX_DIALOG_H_ 5 #ifndef CHROME_BROWSER_VIEWS_CONFIRM_MESSAGE_BOX_DIALOG_H_
6 #define CHROME_BROWSER_VIEWS_CONFIRM_MESSAGE_BOX_DIALOG_H_ 6 #define CHROME_BROWSER_VIEWS_CONFIRM_MESSAGE_BOX_DIALOG_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/gfx/native_widget_types.h" 11 #include "base/gfx/native_widget_types.h"
12 #include "base/message_loop.h" 12 #include "views/controls/label.h"
13 #include "views/window/dialog_delegate.h" 13 #include "views/window/dialog_delegate.h"
14 14
15 class MessageBoxView; 15 // An interface the confirm dialog uses to notify its clients (observers) when
16 // the user makes a decision to confirm or cancel. Only one method will be
17 // invoked per use (i.e per invocation of ConfirmMessageBoxDialog::Run).
18 class ConfirmMessageBoxObserver {
19 public:
20 // The user explicitly confirmed by clicking "OK".
21 virtual void OnConfirmMessageAccept() = 0;
22 // The user chose not to confirm either by clicking "Cancel" or by closing
23 // the dialog.
24 virtual void OnConfirmMessageCancel() {}
25 };
16 26
17 class ConfirmMessageBoxDialog : public views::DialogDelegate, 27 class ConfirmMessageBoxDialog : public views::DialogDelegate,
18 public MessageLoopForUI::Dispatcher { 28 public views::View {
19 public: 29 public:
20 // The method blocks while the dialog is showing, and returns the the value 30 // The method presents a modal confirmation dialog to the user with the title
21 // of the user choice, if the user click in Yes button it returns true, 31 // |window_title| and message |message_text|. |observer| will be notified
22 // otherwise false 32 // when the user makes a decision or closes the dialog. Note that this class
23 static bool Run(gfx::NativeWindow parent, 33 // guarantees it will call one of the observer's methods, so it is the
34 // caller's responsibility to ensure |observer| lives until one of the
35 // methods is invoked; it can be deleted thereafter from this class' point
36 // of view. |parent| specifies where to insert the view into the hierarchy
37 // and effectively assumes ownership of the dialog.
38 static void Run(gfx::NativeWindow parent,
39 ConfirmMessageBoxObserver* observer,
24 const std::wstring& message_text, 40 const std::wstring& message_text,
25 const std::wstring& window_title); 41 const std::wstring& window_title);
26 42
27 virtual ~ConfirmMessageBoxDialog(); 43 virtual ~ConfirmMessageBoxDialog() {}
28
29 bool accepted() const { return accepted_; }
30 44
31 // views::DialogDelegate implementation. 45 // views::DialogDelegate implementation.
32 virtual int GetDialogButtons() const; 46 virtual int GetDialogButtons() const;
33 virtual std::wstring GetWindowTitle() const; 47 virtual std::wstring GetWindowTitle() const;
34 virtual std::wstring GetDialogButtonLabel( 48 virtual std::wstring GetDialogButtonLabel(
35 MessageBoxFlags::DialogButton button) const; 49 MessageBoxFlags::DialogButton button) const;
36 virtual bool Accept(); 50 virtual bool Accept();
37 virtual bool Cancel(); 51 virtual bool Cancel();
38 52
39 // views::WindowDelegate implementation. 53 // views::WindowDelegate implementation.
40 virtual bool IsModal() const { return true; } 54 virtual bool IsModal() const { return true; }
41 virtual views::View* GetContentsView(); 55 virtual views::View* GetContentsView() { return this; }
42 virtual void DeleteDelegate();
43 56
44 // MessageLoop::Dispatcher implementation. 57 // views::View implementation.
45 virtual bool Dispatch(const MSG& msg); 58 virtual void Layout();
59 virtual gfx::Size GetPreferredSize();
46 60
47 private: 61 private:
48 ConfirmMessageBoxDialog(gfx::NativeWindow parent, 62 ConfirmMessageBoxDialog(ConfirmMessageBoxObserver* observer,
49 const std::wstring& message_text, 63 const std::wstring& message_text,
50 const std::wstring& window_title); 64 const std::wstring& window_title);
51 65
52 // The message which will be shown to user. 66 // The message which will be shown to user.
53 std::wstring message_text_; 67 views::Label* message_label_;
54 68
55 // This is the Title bar text. 69 // This is the Title bar text.
56 std::wstring window_title_; 70 std::wstring window_title_;
57 71
58 MessageBoxView* message_box_view_; 72 // The observer to notify of acceptance or cancellation.
59 73 ConfirmMessageBoxObserver* observer_;
60 // Returns true if the user clicks in Yes button, otherwise false
61 bool accepted_;
62
63 // Used to keep track of whether or not to block the message loop (still
64 // waiting for the user to dismiss the dialog).
65 bool is_blocking_;
66 74
67 DISALLOW_COPY_AND_ASSIGN(ConfirmMessageBoxDialog); 75 DISALLOW_COPY_AND_ASSIGN(ConfirmMessageBoxDialog);
68 }; 76 };
69 77
70 #endif // CHROME_BROWSER_VIEWS_CONFIRM_MESSAGE_BOX_DIALOG_H_ 78 #endif // CHROME_BROWSER_VIEWS_CONFIRM_MESSAGE_BOX_DIALOG_H_
OLDNEW
« 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