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

Side by Side Diff: chrome/browser/ui/autofill/password_generation_popup_controller_impl.cc

Issue 1570783003: [Autofill] Move functions from the AutofillPopupController to AutofillPopupLayoutModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed nit Created 4 years, 11 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
OLDNEW
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"
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversion_utils.h" 13 #include "base/strings/utf_string_conversion_utils.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/sync/profile_sync_service_factory.h" 16 #include "chrome/browser/sync/profile_sync_service_factory.h"
17 #include "chrome/browser/ui/autofill/password_generation_popup_observer.h" 17 #include "chrome/browser/ui/autofill/password_generation_popup_observer.h"
18 #include "chrome/browser/ui/autofill/password_generation_popup_view.h" 18 #include "chrome/browser/ui/autofill/password_generation_popup_view.h"
19 #include "chrome/browser/ui/autofill/popup_constants.h" 19 #include "chrome/browser/ui/autofill/popup_constants.h"
20 #include "chrome/browser/ui/browser_finder.h" 20 #include "chrome/browser/ui/browser_finder.h"
21 #include "chrome/browser/ui/chrome_pages.h" 21 #include "chrome/browser/ui/chrome_pages.h"
22 #include "chrome/common/features.h" 22 #include "chrome/common/features.h"
23 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
24 #include "chrome/grit/chromium_strings.h" 24 #include "chrome/grit/chromium_strings.h"
25 #include "chrome/grit/generated_resources.h" 25 #include "chrome/grit/generated_resources.h"
26 #include "components/autofill/content/common/autofill_messages.h" 26 #include "components/autofill/content/common/autofill_messages.h"
27 #include "components/autofill/core/browser/password_generator.h" 27 #include "components/autofill/core/browser/password_generator.h"
28 #include "components/autofill/core/browser/suggestion.h"
28 #include "components/browser_sync/browser/profile_sync_service.h" 29 #include "components/browser_sync/browser/profile_sync_service.h"
29 #include "components/password_manager/core/browser/password_bubble_experiment.h" 30 #include "components/password_manager/core/browser/password_bubble_experiment.h"
30 #include "components/password_manager/core/browser/password_manager.h" 31 #include "components/password_manager/core/browser/password_manager.h"
31 #include "content/public/browser/native_web_keyboard_event.h" 32 #include "content/public/browser/native_web_keyboard_event.h"
32 #include "content/public/browser/render_view_host.h" 33 #include "content/public/browser/render_view_host.h"
33 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
34 #include "ui/base/l10n/l10n_util.h" 35 #include "ui/base/l10n/l10n_util.h"
35 #include "ui/events/keycodes/keyboard_codes.h" 36 #include "ui/events/keycodes/keyboard_codes.h"
36 #include "ui/gfx/geometry/rect_conversions.h" 37 #include "ui/gfx/geometry/rect_conversions.h"
37 #include "ui/gfx/text_utils.h" 38 #include "ui/gfx/text_utils.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 password_manager_->SetHasGeneratedPasswordForForm(driver_, form_, true); 168 password_manager_->SetHasGeneratedPasswordForForm(driver_, form_, true);
168 Hide(); 169 Hide();
169 } 170 }
170 171
171 int PasswordGenerationPopupControllerImpl::GetMinimumWidth() { 172 int PasswordGenerationPopupControllerImpl::GetMinimumWidth() {
172 // Minimum width in pixels. 173 // Minimum width in pixels.
173 const int minimum_width = 350; 174 const int minimum_width = 350;
174 175
175 // If the width of the field is longer than the minimum, use that instead. 176 // If the width of the field is longer than the minimum, use that instead.
176 return std::max(minimum_width, 177 return std::max(minimum_width,
177 controller_common_.RoundedElementBounds().width()); 178 gfx::ToEnclosingRect(element_bounds()).width());
178 } 179 }
179 180
180 void PasswordGenerationPopupControllerImpl::CalculateBounds() { 181 void PasswordGenerationPopupControllerImpl::CalculateBounds() {
181 gfx::Size bounds = view_->GetPreferredSizeOfPasswordView(); 182 gfx::Size bounds = view_->GetPreferredSizeOfPasswordView();
182 183
183 popup_bounds_ = controller_common_.GetPopupBounds(bounds.width(), 184 popup_bounds_ = view_common_.CalculatePopupBounds(
184 bounds.height()); 185 bounds.width(), bounds.height(), gfx::ToEnclosingRect(element_bounds()),
186 container_view(), IsRTL());
185 } 187 }
186 188
187 void PasswordGenerationPopupControllerImpl::Show(bool display_password) { 189 void PasswordGenerationPopupControllerImpl::Show(bool display_password) {
188 display_password_ = display_password; 190 display_password_ = display_password;
189 if (display_password_ && current_password_.empty()) 191 if (display_password_ && current_password_.empty())
190 current_password_ = base::ASCIIToUTF16(generator_->Generate()); 192 current_password_ = base::ASCIIToUTF16(generator_->Generate());
191 193
192 if (!view_) { 194 if (!view_) {
193 view_ = PasswordGenerationPopupView::Create(this); 195 view_ = PasswordGenerationPopupView::Create(this);
194 196
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 259 }
258 260
259 void PasswordGenerationPopupControllerImpl::SelectionCleared() { 261 void PasswordGenerationPopupControllerImpl::SelectionCleared() {
260 PasswordSelected(false); 262 PasswordSelected(false);
261 } 263 }
262 264
263 gfx::NativeView PasswordGenerationPopupControllerImpl::container_view() { 265 gfx::NativeView PasswordGenerationPopupControllerImpl::container_view() {
264 return controller_common_.container_view(); 266 return controller_common_.container_view();
265 } 267 }
266 268
267 const gfx::Rect& PasswordGenerationPopupControllerImpl::popup_bounds() const { 269 gfx::Rect PasswordGenerationPopupControllerImpl::popup_bounds() const {
268 return popup_bounds_; 270 return popup_bounds_;
269 } 271 }
270 272
271 const gfx::RectF& PasswordGenerationPopupControllerImpl::element_bounds() 273 const gfx::RectF& PasswordGenerationPopupControllerImpl::element_bounds()
272 const { 274 const {
273 return controller_common_.element_bounds(); 275 return controller_common_.element_bounds();
274 } 276 }
275 277
276 bool PasswordGenerationPopupControllerImpl::IsRTL() const { 278 bool PasswordGenerationPopupControllerImpl::IsRTL() const {
277 return base::i18n::IsRTL(); 279 return base::i18n::IsRTL();
278 } 280 }
279 281
282 const std::vector<autofill::Suggestion>
283 PasswordGenerationPopupControllerImpl::GetSuggestions() {
284 return std::vector<autofill::Suggestion>();
285 }
286
287 #if !defined(OS_ANDROID)
288 int PasswordGenerationPopupControllerImpl::GetElidedValueWidthForRow(
289 size_t row) {
290 return 0;
291 }
292
293 int PasswordGenerationPopupControllerImpl::GetElidedLabelWidthForRow(
294 size_t row) {
295 return 0;
296 }
297 #endif
298
280 bool PasswordGenerationPopupControllerImpl::display_password() const { 299 bool PasswordGenerationPopupControllerImpl::display_password() const {
281 return display_password_; 300 return display_password_;
282 } 301 }
283 302
284 bool PasswordGenerationPopupControllerImpl::password_selected() const { 303 bool PasswordGenerationPopupControllerImpl::password_selected() const {
285 return password_selected_; 304 return password_selected_;
286 } 305 }
287 306
288 base::string16 PasswordGenerationPopupControllerImpl::password() const { 307 base::string16 PasswordGenerationPopupControllerImpl::password() const {
289 return current_password_; 308 return current_password_;
290 } 309 }
291 310
292 base::string16 PasswordGenerationPopupControllerImpl::SuggestedText() { 311 base::string16 PasswordGenerationPopupControllerImpl::SuggestedText() {
293 return l10n_util::GetStringUTF16(IDS_PASSWORD_GENERATION_SUGGESTION); 312 return l10n_util::GetStringUTF16(IDS_PASSWORD_GENERATION_SUGGESTION);
294 } 313 }
295 314
296 const base::string16& PasswordGenerationPopupControllerImpl::HelpText() { 315 const base::string16& PasswordGenerationPopupControllerImpl::HelpText() {
297 return help_text_; 316 return help_text_;
298 } 317 }
299 318
300 const gfx::Range& PasswordGenerationPopupControllerImpl::HelpTextLinkRange() { 319 const gfx::Range& PasswordGenerationPopupControllerImpl::HelpTextLinkRange() {
301 return link_range_; 320 return link_range_;
302 } 321 }
303 322
304 } // namespace autofill 323 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698