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

Side by Side Diff: chrome/browser/ui/ash/multi_user/multi_user_warning_dialog.cc

Issue 148093008: Create a dialog that warns about possible UI-oddities of the multi-profiles window teleport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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_intro_dialog.h" 5 #include "chrome/browser/ui/ash/multi_user/multi_user_warning_dialog.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "grit/generated_resources.h" 8 #include "grit/generated_resources.h"
9 #include "ui/base/l10n/l10n_util.h" 9 #include "ui/base/l10n/l10n_util.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/views/controls/button/checkbox.h" 11 #include "ui/views/controls/button/checkbox.h"
12 #include "ui/views/controls/label.h" 12 #include "ui/views/controls/label.h"
13 #include "ui/views/layout/grid_layout.h" 13 #include "ui/views/layout/grid_layout.h"
14 #include "ui/views/widget/widget.h" 14 #include "ui/views/widget/widget.h"
15 #include "ui/views/window/dialog_delegate.h" 15 #include "ui/views/window/dialog_delegate.h"
16 16
17 namespace chromeos { 17 namespace chromeos {
18 18
19 namespace { 19 namespace {
20 20
21 // Default width/height of the dialog. 21 // Default width/height of the dialog.
22 const int kDefaultWidth = 600; 22 const int kDefaultWidth = 600;
23 const int kDefaultHeight = 250; 23 const int kDefaultHeight = 250;
24 24
25 const int kPaddingToMessage = 20; 25 const int kPaddingToMessage = 30;
26 const int kPaddingToCheckBox = 50; 26 const int kPaddingToCheckBox = 50;
27 const int kInset = 40; 27 const int kInset = 40;
28 const int kTopInset = 10;
28 29
29 //////////////////////////////////////////////////////////////////////////////// 30 ////////////////////////////////////////////////////////////////////////////////
30 // Dialog for multi-profiles introduction. 31 // Dialog for multi-profiles teleport warning.
Mr4D (OOO till 08-26) 2014/01/28 17:33:02 What happened to the old "multi-profiles introduct
merkulova 2014/01/29 09:11:19 Hm... Nothing, it exists happily. It's just anothe
31 class MultiprofilesIntroView : public views::DialogDelegateView { 32 class TeleportWarningView : public views::DialogDelegateView {
32 public: 33 public:
33 explicit MultiprofilesIntroView(const base::Callback<void(bool)> on_accept); 34 TeleportWarningView(base::Callback<void(bool)> on_accept);
34 virtual ~MultiprofilesIntroView(); 35 virtual ~TeleportWarningView();
35 36
36 static void ShowDialog(const base::Callback<void(bool)> on_accept); 37 static void ShowDialog(const base::Callback<void(bool)> on_accept);
37 38
38 // views::DialogDelegate overrides. 39 // views:DialogDelegate overrides.
Mr4D (OOO till 08-26) 2014/01/28 17:33:02 views::Dialog..
merkulova 2014/01/29 09:11:19 Done.
39 virtual bool Accept() OVERRIDE; 40 virtual bool Accept() OVERRIDE;
40 41
41 // views::WidgetDelegate overrides. 42 // views::WidgetDelegate overrides.
42 virtual ui::ModalType GetModalType() const OVERRIDE; 43 virtual ui::ModalType GetModalType() const OVERRIDE;
43 44
44 // views::View overrides. 45 // views::View overrides.
45 virtual gfx::Size GetPreferredSize() OVERRIDE; 46 virtual gfx::Size GetPreferredSize() OVERRIDE;
46 47
48 static int reciever_user_id;
49
47 private: 50 private:
48 void InitDialog(); 51 void InitDialog();
49 52
50 scoped_ptr<views::Checkbox> no_show_checkbox_; 53 scoped_ptr<views::Checkbox> no_show_checkbox_;
51 const base::Callback<void(bool)> on_accept_; 54 const base::Callback<void(bool)> on_accept_;
52 55
53 DISALLOW_COPY_AND_ASSIGN(MultiprofilesIntroView); 56 DISALLOW_COPY_AND_ASSIGN(TeleportWarningView);
54 }; 57 };
55 58
56 //////////////////////////////////////////////////////////////////////////////// 59 ////////////////////////////////////////////////////////////////////////////////
57 // MultiprofilesIntroDialog implementation. 60 // TeleportWarningView implementation.
58 61
59 MultiprofilesIntroView::MultiprofilesIntroView( 62 TeleportWarningView::TeleportWarningView(
60 const base::Callback<void(bool)> on_accept) 63 const base::Callback<void(bool)> on_accept)
61 : on_accept_(on_accept) { 64 : on_accept_(on_accept) {
62 } 65 }
63 66
64 MultiprofilesIntroView::~MultiprofilesIntroView() { 67 TeleportWarningView::~TeleportWarningView() {
65 } 68 }
66 69
67 // static 70 // static
68 void MultiprofilesIntroView::ShowDialog( 71 void TeleportWarningView::ShowDialog(
69 const base::Callback<void(bool)> on_accept) { 72 const base::Callback<void(bool)> on_accept) {
70 MultiprofilesIntroView* dialog_view = 73 TeleportWarningView* dialog_view =
71 new MultiprofilesIntroView(on_accept); 74 new TeleportWarningView(on_accept);
72 views::DialogDelegate::CreateDialogWidget( 75 views::DialogDelegate::CreateDialogWidget(
73 dialog_view, ash::Shell::GetTargetRootWindow(), NULL); 76 dialog_view, ash::Shell::GetTargetRootWindow(), NULL);
74 dialog_view->InitDialog(); 77 dialog_view->InitDialog();
75 views::Widget* widget = dialog_view->GetWidget(); 78 views::Widget* widget = dialog_view->GetWidget();
76 DCHECK(widget); 79 DCHECK(widget);
77 widget->Show(); 80 widget->Show();
78 } 81 }
79 82
80 bool MultiprofilesIntroView::Accept() { 83 bool TeleportWarningView::Accept() {
81 on_accept_.Run(no_show_checkbox_->checked()); 84 on_accept_.Run(no_show_checkbox_->checked());
82 return true; 85 return true;
83 } 86 }
84 87
85 ui::ModalType MultiprofilesIntroView::GetModalType() const { 88 ui::ModalType TeleportWarningView::GetModalType() const {
86 return ui::MODAL_TYPE_SYSTEM; 89 return ui::MODAL_TYPE_SYSTEM;
87 } 90 }
88 91
89 gfx::Size MultiprofilesIntroView::GetPreferredSize() { 92 gfx::Size TeleportWarningView::GetPreferredSize() {
90 return gfx::Size(kDefaultWidth, kDefaultHeight); 93 return gfx::Size(kDefaultWidth, kDefaultHeight);
91 } 94 }
92 95
93 void MultiprofilesIntroView::InitDialog() { 96 void TeleportWarningView::InitDialog() {
94 const gfx::Insets kDialogInsets(kInset, kInset, kInset, kInset); 97 const gfx::Insets kDialogInsets(kTopInset, kInset, kInset, kInset);
95 98
96 // Create the views and layout manager and set them up. 99 // Create the views and layout manager and set them up.
97 views::GridLayout* grid_layout = views::GridLayout::CreatePanel(this); 100 views::GridLayout* grid_layout = views::GridLayout::CreatePanel(this);
98 grid_layout->SetInsets(kDialogInsets); 101 grid_layout->SetInsets(kDialogInsets);
99 102
100 views::ColumnSet* column_set = grid_layout->AddColumnSet(0); 103 views::ColumnSet* column_set = grid_layout->AddColumnSet(0);
101 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, 104 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
102 views::GridLayout::USE_PREF, 0, 0); 105 views::GridLayout::USE_PREF, 0, 0);
103 106
107 // title
Mr4D (OOO till 08-26) 2014/01/28 17:33:02 Start capitalized.
merkulova 2014/01/29 09:11:19 Done.
104 views::Label* title_label_ = new views::Label( 108 views::Label* title_label_ = new views::Label(
105 l10n_util::GetStringUTF16(IDS_MULTIPROFILES_INTRO_HEADLINE)); 109 l10n_util::GetStringUTF16(IDS_VISIT_DESKTOP_WARNING_TITLE));
106 title_label_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( 110 title_label_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
107 ui::ResourceBundle::MediumBoldFont)); 111 ui::ResourceBundle::MediumBoldFont));
108 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 112 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
109 grid_layout->StartRow(0, 0); 113 grid_layout->StartRow(0, 0);
110 grid_layout->AddView(title_label_); 114 grid_layout->AddView(title_label_);
111 grid_layout->AddPaddingRow(0, kPaddingToMessage); 115 grid_layout->AddPaddingRow(0, kPaddingToMessage);
112 116
113 // Explanation string. 117 // Explanation string
114 views::Label* label = new views::Label( 118 views::Label* label = new views::Label(
115 l10n_util::GetStringUTF16(IDS_MULTIPROFILES_INTRO_MESSAGE)); 119 l10n_util::GetStringUTF16(IDS_VISIT_DESKTOP_WARNING_MESSAGE));
116 label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( 120 label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
117 ui::ResourceBundle::MediumFont)); 121 ui::ResourceBundle::MediumFont));
118 label->SetMultiLine(true); 122 label->SetMultiLine(true);
119 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 123 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
120 label->SetAllowCharacterBreak(true); 124 label->SetAllowCharacterBreak(true);
121 grid_layout->StartRow(0, 0); 125 grid_layout->StartRow(0, 0);
122 grid_layout->AddView(label); 126 grid_layout->AddView(label);
123 127
124 // Next explanation string. 128 // Next explanation string
125 grid_layout->AddPaddingRow(0, kPaddingToMessage); 129 grid_layout->AddPaddingRow(0, kPaddingToMessage);
126 views::Label* lower_label = new views::Label( 130 views::Label* lower_label = new views::Label(
127 l10n_util::GetStringUTF16(IDS_MULTIPROFILES_INTRO_EXPLANATION)); 131 l10n_util::GetStringUTF16(IDS_VISIT_DESKTOP_WARNING_EXPLANATION));
128 lower_label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( 132 lower_label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
129 ui::ResourceBundle::MediumFont)); 133 ui::ResourceBundle::MediumFont));
130 lower_label->SetMultiLine(true); 134 lower_label->SetMultiLine(true);
131 lower_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 135 lower_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
132 lower_label->SetAllowCharacterBreak(true); 136 lower_label->SetAllowCharacterBreak(true);
133 grid_layout->StartRow(0, 0); 137 grid_layout->StartRow(0, 0);
134 grid_layout->AddView(lower_label); 138 grid_layout->AddView(lower_label);
135 139
136 // No-show again checkbox. 140 // No-show again checkbox
137 grid_layout->AddPaddingRow(0, kPaddingToCheckBox); 141 grid_layout->AddPaddingRow(0, kPaddingToCheckBox);
138 no_show_checkbox_.reset(new views::Checkbox( 142 no_show_checkbox_.reset(new views::Checkbox(
139 l10n_util::GetStringUTF16(IDS_MULTIPROFILES_INTRO_NOSHOW_AGAIN))); 143 l10n_util::GetStringUTF16(IDS_VISIT_DESKTOP_WARNING_SHOW_DISMISS)));
140 no_show_checkbox_->SetChecked(true); 144 no_show_checkbox_->SetChecked(true);
141 no_show_checkbox_->SetFontList( 145 no_show_checkbox_->SetFontList(
142 ui::ResourceBundle::GetSharedInstance().GetFontList( 146 ui::ResourceBundle::GetSharedInstance().GetFontList(
143 ui::ResourceBundle::MediumFont)); 147 ui::ResourceBundle::MediumFont));
144 no_show_checkbox_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
145 grid_layout->StartRow(0, 0); 148 grid_layout->StartRow(0, 0);
146 grid_layout->AddView(no_show_checkbox_.get()); 149 grid_layout->AddView(no_show_checkbox_.get());
147 150
148 SetLayoutManager(grid_layout); 151 SetLayoutManager(grid_layout);
149 Layout(); 152 Layout();
150 } 153 }
151 154
152 } // namespace 155 } // namespace
153 156
154 //////////////////////////////////////////////////////////////////////////////// 157 ////////////////////////////////////////////////////////////////////////////////
155 // Factory function. 158 // Factory function.
156 159
157 void ShowMultiprofilesIntroDialog(const base::Callback<void(bool)> on_accept) { 160 void ShowMultiprofilesWarningDialog(
158 MultiprofilesIntroView::ShowDialog(on_accept); 161 const base::Callback<void(bool)> on_accept) {
162 TeleportWarningView::ShowDialog(on_accept);
159 } 163 }
160 164
161 } // namespace chromeos 165 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698