| 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/restart_message_box.h" | 5 #include "chrome/browser/ui/views/restart_message_box.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/message_box_flags.h" | |
| 9 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 10 #include "grit/chromium_strings.h" | 9 #include "grit/chromium_strings.h" |
| 11 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| 11 #include "ui/base/message_box_flags.h" |
| 12 #include "views/controls/message_box_view.h" | 12 #include "views/controls/message_box_view.h" |
| 13 #include "views/window/window.h" | 13 #include "views/window/window.h" |
| 14 | 14 |
| 15 //////////////////////////////////////////////////////////////////////////////// | 15 //////////////////////////////////////////////////////////////////////////////// |
| 16 // RestartMessageBox, public: | 16 // RestartMessageBox, public: |
| 17 | 17 |
| 18 // static | 18 // static |
| 19 void RestartMessageBox::ShowMessageBox(gfx::NativeWindow parent_window) { | 19 void RestartMessageBox::ShowMessageBox(gfx::NativeWindow parent_window) { |
| 20 // When the window closes, it will delete itself. | 20 // When the window closes, it will delete itself. |
| 21 new RestartMessageBox(parent_window); | 21 new RestartMessageBox(parent_window); |
| 22 } | 22 } |
| 23 | 23 |
| 24 int RestartMessageBox::GetDialogButtons() const { | 24 int RestartMessageBox::GetDialogButtons() const { |
| 25 return MessageBoxFlags::DIALOGBUTTON_OK; | 25 return ui::MessageBoxFlags::DIALOGBUTTON_OK; |
| 26 } | 26 } |
| 27 | 27 |
| 28 std::wstring RestartMessageBox::GetDialogButtonLabel( | 28 std::wstring RestartMessageBox::GetDialogButtonLabel( |
| 29 MessageBoxFlags::DialogButton button) const { | 29 ui::MessageBoxFlags::DialogButton button) const { |
| 30 DCHECK(button == MessageBoxFlags::DIALOGBUTTON_OK); | 30 DCHECK(button == ui::MessageBoxFlags::DIALOGBUTTON_OK); |
| 31 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_OK)); | 31 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_OK)); |
| 32 } | 32 } |
| 33 | 33 |
| 34 std::wstring RestartMessageBox::GetWindowTitle() const { | 34 std::wstring RestartMessageBox::GetWindowTitle() const { |
| 35 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 35 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void RestartMessageBox::DeleteDelegate() { | 38 void RestartMessageBox::DeleteDelegate() { |
| 39 delete this; | 39 delete this; |
| 40 } | 40 } |
| 41 | 41 |
| 42 bool RestartMessageBox::IsModal() const { | 42 bool RestartMessageBox::IsModal() const { |
| 43 return true; | 43 return true; |
| 44 } | 44 } |
| 45 | 45 |
| 46 views::View* RestartMessageBox::GetContentsView() { | 46 views::View* RestartMessageBox::GetContentsView() { |
| 47 return message_box_view_; | 47 return message_box_view_; |
| 48 } | 48 } |
| 49 | 49 |
| 50 //////////////////////////////////////////////////////////////////////////////// | 50 //////////////////////////////////////////////////////////////////////////////// |
| 51 // RestartMessageBox, private: | 51 // RestartMessageBox, private: |
| 52 | 52 |
| 53 RestartMessageBox::RestartMessageBox(gfx::NativeWindow parent_window) { | 53 RestartMessageBox::RestartMessageBox(gfx::NativeWindow parent_window) { |
| 54 const int kDialogWidth = 400; | 54 const int kDialogWidth = 400; |
| 55 // Also deleted when the window closes. | 55 // Also deleted when the window closes. |
| 56 message_box_view_ = new MessageBoxView( | 56 message_box_view_ = new MessageBoxView( |
| 57 MessageBoxFlags::kFlagHasMessage | MessageBoxFlags::kFlagHasOKButton, | 57 ui::MessageBoxFlags::kFlagHasMessage | |
| 58 ui::MessageBoxFlags::kFlagHasOKButton, |
| 58 UTF16ToWide( | 59 UTF16ToWide( |
| 59 l10n_util::GetStringUTF16(IDS_OPTIONS_RESTART_REQUIRED)).c_str(), | 60 l10n_util::GetStringUTF16(IDS_OPTIONS_RESTART_REQUIRED)).c_str(), |
| 60 std::wstring(), | 61 std::wstring(), |
| 61 kDialogWidth); | 62 kDialogWidth); |
| 62 views::Window::CreateChromeWindow(parent_window, gfx::Rect(), this)->Show(); | 63 views::Window::CreateChromeWindow(parent_window, gfx::Rect(), this)->Show(); |
| 63 } | 64 } |
| 64 | 65 |
| 65 RestartMessageBox::~RestartMessageBox() { | 66 RestartMessageBox::~RestartMessageBox() { |
| 66 } | 67 } |
| OLD | NEW |