Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / views / update_recommended_message_box.cc
blob8acd6f0a826a3708b9b2714738c7863b673342d4
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/update_recommended_message_box.h"
7 #include "chrome/browser/lifetime/application_lifetime.h"
8 #include "chrome/grit/chromium_strings.h"
9 #include "chrome/grit/generated_resources.h"
10 #include "components/constrained_window/constrained_window_views.h"
11 #include "ui/base/l10n/l10n_util.h"
12 #include "ui/views/controls/message_box_view.h"
13 #include "ui/views/widget/widget.h"
15 #if defined(OS_CHROMEOS)
16 #include "chromeos/dbus/dbus_thread_manager.h"
17 #include "chromeos/dbus/power_manager_client.h"
18 #endif
20 ////////////////////////////////////////////////////////////////////////////////
21 // UpdateRecommendedMessageBox, public:
23 // static
24 void UpdateRecommendedMessageBox::Show(gfx::NativeWindow parent_window) {
25 // When the window closes, it will delete itself.
26 constrained_window::CreateBrowserModalDialogViews(
27 new UpdateRecommendedMessageBox(), parent_window)->Show();
30 ////////////////////////////////////////////////////////////////////////////////
31 // UpdateRecommendedMessageBox, private:
33 UpdateRecommendedMessageBox::UpdateRecommendedMessageBox() {
34 const int kDialogWidth = 400;
35 #if defined(OS_CHROMEOS)
36 const int kProductNameID = IDS_SHORT_PRODUCT_OS_NAME;
37 #else
38 const int kProductNameID = IDS_PRODUCT_NAME;
39 #endif
40 const base::string16 product_name = l10n_util::GetStringUTF16(kProductNameID);
41 views::MessageBoxView::InitParams params(
42 l10n_util::GetStringFUTF16(IDS_UPDATE_RECOMMENDED, product_name));
43 params.message_width = kDialogWidth;
44 // Also deleted when the window closes.
45 message_box_view_ = new views::MessageBoxView(params);
48 UpdateRecommendedMessageBox::~UpdateRecommendedMessageBox() {
51 bool UpdateRecommendedMessageBox::Accept() {
52 #if defined(OS_CHROMEOS)
53 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart();
54 // If running the Chrome OS build, but we're not on the device, fall through
55 #endif
56 chrome::AttemptRestart();
57 return true;
60 base::string16 UpdateRecommendedMessageBox::GetDialogButtonLabel(
61 ui::DialogButton button) const {
62 return l10n_util::GetStringUTF16((button == ui::DIALOG_BUTTON_OK) ?
63 IDS_RELAUNCH_AND_UPDATE : IDS_NOT_NOW);
66 bool UpdateRecommendedMessageBox::ShouldShowWindowTitle() const {
67 #if defined(OS_CHROMEOS)
68 return false;
69 #else
70 return true;
71 #endif
74 base::string16 UpdateRecommendedMessageBox::GetWindowTitle() const {
75 return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
78 void UpdateRecommendedMessageBox::DeleteDelegate() {
79 delete this;
82 ui::ModalType UpdateRecommendedMessageBox::GetModalType() const {
83 return ui::MODAL_TYPE_WINDOW;
86 views::View* UpdateRecommendedMessageBox::GetContentsView() {
87 return message_box_view_;
90 views::Widget* UpdateRecommendedMessageBox::GetWidget() {
91 return message_box_view_->GetWidget();
94 const views::Widget* UpdateRecommendedMessageBox::GetWidget() const {
95 return message_box_view_->GetWidget();