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/views/autofill/password_generation_popup_view_views. h" | 5 #include "chrome/browser/ui/views/autofill/password_generation_popup_view_views. h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "chrome/app/vector_icons/vector_icons.h" | 9 #include "chrome/app/vector_icons/vector_icons.h" |
| 10 #include "chrome/browser/ui/autofill/password_generation_popup_controller.h" | 10 #include "chrome/browser/ui/autofill/password_generation_popup_controller.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 password_view_->Init(controller_->password(), | 170 password_view_->Init(controller_->password(), |
| 171 controller_->SuggestedText(), | 171 controller_->SuggestedText(), |
| 172 font_list_); | 172 font_list_); |
| 173 password_view_->SetPosition(gfx::Point(kPopupBorderThickness, | 173 password_view_->SetPosition(gfx::Point(kPopupBorderThickness, |
| 174 kPopupBorderThickness)); | 174 kPopupBorderThickness)); |
| 175 password_view_->SizeToPreferredSize(); | 175 password_view_->SizeToPreferredSize(); |
| 176 AddChildView(password_view_); | 176 AddChildView(password_view_); |
| 177 } | 177 } |
| 178 | 178 |
| 179 gfx::Size PasswordGenerationPopupViewViews::GetPreferredSizeOfPasswordView() { | 179 gfx::Size PasswordGenerationPopupViewViews::GetPreferredSizeOfPasswordView() { |
| 180 int height = kPopupBorderThickness; | 180 int height = kPopupBorderThickness; |
|
msw
2017/03/31 16:38:26
optional nit: init height to just |help_label_->Ge
dvadym
2017/04/03 12:29:39
Done.
| |
| 181 if (controller_->display_password()) { | 181 if (controller_->display_password()) { |
| 182 // Add divider height as well. | 182 // Add divider height as well. |
| 183 height += | 183 height += |
| 184 PasswordGenerationPopupController::kPopupPasswordSectionHeight + 1; | 184 PasswordGenerationPopupController::kPopupPasswordSectionHeight + 1; |
| 185 } | 185 } |
| 186 int width = controller_->GetMinimumWidth(); | 186 int width = controller_->GetMinimumWidth(); |
| 187 int popup_width = width - 2 * kPopupBorderThickness; | 187 if (password_view_) |
| 188 height += help_label_->GetHeightForWidth(popup_width); | 188 width = std::max(width, password_view_->GetMinimumSize().width()); |
| 189 return gfx::Size(width, height + kPopupBorderThickness); | 189 height += help_label_->GetHeightForWidth(width); |
| 190 return gfx::Size(width + 2 * kPopupBorderThickness, | |
| 191 height + kPopupBorderThickness); | |
| 190 } | 192 } |
| 191 | 193 |
| 192 void PasswordGenerationPopupViewViews::Show() { | 194 void PasswordGenerationPopupViewViews::Show() { |
| 193 DoShow(); | 195 DoShow(); |
| 194 } | 196 } |
| 195 | 197 |
| 196 void PasswordGenerationPopupViewViews::Hide() { | 198 void PasswordGenerationPopupViewViews::Hide() { |
| 197 // The controller is no longer valid after it hides us. | 199 // The controller is no longer valid after it hides us. |
| 198 controller_ = NULL; | 200 controller_ = NULL; |
| 199 | 201 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 return new PasswordGenerationPopupViewViews(controller, observing_widget); | 286 return new PasswordGenerationPopupViewViews(controller, observing_widget); |
| 285 } | 287 } |
| 286 | 288 |
| 287 void PasswordGenerationPopupViewViews::GetAccessibleNodeData( | 289 void PasswordGenerationPopupViewViews::GetAccessibleNodeData( |
| 288 ui::AXNodeData* node_data) { | 290 ui::AXNodeData* node_data) { |
| 289 node_data->SetName(controller_->SuggestedText()); | 291 node_data->SetName(controller_->SuggestedText()); |
| 290 node_data->role = ui::AX_ROLE_MENU_ITEM; | 292 node_data->role = ui::AX_ROLE_MENU_ITEM; |
| 291 } | 293 } |
| 292 | 294 |
| 293 } // namespace autofill | 295 } // namespace autofill |
| OLD | NEW |