| 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 width = controller_->GetMinimumWidth(); |
| 181 if (password_view_) |
| 182 width = std::max(width, password_view_->GetMinimumSize().width()); |
| 183 int height = help_label_->GetHeightForWidth(width); |
| 181 if (controller_->display_password()) { | 184 if (controller_->display_password()) { |
| 182 // Add divider height as well. | 185 // Add divider height as well. |
| 183 height += | 186 height += |
| 184 PasswordGenerationPopupController::kPopupPasswordSectionHeight + 1; | 187 PasswordGenerationPopupController::kPopupPasswordSectionHeight + 1; |
| 185 } | 188 } |
| 186 int width = controller_->GetMinimumWidth(); | 189 return gfx::Size(width + 2 * kPopupBorderThickness, |
| 187 int popup_width = width - 2 * kPopupBorderThickness; | 190 height + 2 * kPopupBorderThickness); |
| 188 height += help_label_->GetHeightForWidth(popup_width); | |
| 189 return gfx::Size(width, height + kPopupBorderThickness); | |
| 190 } | 191 } |
| 191 | 192 |
| 192 void PasswordGenerationPopupViewViews::Show() { | 193 void PasswordGenerationPopupViewViews::Show() { |
| 193 DoShow(); | 194 DoShow(); |
| 194 } | 195 } |
| 195 | 196 |
| 196 void PasswordGenerationPopupViewViews::Hide() { | 197 void PasswordGenerationPopupViewViews::Hide() { |
| 197 // The controller is no longer valid after it hides us. | 198 // The controller is no longer valid after it hides us. |
| 198 controller_ = NULL; | 199 controller_ = NULL; |
| 199 | 200 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 return new PasswordGenerationPopupViewViews(controller, observing_widget); | 285 return new PasswordGenerationPopupViewViews(controller, observing_widget); |
| 285 } | 286 } |
| 286 | 287 |
| 287 void PasswordGenerationPopupViewViews::GetAccessibleNodeData( | 288 void PasswordGenerationPopupViewViews::GetAccessibleNodeData( |
| 288 ui::AXNodeData* node_data) { | 289 ui::AXNodeData* node_data) { |
| 289 node_data->SetName(controller_->SuggestedText()); | 290 node_data->SetName(controller_->SuggestedText()); |
| 290 node_data->role = ui::AX_ROLE_MENU_ITEM; | 291 node_data->role = ui::AX_ROLE_MENU_ITEM; |
| 291 } | 292 } |
| 292 | 293 |
| 293 } // namespace autofill | 294 } // namespace autofill |
| OLD | NEW |