OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/views/simple_message_box_views.h" | 5 #include "chrome/browser/ui/views/simple_message_box_views.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/simple_message_box.h" | 9 #include "chrome/browser/simple_message_box.h" |
10 #include "chrome/browser/ui/views/window.h" | 10 #include "chrome/browser/ui/views/window.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 | 34 |
35 } // namespace browser | 35 } // namespace browser |
36 | 36 |
37 //////////////////////////////////////////////////////////////////////////////// | 37 //////////////////////////////////////////////////////////////////////////////// |
38 // SimpleMessageBoxViews, public: | 38 // SimpleMessageBoxViews, public: |
39 | 39 |
40 // static | 40 // static |
41 void SimpleMessageBoxViews::ShowErrorBox(gfx::NativeWindow parent_window, | 41 void SimpleMessageBoxViews::ShowErrorBox(gfx::NativeWindow parent_window, |
42 const string16& title, | 42 const string16& title, |
43 const string16& message) { | 43 const string16& message) { |
44 int dialog_flags = ui::MessageBoxFlags::kFlagHasMessage | | 44 int dialog_flags = ui::MESSAGE_BOX_HAS_MESSAGE | |
tfarina
2011/11/12 12:40:22
this should be ui::MessageBoxFlags::kIsJavascriptA
| |
45 ui::MessageBoxFlags::kFlagHasOKButton; | 45 ui::MESSAGE_BOX_HAS_OK_BUTTON; |
46 | 46 |
47 // This is a reference counted object so it is given an initial increment | 47 // This is a reference counted object so it is given an initial increment |
48 // in the constructor with a corresponding decrement in DeleteDelegate(). | 48 // in the constructor with a corresponding decrement in DeleteDelegate(). |
49 new SimpleMessageBoxViews(parent_window, dialog_flags, title, message); | 49 new SimpleMessageBoxViews(parent_window, dialog_flags, title, message); |
50 } | 50 } |
51 | 51 |
52 bool SimpleMessageBoxViews::ShowYesNoBox(gfx::NativeWindow parent_window, | 52 bool SimpleMessageBoxViews::ShowYesNoBox(gfx::NativeWindow parent_window, |
53 const string16& title, | 53 const string16& title, |
54 const string16& message) { | 54 const string16& message) { |
55 int dialog_flags = ui::MessageBoxFlags::kIsConfirmMessageBox; | 55 int dialog_flags = ui::MESSAGE_BOX_IS_CONFIRM_DIALOG; |
56 | 56 |
57 // This is a reference counted object so it is given an initial increment | 57 // This is a reference counted object so it is given an initial increment |
58 // in the constructor plus an extra one below to ensure the dialog persists | 58 // in the constructor plus an extra one below to ensure the dialog persists |
59 // until we retrieve the user response.. | 59 // until we retrieve the user response.. |
60 scoped_refptr<SimpleMessageBoxViews> dialog = | 60 scoped_refptr<SimpleMessageBoxViews> dialog = |
61 new SimpleMessageBoxViews(parent_window, dialog_flags, title, message); | 61 new SimpleMessageBoxViews(parent_window, dialog_flags, title, message); |
62 | 62 |
63 // Make sure Chrome doesn't attempt to shut down with the dialog up. | 63 // Make sure Chrome doesn't attempt to shut down with the dialog up. |
64 g_browser_process->AddRefModule(); | 64 g_browser_process->AddRefModule(); |
65 | 65 |
(...skipping 13 matching lines...) Expand all Loading... | |
79 } | 79 } |
80 | 80 |
81 bool SimpleMessageBoxViews::Accept() { | 81 bool SimpleMessageBoxViews::Accept() { |
82 disposition_ = DISPOSITION_OK; | 82 disposition_ = DISPOSITION_OK; |
83 return true; | 83 return true; |
84 } | 84 } |
85 | 85 |
86 int SimpleMessageBoxViews::GetDialogButtons() const { | 86 int SimpleMessageBoxViews::GetDialogButtons() const { |
87 // NOTE: It seems unsafe to assume that the flags for OK/cancel will always | 87 // NOTE: It seems unsafe to assume that the flags for OK/cancel will always |
88 // have the same value as the button ids. | 88 // have the same value as the button ids. |
89 return (dialog_flags_ & ui::MessageBoxFlags::kFlagHasOKButton | 89 return (dialog_flags_ & ui::MESSAGE_BOX_HAS_OK_BUTTON |
90 ? ui::DIALOG_BUTTON_OK : 0) | | 90 ? ui::DIALOG_BUTTON_OK : 0) | |
91 (dialog_flags_ & ui::MessageBoxFlags::kFlagHasCancelButton | 91 (dialog_flags_ & ui::MESSAGE_BOX_HAS_CANCEL_BUTTON |
92 ? ui::DIALOG_BUTTON_CANCEL : 0); | 92 ? ui::DIALOG_BUTTON_CANCEL : 0); |
93 } | 93 } |
94 | 94 |
95 string16 SimpleMessageBoxViews::GetDialogButtonLabel( | 95 string16 SimpleMessageBoxViews::GetDialogButtonLabel( |
96 ui::DialogButton button) const { | 96 ui::DialogButton button) const { |
97 return button == ui::DIALOG_BUTTON_OK ? l10n_util::GetStringUTF16(IDS_OK) | 97 return button == ui::DIALOG_BUTTON_OK ? l10n_util::GetStringUTF16(IDS_OK) |
98 : l10n_util::GetStringUTF16(IDS_CLOSE); | 98 : l10n_util::GetStringUTF16(IDS_CLOSE); |
99 } | 99 } |
100 | 100 |
101 bool SimpleMessageBoxViews::ShouldShowWindowTitle() const { | 101 bool SimpleMessageBoxViews::ShouldShowWindowTitle() const { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 if (disposition_ == DISPOSITION_UNKNOWN) | 163 if (disposition_ == DISPOSITION_UNKNOWN) |
164 return base::MessagePumpDispatcher::EVENT_PROCESSED; | 164 return base::MessagePumpDispatcher::EVENT_PROCESSED; |
165 return base::MessagePumpDispatcher::EVENT_QUIT; | 165 return base::MessagePumpDispatcher::EVENT_QUIT; |
166 } | 166 } |
167 #else | 167 #else |
168 bool SimpleMessageBoxViews::Dispatch(GdkEvent* event) { | 168 bool SimpleMessageBoxViews::Dispatch(GdkEvent* event) { |
169 gtk_main_do_event(event); | 169 gtk_main_do_event(event); |
170 return disposition_ == DISPOSITION_UNKNOWN; | 170 return disposition_ == DISPOSITION_UNKNOWN; |
171 } | 171 } |
172 #endif | 172 #endif |
OLD | NEW |