| 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 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 | 75 |
| 76 void ProfileSigninConfirmationDialogViews::Show(bool prompt_for_new_profile) { | 76 void ProfileSigninConfirmationDialogViews::Show(bool prompt_for_new_profile) { |
| 77 prompt_for_new_profile_ = prompt_for_new_profile; | 77 prompt_for_new_profile_ = prompt_for_new_profile; |
| 78 constrained_window::CreateBrowserModalDialogViews( | 78 constrained_window::CreateBrowserModalDialogViews( |
| 79 this, browser_->window()->GetNativeWindow())->Show(); | 79 this, browser_->window()->GetNativeWindow())->Show(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 base::string16 ProfileSigninConfirmationDialogViews::GetWindowTitle() const { | 82 base::string16 ProfileSigninConfirmationDialogViews::GetWindowTitle() const { |
| 83 return l10n_util::GetStringUTF16( | 83 return l10n_util::GetStringUTF16( |
| 84 IDS_ENTERPRISE_SIGNIN_TITLE_NEW_STYLE); | 84 IDS_ENTERPRISE_SIGNIN_TITLE); |
| 85 } | 85 } |
| 86 | 86 |
| 87 base::string16 ProfileSigninConfirmationDialogViews::GetDialogButtonLabel( | 87 base::string16 ProfileSigninConfirmationDialogViews::GetDialogButtonLabel( |
| 88 ui::DialogButton button) const { | 88 ui::DialogButton button) const { |
| 89 if (button == ui::DIALOG_BUTTON_OK) { | 89 if (button == ui::DIALOG_BUTTON_OK) { |
| 90 // If we're giving the option to create a new profile, then OK is | 90 // If we're giving the option to create a new profile, then OK is |
| 91 // "Create new profile". Otherwise it is "Continue signin". | 91 // "Create new profile". Otherwise it is "Continue signin". |
| 92 return l10n_util::GetStringUTF16( | 92 return l10n_util::GetStringUTF16( |
| 93 prompt_for_new_profile_ ? | 93 prompt_for_new_profile_ ? |
| 94 IDS_ENTERPRISE_SIGNIN_CREATE_NEW_PROFILE_NEW_STYLE : | 94 IDS_ENTERPRISE_SIGNIN_CREATE_NEW_PROFILE : |
| 95 IDS_ENTERPRISE_SIGNIN_CONTINUE_NEW_STYLE); | 95 IDS_ENTERPRISE_SIGNIN_CONTINUE); |
| 96 } | 96 } |
| 97 return l10n_util::GetStringUTF16(IDS_ENTERPRISE_SIGNIN_CANCEL); | 97 return l10n_util::GetStringUTF16(IDS_ENTERPRISE_SIGNIN_CANCEL); |
| 98 } | 98 } |
| 99 | 99 |
| 100 int ProfileSigninConfirmationDialogViews::GetDefaultDialogButton() const { | 100 int ProfileSigninConfirmationDialogViews::GetDefaultDialogButton() const { |
| 101 return ui::DIALOG_BUTTON_NONE; | 101 return ui::DIALOG_BUTTON_NONE; |
| 102 } | 102 } |
| 103 | 103 |
| 104 views::View* ProfileSigninConfirmationDialogViews::CreateExtraView() { | 104 views::View* ProfileSigninConfirmationDialogViews::CreateExtraView() { |
| 105 if (!prompt_for_new_profile_) | 105 if (!prompt_for_new_profile_) |
| 106 return nullptr; | 106 return nullptr; |
| 107 | 107 |
| 108 const base::string16 continue_signin_text = | 108 const base::string16 continue_signin_text = |
| 109 l10n_util::GetStringUTF16(IDS_ENTERPRISE_SIGNIN_CONTINUE_NEW_STYLE); | 109 l10n_util::GetStringUTF16(IDS_ENTERPRISE_SIGNIN_CONTINUE); |
| 110 return views::MdTextButton::CreateSecondaryUiButton(this, | 110 return views::MdTextButton::CreateSecondaryUiButton(this, |
| 111 continue_signin_text); | 111 continue_signin_text); |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool ProfileSigninConfirmationDialogViews::Accept() { | 114 bool ProfileSigninConfirmationDialogViews::Accept() { |
| 115 if (delegate_) { | 115 if (delegate_) { |
| 116 if (prompt_for_new_profile_) | 116 if (prompt_for_new_profile_) |
| 117 delegate_->OnSigninWithNewProfile(); | 117 delegate_->OnSigninWithNewProfile(); |
| 118 else | 118 else |
| 119 delegate_->OnContinueSignin(); | 119 delegate_->OnContinueSignin(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 144 ui::GetSigninConfirmationPromptBarColor( | 144 ui::GetSigninConfirmationPromptBarColor( |
| 145 GetNativeTheme(), ui::kSigninConfirmationPromptBarBackgroundAlpha); | 145 GetNativeTheme(), ui::kSigninConfirmationPromptBarBackgroundAlpha); |
| 146 | 146 |
| 147 // Create the prompt label. | 147 // Create the prompt label. |
| 148 size_t offset; | 148 size_t offset; |
| 149 const base::string16 domain = | 149 const base::string16 domain = |
| 150 base::ASCIIToUTF16(gaia::ExtractDomainName(username_)); | 150 base::ASCIIToUTF16(gaia::ExtractDomainName(username_)); |
| 151 const base::string16 username = base::ASCIIToUTF16(username_); | 151 const base::string16 username = base::ASCIIToUTF16(username_); |
| 152 const base::string16 prompt_text = | 152 const base::string16 prompt_text = |
| 153 l10n_util::GetStringFUTF16( | 153 l10n_util::GetStringFUTF16( |
| 154 IDS_ENTERPRISE_SIGNIN_ALERT_NEW_STYLE, | 154 IDS_ENTERPRISE_SIGNIN_ALERT, |
| 155 domain, &offset); | 155 domain, &offset); |
| 156 views::StyledLabel* prompt_label = new views::StyledLabel(prompt_text, this); | 156 views::StyledLabel* prompt_label = new views::StyledLabel(prompt_text, this); |
| 157 prompt_label->SetDisplayedOnBackgroundColor(kPromptBarBackgroundColor); | 157 prompt_label->SetDisplayedOnBackgroundColor(kPromptBarBackgroundColor); |
| 158 | 158 |
| 159 views::StyledLabel::RangeStyleInfo bold_style; | 159 views::StyledLabel::RangeStyleInfo bold_style; |
| 160 bold_style.weight = gfx::Font::Weight::BOLD; | 160 bold_style.weight = gfx::Font::Weight::BOLD; |
| 161 prompt_label->AddStyleRange( | 161 prompt_label->AddStyleRange( |
| 162 gfx::Range(offset, offset + domain.size()), bold_style); | 162 gfx::Range(offset, offset + domain.size()), bold_style); |
| 163 | 163 |
| 164 // Create the prompt bar. | 164 // Create the prompt bar. |
| 165 views::View* prompt_bar = new views::View; | 165 views::View* prompt_bar = new views::View; |
| 166 prompt_bar->SetBorder(views::CreateSolidSidedBorder( | 166 prompt_bar->SetBorder(views::CreateSolidSidedBorder( |
| 167 1, 0, 1, 0, | 167 1, 0, 1, 0, |
| 168 ui::GetSigninConfirmationPromptBarColor( | 168 ui::GetSigninConfirmationPromptBarColor( |
| 169 GetNativeTheme(), ui::kSigninConfirmationPromptBarBorderAlpha))); | 169 GetNativeTheme(), ui::kSigninConfirmationPromptBarBorderAlpha))); |
| 170 prompt_bar->set_background(views::Background::CreateSolidBackground( | 170 prompt_bar->set_background(views::Background::CreateSolidBackground( |
| 171 kPromptBarBackgroundColor)); | 171 kPromptBarBackgroundColor)); |
| 172 | 172 |
| 173 // Create the explanation label. | 173 // Create the explanation label. |
| 174 std::vector<size_t> offsets; | 174 std::vector<size_t> offsets; |
| 175 const base::string16 learn_more_text = | 175 const base::string16 learn_more_text = |
| 176 l10n_util::GetStringUTF16( | 176 l10n_util::GetStringUTF16( |
| 177 IDS_ENTERPRISE_SIGNIN_PROFILE_LINK_LEARN_MORE); | 177 IDS_ENTERPRISE_SIGNIN_PROFILE_LINK_LEARN_MORE); |
| 178 const base::string16 signin_explanation_text = | 178 const base::string16 signin_explanation_text = |
| 179 l10n_util::GetStringFUTF16(prompt_for_new_profile_ ? | 179 l10n_util::GetStringFUTF16(prompt_for_new_profile_ ? |
| 180 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITH_PROFILE_CREATION_NEW_STYLE : | 180 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITH_PROFILE_CREATION : |
| 181 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITHOUT_PROFILE_CREATION_NEW_STYLE, | 181 IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITHOUT_PROFILE_CREATION, |
| 182 username, learn_more_text, &offsets); | 182 username, learn_more_text, &offsets); |
| 183 views::StyledLabel* explanation_label = | 183 views::StyledLabel* explanation_label = |
| 184 new views::StyledLabel(signin_explanation_text, this); | 184 new views::StyledLabel(signin_explanation_text, this); |
| 185 explanation_label->AddStyleRange( | 185 explanation_label->AddStyleRange( |
| 186 gfx::Range(offsets[1], offsets[1] + learn_more_text.size()), | 186 gfx::Range(offsets[1], offsets[1] + learn_more_text.size()), |
| 187 views::StyledLabel::RangeStyleInfo::CreateForLink()); | 187 views::StyledLabel::RangeStyleInfo::CreateForLink()); |
| 188 | 188 |
| 189 // Layout the components. | 189 // Layout the components. |
| 190 views::GridLayout* dialog_layout = new views::GridLayout(this); | 190 views::GridLayout* dialog_layout = new views::GridLayout(this); |
| 191 dialog_layout->SetInsets(views::kPanelVertMargin, 0, 0, 0); | 191 dialog_layout->SetInsets(views::kPanelVertMargin, 0, 0, 0); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 void ProfileSigninConfirmationDialogViews::ButtonPressed( | 243 void ProfileSigninConfirmationDialogViews::ButtonPressed( |
| 244 views::Button* sender, | 244 views::Button* sender, |
| 245 const ui::Event& event) { | 245 const ui::Event& event) { |
| 246 DCHECK(prompt_for_new_profile_); | 246 DCHECK(prompt_for_new_profile_); |
| 247 if (delegate_) { | 247 if (delegate_) { |
| 248 delegate_->OnContinueSignin(); | 248 delegate_->OnContinueSignin(); |
| 249 delegate_ = NULL; | 249 delegate_ = NULL; |
| 250 } | 250 } |
| 251 GetWidget()->Close(); | 251 GetWidget()->Close(); |
| 252 } | 252 } |
| OLD | NEW |