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 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 if (previous.get() && previous->element_bounds() == bounds && | 55 if (previous.get() && previous->element_bounds() == bounds && |
56 previous->web_contents_ == web_contents && | 56 previous->web_contents_ == web_contents && |
57 previous->container_view() == container_view) { | 57 previous->container_view() == container_view) { |
58 return previous; | 58 return previous; |
59 } | 59 } |
60 | 60 |
61 if (previous.get()) | 61 if (previous.get()) |
62 previous->Hide(); | 62 previous->Hide(); |
63 | 63 |
64 PasswordGenerationPopupControllerImpl* controller = | 64 PasswordGenerationPopupControllerImpl* controller = |
65 new PasswordGenerationPopupControllerImpl( | 65 new PasswordGenerationPopupControllerImpl(bounds, form, max_length, |
66 bounds, form, max_length, password_manager, driver, observer, | 66 driver, observer, web_contents, |
67 web_contents, container_view); | 67 container_view); |
68 return controller->GetWeakPtr(); | 68 return controller->GetWeakPtr(); |
69 } | 69 } |
70 | 70 |
71 PasswordGenerationPopupControllerImpl::PasswordGenerationPopupControllerImpl( | 71 PasswordGenerationPopupControllerImpl::PasswordGenerationPopupControllerImpl( |
72 const gfx::RectF& bounds, | 72 const gfx::RectF& bounds, |
73 const PasswordForm& form, | 73 const PasswordForm& form, |
74 int max_length, | 74 int max_length, |
75 password_manager::PasswordManager* password_manager, | |
76 password_manager::PasswordManagerDriver* driver, | 75 password_manager::PasswordManagerDriver* driver, |
77 PasswordGenerationPopupObserver* observer, | 76 PasswordGenerationPopupObserver* observer, |
78 content::WebContents* web_contents, | 77 content::WebContents* web_contents, |
79 gfx::NativeView container_view) | 78 gfx::NativeView container_view) |
80 : view_(NULL), | 79 : view_(NULL), |
81 form_(form), | 80 form_(form), |
82 password_manager_(password_manager), | |
83 driver_(driver), | 81 driver_(driver), |
84 observer_(observer), | 82 observer_(observer), |
85 generator_(new PasswordGenerator(max_length)), | 83 generator_(new PasswordGenerator(max_length)), |
86 // TODO(estade): use correct text direction. | 84 // TODO(estade): use correct text direction. |
87 controller_common_(bounds, base::i18n::LEFT_TO_RIGHT, container_view), | 85 controller_common_(bounds, base::i18n::LEFT_TO_RIGHT, container_view), |
88 password_selected_(false), | 86 password_selected_(false), |
89 display_password_(false), | 87 display_password_(false), |
90 web_contents_(web_contents), | 88 web_contents_(web_contents), |
91 weak_ptr_factory_(this) { | 89 weak_ptr_factory_(this) { |
92 base::string16 link = | 90 base::string16 link = |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 password_selected_ = selected; | 139 password_selected_ = selected; |
142 view_->PasswordSelectionUpdated(); | 140 view_->PasswordSelectionUpdated(); |
143 view_->UpdateBoundsAndRedrawPopup(); | 141 view_->UpdateBoundsAndRedrawPopup(); |
144 } | 142 } |
145 | 143 |
146 void PasswordGenerationPopupControllerImpl::PasswordAccepted() { | 144 void PasswordGenerationPopupControllerImpl::PasswordAccepted() { |
147 if (!display_password_) | 145 if (!display_password_) |
148 return; | 146 return; |
149 | 147 |
150 driver_->GeneratedPasswordAccepted(current_password_); | 148 driver_->GeneratedPasswordAccepted(current_password_); |
151 password_manager_->SetHasGeneratedPasswordForForm(driver_, form_, true); | |
152 Hide(); | 149 Hide(); |
153 } | 150 } |
154 | 151 |
155 int PasswordGenerationPopupControllerImpl::GetMinimumWidth() { | 152 int PasswordGenerationPopupControllerImpl::GetMinimumWidth() { |
156 // Minimum width in pixels. | 153 // Minimum width in pixels. |
157 const int minimum_width = 350; | 154 const int minimum_width = 350; |
158 | 155 |
159 // If the width of the field is longer than the minimum, use that instead. | 156 // If the width of the field is longer than the minimum, use that instead. |
160 return std::max(minimum_width, | 157 return std::max(minimum_width, |
161 gfx::ToEnclosingRect(element_bounds()).width()); | 158 gfx::ToEnclosingRect(element_bounds()).width()); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 299 |
303 const base::string16& PasswordGenerationPopupControllerImpl::HelpText() { | 300 const base::string16& PasswordGenerationPopupControllerImpl::HelpText() { |
304 return help_text_; | 301 return help_text_; |
305 } | 302 } |
306 | 303 |
307 const gfx::Range& PasswordGenerationPopupControllerImpl::HelpTextLinkRange() { | 304 const gfx::Range& PasswordGenerationPopupControllerImpl::HelpTextLinkRange() { |
308 return link_range_; | 305 return link_range_; |
309 } | 306 } |
310 | 307 |
311 } // namespace autofill | 308 } // namespace autofill |
OLD | NEW |