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

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: peter review 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
« no previous file with comments | « chrome/browser/ui/views/update_recommended_message_box.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
24 //////////////////////////////////////////////////////////////////////////////// 19 ////////////////////////////////////////////////////////////////////////////////
25 // UpdateRecommendedMessageBox, public: 20 // UpdateRecommendedMessageBox, public:
26 21
27 // static 22 // static
28 void UpdateRecommendedMessageBox::ShowMessageBox( 23 void UpdateRecommendedMessageBox::Show(gfx::NativeWindow parent_window) {
29 gfx::NativeWindow parent_window) {
30 // When the window closes, it will delete itself. 24 // When the window closes, it will delete itself.
31 new UpdateRecommendedMessageBox(parent_window); 25 views::Widget::CreateWindowWithParent(new UpdateRecommendedMessageBox(),
26 parent_window)->Show();
27 }
28
29 ////////////////////////////////////////////////////////////////////////////////
30 // UpdateRecommendedMessageBox, private:
31
32 UpdateRecommendedMessageBox::UpdateRecommendedMessageBox() {
33 const int kDialogWidth = 400;
34 #if defined(OS_CHROMEOS)
35 const int kProductNameID = IDS_PRODUCT_OS_NAME;
36 #else
37 const int kProductNameID = IDS_PRODUCT_NAME;
38 #endif
39 const string16 product_name = l10n_util::GetStringUTF16(kProductNameID);
40 // Also deleted when the window closes.
41 message_box_view_ = new views::MessageBoxView(
42 views::MessageBoxView::NO_OPTIONS,
43 l10n_util::GetStringFUTF16(IDS_UPDATE_RECOMMENDED, product_name),
44 string16(),
45 kDialogWidth);
46 }
47
48 UpdateRecommendedMessageBox::~UpdateRecommendedMessageBox() {
32 } 49 }
33 50
34 bool UpdateRecommendedMessageBox::Accept() { 51 bool UpdateRecommendedMessageBox::Accept() {
35 #if defined(OS_CHROMEOS) 52 #if defined(OS_CHROMEOS)
36 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); 53 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart();
37 // If running the Chrome OS build, but we're not on the device, fall through 54 // If running the Chrome OS build, but we're not on the device, fall through
38 #endif 55 #endif
39 BrowserList::AttemptRestart(); 56 BrowserList::AttemptRestart();
40 return true; 57 return true;
41 } 58 }
(...skipping 28 matching lines...) Expand all
70 return message_box_view_; 87 return message_box_view_;
71 } 88 }
72 89
73 views::Widget* UpdateRecommendedMessageBox::GetWidget() { 90 views::Widget* UpdateRecommendedMessageBox::GetWidget() {
74 return message_box_view_->GetWidget(); 91 return message_box_view_->GetWidget();
75 } 92 }
76 93
77 const views::Widget* UpdateRecommendedMessageBox::GetWidget() const { 94 const views::Widget* UpdateRecommendedMessageBox::GetWidget() const {
78 return message_box_view_->GetWidget(); 95 return message_box_view_->GetWidget();
79 } 96 }
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
« no previous file with comments | « chrome/browser/ui/views/update_recommended_message_box.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698