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

Side by Side Diff: chrome/browser/ui/views/profiles/forced_reauthentication_dialog.cc

Issue 2928253002: Remove references to ui/views/layout/layout_constants.h (Closed)
Patch Set: Fix build errors Created 3 years, 6 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
« no previous file with comments | « chrome/browser/ui/views/chrome_cleaner_dialog_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/profiles/forced_reauthentication_dialog.h" 5 #include "chrome/browser/ui/views/profiles/forced_reauthentication_dialog.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/i18n/message_formatter.h" 11 #include "base/i18n/message_formatter.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_list.h" 16 #include "chrome/browser/ui/browser_list.h"
17 #include "chrome/browser/ui/browser_window.h" 17 #include "chrome/browser/ui/browser_window.h"
18 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" 18 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 19 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/browser/ui/views/frame/browser_view.h" 20 #include "chrome/browser/ui/views/frame/browser_view.h"
21 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h"
21 #include "chrome/grit/chromium_strings.h" 22 #include "chrome/grit/chromium_strings.h"
22 #include "chrome/grit/generated_resources.h" 23 #include "chrome/grit/generated_resources.h"
23 #include "components/constrained_window/constrained_window_views.h" 24 #include "components/constrained_window/constrained_window_views.h"
24 #include "components/signin/core/browser/signin_manager.h" 25 #include "components/signin/core/browser/signin_manager.h"
25 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
26 #include "ui/views/background.h" 27 #include "ui/views/background.h"
27 #include "ui/views/border.h" 28 #include "ui/views/border.h"
28 #include "ui/views/controls/styled_label.h" 29 #include "ui/views/controls/styled_label.h"
29 #include "ui/views/layout/grid_layout.h" 30 #include "ui/views/layout/grid_layout.h"
30 #include "ui/views/layout/layout_constants.h"
31 #include "ui/views/layout/layout_provider.h"
32 #include "ui/views/view.h" 31 #include "ui/views/view.h"
33 #include "ui/views/window/dialog_client_view.h" 32 #include "ui/views/window/dialog_client_view.h"
34 33
35 namespace { 34 namespace {
36 35
37 // Refresh title of the dialog every second. 36 // Refresh title of the dialog every second.
38 constexpr int kRefreshTitleTimer = 1; 37 constexpr int kRefreshTitleTimer = 1;
39 38
40 // If browser windows are going to be closed soon, close browser window before 39 // If browser windows are going to be closed soon, close browser window before
41 // showing sign in dialog because there might not be enough time for user to 40 // showing sign in dialog because there might not be enough time for user to
(...skipping 27 matching lines...) Expand all
69 return nullptr; 68 return nullptr;
70 } 69 }
71 70
72 // PromptLabel overrides the default insets of StyledLabel. 71 // PromptLabel overrides the default insets of StyledLabel.
73 class PromptLabel : public views::StyledLabel { 72 class PromptLabel : public views::StyledLabel {
74 public: 73 public:
75 PromptLabel(const base::string16& text, views::StyledLabelListener* listener) 74 PromptLabel(const base::string16& text, views::StyledLabelListener* listener)
76 : views::StyledLabel(text, listener) {} 75 : views::StyledLabel(text, listener) {}
77 76
78 gfx::Insets GetInsets() const override { 77 gfx::Insets GetInsets() const override {
79 return views::LayoutProvider::Get()->GetInsetsMetric( 78 return ChromeLayoutProvider::Get()->GetInsetsMetric(
80 views::INSETS_DIALOG_CONTENTS); 79 views::INSETS_DIALOG_CONTENTS);
81 } 80 }
82 }; 81 };
83 82
84 } // namespace 83 } // namespace
85 84
86 ForcedReauthenticationDialog::ForcedReauthenticationDialog( 85 ForcedReauthenticationDialog::ForcedReauthenticationDialog(
87 Browser* browser, 86 Browser* browser,
88 SigninManager* signin_manager, 87 SigninManager* signin_manager,
89 const base::TimeDelta& countdown_duration) 88 const base::TimeDelta& countdown_duration)
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 IDS_ENTERPRISE_FORCE_SIGNOUT_EXPLANATION_WITHOUT_USER_NAME, 191 IDS_ENTERPRISE_FORCE_SIGNOUT_EXPLANATION_WITHOUT_USER_NAME,
193 close_warning); 192 close_warning);
194 } else { 193 } else {
195 signin_explanation_text = 194 signin_explanation_text =
196 l10n_util::GetStringFUTF16(IDS_ENTERPRISE_FORCE_SIGNOUT_EXPLANATION, 195 l10n_util::GetStringFUTF16(IDS_ENTERPRISE_FORCE_SIGNOUT_EXPLANATION,
197 base::ASCIIToUTF16(email), close_warning); 196 base::ASCIIToUTF16(email), close_warning);
198 } 197 }
199 views::StyledLabel* explanation_label = 198 views::StyledLabel* explanation_label =
200 new views::StyledLabel(signin_explanation_text, nullptr); 199 new views::StyledLabel(signin_explanation_text, nullptr);
201 200
201 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
202 // Layout the components. 202 // Layout the components.
203 const gfx::Insets panel_insets = 203 const gfx::Insets dialog_insets =
204 views::LayoutProvider::Get()->GetInsetsMetric( 204 provider->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS);
205 views::INSETS_DIALOG_CONTENTS); 205 SetBorder(views::CreateEmptyBorder(dialog_insets.top(), 0,
206 SetBorder(views::CreateEmptyBorder(panel_insets.top(), 0, 206 dialog_insets.bottom(), 0));
207 panel_insets.bottom(), 0));
208 views::GridLayout* dialog_layout = new views::GridLayout(this); 207 views::GridLayout* dialog_layout = new views::GridLayout(this);
209 SetLayoutManager(dialog_layout); 208 SetLayoutManager(dialog_layout);
210 209
211 // Use a column set with no padding. 210 // Use a column set with no padding.
212 dialog_layout->AddColumnSet(0)->AddColumn(views::GridLayout::FILL, 211 dialog_layout->AddColumnSet(0)->AddColumn(views::GridLayout::FILL,
213 views::GridLayout::FILL, 100, 212 views::GridLayout::FILL, 100,
214 views::GridLayout::USE_PREF, 0, 0); 213 views::GridLayout::USE_PREF, 0, 0);
215 dialog_layout->StartRow(0, 0); 214 dialog_layout->StartRow(0, 0);
216 dialog_layout->AddView(prompt_label, 1, 1, views::GridLayout::FILL, 215 dialog_layout->AddView(prompt_label, 1, 1, views::GridLayout::FILL,
217 views::GridLayout::FILL, 0, 0); 216 views::GridLayout::FILL, 0, 0);
218 217
219 // Use a new column set for the explanation label so we can add padding. 218 // Use a new column set for the explanation label so we can add padding.
220 dialog_layout->AddPaddingRow(0.0, views::kPanelVertMargin); 219 dialog_layout->AddPaddingRow(0.0, dialog_insets.top());
221 views::ColumnSet* explanation_columns = dialog_layout->AddColumnSet(1); 220 views::ColumnSet* explanation_columns = dialog_layout->AddColumnSet(1);
222 explanation_columns->AddPaddingColumn(0.0, views::kButtonHEdgeMarginNew); 221
222 explanation_columns->AddPaddingColumn(0.0, dialog_insets.left());
223 explanation_columns->AddColumn(views::GridLayout::FILL, 223 explanation_columns->AddColumn(views::GridLayout::FILL,
224 views::GridLayout::FILL, 100, 224 views::GridLayout::FILL, 100,
225 views::GridLayout::USE_PREF, 0, 0); 225 views::GridLayout::USE_PREF, 0, 0);
226 explanation_columns->AddPaddingColumn(0.0, views::kButtonHEdgeMarginNew); 226 explanation_columns->AddPaddingColumn(0.0, dialog_insets.right());
227 dialog_layout->StartRow(0, 1); 227 dialog_layout->StartRow(0, 1);
228 const int kPreferredWidth = 440; 228 const int kPreferredWidth = 440;
229 dialog_layout->AddView(explanation_label, 1, 1, views::GridLayout::FILL, 229 dialog_layout->AddView(explanation_label, 1, 1, views::GridLayout::FILL,
230 views::GridLayout::FILL, kPreferredWidth, 230 views::GridLayout::FILL, kPreferredWidth,
231 explanation_label->GetHeightForWidth(kPreferredWidth)); 231 explanation_label->GetHeightForWidth(kPreferredWidth));
232 refresh_timer_.Start(FROM_HERE, 232 refresh_timer_.Start(FROM_HERE,
233 base::TimeDelta::FromSeconds(kRefreshTitleTimer), this, 233 base::TimeDelta::FromSeconds(kRefreshTitleTimer), this,
234 &ForcedReauthenticationDialog::OnCountDown); 234 &ForcedReauthenticationDialog::OnCountDown);
235 } 235 }
236 236
237 void ForcedReauthenticationDialog::OnCountDown() { 237 void ForcedReauthenticationDialog::OnCountDown() {
238 if (desired_close_time_ <= base::TimeTicks::Now()) { 238 if (desired_close_time_ <= base::TimeTicks::Now()) {
239 Cancel(); 239 Cancel();
240 GetWidget()->Close(); 240 GetWidget()->Close();
241 } 241 }
242 GetWidget()->UpdateWindowTitle(); 242 GetWidget()->UpdateWindowTitle();
243 } 243 }
244 244
245 base::TimeDelta ForcedReauthenticationDialog::GetTimeRemaining() const { 245 base::TimeDelta ForcedReauthenticationDialog::GetTimeRemaining() const {
246 base::TimeTicks now = base::TimeTicks::Now(); 246 base::TimeTicks now = base::TimeTicks::Now();
247 if (desired_close_time_ <= now) 247 if (desired_close_time_ <= now)
248 return base::TimeDelta(); 248 return base::TimeDelta();
249 return desired_close_time_ - now; 249 return desired_close_time_ - now;
250 } 250 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/chrome_cleaner_dialog_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698