| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/profiles/multiprofiles_session_aborted_dialog.
h" | 5 #include "chrome/browser/chromeos/profiles/multiprofiles_session_aborted_dialog.
h" |
| 6 | 6 |
| 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/shelf/shelf.h" |
| 7 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/lifetime/application_lifetime.h" | 12 #include "chrome/browser/lifetime/application_lifetime.h" |
| 11 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 13 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 14 #include "ui/views/controls/button/checkbox.h" | 16 #include "ui/views/controls/button/checkbox.h" |
| 15 #include "ui/views/controls/label.h" | 17 #include "ui/views/controls/label.h" |
| 16 #include "ui/views/layout/grid_layout.h" | 18 #include "ui/views/layout/grid_layout.h" |
| 17 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
| 18 #include "ui/views/window/dialog_delegate.h" | 20 #include "ui/views/window/dialog_delegate.h" |
| 19 | 21 |
| 20 namespace chromeos { | 22 namespace chromeos { |
| 21 | 23 |
| 22 namespace { | 24 namespace { |
| 23 | 25 |
| 24 // Default width/height of the dialog. | 26 // Default width/height of the dialog. |
| 25 const int kDefaultWidth = 600; | 27 const int kDefaultWidth = 600; |
| 26 const int kDefaultHeight = 250; | 28 const int kDefaultHeight = 250; |
| 27 | 29 |
| 28 const int kPaddingToMessage = 20; | 30 const int kPaddingToMessage = 20; |
| 29 const int kInset = 40; | 31 const int kInset = 40; |
| 30 const int kTopInset = 10; | 32 const int kTopInset = 10; |
| 31 | 33 |
| 32 //////////////////////////////////////////////////////////////////////////////// | 34 //////////////////////////////////////////////////////////////////////////////// |
| 33 // Dialog for an aborted multi-profile session due to a user policy change . | 35 // Dialog for an aborted multi-profile session due to a user policy change . |
| 34 class MultiprofilesSessionAbortedView : public views::DialogDelegateView { | 36 class MultiprofilesSessionAbortedView : public views::DialogDelegateView { |
| 35 public: | 37 public: |
| 36 explicit MultiprofilesSessionAbortedView(); | 38 MultiprofilesSessionAbortedView(); |
| 37 ~MultiprofilesSessionAbortedView() override; | 39 ~MultiprofilesSessionAbortedView() override; |
| 38 | 40 |
| 39 static void ShowDialog(const std::string& user_email); | 41 static void ShowDialog(const std::string& user_email); |
| 40 | 42 |
| 41 // views::DialogDelegate overrides. | 43 // views::DialogDelegate overrides. |
| 42 bool Accept() override; | 44 bool Accept() override; |
| 43 int GetDialogButtons() const override; | 45 int GetDialogButtons() const override; |
| 44 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; | 46 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; |
| 45 | 47 |
| 46 // views::WidgetDelegate overrides. | 48 // views::WidgetDelegate overrides. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 71 new MultiprofilesSessionAbortedView(); | 73 new MultiprofilesSessionAbortedView(); |
| 72 views::DialogDelegate::CreateDialogWidget( | 74 views::DialogDelegate::CreateDialogWidget( |
| 73 dialog_view, ash::Shell::GetTargetRootWindow(), NULL); | 75 dialog_view, ash::Shell::GetTargetRootWindow(), NULL); |
| 74 dialog_view->InitDialog(user_email); | 76 dialog_view->InitDialog(user_email); |
| 75 views::Widget* widget = dialog_view->GetWidget(); | 77 views::Widget* widget = dialog_view->GetWidget(); |
| 76 DCHECK(widget); | 78 DCHECK(widget); |
| 77 widget->Show(); | 79 widget->Show(); |
| 78 | 80 |
| 79 // Since this is the last thing the user ever sees, we also hide all system | 81 // Since this is the last thing the user ever sees, we also hide all system |
| 80 // tray's from the screen. | 82 // tray's from the screen. |
| 81 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); | 83 std::vector<ash::RootWindowController*> controllers = |
| 82 for (aura::Window::Windows::const_iterator iter = root_windows.begin(); | 84 ash::Shell::GetAllRootWindowControllers(); |
| 83 iter != root_windows.end(); ++iter) { | 85 for (ash::RootWindowController* controller : controllers) { |
| 84 ash::Shell::GetInstance()->SetShelfAutoHideBehavior( | 86 controller->GetShelf()->SetAutoHideBehavior( |
| 85 ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN, *iter); | 87 ash::SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 86 } | 88 } |
| 87 } | 89 } |
| 88 | 90 |
| 89 bool MultiprofilesSessionAbortedView::Accept() { | 91 bool MultiprofilesSessionAbortedView::Accept() { |
| 90 chrome::AttemptUserExit(); | 92 chrome::AttemptUserExit(); |
| 91 return true; | 93 return true; |
| 92 } | 94 } |
| 93 | 95 |
| 94 int MultiprofilesSessionAbortedView::GetDialogButtons() const { | 96 int MultiprofilesSessionAbortedView::GetDialogButtons() const { |
| 95 return ui::DIALOG_BUTTON_OK; | 97 return ui::DIALOG_BUTTON_OK; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } // namespace | 151 } // namespace |
| 150 | 152 |
| 151 //////////////////////////////////////////////////////////////////////////////// | 153 //////////////////////////////////////////////////////////////////////////////// |
| 152 // Factory function. | 154 // Factory function. |
| 153 | 155 |
| 154 void ShowMultiprofilesSessionAbortedDialog(const std::string& user_email) { | 156 void ShowMultiprofilesSessionAbortedDialog(const std::string& user_email) { |
| 155 MultiprofilesSessionAbortedView::ShowDialog(user_email); | 157 MultiprofilesSessionAbortedView::ShowDialog(user_email); |
| 156 } | 158 } |
| 157 | 159 |
| 158 } // namespace chromeos | 160 } // namespace chromeos |
| OLD | NEW |