| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/update_recommended_message_box.h" | 5 #include "chrome/browser/views/update_recommended_message_box.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/message_box_flags.h" | 8 #include "app/message_box_flags.h" |
| 9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
| 12 #include "chrome/browser/views/window.h" |
| 12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 13 #include "grit/chromium_strings.h" | 14 #include "grit/chromium_strings.h" |
| 14 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 15 #include "views/controls/message_box_view.h" | 16 #include "views/controls/message_box_view.h" |
| 16 #include "views/window/window.h" | 17 #include "views/window/window.h" |
| 17 | 18 |
| 19 #if defined(OS_CHROMEOS) |
| 20 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 21 #include "chrome/browser/chromeos/cros/power_library.h" |
| 22 #endif |
| 23 |
| 18 //////////////////////////////////////////////////////////////////////////////// | 24 //////////////////////////////////////////////////////////////////////////////// |
| 19 // UpdateRecommendedMessageBox, public: | 25 // UpdateRecommendedMessageBox, public: |
| 20 | 26 |
| 21 // static | 27 // static |
| 22 void UpdateRecommendedMessageBox::ShowMessageBox( | 28 void UpdateRecommendedMessageBox::ShowMessageBox( |
| 23 gfx::NativeWindow parent_window) { | 29 gfx::NativeWindow parent_window) { |
| 24 // When the window closes, it will delete itself. | 30 // When the window closes, it will delete itself. |
| 25 new UpdateRecommendedMessageBox(parent_window); | 31 new UpdateRecommendedMessageBox(parent_window); |
| 26 } | 32 } |
| 27 | 33 |
| 28 bool UpdateRecommendedMessageBox::Accept() { | 34 bool UpdateRecommendedMessageBox::Accept() { |
| 29 // Set the flag to restore the last session on shutdown. | 35 // Set the flag to restore the last session on shutdown. |
| 30 PrefService* pref_service = g_browser_process->local_state(); | 36 PrefService* pref_service = g_browser_process->local_state(); |
| 31 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); | 37 pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); |
| 32 | 38 |
| 39 #if defined(OS_CHROMEOS) |
| 40 chromeos::CrosLibrary::Get()->GetPowerLibrary()->RequestRestart(); |
| 41 // If running the Chrome OS build, but we're not on the device, fall through |
| 42 #endif |
| 33 BrowserList::CloseAllBrowsersAndExit(); | 43 BrowserList::CloseAllBrowsersAndExit(); |
| 34 | 44 |
| 35 return true; | 45 return true; |
| 36 } | 46 } |
| 37 | 47 |
| 38 int UpdateRecommendedMessageBox::GetDialogButtons() const { | 48 int UpdateRecommendedMessageBox::GetDialogButtons() const { |
| 39 return MessageBoxFlags::DIALOGBUTTON_OK | | 49 return MessageBoxFlags::DIALOGBUTTON_OK | |
| 40 MessageBoxFlags::DIALOGBUTTON_CANCEL; | 50 MessageBoxFlags::DIALOGBUTTON_CANCEL; |
| 41 } | 51 } |
| 42 | 52 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 64 views::View* UpdateRecommendedMessageBox::GetContentsView() { | 74 views::View* UpdateRecommendedMessageBox::GetContentsView() { |
| 65 return message_box_view_; | 75 return message_box_view_; |
| 66 } | 76 } |
| 67 | 77 |
| 68 //////////////////////////////////////////////////////////////////////////////// | 78 //////////////////////////////////////////////////////////////////////////////// |
| 69 // UpdateRecommendedMessageBox, private: | 79 // UpdateRecommendedMessageBox, private: |
| 70 | 80 |
| 71 UpdateRecommendedMessageBox::UpdateRecommendedMessageBox( | 81 UpdateRecommendedMessageBox::UpdateRecommendedMessageBox( |
| 72 gfx::NativeWindow parent_window) { | 82 gfx::NativeWindow parent_window) { |
| 73 const int kDialogWidth = 400; | 83 const int kDialogWidth = 400; |
| 84 #if defined(OS_CHROMEOS) |
| 85 const std::wstring product_name = l10n_util::GetString(IDS_PRODUCT_OS_NAME); |
| 86 #else |
| 87 const std::wstring product_name = l10n_util::GetString(IDS_PRODUCT_NAME); |
| 88 #endif |
| 74 // Also deleted when the window closes. | 89 // Also deleted when the window closes. |
| 75 message_box_view_ = new MessageBoxView( | 90 message_box_view_ = new MessageBoxView( |
| 76 MessageBoxFlags::kFlagHasMessage | MessageBoxFlags::kFlagHasOKButton, | 91 MessageBoxFlags::kFlagHasMessage | MessageBoxFlags::kFlagHasOKButton, |
| 77 l10n_util::GetStringF(IDS_UPDATE_RECOMMENDED, | 92 l10n_util::GetStringF(IDS_UPDATE_RECOMMENDED, product_name), |
| 78 l10n_util::GetString(IDS_PRODUCT_NAME)), | |
| 79 std::wstring(), | 93 std::wstring(), |
| 80 kDialogWidth); | 94 kDialogWidth); |
| 81 views::Window::CreateChromeWindow(parent_window, gfx::Rect(), this)->Show(); | 95 browser::CreateViewsWindow(parent_window, gfx::Rect(), this)->Show(); |
| 82 } | 96 } |
| 83 | 97 |
| 84 UpdateRecommendedMessageBox::~UpdateRecommendedMessageBox() { | 98 UpdateRecommendedMessageBox::~UpdateRecommendedMessageBox() { |
| 85 } | 99 } |
| OLD | NEW |