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