| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 kExplanatoryTextBackgroundColor)); | 148 kExplanatoryTextBackgroundColor)); |
| 149 help_label_->SetBorder(views::CreateEmptyBorder( | 149 help_label_->SetBorder(views::CreateEmptyBorder( |
| 150 PasswordGenerationPopupController::kHelpVerticalPadding - | 150 PasswordGenerationPopupController::kHelpVerticalPadding - |
| 151 kHelpVerticalOffset, | 151 kHelpVerticalOffset, |
| 152 PasswordGenerationPopupController::kHorizontalPadding, | 152 PasswordGenerationPopupController::kHorizontalPadding, |
| 153 PasswordGenerationPopupController::kHelpVerticalPadding - | 153 PasswordGenerationPopupController::kHelpVerticalPadding - |
| 154 kHelpVerticalOffset, | 154 kHelpVerticalOffset, |
| 155 PasswordGenerationPopupController::kHorizontalPadding)); | 155 PasswordGenerationPopupController::kHorizontalPadding)); |
| 156 AddChildView(help_label_); | 156 AddChildView(help_label_); |
| 157 | 157 |
| 158 set_background(views::Background::CreateThemedSolidBackground( | 158 set_background(views::Background::CreateSolidBackground( |
| 159 this, ui::NativeTheme::kColorId_ResultsTableNormalBackground)); | 159 GetNativeTheme()->GetSystemColor( |
| 160 ui::NativeTheme::kColorId_ResultsTableNormalBackground))); |
| 160 } | 161 } |
| 161 | 162 |
| 162 PasswordGenerationPopupViewViews::~PasswordGenerationPopupViewViews() {} | 163 PasswordGenerationPopupViewViews::~PasswordGenerationPopupViewViews() {} |
| 163 | 164 |
| 164 void PasswordGenerationPopupViewViews::CreatePasswordView() { | 165 void PasswordGenerationPopupViewViews::CreatePasswordView() { |
| 165 if (password_view_) | 166 if (password_view_) |
| 166 return; | 167 return; |
| 167 | 168 |
| 168 password_view_ = new PasswordBox(); | 169 password_view_ = new PasswordBox(); |
| 169 password_view_->Init(controller_->password(), | 170 password_view_->Init(controller_->password(), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 DoUpdateBoundsAndRedrawPopup(); | 205 DoUpdateBoundsAndRedrawPopup(); |
| 205 } | 206 } |
| 206 | 207 |
| 207 void PasswordGenerationPopupViewViews::PasswordSelectionUpdated() { | 208 void PasswordGenerationPopupViewViews::PasswordSelectionUpdated() { |
| 208 if (!password_view_) | 209 if (!password_view_) |
| 209 return; | 210 return; |
| 210 | 211 |
| 211 if (controller_->password_selected()) | 212 if (controller_->password_selected()) |
| 212 NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); | 213 NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); |
| 213 | 214 |
| 214 password_view_->set_background(views::Background::CreateThemedSolidBackground( | 215 password_view_->set_background( |
| 215 password_view_, | 216 views::Background::CreateSolidBackground( |
| 216 controller_->password_selected() | 217 GetNativeTheme()->GetSystemColor( |
| 217 ? ui::NativeTheme::kColorId_ResultsTableHoveredBackground | 218 controller_->password_selected() ? |
| 218 : ui::NativeTheme::kColorId_ResultsTableNormalBackground)); | 219 ui::NativeTheme::kColorId_ResultsTableHoveredBackground : |
| 220 ui::NativeTheme::kColorId_ResultsTableNormalBackground))); |
| 219 } | 221 } |
| 220 | 222 |
| 221 void PasswordGenerationPopupViewViews::Layout() { | 223 void PasswordGenerationPopupViewViews::Layout() { |
| 222 // Need to leave room for the border. | 224 // Need to leave room for the border. |
| 223 int y = kPopupBorderThickness; | 225 int y = kPopupBorderThickness; |
| 224 int popup_width = bounds().width() - 2 * kPopupBorderThickness; | 226 int popup_width = bounds().width() - 2 * kPopupBorderThickness; |
| 225 if (controller_->display_password()) { | 227 if (controller_->display_password()) { |
| 226 // Currently the UI can change from not offering a password to offering | 228 // Currently the UI can change from not offering a password to offering |
| 227 // a password (e.g. the user is editing a generated password and deletes | 229 // a password (e.g. the user is editing a generated password and deletes |
| 228 // it), but it can't change the other way around. | 230 // it), but it can't change the other way around. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 return new PasswordGenerationPopupViewViews(controller, observing_widget); | 285 return new PasswordGenerationPopupViewViews(controller, observing_widget); |
| 284 } | 286 } |
| 285 | 287 |
| 286 void PasswordGenerationPopupViewViews::GetAccessibleNodeData( | 288 void PasswordGenerationPopupViewViews::GetAccessibleNodeData( |
| 287 ui::AXNodeData* node_data) { | 289 ui::AXNodeData* node_data) { |
| 288 node_data->SetName(controller_->SuggestedText()); | 290 node_data->SetName(controller_->SuggestedText()); |
| 289 node_data->role = ui::AX_ROLE_MENU_ITEM; | 291 node_data->role = ui::AX_ROLE_MENU_ITEM; |
| 290 } | 292 } |
| 291 | 293 |
| 292 } // namespace autofill | 294 } // namespace autofill |
| OLD | NEW |