| OLD | NEW | 
| (Empty) |  | 
 |   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 | 
 |   3 // found in the LICENSE file. | 
 |   4  | 
 |   5 #include "chrome/browser/views/update_recommended_message_box.h" | 
 |   6  | 
 |   7 #include "app/l10n_util.h" | 
 |   8 #include "app/message_box_flags.h" | 
 |   9 #include "chrome/browser/browser_list.h" | 
 |  10 #include "chrome/browser/browser_process.h" | 
 |  11 #include "chrome/browser/pref_service.h" | 
 |  12 #include "chrome/common/pref_names.h" | 
 |  13 #include "grit/chromium_strings.h" | 
 |  14 #include "grit/generated_resources.h" | 
 |  15 #include "views/controls/message_box_view.h" | 
 |  16 #include "views/window/window.h" | 
 |  17  | 
 |  18 //////////////////////////////////////////////////////////////////////////////// | 
 |  19 // UpdateRecommendedMessageBox, public: | 
 |  20  | 
 |  21 // static | 
 |  22 void UpdateRecommendedMessageBox::ShowMessageBox( | 
 |  23     gfx::NativeWindow parent_window) { | 
 |  24   // When the window closes, it will delete itself. | 
 |  25   new UpdateRecommendedMessageBox(parent_window); | 
 |  26 } | 
 |  27  | 
 |  28 void UpdateRecommendedMessageBox::RegisterUpdateRecommendedPrefs( | 
 |  29     PrefService* prefs) { | 
 |  30   prefs->RegisterBooleanPref(prefs::kRestartLastSessionOnShutdown, false); | 
 |  31 } | 
 |  32  | 
 |  33 bool UpdateRecommendedMessageBox::Accept() { | 
 |  34   // Set the flag to restore the last session on shutdown. | 
 |  35   PrefService* pref_service = g_browser_process->local_state(); | 
 |  36   pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true); | 
 |  37  | 
 |  38   BrowserList::CloseAllBrowsersAndExit(); | 
 |  39  | 
 |  40   return true; | 
 |  41 } | 
 |  42  | 
 |  43 int UpdateRecommendedMessageBox::GetDialogButtons() const { | 
 |  44   return MessageBoxFlags::DIALOGBUTTON_OK | | 
 |  45          MessageBoxFlags::DIALOGBUTTON_CANCEL; | 
 |  46 } | 
 |  47  | 
 |  48 std::wstring UpdateRecommendedMessageBox::GetDialogButtonLabel( | 
 |  49     MessageBoxFlags::DialogButton button) const { | 
 |  50   DCHECK(button == MessageBoxFlags::DIALOGBUTTON_OK || | 
 |  51          button == MessageBoxFlags::DIALOGBUTTON_CANCEL); | 
 |  52   return button == MessageBoxFlags::DIALOGBUTTON_OK ? | 
 |  53       l10n_util::GetString(IDS_RESTART_AND_UPDATE) : | 
 |  54       l10n_util::GetString(IDS_NOT_NOW); | 
 |  55 } | 
 |  56  | 
 |  57 std::wstring UpdateRecommendedMessageBox::GetWindowTitle() const { | 
 |  58   return l10n_util::GetString(IDS_PRODUCT_NAME); | 
 |  59 } | 
 |  60  | 
 |  61 void UpdateRecommendedMessageBox::DeleteDelegate() { | 
 |  62   delete this; | 
 |  63 } | 
 |  64  | 
 |  65 bool UpdateRecommendedMessageBox::IsModal() const { | 
 |  66   return true; | 
 |  67 } | 
 |  68  | 
 |  69 views::View* UpdateRecommendedMessageBox::GetContentsView() { | 
 |  70   return message_box_view_; | 
 |  71 } | 
 |  72  | 
 |  73 //////////////////////////////////////////////////////////////////////////////// | 
 |  74 // UpdateRecommendedMessageBox, private: | 
 |  75  | 
 |  76 UpdateRecommendedMessageBox::UpdateRecommendedMessageBox( | 
 |  77     gfx::NativeWindow parent_window) { | 
 |  78   const int kDialogWidth = 400; | 
 |  79   // Also deleted when the window closes. | 
 |  80   message_box_view_ = new MessageBoxView( | 
 |  81       MessageBoxFlags::kFlagHasMessage | MessageBoxFlags::kFlagHasOKButton, | 
 |  82       l10n_util::GetStringF(IDS_UPDATE_RECOMMENDED, | 
 |  83                             l10n_util::GetString(IDS_PRODUCT_NAME)), | 
 |  84       std::wstring(), | 
 |  85       kDialogWidth); | 
 |  86   views::Window::CreateChromeWindow(parent_window, gfx::Rect(), this)->Show(); | 
 |  87 } | 
 |  88  | 
 |  89 UpdateRecommendedMessageBox::~UpdateRecommendedMessageBox() { | 
 |  90 } | 
| OLD | NEW |