Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/autofill/password_generation_popup_controller_impl.h " | 5 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h " |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversion_utils.h" | 9 #include "base/strings/utf_string_conversion_utils.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 switch (event.windowsKeyCode) { | 98 switch (event.windowsKeyCode) { |
| 99 case ui::VKEY_UP: | 99 case ui::VKEY_UP: |
| 100 case ui::VKEY_DOWN: | 100 case ui::VKEY_DOWN: |
| 101 PasswordSelected(true); | 101 PasswordSelected(true); |
| 102 return true; | 102 return true; |
| 103 case ui::VKEY_ESCAPE: | 103 case ui::VKEY_ESCAPE: |
| 104 Hide(); | 104 Hide(); |
| 105 return true; | 105 return true; |
| 106 case ui::VKEY_RETURN: | 106 case ui::VKEY_RETURN: |
| 107 case ui::VKEY_TAB: | 107 case ui::VKEY_TAB: |
| 108 // We supress tab if the password is selected because we will | 108 // We suppress tab if the password is selected because we will |
| 109 // automatically advance focus anyway. | 109 // automatically advance focus anyway. |
| 110 return PossiblyAcceptPassword(); | 110 return PossiblyAcceptPassword(); |
| 111 default: | 111 default: |
| 112 return false; | 112 return false; |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool PasswordGenerationPopupControllerImpl::PossiblyAcceptPassword() { | 116 bool PasswordGenerationPopupControllerImpl::PossiblyAcceptPassword() { |
| 117 if (password_selected_) | 117 if (password_selected_) { |
| 118 PasswordAccepted(); | 118 PasswordAccepted(); // This will delete |this| |
|
Evan Stade
2014/01/31 22:39:57
nit: final punctuation.
Garrett Casto
2014/01/31 22:58:00
Done.
| |
| 119 return true; | |
| 120 } | |
| 119 | 121 |
| 120 return password_selected_; | 122 return false; |
| 121 } | 123 } |
| 122 | 124 |
| 123 void PasswordGenerationPopupControllerImpl::PasswordSelected(bool selected) { | 125 void PasswordGenerationPopupControllerImpl::PasswordSelected(bool selected) { |
| 124 password_selected_ = selected; | 126 password_selected_ = selected; |
| 125 view_->UpdateBoundsAndRedrawPopup(); | 127 view_->UpdateBoundsAndRedrawPopup(); |
| 126 } | 128 } |
| 127 | 129 |
| 128 void PasswordGenerationPopupControllerImpl::PasswordAccepted() { | 130 void PasswordGenerationPopupControllerImpl::PasswordAccepted() { |
| 129 web_contents()->GetRenderViewHost()->Send( | 131 web_contents()->GetRenderViewHost()->Send( |
| 130 new AutofillMsg_GeneratedPasswordAccepted( | 132 new AutofillMsg_GeneratedPasswordAccepted( |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 view_ = PasswordGenerationPopupView::Create(this); | 202 view_ = PasswordGenerationPopupView::Create(this); |
| 201 view_->Show(); | 203 view_->Show(); |
| 202 } | 204 } |
| 203 | 205 |
| 204 controller_common_.RegisterKeyPressCallback(); | 206 controller_common_.RegisterKeyPressCallback(); |
| 205 | 207 |
| 206 if (observer_) | 208 if (observer_) |
| 207 observer_->OnPopupShown(); | 209 observer_->OnPopupShown(); |
| 208 } | 210 } |
| 209 | 211 |
| 212 void PasswordGenerationPopupControllerImpl::HideAndDestroy() { | |
| 213 Hide(); | |
| 214 } | |
| 215 | |
| 210 void PasswordGenerationPopupControllerImpl::Hide() { | 216 void PasswordGenerationPopupControllerImpl::Hide() { |
| 211 controller_common_.RemoveKeyPressCallback(); | 217 controller_common_.RemoveKeyPressCallback(); |
| 212 | 218 |
| 213 if (view_) | 219 if (view_) |
| 214 view_->Hide(); | 220 view_->Hide(); |
| 215 | 221 |
| 216 if (observer_) | 222 if (observer_) |
| 217 observer_->OnPopupHidden(); | 223 observer_->OnPopupHidden(); |
| 218 | 224 |
| 219 delete this; | 225 delete this; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 | 298 |
| 293 base::string16 PasswordGenerationPopupControllerImpl::HelpText() { | 299 base::string16 PasswordGenerationPopupControllerImpl::HelpText() { |
| 294 return l10n_util::GetStringUTF16(IDS_PASSWORD_GENERATION_PROMPT); | 300 return l10n_util::GetStringUTF16(IDS_PASSWORD_GENERATION_PROMPT); |
| 295 } | 301 } |
| 296 | 302 |
| 297 base::string16 PasswordGenerationPopupControllerImpl::LearnMoreLink() { | 303 base::string16 PasswordGenerationPopupControllerImpl::LearnMoreLink() { |
| 298 return l10n_util::GetStringUTF16(IDS_PASSWORD_GENERATION_LEARN_MORE_LINK); | 304 return l10n_util::GetStringUTF16(IDS_PASSWORD_GENERATION_LEARN_MORE_LINK); |
| 299 } | 305 } |
| 300 | 306 |
| 301 } // namespace autofill | 307 } // namespace autofill |
| OLD | NEW |