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

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

Issue 10084023: views: Create update recommended dialog inside the Show() function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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
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/views/update_recommended_message_box.h" 5 #include "chrome/browser/ui/views/update_recommended_message_box.h"
6 6
7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/ui/browser_list.h" 7 #include "chrome/browser/ui/browser_list.h"
10 #include "chrome/browser/ui/dialog_style.h"
11 #include "chrome/browser/ui/views/window.h"
12 #include "grit/chromium_strings.h" 8 #include "grit/chromium_strings.h"
13 #include "grit/generated_resources.h" 9 #include "grit/generated_resources.h"
14 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/views/controls/message_box_view.h" 11 #include "ui/views/controls/message_box_view.h"
16 #include "ui/views/widget/widget.h" 12 #include "ui/views/widget/widget.h"
17 13
18 #if defined(OS_CHROMEOS) 14 #if defined(OS_CHROMEOS)
19 #include "chrome/browser/chromeos/cros/cros_library.h"
20 #include "chromeos/dbus/dbus_thread_manager.h" 15 #include "chromeos/dbus/dbus_thread_manager.h"
21 #include "chromeos/dbus/power_manager_client.h" 16 #include "chromeos/dbus/power_manager_client.h"
22 #endif 17 #endif
23 18
19 namespace {
20
21 #if defined(OS_CHROMEOS)
Peter Kasting 2012/04/13 21:45:37 Nit: I think defining these in the function body (
22 const int kProductNameID = IDS_PRODUCT_OS_NAME;
23 #else
24 const int kProductNameID = IDS_PRODUCT_NAME;
25 #endif
26
27 const int kDialogWidth = 400;
28
29 } // namespace
30
24 //////////////////////////////////////////////////////////////////////////////// 31 ////////////////////////////////////////////////////////////////////////////////
25 // UpdateRecommendedMessageBox, public: 32 // UpdateRecommendedMessageBox, public:
26 33
27 // static 34 // static
28 void UpdateRecommendedMessageBox::ShowMessageBox( 35 void UpdateRecommendedMessageBox::Show(gfx::NativeWindow parent_window) {
29 gfx::NativeWindow parent_window) {
30 // When the window closes, it will delete itself. 36 // When the window closes, it will delete itself.
31 new UpdateRecommendedMessageBox(parent_window); 37 UpdateRecommendedMessageBox* window = new UpdateRecommendedMessageBox;
Peter Kasting 2012/04/13 21:45:37 Nit: Can inline into the next line. I also sugges
38 views::Widget::CreateWindowWithParent(window, parent_window)->Show();
39 }
40
41 ////////////////////////////////////////////////////////////////////////////////
42 // UpdateRecommendedMessageBox, private:
43
44 UpdateRecommendedMessageBox::UpdateRecommendedMessageBox() {
45 const string16 product_name = l10n_util::GetStringUTF16(kProductNameID);
46 // Also deleted when the window closes.
47 message_box_view_ = new views::MessageBoxView(
48 views::MessageBoxView::NO_OPTIONS,
49 l10n_util::GetStringFUTF16(IDS_UPDATE_RECOMMENDED, product_name),
50 string16(),
51 kDialogWidth);
52 }
53
54 UpdateRecommendedMessageBox::~UpdateRecommendedMessageBox() {
32 } 55 }
33 56
34 bool UpdateRecommendedMessageBox::Accept() { 57 bool UpdateRecommendedMessageBox::Accept() {
35 #if defined(OS_CHROMEOS) 58 #if defined(OS_CHROMEOS)
36 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); 59 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart();
37 // If running the Chrome OS build, but we're not on the device, fall through 60 // If running the Chrome OS build, but we're not on the device, fall through
38 #endif 61 #endif
39 BrowserList::AttemptRestart(); 62 BrowserList::AttemptRestart();
40 return true; 63 return true;
41 } 64 }
(...skipping 28 matching lines...) Expand all
70 return message_box_view_; 93 return message_box_view_;
71 } 94 }
72 95
73 views::Widget* UpdateRecommendedMessageBox::GetWidget() { 96 views::Widget* UpdateRecommendedMessageBox::GetWidget() {
74 return message_box_view_->GetWidget(); 97 return message_box_view_->GetWidget();
75 } 98 }
76 99
77 const views::Widget* UpdateRecommendedMessageBox::GetWidget() const { 100 const views::Widget* UpdateRecommendedMessageBox::GetWidget() const {
78 return message_box_view_->GetWidget(); 101 return message_box_view_->GetWidget();
79 } 102 }
80
81 ////////////////////////////////////////////////////////////////////////////////
82 // UpdateRecommendedMessageBox, private:
83
84 UpdateRecommendedMessageBox::UpdateRecommendedMessageBox(
85 gfx::NativeWindow parent_window) {
86 const int kDialogWidth = 400;
87 #if defined(OS_CHROMEOS)
88 const int kProductNameId = IDS_PRODUCT_OS_NAME;
89 #else
90 const int kProductNameId = IDS_PRODUCT_NAME;
91 #endif
92 const string16 product_name = l10n_util::GetStringUTF16(kProductNameId);
93 // Also deleted when the window closes.
94 message_box_view_ = new views::MessageBoxView(
95 views::MessageBoxView::NO_OPTIONS,
96 l10n_util::GetStringFUTF16(IDS_UPDATE_RECOMMENDED, product_name),
97 string16(),
98 kDialogWidth);
99 views::Widget::CreateWindowWithParent(this, parent_window)->Show();
100 }
101
102 UpdateRecommendedMessageBox::~UpdateRecommendedMessageBox() {
103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698