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

Side by Side Diff: chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.cc

Issue 2713803002: Views/Harmony: Use LayoutDelegate::GetMetric for views::kPanelVertMargin. (Closed)
Patch Set: Fix many crashes. Created 3 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 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"
16 #include "chrome/grit/chromium_strings.h" 17 #include "chrome/grit/chromium_strings.h"
17 #include "chrome/grit/generated_resources.h" 18 #include "chrome/grit/generated_resources.h"
18 #include "components/constrained_window/constrained_window_views.h" 19 #include "components/constrained_window/constrained_window_views.h"
19 #include "components/signin/core/common/profile_management_switches.h" 20 #include "components/signin/core/common/profile_management_switches.h"
20 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
21 #include "google_apis/gaia/gaia_auth_util.h" 22 #include "google_apis/gaia/gaia_auth_util.h"
22 #include "third_party/skia/include/core/SkColor.h" 23 #include "third_party/skia/include/core/SkColor.h"
23 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/ui_features.h" 25 #include "ui/base/ui_features.h"
25 #include "ui/gfx/font.h" 26 #include "ui/gfx/font.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITH_PROFILE_CREATION : 187 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITH_PROFILE_CREATION :
187 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITHOUT_PROFILE_CREATION, 188 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITHOUT_PROFILE_CREATION,
188 username, learn_more_text, &offsets); 189 username, learn_more_text, &offsets);
189 views::StyledLabel* explanation_label = 190 views::StyledLabel* explanation_label =
190 new views::StyledLabel(signin_explanation_text, this); 191 new views::StyledLabel(signin_explanation_text, this);
191 explanation_label->AddStyleRange( 192 explanation_label->AddStyleRange(
192 gfx::Range(offsets[1], offsets[1] + learn_more_text.size()), 193 gfx::Range(offsets[1], offsets[1] + learn_more_text.size()),
193 views::StyledLabel::RangeStyleInfo::CreateForLink()); 194 views::StyledLabel::RangeStyleInfo::CreateForLink());
194 195
195 // Layout the components. 196 // Layout the components.
197 const int panel_margin = LayoutDelegate::Get()->GetMetric(
198 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN);
196 views::GridLayout* dialog_layout = new views::GridLayout(this); 199 views::GridLayout* dialog_layout = new views::GridLayout(this);
197 dialog_layout->SetInsets(views::kPanelVertMargin, 0, 0, 0); 200 dialog_layout->SetInsets(panel_margin, 0, 0, 0);
198 SetLayoutManager(dialog_layout); 201 SetLayoutManager(dialog_layout);
199 202
200 // Use GridLayout inside the prompt bar because StyledLabel requires it. 203 // Use GridLayout inside the prompt bar because StyledLabel requires it.
201 views::GridLayout* prompt_layout = views::GridLayout::CreatePanel(prompt_bar); 204 views::GridLayout* prompt_layout = views::GridLayout::CreatePanel(prompt_bar);
202 prompt_bar->SetLayoutManager(prompt_layout); 205 prompt_bar->SetLayoutManager(prompt_layout);
203 prompt_layout->AddColumnSet(0)->AddColumn( 206 prompt_layout->AddColumnSet(0)->AddColumn(
204 views::GridLayout::FILL, views::GridLayout::CENTER, 100, 207 views::GridLayout::FILL, views::GridLayout::CENTER, 100,
205 views::GridLayout::USE_PREF, 0, 0); 208 views::GridLayout::USE_PREF, 0, 0);
206 prompt_layout->StartRow(0, 0); 209 prompt_layout->StartRow(0, 0);
207 prompt_layout->AddView(prompt_label); 210 prompt_layout->AddView(prompt_label);
208 // Use a column set with no padding. 211 // Use a column set with no padding.
209 dialog_layout->AddColumnSet(0)->AddColumn( 212 dialog_layout->AddColumnSet(0)->AddColumn(
210 views::GridLayout::FILL, views::GridLayout::FILL, 100, 213 views::GridLayout::FILL, views::GridLayout::FILL, 100,
211 views::GridLayout::USE_PREF, 0, 0); 214 views::GridLayout::USE_PREF, 0, 0);
212 dialog_layout->StartRow(0, 0); 215 dialog_layout->StartRow(0, 0);
213 dialog_layout->AddView( 216 dialog_layout->AddView(
214 prompt_bar, 1, 1, 217 prompt_bar, 1, 1,
215 views::GridLayout::FILL, views::GridLayout::FILL, 0, 0); 218 views::GridLayout::FILL, views::GridLayout::FILL, 0, 0);
216 219
217 // Use a new column set for the explanation label so we can add padding. 220 // Use a new column set for the explanation label so we can add padding.
218 dialog_layout->AddPaddingRow(0.0, views::kPanelVertMargin); 221 dialog_layout->AddPaddingRow(0.0, panel_margin);
219 views::ColumnSet* explanation_columns = dialog_layout->AddColumnSet(1); 222 views::ColumnSet* explanation_columns = dialog_layout->AddColumnSet(1);
220 explanation_columns->AddPaddingColumn(0.0, views::kButtonHEdgeMarginNew); 223 explanation_columns->AddPaddingColumn(0.0, views::kButtonHEdgeMarginNew);
221 explanation_columns->AddColumn( 224 explanation_columns->AddColumn(
222 views::GridLayout::FILL, views::GridLayout::FILL, 100, 225 views::GridLayout::FILL, views::GridLayout::FILL, 100,
223 views::GridLayout::USE_PREF, 0, 0); 226 views::GridLayout::USE_PREF, 0, 0);
224 explanation_columns->AddPaddingColumn(0.0, views::kButtonHEdgeMarginNew); 227 explanation_columns->AddPaddingColumn(0.0, views::kButtonHEdgeMarginNew);
225 dialog_layout->StartRow(0, 1); 228 dialog_layout->StartRow(0, 1);
226 const int kPreferredWidth = 440; 229 const int kPreferredWidth = 440;
227 dialog_layout->AddView(explanation_label, 1, 1, views::GridLayout::FILL, 230 dialog_layout->AddView(explanation_label, 1, 1, views::GridLayout::FILL,
228 views::GridLayout::FILL, kPreferredWidth, 231 views::GridLayout::FILL, kPreferredWidth,
(...skipping 20 matching lines...) Expand all
249 void ProfileSigninConfirmationDialogViews::ButtonPressed( 252 void ProfileSigninConfirmationDialogViews::ButtonPressed(
250 views::Button* sender, 253 views::Button* sender,
251 const ui::Event& event) { 254 const ui::Event& event) {
252 DCHECK(prompt_for_new_profile_); 255 DCHECK(prompt_for_new_profile_);
253 if (delegate_) { 256 if (delegate_) {
254 delegate_->OnContinueSignin(); 257 delegate_->OnContinueSignin();
255 delegate_ = nullptr; 258 delegate_ = nullptr;
256 } 259 }
257 GetWidget()->Close(); 260 GetWidget()->Close();
258 } 261 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698