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

Side by Side Diff: remoting/host/chromeos/message_box.h

Issue 690183002: Remote assistance on Chrome OS Part V - It2MeHost Continue Window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Dan's feedbacks Created 6 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef REMOTING_HOST_CHROMEOS_MESSAGE_BOX_H_
6 #define REMOTING_HOST_CHROMEOS_MESSAGE_BOX_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "ui/views/window/dialog_delegate.h"
10
11 namespace remoting {
12
13 // Overview:
14 // Shows a system modal message box with ok and cancel buttons. This class
Wez 2014/10/31 21:22:24 s/ok/OK
kelvinp 2014/11/01 00:42:00 Done.
15 // is not thread-safe, it must be called on the UI thread of the browser
16 // process.
Wez 2014/10/31 21:22:24 If it's not thread-safe, why is it not base::NonTh
kelvinp 2014/11/01 00:42:00 ThreadChecker is added. According to the comments
17 //
18 // Implementation details:
19 // The MessageBox creates the dialog using the views::DialogWidget. The
20 // DialogWidget is created by the caller but its lifetime is managed by the
21 // NativeWidget. The DialogWidget communicates with the MessageBox using the
22 // DialogDelegateView interface. DialogDelegateView must remain valid until
23 // DeleteDelegate() is called, at which the DialogDelegateView deletes itself.
24 // To abstract this awkward ownership model, the MessageBox object is
25 // RefCounted. It calls AddRef() on itself when the widget is created and calls
26 // Release() when DeleteDelegate() is called.
27 class MessageBox : public views::DialogDelegateView,
28 public base::RefCounted<MessageBox> {
Wez 2014/10/31 21:22:24 Ugh... you really don't need to ref-count here. Ju
kelvinp 2014/11/01 00:42:00 Done.
29 public:
30 enum Result {
31 OK,
32 CANCEL
33 };
34
35 // ResultCallback will be invoked with Result::Cancel if the user closes the
36 // MessageBox without clicking on any buttons.
37 typedef base::Callback<void(Result)> ResultCallback;
38
39 MessageBox(const base::string16& message_label,
40 const base::string16& ok_label,
41 const base::string16& cancel_label,
42 ResultCallback result_callback);
43
44 // Shows the message box.
45 void Show();
46 // Hides the message box.
47 void Hide();
Wez 2014/10/31 21:22:24 These methods comments add nothing.
kelvinp 2014/11/01 00:42:00 Done.
48
49 // views::DialogDelegateView interface.
50 bool Accept() override;
51 bool Cancel() override;
52 ui::ModalType GetModalType() const override;
53 base::string16 GetWindowTitle() const override;
54 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
55 void DeleteDelegate() override;
56
57 private:
58 friend class base::RefCounted<MessageBox>;
59 ~MessageBox() override;
Wez 2014/10/31 21:22:24 Why are you overriding the destructor, only to do
kelvinp 2014/11/01 00:42:00 Done.
60
61 const base::string16 message_label_;
62 const base::string16 ok_label_;
63 const base::string16 cancel_label_;
64 ResultCallback result_callback_;
65
66 DISALLOW_COPY_AND_ASSIGN(MessageBox);
67 };
68
69 } // namespace remoting
70
71 #endif // REMOTING_HOST_CHROMEOS_MESSAGE_BOX_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/host/chromeos/message_box.cc » ('j') | remoting/host/chromeos/message_box.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698