| 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/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "chrome/browser/ui/autofill/password_generation_popup_controller.h" | 8 #include "chrome/browser/ui/autofill/password_generation_popup_controller.h" |
| 9 #include "chrome/browser/ui/autofill/popup_constants.h" | 9 #include "chrome/browser/ui/autofill/popup_constants.h" |
| 10 #include "grit/theme_resources.h" | 10 #include "grit/theme_resources.h" |
| 11 #include "ui/base/resource/resource_bundle.h" | 11 #include "ui/base/resource/resource_bundle.h" |
| 12 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
| 13 #include "ui/views/background.h" | 13 #include "ui/views/background.h" |
| 14 #include "ui/views/border.h" | 14 #include "ui/views/border.h" |
| 15 #include "ui/views/controls/image_view.h" | 15 #include "ui/views/controls/image_view.h" |
| 16 #include "ui/views/controls/label.h" | 16 #include "ui/views/controls/label.h" |
| 17 #include "ui/views/controls/styled_label.h" | 17 #include "ui/views/controls/styled_label.h" |
| 18 #include "ui/views/layout/box_layout.h" | 18 #include "ui/views/layout/box_layout.h" |
| 19 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
| 20 | 20 |
| 21 namespace autofill { | 21 namespace autofill { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // The amount of whitespace that is present when there is no padding. Used | 25 // The amount of whitespace that is present when there is no padding. Used |
| 26 // to get the proper spacing in the help section. | 26 // to get the proper spacing in the help section. |
| 27 const int kHelpVerticalOffset = 5; | 27 const int kHelpVerticalOffset = 5; |
| 28 const int kPasswordSectionHeight = 62; | |
| 29 | 28 |
| 30 // Wrapper around just the text portions of the generation UI (password and | 29 // Wrapper around just the text portions of the generation UI (password and |
| 31 // prompting text). | 30 // prompting text). |
| 32 class PasswordTextBox : public views::View { | 31 class PasswordTextBox : public views::View { |
| 33 public: | 32 public: |
| 34 PasswordTextBox() {} | 33 PasswordTextBox() {} |
| 35 virtual ~PasswordTextBox() {} | 34 virtual ~PasswordTextBox() {} |
| 36 | 35 |
| 37 // |suggestion_text| prompts the user to select the password, | 36 // |suggestion_text| prompts the user to select the password, |
| 38 // |generated_password| is the generated password, and |font_list| is the font | 37 // |generated_password| is the generated password, and |font_list| is the font |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 password_view_->SetPosition(gfx::Point(kPopupBorderThickness, | 165 password_view_->SetPosition(gfx::Point(kPopupBorderThickness, |
| 167 kPopupBorderThickness)); | 166 kPopupBorderThickness)); |
| 168 password_view_->SizeToPreferredSize(); | 167 password_view_->SizeToPreferredSize(); |
| 169 AddChildView(password_view_); | 168 AddChildView(password_view_); |
| 170 } | 169 } |
| 171 | 170 |
| 172 gfx::Size PasswordGenerationPopupViewViews::GetPreferredSizeOfPasswordView() { | 171 gfx::Size PasswordGenerationPopupViewViews::GetPreferredSizeOfPasswordView() { |
| 173 int height = kPopupBorderThickness; | 172 int height = kPopupBorderThickness; |
| 174 if (controller_->display_password()) { | 173 if (controller_->display_password()) { |
| 175 // Add divider height as well. | 174 // Add divider height as well. |
| 176 height += kPasswordSectionHeight + 1; | 175 height += |
| 176 PasswordGenerationPopupController::kPopupPasswordSectionHeight + 1; |
| 177 } | 177 } |
| 178 int width = controller_->GetMinimumWidth(); | 178 int width = controller_->GetMinimumWidth(); |
| 179 int popup_width = width - 2 * kPopupBorderThickness; | 179 int popup_width = width - 2 * kPopupBorderThickness; |
| 180 height += help_label_->GetHeightForWidth(popup_width); | 180 height += help_label_->GetHeightForWidth(popup_width); |
| 181 return gfx::Size(width, height + kPopupBorderThickness); | 181 return gfx::Size(width, height + kPopupBorderThickness); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void PasswordGenerationPopupViewViews::Show() { | 184 void PasswordGenerationPopupViewViews::Show() { |
| 185 DoShow(); | 185 DoShow(); |
| 186 } | 186 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 261 |
| 262 // If the top level widget can't be found, cancel the popup since we can't | 262 // If the top level widget can't be found, cancel the popup since we can't |
| 263 // fully set it up. | 263 // fully set it up. |
| 264 if (!observing_widget) | 264 if (!observing_widget) |
| 265 return NULL; | 265 return NULL; |
| 266 | 266 |
| 267 return new PasswordGenerationPopupViewViews(controller, observing_widget); | 267 return new PasswordGenerationPopupViewViews(controller, observing_widget); |
| 268 } | 268 } |
| 269 | 269 |
| 270 } // namespace autofill | 270 } // namespace autofill |
| OLD | NEW |