| 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/browser/ui/autofill/password_generation_popup_controller.h" | 9 #include "chrome/browser/ui/autofill/password_generation_popup_controller.h" |
| 10 #include "chrome/browser/ui/autofill/popup_constants.h" | 10 #include "chrome/browser/ui/autofill/popup_constants.h" |
| 11 #include "ui/accessibility/ax_node_data.h" | 11 #include "ui/accessibility/ax_node_data.h" |
| 12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
| 13 #include "ui/gfx/canvas.h" | 13 #include "ui/gfx/canvas.h" |
| 14 #include "ui/gfx/color_palette.h" | 14 #include "ui/gfx/color_palette.h" |
| 15 #include "ui/gfx/paint_vector_icon.h" | 15 #include "ui/gfx/paint_vector_icon.h" |
| 16 #include "ui/gfx/vector_icons_public.h" | 16 #include "ui/gfx/vector_icons_public.h" |
| 17 #include "ui/native_theme/native_theme.h" |
| 17 #include "ui/views/background.h" | 18 #include "ui/views/background.h" |
| 18 #include "ui/views/border.h" | 19 #include "ui/views/border.h" |
| 19 #include "ui/views/controls/image_view.h" | 20 #include "ui/views/controls/image_view.h" |
| 20 #include "ui/views/controls/label.h" | 21 #include "ui/views/controls/label.h" |
| 21 #include "ui/views/controls/styled_label.h" | 22 #include "ui/views/controls/styled_label.h" |
| 22 #include "ui/views/layout/box_layout.h" | 23 #include "ui/views/layout/box_layout.h" |
| 23 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
| 24 | 25 |
| 25 namespace autofill { | 26 namespace autofill { |
| 26 | 27 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 kExplanatoryTextBackgroundColor)); | 147 kExplanatoryTextBackgroundColor)); |
| 147 help_label_->SetBorder(views::CreateEmptyBorder( | 148 help_label_->SetBorder(views::CreateEmptyBorder( |
| 148 PasswordGenerationPopupController::kHelpVerticalPadding - | 149 PasswordGenerationPopupController::kHelpVerticalPadding - |
| 149 kHelpVerticalOffset, | 150 kHelpVerticalOffset, |
| 150 PasswordGenerationPopupController::kHorizontalPadding, | 151 PasswordGenerationPopupController::kHorizontalPadding, |
| 151 PasswordGenerationPopupController::kHelpVerticalPadding - | 152 PasswordGenerationPopupController::kHelpVerticalPadding - |
| 152 kHelpVerticalOffset, | 153 kHelpVerticalOffset, |
| 153 PasswordGenerationPopupController::kHorizontalPadding)); | 154 PasswordGenerationPopupController::kHorizontalPadding)); |
| 154 AddChildView(help_label_); | 155 AddChildView(help_label_); |
| 155 | 156 |
| 156 set_background(views::Background::CreateSolidBackground(kPopupBackground)); | 157 set_background(views::Background::CreateSolidBackground( |
| 158 GetNativeTheme()->GetSystemColor( |
| 159 ui::NativeTheme::kColorId_ResultsTableNormalBackground))); |
| 157 } | 160 } |
| 158 | 161 |
| 159 PasswordGenerationPopupViewViews::~PasswordGenerationPopupViewViews() {} | 162 PasswordGenerationPopupViewViews::~PasswordGenerationPopupViewViews() {} |
| 160 | 163 |
| 161 void PasswordGenerationPopupViewViews::CreatePasswordView() { | 164 void PasswordGenerationPopupViewViews::CreatePasswordView() { |
| 162 if (password_view_) | 165 if (password_view_) |
| 163 return; | 166 return; |
| 164 | 167 |
| 165 password_view_ = new PasswordBox(); | 168 password_view_ = new PasswordBox(); |
| 166 password_view_->Init(controller_->password(), | 169 password_view_->Init(controller_->password(), |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 205 |
| 203 void PasswordGenerationPopupViewViews::PasswordSelectionUpdated() { | 206 void PasswordGenerationPopupViewViews::PasswordSelectionUpdated() { |
| 204 if (!password_view_) | 207 if (!password_view_) |
| 205 return; | 208 return; |
| 206 | 209 |
| 207 if (controller_->password_selected()) | 210 if (controller_->password_selected()) |
| 208 NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); | 211 NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); |
| 209 | 212 |
| 210 password_view_->set_background( | 213 password_view_->set_background( |
| 211 views::Background::CreateSolidBackground( | 214 views::Background::CreateSolidBackground( |
| 212 controller_->password_selected() ? | 215 GetNativeTheme()->GetSystemColor( |
| 213 kHoveredBackgroundColor : | 216 controller_->password_selected() ? |
| 214 kPopupBackground)); | 217 ui::NativeTheme::kColorId_ResultsTableHoveredBackground : |
| 218 ui::NativeTheme::kColorId_ResultsTableNormalBackground))); |
| 215 } | 219 } |
| 216 | 220 |
| 217 void PasswordGenerationPopupViewViews::Layout() { | 221 void PasswordGenerationPopupViewViews::Layout() { |
| 218 // Need to leave room for the border. | 222 // Need to leave room for the border. |
| 219 int y = kPopupBorderThickness; | 223 int y = kPopupBorderThickness; |
| 220 int popup_width = bounds().width() - 2 * kPopupBorderThickness; | 224 int popup_width = bounds().width() - 2 * kPopupBorderThickness; |
| 221 if (controller_->display_password()) { | 225 if (controller_->display_password()) { |
| 222 // Currently the UI can change from not offering a password to offering | 226 // Currently the UI can change from not offering a password to offering |
| 223 // a password (e.g. the user is editing a generated password and deletes | 227 // a password (e.g. the user is editing a generated password and deletes |
| 224 // it), but it can't change the other way around. | 228 // it), but it can't change the other way around. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 return new PasswordGenerationPopupViewViews(controller, observing_widget); | 283 return new PasswordGenerationPopupViewViews(controller, observing_widget); |
| 280 } | 284 } |
| 281 | 285 |
| 282 void PasswordGenerationPopupViewViews::GetAccessibleNodeData( | 286 void PasswordGenerationPopupViewViews::GetAccessibleNodeData( |
| 283 ui::AXNodeData* node_data) { | 287 ui::AXNodeData* node_data) { |
| 284 node_data->SetName(controller_->SuggestedText()); | 288 node_data->SetName(controller_->SuggestedText()); |
| 285 node_data->role = ui::AX_ROLE_MENU_ITEM; | 289 node_data->role = ui::AX_ROLE_MENU_ITEM; |
| 286 } | 290 } |
| 287 | 291 |
| 288 } // namespace autofill | 292 } // namespace autofill |
| OLD | NEW |