Chromium Code Reviews| Index: chrome/browser/chromeos/profiles/multiprofiles_session_aborted_dialog.cc |
| diff --git a/chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.cc b/chrome/browser/chromeos/profiles/multiprofiles_session_aborted_dialog.cc |
| similarity index 52% |
| copy from chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.cc |
| copy to chrome/browser/chromeos/profiles/multiprofiles_session_aborted_dialog.cc |
| index c5b0261d9c03f168b9c7ddca893eca9ca54b0391..ddb6af7657d242408a8c44ffcedcd055e61c4148 100644 |
| --- a/chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.cc |
| +++ b/chrome/browser/chromeos/profiles/multiprofiles_session_aborted_dialog.cc |
| @@ -2,9 +2,11 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.h" |
| +#include "chrome/browser/chromeos/profiles/multiprofiles_session_aborted_dialog.h" |
| #include "ash/shell.h" |
| +#include "base/strings/utf_string_conversions.h" |
| +#include "chrome/browser/lifetime/application_lifetime.h" |
| #include "grit/generated_resources.h" |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/base/resource/resource_bundle.h" |
| @@ -23,21 +25,23 @@ const int kDefaultWidth = 600; |
| const int kDefaultHeight = 250; |
| const int kPaddingToMessage = 20; |
| -const int kPaddingToCheckBox = 50; |
| const int kInset = 40; |
| const int kTopInset = 10; |
| //////////////////////////////////////////////////////////////////////////////// |
| -// Dialog for multi-profiles introduction. |
| -class MultiprofilesIntroView : public views::DialogDelegateView { |
| +// Dialog for an aborted multi-profile session due to a user policy change . |
| +class MultiprofilesSessionAbortedView : public views::DialogDelegateView { |
| public: |
| - explicit MultiprofilesIntroView(const base::Callback<void(bool)> on_accept); |
| - virtual ~MultiprofilesIntroView(); |
| + explicit MultiprofilesSessionAbortedView(); |
| + virtual ~MultiprofilesSessionAbortedView(); |
| - static void ShowDialog(const base::Callback<void(bool)> on_accept); |
| + static void ShowDialog(const std::string& user_email); |
| // views::DialogDelegate overrides. |
| virtual bool Accept() OVERRIDE; |
| + virtual int GetDialogButtons() const OVERRIDE; |
| + virtual base::string16 GetDialogButtonLabel( |
| + ui::DialogButton button) const OVERRIDE; |
| // views::WidgetDelegate overrides. |
| virtual ui::ModalType GetModalType() const OVERRIDE; |
| @@ -46,52 +50,67 @@ class MultiprofilesIntroView : public views::DialogDelegateView { |
| virtual gfx::Size GetPreferredSize() OVERRIDE; |
| private: |
| - void InitDialog(); |
| + void InitDialog(const std::string& user_email); |
| - scoped_ptr<views::Checkbox> no_show_checkbox_; |
| - const base::Callback<void(bool)> on_accept_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(MultiprofilesIntroView); |
| + DISALLOW_COPY_AND_ASSIGN(MultiprofilesSessionAbortedView); |
| }; |
| //////////////////////////////////////////////////////////////////////////////// |
| -// MultiprofilesIntroDialog implementation. |
| +// MultiprofilesSessionAbortedView implementation. |
| -MultiprofilesIntroView::MultiprofilesIntroView( |
| - const base::Callback<void(bool)> on_accept) |
| - : on_accept_(on_accept) { |
| +MultiprofilesSessionAbortedView::MultiprofilesSessionAbortedView() { |
| } |
| -MultiprofilesIntroView::~MultiprofilesIntroView() { |
| +MultiprofilesSessionAbortedView::~MultiprofilesSessionAbortedView() { |
| } |
| // static |
| -void MultiprofilesIntroView::ShowDialog( |
| - const base::Callback<void(bool)> on_accept) { |
| - MultiprofilesIntroView* dialog_view = |
| - new MultiprofilesIntroView(on_accept); |
| +void MultiprofilesSessionAbortedView::ShowDialog( |
| + const std::string& user_email) { |
| + MultiprofilesSessionAbortedView* dialog_view = |
| + new MultiprofilesSessionAbortedView(); |
| views::DialogDelegate::CreateDialogWidget( |
| dialog_view, ash::Shell::GetTargetRootWindow(), NULL); |
| - dialog_view->InitDialog(); |
| + dialog_view->InitDialog(user_email); |
| views::Widget* widget = dialog_view->GetWidget(); |
| DCHECK(widget); |
| widget->Show(); |
| + |
| + // Since this is the last thing the user ever sees, we also hide all system |
| + // tray's from the screen. |
| + aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); |
| + for (aura::Window::Windows::const_iterator iter = root_windows.begin(); |
| + iter != root_windows.end(); ++iter) { |
| + ash::Shell::GetInstance()->SetShelfAutoHideBehavior( |
| + ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN, *iter); |
| + } |
| } |
| -bool MultiprofilesIntroView::Accept() { |
| - on_accept_.Run(no_show_checkbox_->checked()); |
| +bool MultiprofilesSessionAbortedView::Accept() { |
| + chrome::AttemptUserExit(); |
|
Dmitry Polukhin
2014/01/28 23:45:24
I'm not sure but perhaps AttemptUserExit is not en
Mr4D (OOO till 08-26)
2014/01/28 23:58:35
This is only needed for ChromeOS and ChromeOS does
|
| return true; |
| } |
| -ui::ModalType MultiprofilesIntroView::GetModalType() const { |
| +int MultiprofilesSessionAbortedView::GetDialogButtons() const { |
| + return ui::DIALOG_BUTTON_OK; |
| +} |
| + |
| +base::string16 MultiprofilesSessionAbortedView::GetDialogButtonLabel( |
| + ui::DialogButton button) const { |
| + return l10n_util::GetStringUTF16( |
| + IDS_MULTIPROFILES_SESSION_ABORT_BUTTON_LABEL); |
| +} |
| + |
| +ui::ModalType MultiprofilesSessionAbortedView::GetModalType() const { |
| return ui::MODAL_TYPE_SYSTEM; |
| } |
| -gfx::Size MultiprofilesIntroView::GetPreferredSize() { |
| +gfx::Size MultiprofilesSessionAbortedView::GetPreferredSize() { |
| return gfx::Size(kDefaultWidth, kDefaultHeight); |
| } |
| -void MultiprofilesIntroView::InitDialog() { |
| +void MultiprofilesSessionAbortedView::InitDialog( |
| + const std::string& user_email) { |
| const gfx::Insets kDialogInsets(kTopInset, kInset, kInset, kInset); |
| // Create the views and layout manager and set them up. |
| @@ -103,7 +122,7 @@ void MultiprofilesIntroView::InitDialog() { |
| views::GridLayout::USE_PREF, 0, 0); |
| views::Label* title_label_ = new views::Label( |
| - l10n_util::GetStringUTF16(IDS_MULTIPROFILES_INTRO_HEADLINE)); |
| + l10n_util::GetStringUTF16(IDS_MULTIPROFILES_SESSION_ABORT_HEADLINE)); |
| title_label_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
| ui::ResourceBundle::MediumBoldFont)); |
| title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| @@ -113,7 +132,8 @@ void MultiprofilesIntroView::InitDialog() { |
| // Explanation string. |
| views::Label* label = new views::Label( |
| - l10n_util::GetStringUTF16(IDS_MULTIPROFILES_INTRO_MESSAGE)); |
| + l10n_util::GetStringFUTF16(IDS_MULTIPROFILES_SESSION_ABORT_MESSAGE, |
| + base::ASCIIToUTF16(user_email))); |
| label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
| ui::ResourceBundle::MediumFont)); |
| label->SetMultiLine(true); |
| @@ -122,30 +142,6 @@ void MultiprofilesIntroView::InitDialog() { |
| grid_layout->StartRow(0, 0); |
| grid_layout->AddView(label); |
| - // Next explanation string. |
| - grid_layout->AddPaddingRow(0, kPaddingToMessage); |
| - views::Label* lower_label = new views::Label( |
| - l10n_util::GetStringUTF16(IDS_MULTIPROFILES_INTRO_EXPLANATION)); |
| - lower_label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
| - ui::ResourceBundle::MediumFont)); |
| - lower_label->SetMultiLine(true); |
| - lower_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| - lower_label->SetAllowCharacterBreak(true); |
| - grid_layout->StartRow(0, 0); |
| - grid_layout->AddView(lower_label); |
| - |
| - // No-show again checkbox. |
| - grid_layout->AddPaddingRow(0, kPaddingToCheckBox); |
| - no_show_checkbox_.reset(new views::Checkbox( |
| - l10n_util::GetStringUTF16(IDS_MULTIPROFILES_INTRO_NOSHOW_AGAIN))); |
| - no_show_checkbox_->SetChecked(true); |
| - no_show_checkbox_->SetFontList( |
| - ui::ResourceBundle::GetSharedInstance().GetFontList( |
| - ui::ResourceBundle::MediumFont)); |
| - no_show_checkbox_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| - grid_layout->StartRow(0, 0); |
| - grid_layout->AddView(no_show_checkbox_.get()); |
| - |
| SetLayoutManager(grid_layout); |
| Layout(); |
| } |
| @@ -155,8 +151,8 @@ void MultiprofilesIntroView::InitDialog() { |
| //////////////////////////////////////////////////////////////////////////////// |
| // Factory function. |
| -void ShowMultiprofilesIntroDialog(const base::Callback<void(bool)> on_accept) { |
| - MultiprofilesIntroView::ShowDialog(on_accept); |
| +void ShowMultiprofilesSessionAbortedDialog(const std::string& user_email) { |
| + MultiprofilesSessionAbortedView::ShowDialog(user_email); |
| } |
| } // namespace chromeos |