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

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

Issue 2517843002: Http Bad: Put icon on the left of http warning message on Views (Closed)
Patch Set: fix mac Created 4 years 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
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/autofill_popup_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 320 }
321 321
322 #if !defined(OS_ANDROID) 322 #if !defined(OS_ANDROID)
323 int AutofillPopupControllerImpl::GetElidedValueWidthForRow(size_t row) { 323 int AutofillPopupControllerImpl::GetElidedValueWidthForRow(size_t row) {
324 return gfx::GetStringWidth(GetElidedValueAt(row), 324 return gfx::GetStringWidth(GetElidedValueAt(row),
325 layout_model_.GetValueFontListForRow(row)); 325 layout_model_.GetValueFontListForRow(row));
326 } 326 }
327 327
328 int AutofillPopupControllerImpl::GetElidedLabelWidthForRow(size_t row) { 328 int AutofillPopupControllerImpl::GetElidedLabelWidthForRow(size_t row) {
329 return gfx::GetStringWidth(GetElidedLabelAt(row), 329 return gfx::GetStringWidth(GetElidedLabelAt(row),
330 layout_model_.GetLabelFontList()); 330 layout_model_.GetLabelFontListForRow(row));
331 } 331 }
332 #endif 332 #endif
333 333
334 size_t AutofillPopupControllerImpl::GetLineCount() const { 334 size_t AutofillPopupControllerImpl::GetLineCount() const {
335 return suggestions_.size(); 335 return suggestions_.size();
336 } 336 }
337 337
338 const autofill::Suggestion& AutofillPopupControllerImpl::GetSuggestionAt( 338 const autofill::Suggestion& AutofillPopupControllerImpl::GetSuggestionAt(
339 size_t row) const { 339 size_t row) const {
340 return suggestions_[row]; 340 return suggestions_[row];
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 WeakPtr<AutofillPopupControllerImpl> AutofillPopupControllerImpl::GetWeakPtr() { 503 WeakPtr<AutofillPopupControllerImpl> AutofillPopupControllerImpl::GetWeakPtr() {
504 return weak_ptr_factory_.GetWeakPtr(); 504 return weak_ptr_factory_.GetWeakPtr();
505 } 505 }
506 506
507 #if !defined(OS_ANDROID) 507 #if !defined(OS_ANDROID)
508 void AutofillPopupControllerImpl::ElideValueAndLabelForRow( 508 void AutofillPopupControllerImpl::ElideValueAndLabelForRow(
509 size_t row, 509 size_t row,
510 int available_width) { 510 int available_width) {
511 int value_width = gfx::GetStringWidth( 511 int value_width = gfx::GetStringWidth(
512 suggestions_[row].value, layout_model_.GetValueFontListForRow(row)); 512 suggestions_[row].value, layout_model_.GetValueFontListForRow(row));
513 int label_width = gfx::GetStringWidth(suggestions_[row].label, 513 int label_width = gfx::GetStringWidth(
514 layout_model_.GetLabelFontList()); 514 suggestions_[row].label, layout_model_.GetLabelFontListForRow(row));
515 int total_text_length = value_width + label_width; 515 int total_text_length = value_width + label_width;
516 516
517 // The line can have no strings if it represents a UI element, such as 517 // The line can have no strings if it represents a UI element, such as
518 // a separator line. 518 // a separator line.
519 if (total_text_length == 0) 519 if (total_text_length == 0)
520 return; 520 return;
521 521
522 // Each field receives space in proportion to its length. 522 // Each field receives space in proportion to its length.
523 int value_size = available_width * value_width / total_text_length; 523 int value_size = available_width * value_width / total_text_length;
524 elided_values_[row] = gfx::ElideText( 524 elided_values_[row] = gfx::ElideText(
525 suggestions_[row].value, layout_model_.GetValueFontListForRow(row), 525 suggestions_[row].value, layout_model_.GetValueFontListForRow(row),
526 value_size, gfx::ELIDE_TAIL); 526 value_size, gfx::ELIDE_TAIL);
527 527
528 int label_size = available_width * label_width / total_text_length; 528 int label_size = available_width * label_width / total_text_length;
529 elided_labels_[row] = 529 elided_labels_[row] = gfx::ElideText(
530 gfx::ElideText(suggestions_[row].label, layout_model_.GetLabelFontList(), 530 suggestions_[row].label, layout_model_.GetLabelFontListForRow(row),
531 label_size, gfx::ELIDE_TAIL); 531 label_size, gfx::ELIDE_TAIL);
532 } 532 }
533 #endif 533 #endif
534 534
535 void AutofillPopupControllerImpl::ClearState() { 535 void AutofillPopupControllerImpl::ClearState() {
536 // Don't clear view_, because otherwise the popup will have to get regenerated 536 // Don't clear view_, because otherwise the popup will have to get regenerated
537 // and this will cause flickering. 537 // and this will cause flickering.
538 suggestions_.clear(); 538 suggestions_.clear();
539 elided_values_.clear(); 539 elided_values_.clear();
540 elided_labels_.clear(); 540 elided_labels_.clear();
541 541
542 selected_line_ = kNoSelection; 542 selected_line_ = kNoSelection;
543 } 543 }
544 544
545 } // namespace autofill 545 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698