| 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 |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_navigator.h" | 13 #include "chrome/browser/ui/browser_navigator.h" |
| 14 #include "chrome/browser/ui/browser_navigator_params.h" | 14 #include "chrome/browser/ui/browser_navigator_params.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chrome/browser/ui/views/harmony/layout_delegate.h" | |
| 17 #include "chrome/grit/chromium_strings.h" | 16 #include "chrome/grit/chromium_strings.h" |
| 18 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
| 19 #include "components/constrained_window/constrained_window_views.h" | 18 #include "components/constrained_window/constrained_window_views.h" |
| 20 #include "components/signin/core/common/profile_management_switches.h" | 19 #include "components/signin/core/common/profile_management_switches.h" |
| 21 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 22 #include "google_apis/gaia/gaia_auth_util.h" | 21 #include "google_apis/gaia/gaia_auth_util.h" |
| 23 #include "third_party/skia/include/core/SkColor.h" | 22 #include "third_party/skia/include/core/SkColor.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/base/ui_features.h" | 24 #include "ui/base/ui_features.h" |
| 26 #include "ui/gfx/font.h" | 25 #include "ui/gfx/font.h" |
| 27 #include "ui/gfx/native_widget_types.h" | 26 #include "ui/gfx/native_widget_types.h" |
| 28 #include "ui/gfx/range/range.h" | 27 #include "ui/gfx/range/range.h" |
| 29 #include "ui/views/background.h" | 28 #include "ui/views/background.h" |
| 30 #include "ui/views/border.h" | 29 #include "ui/views/border.h" |
| 31 #include "ui/views/controls/button/md_text_button.h" | 30 #include "ui/views/controls/button/md_text_button.h" |
| 32 #include "ui/views/controls/label.h" | 31 #include "ui/views/controls/label.h" |
| 33 #include "ui/views/controls/styled_label.h" | 32 #include "ui/views/controls/styled_label.h" |
| 34 #include "ui/views/layout/box_layout.h" | 33 #include "ui/views/layout/box_layout.h" |
| 35 #include "ui/views/layout/grid_layout.h" | 34 #include "ui/views/layout/grid_layout.h" |
| 36 #include "ui/views/layout/layout_constants.h" | 35 #include "ui/views/views_delegate.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 const gfx::Insets panel_insets = |
| 198 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN); | 197 views::ViewsDelegate::GetInstance()->GetInsetsMetric( |
| 198 views::InsetsMetric::PANEL); |
| 199 // The prompt bar needs to go to the edge of the dialog, so ignore insets for |
| 200 // the outer layout. |
| 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_insets.top(), 0, panel_insets.bottom(), 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 constexpr int kPromptBarColumnSetId = 0; |
| 206 views::GridLayout::FILL, views::GridLayout::CENTER, 100, | 208 prompt_layout->AddColumnSet(kPromptBarColumnSetId) |
| 207 views::GridLayout::USE_PREF, 0, 0); | 209 ->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 100, |
| 208 prompt_layout->StartRow(0, 0); | 210 views::GridLayout::USE_PREF, 0, 0); |
| 211 prompt_layout->StartRow(0, kPromptBarColumnSetId); |
| 209 prompt_layout->AddView(prompt_label); | 212 prompt_layout->AddView(prompt_label); |
| 210 // Use a column set with no padding. | 213 // Use a column set with no padding. |
| 211 dialog_layout->AddColumnSet(0)->AddColumn( | 214 dialog_layout->AddColumnSet(0)->AddColumn( |
| 212 views::GridLayout::FILL, views::GridLayout::FILL, 100, | 215 views::GridLayout::FILL, views::GridLayout::FILL, 100, |
| 213 views::GridLayout::USE_PREF, 0, 0); | 216 views::GridLayout::USE_PREF, 0, 0); |
| 214 dialog_layout->StartRow(0, 0); | 217 dialog_layout->StartRow(0, 0); |
| 215 dialog_layout->AddView( | 218 dialog_layout->AddView( |
| 216 prompt_bar, 1, 1, | 219 prompt_bar, 1, 1, |
| 217 views::GridLayout::FILL, views::GridLayout::FILL, 0, 0); | 220 views::GridLayout::FILL, views::GridLayout::FILL, 0, 0); |
| 218 | 221 |
| 219 // Use a new column set for the explanation label so we can add padding. | 222 // Use a new column set for the explanation label so we can add padding. |
| 220 dialog_layout->AddPaddingRow(0.0, panel_margin); | 223 dialog_layout->AddPaddingRow(0.0, panel_insets.top()); |
| 221 views::ColumnSet* explanation_columns = dialog_layout->AddColumnSet(1); | 224 constexpr int kExplanationColumnSetId = 1; |
| 222 explanation_columns->AddPaddingColumn(0.0, views::kButtonHEdgeMarginNew); | 225 views::ColumnSet* explanation_columns = |
| 226 dialog_layout->AddColumnSet(kExplanationColumnSetId); |
| 227 explanation_columns->AddPaddingColumn(0.0, panel_insets.left()); |
| 223 explanation_columns->AddColumn( | 228 explanation_columns->AddColumn( |
| 224 views::GridLayout::FILL, views::GridLayout::FILL, 100, | 229 views::GridLayout::FILL, views::GridLayout::FILL, 100, |
| 225 views::GridLayout::USE_PREF, 0, 0); | 230 views::GridLayout::USE_PREF, 0, 0); |
| 226 explanation_columns->AddPaddingColumn(0.0, views::kButtonHEdgeMarginNew); | 231 explanation_columns->AddPaddingColumn(0.0, panel_insets.right()); |
| 227 dialog_layout->StartRow(0, 1); | 232 dialog_layout->StartRow(0, kExplanationColumnSetId); |
| 228 const int kPreferredWidth = 440; | 233 const int kPreferredWidth = 440; |
| 229 dialog_layout->AddView(explanation_label, 1, 1, views::GridLayout::FILL, | 234 dialog_layout->AddView(explanation_label, 1, 1, views::GridLayout::FILL, |
| 230 views::GridLayout::FILL, kPreferredWidth, | 235 views::GridLayout::FILL, kPreferredWidth, |
| 231 explanation_label->GetHeightForWidth(kPreferredWidth)); | 236 explanation_label->GetHeightForWidth(kPreferredWidth)); |
| 232 } | 237 } |
| 233 | 238 |
| 234 void ProfileSigninConfirmationDialogViews::WindowClosing() { | 239 void ProfileSigninConfirmationDialogViews::WindowClosing() { |
| 235 Cancel(); | 240 Cancel(); |
| 236 } | 241 } |
| 237 | 242 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 251 void ProfileSigninConfirmationDialogViews::ButtonPressed( | 256 void ProfileSigninConfirmationDialogViews::ButtonPressed( |
| 252 views::Button* sender, | 257 views::Button* sender, |
| 253 const ui::Event& event) { | 258 const ui::Event& event) { |
| 254 DCHECK(prompt_for_new_profile_); | 259 DCHECK(prompt_for_new_profile_); |
| 255 if (delegate_) { | 260 if (delegate_) { |
| 256 delegate_->OnContinueSignin(); | 261 delegate_->OnContinueSignin(); |
| 257 delegate_ = nullptr; | 262 delegate_ = nullptr; |
| 258 } | 263 } |
| 259 GetWidget()->Close(); | 264 GetWidget()->Close(); |
| 260 } | 265 } |
| OLD | NEW |