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

Side by Side Diff: chrome/browser/ui/views/passwords/manage_password_item_view.cc

Issue 87853004: Refactoring Manage Passwords Bubble Code to exclude TabSpecificContentSettings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@movingclasses
Patch Set: Android fix Created 7 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
OLDNEW
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/passwords/manage_password_item_view.h" 5 #include "chrome/browser/ui/views/passwords/manage_password_item_view.h"
6 6
7 #include "grit/generated_resources.h" 7 #include "grit/generated_resources.h"
8 #include "grit/ui_resources.h" 8 #include "grit/ui_resources.h"
9 #include "ui/base/l10n/l10n_util.h" 9 #include "ui/base/l10n/l10n_util.h"
10 #include "ui/views/controls/button/button.h" 10 #include "ui/views/controls/button/button.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 -1, button_height); 80 -1, button_height);
81 if (manage_passwords_bubble_model_->manage_passwords_bubble_state() != 81 if (manage_passwords_bubble_model_->manage_passwords_bubble_state() !=
82 ManagePasswordsBubbleModel::PASSWORD_TO_BE_SAVED) { 82 ManagePasswordsBubbleModel::PASSWORD_TO_BE_SAVED) {
83 layout->AddView(delete_or_undo_button_); 83 layout->AddView(delete_or_undo_button_);
84 } 84 }
85 } 85 }
86 86
87 // static 87 // static
88 string16 ManagePasswordItemView::GetPasswordDisplayString( 88 string16 ManagePasswordItemView::GetPasswordDisplayString(
89 const string16& password) { 89 const string16& password) {
90 const wchar_t password_bullet = 0x2022; 90 const wchar_t kPasswordBullet = 0x2022;
91 const size_t max_password_char = 22; 91 const size_t kMaxPasswordChar = 22;
92 return string16(std::min(password.length(), max_password_char), 92 return string16(std::min(password.length(), kMaxPasswordChar),
93 password_bullet); 93 kPasswordBullet);
94 } 94 }
95 95
96 ManagePasswordItemView::~ManagePasswordItemView() { 96 ManagePasswordItemView::~ManagePasswordItemView() {
97 if (delete_password_) 97 if (delete_password_)
98 manage_passwords_bubble_model_->DeleteFromBestMatches(password_form_); 98 manage_passwords_bubble_model_->DeleteFromBestMatches(password_form_);
99 } 99 }
100 100
101 void ManagePasswordItemView::Refresh() { 101 void ManagePasswordItemView::Refresh() {
102 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 102 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
103 if (delete_password_) { 103 if (delete_password_) {
104 label_1_->SetText(l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_DELETED)); 104 label_1_->SetText(l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_DELETED));
105 label_2_->SetText(l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_UNDO)); 105 label_2_->SetText(l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_UNDO));
106 label_2_->SetHorizontalAlignment(gfx::ALIGN_RIGHT); 106 label_2_->SetHorizontalAlignment(gfx::ALIGN_RIGHT);
107 delete_or_undo_button_->SetImage( 107 delete_or_undo_button_->SetImage(
108 views::Button::STATE_NORMAL, 108 views::Button::STATE_NORMAL,
109 *rb->GetImageSkiaNamed(IDR_PASSWORD_UNDO_ARROW)); 109 *rb->GetImageSkiaNamed(IDR_PASSWORD_UNDO_ARROW));
110 manage_passwords_bubble_model_->PasswordAction(password_form_, true); 110 manage_passwords_bubble_model_->OnPasswordAction(password_form_, true);
111 } else { 111 } else {
112 label_1_->SetText(password_form_.username_value); 112 label_1_->SetText(password_form_.username_value);
113 label_2_->SetText(GetPasswordDisplayString(password_form_.password_value)); 113 label_2_->SetText(GetPasswordDisplayString(password_form_.password_value));
114 label_2_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 114 label_2_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
115 delete_or_undo_button_->SetImage(views::Button::STATE_NORMAL, 115 delete_or_undo_button_->SetImage(views::Button::STATE_NORMAL,
116 *rb->GetImageSkiaNamed(IDR_CLOSE_2)); 116 *rb->GetImageSkiaNamed(IDR_CLOSE_2));
117 manage_passwords_bubble_model_->PasswordAction(password_form_, false); 117 manage_passwords_bubble_model_->OnPasswordAction(password_form_, false);
118 } 118 }
119 } 119 }
120 120
121 void ManagePasswordItemView::ButtonPressed(views::Button* sender, 121 void ManagePasswordItemView::ButtonPressed(views::Button* sender,
122 const ui::Event& event) { 122 const ui::Event& event) {
123 DCHECK_EQ(delete_or_undo_button_, sender); 123 DCHECK_EQ(delete_or_undo_button_, sender);
124 delete_password_ = !delete_password_; 124 delete_password_ = !delete_password_;
125 Refresh(); 125 Refresh();
126 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698