| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITH_PROFILE_CREATION : | 191 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITH_PROFILE_CREATION : |
| 192 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITHOUT_PROFILE_CREATION, | 192 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITHOUT_PROFILE_CREATION, |
| 193 username, learn_more_text, &offsets); | 193 username, learn_more_text, &offsets); |
| 194 views::StyledLabel* explanation_label = | 194 views::StyledLabel* explanation_label = |
| 195 new views::StyledLabel(signin_explanation_text, this); | 195 new views::StyledLabel(signin_explanation_text, this); |
| 196 explanation_label->AddStyleRange( | 196 explanation_label->AddStyleRange( |
| 197 gfx::Range(offsets[1], offsets[1] + learn_more_text.size()), | 197 gfx::Range(offsets[1], offsets[1] + learn_more_text.size()), |
| 198 views::StyledLabel::RangeStyleInfo::CreateForLink()); | 198 views::StyledLabel::RangeStyleInfo::CreateForLink()); |
| 199 | 199 |
| 200 // Layout the components. | 200 // Layout the components. |
| 201 const gfx::Insets panel_insets = | 201 const gfx::Insets content_insets = |
| 202 views::LayoutProvider::Get()->GetInsetsMetric(views::INSETS_PANEL); | 202 views::LayoutProvider::Get()->GetInsetsMetric( |
| 203 // The prompt bar needs to go to the edge of the dialog, so ignore insets for | 203 views::INSETS_DIALOG_CONTENTS); |
| 204 // the outer layout. | 204 // The prompt bar needs to go to the edge of the dialog, so remove horizontal |
| 205 SetBorder(views::CreateEmptyBorder(panel_insets.top(), 0, | 205 // insets. |
| 206 panel_insets.bottom(), 0)); | 206 SetBorder(views::CreateEmptyBorder(content_insets.top(), 0, |
| 207 content_insets.bottom(), 0)); |
| 207 views::GridLayout* dialog_layout = new views::GridLayout(this); | 208 views::GridLayout* dialog_layout = new views::GridLayout(this); |
| 208 SetLayoutManager(dialog_layout); | 209 SetLayoutManager(dialog_layout); |
| 209 | 210 |
| 210 // Use GridLayout inside the prompt bar because StyledLabel requires it. | 211 // Use GridLayout inside the prompt bar because StyledLabel requires it. |
| 211 views::GridLayout* prompt_layout = views::GridLayout::CreatePanel(prompt_bar); | 212 views::GridLayout* prompt_layout = views::GridLayout::CreatePanel(prompt_bar); |
| 212 constexpr int kPromptBarColumnSetId = 0; | 213 constexpr int kPromptBarColumnSetId = 0; |
| 213 prompt_layout->AddColumnSet(kPromptBarColumnSetId) | 214 prompt_layout->AddColumnSet(kPromptBarColumnSetId) |
| 214 ->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 100, | 215 ->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 100, |
| 215 views::GridLayout::USE_PREF, 0, 0); | 216 views::GridLayout::USE_PREF, 0, 0); |
| 216 prompt_layout->StartRow(0, kPromptBarColumnSetId); | 217 prompt_layout->StartRow(0, kPromptBarColumnSetId); |
| 217 prompt_layout->AddView(prompt_label); | 218 prompt_layout->AddView(prompt_label); |
| 218 // Use a column set with no padding. | 219 // Use a column set with no padding. |
| 219 dialog_layout->AddColumnSet(0)->AddColumn( | 220 dialog_layout->AddColumnSet(0)->AddColumn( |
| 220 views::GridLayout::FILL, views::GridLayout::FILL, 100, | 221 views::GridLayout::FILL, views::GridLayout::FILL, 100, |
| 221 views::GridLayout::USE_PREF, 0, 0); | 222 views::GridLayout::USE_PREF, 0, 0); |
| 222 dialog_layout->StartRow(0, 0); | 223 dialog_layout->StartRow(0, 0); |
| 223 dialog_layout->AddView( | 224 dialog_layout->AddView( |
| 224 prompt_bar, 1, 1, | 225 prompt_bar, 1, 1, |
| 225 views::GridLayout::FILL, views::GridLayout::FILL, 0, 0); | 226 views::GridLayout::FILL, views::GridLayout::FILL, 0, 0); |
| 226 | 227 |
| 227 // Use a new column set for the explanation label so we can add padding. | 228 // Use a new column set for the explanation label so we can add padding. |
| 228 dialog_layout->AddPaddingRow(0.0, panel_insets.top()); | 229 dialog_layout->AddPaddingRow(0.0, content_insets.top()); |
| 229 constexpr int kExplanationColumnSetId = 1; | 230 constexpr int kExplanationColumnSetId = 1; |
| 230 views::ColumnSet* explanation_columns = | 231 views::ColumnSet* explanation_columns = |
| 231 dialog_layout->AddColumnSet(kExplanationColumnSetId); | 232 dialog_layout->AddColumnSet(kExplanationColumnSetId); |
| 232 explanation_columns->AddPaddingColumn(0.0, panel_insets.left()); | 233 explanation_columns->AddPaddingColumn(0.0, content_insets.left()); |
| 233 explanation_columns->AddColumn( | 234 explanation_columns->AddColumn( |
| 234 views::GridLayout::FILL, views::GridLayout::FILL, 100, | 235 views::GridLayout::FILL, views::GridLayout::FILL, 100, |
| 235 views::GridLayout::USE_PREF, 0, 0); | 236 views::GridLayout::USE_PREF, 0, 0); |
| 236 explanation_columns->AddPaddingColumn(0.0, panel_insets.right()); | 237 explanation_columns->AddPaddingColumn(0.0, content_insets.right()); |
| 237 dialog_layout->StartRow(0, kExplanationColumnSetId); | 238 dialog_layout->StartRow(0, kExplanationColumnSetId); |
| 238 const int kPreferredWidth = 440; | 239 const int kPreferredWidth = 440; |
| 239 dialog_layout->AddView(explanation_label, 1, 1, views::GridLayout::FILL, | 240 dialog_layout->AddView(explanation_label, 1, 1, views::GridLayout::FILL, |
| 240 views::GridLayout::FILL, kPreferredWidth, | 241 views::GridLayout::FILL, kPreferredWidth, |
| 241 explanation_label->GetHeightForWidth(kPreferredWidth)); | 242 explanation_label->GetHeightForWidth(kPreferredWidth)); |
| 242 } | 243 } |
| 243 | 244 |
| 244 void ProfileSigninConfirmationDialogViews::WindowClosing() { | 245 void ProfileSigninConfirmationDialogViews::WindowClosing() { |
| 245 Cancel(); | 246 Cancel(); |
| 246 } | 247 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 261 void ProfileSigninConfirmationDialogViews::ButtonPressed( | 262 void ProfileSigninConfirmationDialogViews::ButtonPressed( |
| 262 views::Button* sender, | 263 views::Button* sender, |
| 263 const ui::Event& event) { | 264 const ui::Event& event) { |
| 264 DCHECK(prompt_for_new_profile_); | 265 DCHECK(prompt_for_new_profile_); |
| 265 if (delegate_) { | 266 if (delegate_) { |
| 266 delegate_->OnContinueSignin(); | 267 delegate_->OnContinueSignin(); |
| 267 delegate_ = nullptr; | 268 delegate_ = nullptr; |
| 268 } | 269 } |
| 269 GetWidget()->Close(); | 270 GetWidget()->Close(); |
| 270 } | 271 } |
| OLD | NEW |