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

Side by Side Diff: chrome/browser/ui/views/simple_message_box_views.cc

Issue 10536075: Use proper anchor window in SimpleMessageBoxViews (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/simple_message_box.h" 5 #include "chrome/browser/ui/simple_message_box.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 16 matching lines...) Expand all
27 27
28 class SimpleMessageBoxViews : public views::DialogDelegate, 28 class SimpleMessageBoxViews : public views::DialogDelegate,
29 public MessageLoop::Dispatcher { 29 public MessageLoop::Dispatcher {
30 public: 30 public:
31 SimpleMessageBoxViews(const string16& title, 31 SimpleMessageBoxViews(const string16& title,
32 const string16& message, 32 const string16& message,
33 MessageBoxType type); 33 MessageBoxType type);
34 34
35 MessageBoxResult result() const { return result_; } 35 MessageBoxResult result() const { return result_; }
36 36
37 private:
38 virtual ~SimpleMessageBoxViews(); 37 virtual ~SimpleMessageBoxViews();
39 38
40 // Overridden from views::DialogDelegate: 39 // Overridden from views::DialogDelegate:
41 virtual int GetDialogButtons() const OVERRIDE; 40 virtual int GetDialogButtons() const OVERRIDE;
42 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; 41 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE;
43 virtual bool Cancel() OVERRIDE; 42 virtual bool Cancel() OVERRIDE;
44 virtual bool Accept() OVERRIDE; 43 virtual bool Accept() OVERRIDE;
45 44
46 // Overridden from views::WidgetDelegate: 45 // Overridden from views::WidgetDelegate:
47 virtual string16 GetWindowTitle() const OVERRIDE; 46 virtual string16 GetWindowTitle() const OVERRIDE;
48 virtual void DeleteDelegate() OVERRIDE; 47 virtual void DeleteDelegate() OVERRIDE;
49 virtual ui::ModalType GetModalType() const OVERRIDE; 48 virtual ui::ModalType GetModalType() const OVERRIDE;
50 virtual views::View* GetContentsView() OVERRIDE; 49 virtual views::View* GetContentsView() OVERRIDE;
51 virtual views::Widget* GetWidget() OVERRIDE; 50 virtual views::Widget* GetWidget() OVERRIDE;
52 virtual const views::Widget* GetWidget() const OVERRIDE; 51 virtual const views::Widget* GetWidget() const OVERRIDE;
53 52
54 // Overridden from MessageLoop::Dispatcher: 53 // Overridden from MessageLoop::Dispatcher:
55 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; 54 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
56 55
56 private:
57 const string16 window_title_; 57 const string16 window_title_;
58 const MessageBoxType type_; 58 const MessageBoxType type_;
59 MessageBoxResult result_; 59 MessageBoxResult result_;
60 views::MessageBoxView* message_box_view_; 60 views::MessageBoxView* message_box_view_;
61 61
62 // Set to false as soon as the user clicks a dialog button; this tells the 62 // Set to false as soon as the user clicks a dialog button; this tells the
63 // dispatcher we're done. 63 // dispatcher we're done.
64 bool should_show_dialog_; 64 bool should_show_dialog_;
65 65
66 DISALLOW_COPY_AND_ASSIGN(SimpleMessageBoxViews); 66 DISALLOW_COPY_AND_ASSIGN(SimpleMessageBoxViews);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 MessageBoxResult ShowMessageBox(gfx::NativeWindow parent, 153 MessageBoxResult ShowMessageBox(gfx::NativeWindow parent,
154 const string16& title, 154 const string16& title,
155 const string16& message, 155 const string16& message,
156 MessageBoxType type) { 156 MessageBoxType type) {
157 SimpleMessageBoxViews* dialog = 157 SimpleMessageBoxViews* dialog =
158 new SimpleMessageBoxViews(title, message, type); 158 new SimpleMessageBoxViews(title, message, type);
159 159
160 views::Widget::CreateWindowWithParent(dialog, parent)->Show(); 160 views::Widget::CreateWindowWithParent(dialog, parent)->Show();
161 161
162 #if defined(USE_AURA) 162 #if defined(USE_AURA)
163 aura::client::GetDispatcherClient(parent->GetRootWindow())->RunWithDispatcher( 163 // Use the widget's window itself so that the message loop
164 dialog, parent, true); 164 // exists when the dialog is closed by some other means than
165 // |Cancel| or |Accept|.
166 aura::Window* anchor = parent ?
167 parent : dialog->GetWidget()->GetNativeWindow();
168 aura::client::GetDispatcherClient(anchor->GetRootWindow())->
169 RunWithDispatcher(dialog, anchor, true);
165 #else 170 #else
166 { 171 {
167 MessageLoop::ScopedNestableTaskAllower allow(MessageLoopForUI::current()); 172 MessageLoop::ScopedNestableTaskAllower allow(MessageLoopForUI::current());
168 MessageLoopForUI::current()->RunWithDispatcher(dialog); 173 MessageLoopForUI::current()->RunWithDispatcher(dialog);
169 } 174 }
170 #endif 175 #endif
171
172 return dialog->result(); 176 return dialog->result();
173 } 177 }
174 178
175 } // namespace browser 179 } // namespace browser
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698