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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/browser_dialogs.h" | 11 #include "chrome/browser/ui/browser_dialogs.h" |
12 #include "chrome/browser/ui/browser_navigator.h" | 12 #include "chrome/browser/ui/browser_navigator.h" |
13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
14 #include "chrome/browser/ui/host_desktop.h" | 14 #include "chrome/browser/ui/host_desktop.h" |
15 #include "chrome/browser/ui/views/constrained_window_views.h" | 15 #include "chrome/browser/ui/views/constrained_window_views.h" |
16 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 16 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
17 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | 17 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
19 #include "content/public/browser/web_contents_view.h" | 19 #include "content/public/browser/web_contents_view.h" |
20 #include "google_apis/gaia/gaia_auth_util.h" | 20 #include "google_apis/gaia/gaia_auth_util.h" |
21 #include "grit/chromium_strings.h" | 21 #include "grit/chromium_strings.h" |
22 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
23 #include "third_party/skia/include/core/SkColor.h" | 23 #include "third_party/skia/include/core/SkColor.h" |
24 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
25 #include "ui/base/range/range.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" |
| 27 #include "ui/gfx/range/range.h" |
28 #include "ui/views/background.h" | 28 #include "ui/views/background.h" |
29 #include "ui/views/controls/label.h" | 29 #include "ui/views/controls/label.h" |
30 #include "ui/views/controls/styled_label.h" | 30 #include "ui/views/controls/styled_label.h" |
31 #include "ui/views/layout/box_layout.h" | 31 #include "ui/views/layout/box_layout.h" |
32 #include "ui/views/layout/grid_layout.h" | 32 #include "ui/views/layout/grid_layout.h" |
33 #include "ui/views/layout/layout_constants.h" | 33 #include "ui/views/layout/layout_constants.h" |
34 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
35 #include "ui/views/window/dialog_client_view.h" | 35 #include "ui/views/window/dialog_client_view.h" |
36 | 36 |
37 namespace chrome { | 37 namespace chrome { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 const string16 prompt_text = | 164 const string16 prompt_text = |
165 l10n_util::GetStringFUTF16( | 165 l10n_util::GetStringFUTF16( |
166 IDS_ENTERPRISE_SIGNIN_ALERT_NEW_STYLE, | 166 IDS_ENTERPRISE_SIGNIN_ALERT_NEW_STYLE, |
167 domain, &offset); | 167 domain, &offset); |
168 views::StyledLabel* prompt_label = new views::StyledLabel(prompt_text, this); | 168 views::StyledLabel* prompt_label = new views::StyledLabel(prompt_text, this); |
169 prompt_label->SetDisplayedOnBackgroundColor(kPromptBarBackgroundColor); | 169 prompt_label->SetDisplayedOnBackgroundColor(kPromptBarBackgroundColor); |
170 | 170 |
171 views::StyledLabel::RangeStyleInfo bold_style; | 171 views::StyledLabel::RangeStyleInfo bold_style; |
172 bold_style.font_style = gfx::Font::BOLD; | 172 bold_style.font_style = gfx::Font::BOLD; |
173 prompt_label->AddStyleRange( | 173 prompt_label->AddStyleRange( |
174 ui::Range(offset, offset + domain.size()), bold_style); | 174 gfx::Range(offset, offset + domain.size()), bold_style); |
175 | 175 |
176 // Create the prompt bar. | 176 // Create the prompt bar. |
177 views::View* prompt_bar = new views::View; | 177 views::View* prompt_bar = new views::View; |
178 prompt_bar->set_border( | 178 prompt_bar->set_border( |
179 views::Border::CreateSolidSidedBorder( | 179 views::Border::CreateSolidSidedBorder( |
180 1, 0, 1, 0, | 180 1, 0, 1, 0, |
181 ui::GetSigninConfirmationPromptBarColor( | 181 ui::GetSigninConfirmationPromptBarColor( |
182 ui::kSigninConfirmationPromptBarBorderAlpha))); | 182 ui::kSigninConfirmationPromptBarBorderAlpha))); |
183 prompt_bar->set_background(views::Background::CreateSolidBackground( | 183 prompt_bar->set_background(views::Background::CreateSolidBackground( |
184 kPromptBarBackgroundColor)); | 184 kPromptBarBackgroundColor)); |
185 | 185 |
186 // Create the explanation label. | 186 // Create the explanation label. |
187 std::vector<size_t> offsets; | 187 std::vector<size_t> offsets; |
188 const string16 learn_more_text = | 188 const string16 learn_more_text = |
189 l10n_util::GetStringUTF16( | 189 l10n_util::GetStringUTF16( |
190 IDS_ENTERPRISE_SIGNIN_PROFILE_LINK_LEARN_MORE); | 190 IDS_ENTERPRISE_SIGNIN_PROFILE_LINK_LEARN_MORE); |
191 const string16 signin_explanation_text = | 191 const string16 signin_explanation_text = |
192 l10n_util::GetStringFUTF16(prompt_for_new_profile_ ? | 192 l10n_util::GetStringFUTF16(prompt_for_new_profile_ ? |
193 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITH_PROFILE_CREATION_NEW_STYLE : | 193 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITH_PROFILE_CREATION_NEW_STYLE : |
194 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITHOUT_PROFILE_CREATION_NEW_STYLE, | 194 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITHOUT_PROFILE_CREATION_NEW_STYLE, |
195 username, learn_more_text, &offsets); | 195 username, learn_more_text, &offsets); |
196 explanation_label_ = new views::StyledLabel(signin_explanation_text, this); | 196 explanation_label_ = new views::StyledLabel(signin_explanation_text, this); |
197 explanation_label_->AddStyleRange( | 197 explanation_label_->AddStyleRange( |
198 ui::Range(offsets[1], offsets[1] + learn_more_text.size()), | 198 gfx::Range(offsets[1], offsets[1] + learn_more_text.size()), |
199 views::StyledLabel::RangeStyleInfo::CreateForLink()); | 199 views::StyledLabel::RangeStyleInfo::CreateForLink()); |
200 | 200 |
201 // Layout the components. | 201 // Layout the components. |
202 views::GridLayout* dialog_layout = new views::GridLayout(this); | 202 views::GridLayout* dialog_layout = new views::GridLayout(this); |
203 SetLayoutManager(dialog_layout); | 203 SetLayoutManager(dialog_layout); |
204 | 204 |
205 // Use GridLayout inside the prompt bar because StyledLabel requires it. | 205 // Use GridLayout inside the prompt bar because StyledLabel requires it. |
206 views::GridLayout* prompt_layout = views::GridLayout::CreatePanel(prompt_bar); | 206 views::GridLayout* prompt_layout = views::GridLayout::CreatePanel(prompt_bar); |
207 prompt_bar->SetLayoutManager(prompt_layout); | 207 prompt_bar->SetLayoutManager(prompt_layout); |
208 prompt_layout->AddColumnSet(0)->AddColumn( | 208 prompt_layout->AddColumnSet(0)->AddColumn( |
(...skipping 20 matching lines...) Expand all Loading... |
229 explanation_columns->AddPaddingColumn(0.0, views::kButtonHEdgeMarginNew); | 229 explanation_columns->AddPaddingColumn(0.0, views::kButtonHEdgeMarginNew); |
230 dialog_layout->StartRow(0, 1); | 230 dialog_layout->StartRow(0, 1); |
231 const int kPreferredWidth = 440; | 231 const int kPreferredWidth = 440; |
232 dialog_layout->AddView( | 232 dialog_layout->AddView( |
233 explanation_label_, 1, 1, | 233 explanation_label_, 1, 1, |
234 views::GridLayout::FILL, views::GridLayout::FILL, | 234 views::GridLayout::FILL, views::GridLayout::FILL, |
235 kPreferredWidth, explanation_label_->GetHeightForWidth(kPreferredWidth)); | 235 kPreferredWidth, explanation_label_->GetHeightForWidth(kPreferredWidth)); |
236 } | 236 } |
237 | 237 |
238 void ProfileSigninConfirmationDialogViews::StyledLabelLinkClicked( | 238 void ProfileSigninConfirmationDialogViews::StyledLabelLinkClicked( |
239 const ui::Range& range, | 239 const gfx::Range& range, |
240 int event_flags) { | 240 int event_flags) { |
241 chrome::NavigateParams params( | 241 chrome::NavigateParams params( |
242 browser_, | 242 browser_, |
243 GURL("http://support.google.com/chromeos/bin/answer.py?answer=1331549"), | 243 GURL("http://support.google.com/chromeos/bin/answer.py?answer=1331549"), |
244 content::PAGE_TRANSITION_LINK); | 244 content::PAGE_TRANSITION_LINK); |
245 params.disposition = NEW_POPUP; | 245 params.disposition = NEW_POPUP; |
246 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 246 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
247 chrome::Navigate(¶ms); | 247 chrome::Navigate(¶ms); |
248 } | 248 } |
249 | 249 |
250 void ProfileSigninConfirmationDialogViews::ButtonPressed( | 250 void ProfileSigninConfirmationDialogViews::ButtonPressed( |
251 views::Button* sender, | 251 views::Button* sender, |
252 const ui::Event& event) { | 252 const ui::Event& event) { |
253 DCHECK(prompt_for_new_profile_); | 253 DCHECK(prompt_for_new_profile_); |
254 DCHECK_EQ(continue_signin_button_, sender); | 254 DCHECK_EQ(continue_signin_button_, sender); |
255 if (delegate_) { | 255 if (delegate_) { |
256 delegate_->OnContinueSignin(); | 256 delegate_->OnContinueSignin(); |
257 delegate_ = NULL; | 257 delegate_ = NULL; |
258 } | 258 } |
259 GetWidget()->Close(); | 259 GetWidget()->Close(); |
260 } | 260 } |
OLD | NEW |