Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/views/sync/profile_signin_confirmation_dialog_views. h" | 5 #include "chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views. h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 #include "ui/gfx/font.h" | 26 #include "ui/gfx/font.h" |
| 27 #include "ui/gfx/native_widget_types.h" | 27 #include "ui/gfx/native_widget_types.h" |
| 28 #include "ui/gfx/range/range.h" | 28 #include "ui/gfx/range/range.h" |
| 29 #include "ui/views/background.h" | 29 #include "ui/views/background.h" |
| 30 #include "ui/views/border.h" | 30 #include "ui/views/border.h" |
| 31 #include "ui/views/controls/button/md_text_button.h" | 31 #include "ui/views/controls/button/md_text_button.h" |
| 32 #include "ui/views/controls/label.h" | 32 #include "ui/views/controls/label.h" |
| 33 #include "ui/views/controls/styled_label.h" | 33 #include "ui/views/controls/styled_label.h" |
| 34 #include "ui/views/layout/box_layout.h" | 34 #include "ui/views/layout/box_layout.h" |
| 35 #include "ui/views/layout/grid_layout.h" | 35 #include "ui/views/layout/grid_layout.h" |
| 36 #include "ui/views/layout/layout_constants.h" | |
| 37 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
| 38 #include "ui/views/window/dialog_client_view.h" | 37 #include "ui/views/window/dialog_client_view.h" |
| 39 | 38 |
| 40 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) | 39 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) |
| 41 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" | 40 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" |
| 42 #endif | 41 #endif |
| 43 | 42 |
| 44 ProfileSigninConfirmationDialogViews::ProfileSigninConfirmationDialogViews( | 43 ProfileSigninConfirmationDialogViews::ProfileSigninConfirmationDialogViews( |
| 45 Browser* browser, | 44 Browser* browser, |
| 46 const std::string& username, | 45 const std::string& username, |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITH_PROFILE_CREATION : | 186 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITH_PROFILE_CREATION : |
| 188 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITHOUT_PROFILE_CREATION, | 187 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITHOUT_PROFILE_CREATION, |
| 189 username, learn_more_text, &offsets); | 188 username, learn_more_text, &offsets); |
| 190 views::StyledLabel* explanation_label = | 189 views::StyledLabel* explanation_label = |
| 191 new views::StyledLabel(signin_explanation_text, this); | 190 new views::StyledLabel(signin_explanation_text, this); |
| 192 explanation_label->AddStyleRange( | 191 explanation_label->AddStyleRange( |
| 193 gfx::Range(offsets[1], offsets[1] + learn_more_text.size()), | 192 gfx::Range(offsets[1], offsets[1] + learn_more_text.size()), |
| 194 views::StyledLabel::RangeStyleInfo::CreateForLink()); | 193 views::StyledLabel::RangeStyleInfo::CreateForLink()); |
| 195 | 194 |
| 196 // Layout the components. | 195 // Layout the components. |
| 197 const int panel_margin = LayoutDelegate::Get()->GetMetric( | 196 LayoutDelegate* layout_delegate = LayoutDelegate::Get(); |
| 198 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN); | 197 const int panel_margin = |
| 198 layout_delegate->GetMetric(LayoutDelegate::Metric::PANEL_CONTENT_MARGIN); | |
| 199 const int button_margin = | |
| 200 layout_delegate->GetMetric(LayoutDelegate::Metric::DIALOG_BUTTON_MARGIN); | |
| 199 views::GridLayout* dialog_layout = new views::GridLayout(this); | 201 views::GridLayout* dialog_layout = new views::GridLayout(this); |
| 200 dialog_layout->SetInsets(panel_margin, 0, 0, 0); | 202 dialog_layout->SetInsets(panel_margin, 0, 0, 0); |
| 201 SetLayoutManager(dialog_layout); | 203 SetLayoutManager(dialog_layout); |
| 202 | 204 |
| 203 // Use GridLayout inside the prompt bar because StyledLabel requires it. | 205 // Use GridLayout inside the prompt bar because StyledLabel requires it. |
| 204 views::GridLayout* prompt_layout = views::GridLayout::CreatePanel(prompt_bar); | 206 views::GridLayout* prompt_layout = views::GridLayout::CreatePanel(prompt_bar); |
| 205 prompt_layout->AddColumnSet(0)->AddColumn( | 207 prompt_layout->AddColumnSet(0)->AddColumn( |
| 206 views::GridLayout::FILL, views::GridLayout::CENTER, 100, | 208 views::GridLayout::FILL, views::GridLayout::CENTER, 100, |
| 207 views::GridLayout::USE_PREF, 0, 0); | 209 views::GridLayout::USE_PREF, 0, 0); |
| 208 prompt_layout->StartRow(0, 0); | 210 prompt_layout->StartRow(0, 0); |
| 209 prompt_layout->AddView(prompt_label); | 211 prompt_layout->AddView(prompt_label); |
| 210 // Use a column set with no padding. | 212 // Use a column set with no padding. |
| 211 dialog_layout->AddColumnSet(0)->AddColumn( | 213 dialog_layout->AddColumnSet(0)->AddColumn( |
| 212 views::GridLayout::FILL, views::GridLayout::FILL, 100, | 214 views::GridLayout::FILL, views::GridLayout::FILL, 100, |
| 213 views::GridLayout::USE_PREF, 0, 0); | 215 views::GridLayout::USE_PREF, 0, 0); |
| 214 dialog_layout->StartRow(0, 0); | 216 dialog_layout->StartRow(0, 0); |
| 215 dialog_layout->AddView( | 217 dialog_layout->AddView( |
| 216 prompt_bar, 1, 1, | 218 prompt_bar, 1, 1, |
| 217 views::GridLayout::FILL, views::GridLayout::FILL, 0, 0); | 219 views::GridLayout::FILL, views::GridLayout::FILL, 0, 0); |
| 218 | 220 |
| 219 // Use a new column set for the explanation label so we can add padding. | 221 // Use a new column set for the explanation label so we can add padding. |
| 220 dialog_layout->AddPaddingRow(0.0, panel_margin); | 222 dialog_layout->AddPaddingRow(0.0, panel_margin); |
| 221 views::ColumnSet* explanation_columns = dialog_layout->AddColumnSet(1); | 223 views::ColumnSet* explanation_columns = dialog_layout->AddColumnSet(1); |
| 222 explanation_columns->AddPaddingColumn(0.0, views::kButtonHEdgeMarginNew); | 224 explanation_columns->AddPaddingColumn(0.0, button_margin); |
| 223 explanation_columns->AddColumn( | 225 explanation_columns->AddColumn( |
| 224 views::GridLayout::FILL, views::GridLayout::FILL, 100, | 226 views::GridLayout::FILL, views::GridLayout::FILL, 100, |
| 225 views::GridLayout::USE_PREF, 0, 0); | 227 views::GridLayout::USE_PREF, 0, 0); |
| 226 explanation_columns->AddPaddingColumn(0.0, views::kButtonHEdgeMarginNew); | 228 explanation_columns->AddPaddingColumn(0.0, button_margin); |
|
Patti Lor
2017/04/06 02:17:19
Not sure if these two should also be |panel_margin
tapted
2017/04/06 03:09:56
|prompt_bar| is the host passed to GridLayout::Cre
Patti Lor
2017/04/06 04:49:58
Done.
| |
| 227 dialog_layout->StartRow(0, 1); | 229 dialog_layout->StartRow(0, 1); |
| 228 const int kPreferredWidth = 440; | 230 const int kPreferredWidth = 440; |
| 229 dialog_layout->AddView(explanation_label, 1, 1, views::GridLayout::FILL, | 231 dialog_layout->AddView(explanation_label, 1, 1, views::GridLayout::FILL, |
| 230 views::GridLayout::FILL, kPreferredWidth, | 232 views::GridLayout::FILL, kPreferredWidth, |
| 231 explanation_label->GetHeightForWidth(kPreferredWidth)); | 233 explanation_label->GetHeightForWidth(kPreferredWidth)); |
| 232 } | 234 } |
| 233 | 235 |
| 234 void ProfileSigninConfirmationDialogViews::WindowClosing() { | 236 void ProfileSigninConfirmationDialogViews::WindowClosing() { |
| 235 Cancel(); | 237 Cancel(); |
| 236 } | 238 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 251 void ProfileSigninConfirmationDialogViews::ButtonPressed( | 253 void ProfileSigninConfirmationDialogViews::ButtonPressed( |
| 252 views::Button* sender, | 254 views::Button* sender, |
| 253 const ui::Event& event) { | 255 const ui::Event& event) { |
| 254 DCHECK(prompt_for_new_profile_); | 256 DCHECK(prompt_for_new_profile_); |
| 255 if (delegate_) { | 257 if (delegate_) { |
| 256 delegate_->OnContinueSignin(); | 258 delegate_->OnContinueSignin(); |
| 257 delegate_ = nullptr; | 259 delegate_ = nullptr; |
| 258 } | 260 } |
| 259 GetWidget()->Close(); | 261 GetWidget()->Close(); |
| 260 } | 262 } |
| OLD | NEW |