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

Side by Side Diff: chrome/browser/chromeos/profiles/multiprofiles_session_aborted_dialog.cc

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
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/shell.h" 7 #include "ash/shell.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/lifetime/application_lifetime.h" 9 #include "chrome/browser/lifetime/application_lifetime.h"
10 #include "chrome/grit/generated_resources.h" 10 #include "chrome/grit/generated_resources.h"
11 #include "components/user_manager/user_id.h"
11 #include "ui/base/l10n/l10n_util.h" 12 #include "ui/base/l10n/l10n_util.h"
12 #include "ui/base/resource/resource_bundle.h" 13 #include "ui/base/resource/resource_bundle.h"
13 #include "ui/views/controls/button/checkbox.h" 14 #include "ui/views/controls/button/checkbox.h"
14 #include "ui/views/controls/label.h" 15 #include "ui/views/controls/label.h"
15 #include "ui/views/layout/grid_layout.h" 16 #include "ui/views/layout/grid_layout.h"
16 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
17 #include "ui/views/window/dialog_delegate.h" 18 #include "ui/views/window/dialog_delegate.h"
18 19
19 namespace chromeos { 20 namespace chromeos {
20 21
21 namespace { 22 namespace {
22 23
23 // Default width/height of the dialog. 24 // Default width/height of the dialog.
24 const int kDefaultWidth = 600; 25 const int kDefaultWidth = 600;
25 const int kDefaultHeight = 250; 26 const int kDefaultHeight = 250;
26 27
27 const int kPaddingToMessage = 20; 28 const int kPaddingToMessage = 20;
28 const int kInset = 40; 29 const int kInset = 40;
29 const int kTopInset = 10; 30 const int kTopInset = 10;
30 31
31 //////////////////////////////////////////////////////////////////////////////// 32 ////////////////////////////////////////////////////////////////////////////////
32 // Dialog for an aborted multi-profile session due to a user policy change . 33 // Dialog for an aborted multi-profile session due to a user policy change .
33 class MultiprofilesSessionAbortedView : public views::DialogDelegateView { 34 class MultiprofilesSessionAbortedView : public views::DialogDelegateView {
34 public: 35 public:
35 explicit MultiprofilesSessionAbortedView(); 36 explicit MultiprofilesSessionAbortedView();
36 ~MultiprofilesSessionAbortedView() override; 37 ~MultiprofilesSessionAbortedView() override;
37 38
38 static void ShowDialog(const std::string& user_email); 39 static void ShowDialog(const user_manager::UserID& user_email);
39 40
40 // views::DialogDelegate overrides. 41 // views::DialogDelegate overrides.
41 bool Accept() override; 42 bool Accept() override;
42 int GetDialogButtons() const override; 43 int GetDialogButtons() const override;
43 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; 44 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
44 45
45 // views::WidgetDelegate overrides. 46 // views::WidgetDelegate overrides.
46 ui::ModalType GetModalType() const override; 47 ui::ModalType GetModalType() const override;
47 48
48 // views::View overrides. 49 // views::View overrides.
49 gfx::Size GetPreferredSize() const override; 50 gfx::Size GetPreferredSize() const override;
50 51
51 private: 52 private:
52 void InitDialog(const std::string& user_email); 53 void InitDialog(const std::string& user_email);
53 54
54 DISALLOW_COPY_AND_ASSIGN(MultiprofilesSessionAbortedView); 55 DISALLOW_COPY_AND_ASSIGN(MultiprofilesSessionAbortedView);
55 }; 56 };
56 57
57 //////////////////////////////////////////////////////////////////////////////// 58 ////////////////////////////////////////////////////////////////////////////////
58 // MultiprofilesSessionAbortedView implementation. 59 // MultiprofilesSessionAbortedView implementation.
59 60
60 MultiprofilesSessionAbortedView::MultiprofilesSessionAbortedView() { 61 MultiprofilesSessionAbortedView::MultiprofilesSessionAbortedView() {
61 } 62 }
62 63
63 MultiprofilesSessionAbortedView::~MultiprofilesSessionAbortedView() { 64 MultiprofilesSessionAbortedView::~MultiprofilesSessionAbortedView() {
64 } 65 }
65 66
66 // static 67 // static
67 void MultiprofilesSessionAbortedView::ShowDialog( 68 void MultiprofilesSessionAbortedView::ShowDialog(
68 const std::string& user_email) { 69 const user_manager::UserID& user_id) {
69 MultiprofilesSessionAbortedView* dialog_view = 70 MultiprofilesSessionAbortedView* dialog_view =
70 new MultiprofilesSessionAbortedView(); 71 new MultiprofilesSessionAbortedView();
71 views::DialogDelegate::CreateDialogWidget( 72 views::DialogDelegate::CreateDialogWidget(
72 dialog_view, ash::Shell::GetTargetRootWindow(), NULL); 73 dialog_view, ash::Shell::GetTargetRootWindow(), NULL);
73 dialog_view->InitDialog(user_email); 74 dialog_view->InitDialog(user_id.GetUserEmail());
74 views::Widget* widget = dialog_view->GetWidget(); 75 views::Widget* widget = dialog_view->GetWidget();
75 DCHECK(widget); 76 DCHECK(widget);
76 widget->Show(); 77 widget->Show();
77 78
78 // Since this is the last thing the user ever sees, we also hide all system 79 // Since this is the last thing the user ever sees, we also hide all system
79 // tray's from the screen. 80 // tray's from the screen.
80 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows(); 81 aura::Window::Windows root_windows = ash::Shell::GetAllRootWindows();
81 for (aura::Window::Windows::const_iterator iter = root_windows.begin(); 82 for (aura::Window::Windows::const_iterator iter = root_windows.begin();
82 iter != root_windows.end(); ++iter) { 83 iter != root_windows.end(); ++iter) {
83 ash::Shell::GetInstance()->SetShelfAutoHideBehavior( 84 ash::Shell::GetInstance()->SetShelfAutoHideBehavior(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 144
144 SetLayoutManager(grid_layout); 145 SetLayoutManager(grid_layout);
145 Layout(); 146 Layout();
146 } 147 }
147 148
148 } // namespace 149 } // namespace
149 150
150 //////////////////////////////////////////////////////////////////////////////// 151 ////////////////////////////////////////////////////////////////////////////////
151 // Factory function. 152 // Factory function.
152 153
153 void ShowMultiprofilesSessionAbortedDialog(const std::string& user_email) { 154 void ShowMultiprofilesSessionAbortedDialog(const user_manager::UserID& user_id) {
154 MultiprofilesSessionAbortedView::ShowDialog(user_email); 155 MultiprofilesSessionAbortedView::ShowDialog(user_id);
155 } 156 }
156 157
157 } // namespace chromeos 158 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698