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 |
| 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, 0, 0); |
|
Peter Kasting
2017/04/06 06:12:39
FWIW, I think we should use the bottom inset here
Patti Lor
2017/04/07 00:53:55
Done.
| |
| 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_insets.bottom()); |
|
Peter Kasting
2017/04/06 06:12:39
I think you actually want the top inset again rath
Patti Lor
2017/04/07 00:53:55
Done.
| |
| 221 views::ColumnSet* explanation_columns = dialog_layout->AddColumnSet(1); | 223 constexpr int kExplanationColumnSetId = 1; |
|
Peter Kasting
2017/04/06 06:12:39
Nit: I don't mind naming the column set like this,
Patti Lor
2017/04/07 00:53:55
Done.
| |
| 222 explanation_columns->AddPaddingColumn(0.0, views::kButtonHEdgeMarginNew); | 224 views::ColumnSet* explanation_columns = |
| 225 dialog_layout->AddColumnSet(kExplanationColumnSetId); | |
| 226 explanation_columns->AddPaddingColumn(0.0, panel_insets.left()); | |
| 223 explanation_columns->AddColumn( | 227 explanation_columns->AddColumn( |
| 224 views::GridLayout::FILL, views::GridLayout::FILL, 100, | 228 views::GridLayout::FILL, views::GridLayout::FILL, 100, |
| 225 views::GridLayout::USE_PREF, 0, 0); | 229 views::GridLayout::USE_PREF, 0, 0); |
| 226 explanation_columns->AddPaddingColumn(0.0, views::kButtonHEdgeMarginNew); | 230 explanation_columns->AddPaddingColumn(0.0, panel_insets.right()); |
| 227 dialog_layout->StartRow(0, 1); | 231 dialog_layout->StartRow(0, kExplanationColumnSetId); |
| 228 const int kPreferredWidth = 440; | 232 const int kPreferredWidth = 440; |
| 229 dialog_layout->AddView(explanation_label, 1, 1, views::GridLayout::FILL, | 233 dialog_layout->AddView(explanation_label, 1, 1, views::GridLayout::FILL, |
| 230 views::GridLayout::FILL, kPreferredWidth, | 234 views::GridLayout::FILL, kPreferredWidth, |
| 231 explanation_label->GetHeightForWidth(kPreferredWidth)); | 235 explanation_label->GetHeightForWidth(kPreferredWidth)); |
| 232 } | 236 } |
| 233 | 237 |
| 234 void ProfileSigninConfirmationDialogViews::WindowClosing() { | 238 void ProfileSigninConfirmationDialogViews::WindowClosing() { |
| 235 Cancel(); | 239 Cancel(); |
| 236 } | 240 } |
| 237 | 241 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 251 void ProfileSigninConfirmationDialogViews::ButtonPressed( | 255 void ProfileSigninConfirmationDialogViews::ButtonPressed( |
| 252 views::Button* sender, | 256 views::Button* sender, |
| 253 const ui::Event& event) { | 257 const ui::Event& event) { |
| 254 DCHECK(prompt_for_new_profile_); | 258 DCHECK(prompt_for_new_profile_); |
| 255 if (delegate_) { | 259 if (delegate_) { |
| 256 delegate_->OnContinueSignin(); | 260 delegate_->OnContinueSignin(); |
| 257 delegate_ = nullptr; | 261 delegate_ = nullptr; |
| 258 } | 262 } |
| 259 GetWidget()->Close(); | 263 GetWidget()->Close(); |
| 260 } | 264 } |
| OLD | NEW |