| 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::CreateSolidBackground( | 158 set_background(views::Background::CreateThemedSolidBackground( |
| 159 GetNativeTheme()->GetSystemColor( | 159 this, ui::NativeTheme::kColorId_ResultsTableNormalBackground)); |
| 160 ui::NativeTheme::kColorId_ResultsTableNormalBackground))); | |
| 161 } | 160 } |
| 162 | 161 |
| 163 PasswordGenerationPopupViewViews::~PasswordGenerationPopupViewViews() {} | 162 PasswordGenerationPopupViewViews::~PasswordGenerationPopupViewViews() {} |
| 164 | 163 |
| 165 void PasswordGenerationPopupViewViews::CreatePasswordView() { | 164 void PasswordGenerationPopupViewViews::CreatePasswordView() { |
| 166 if (password_view_) | 165 if (password_view_) |
| 167 return; | 166 return; |
| 168 | 167 |
| 169 password_view_ = new PasswordBox(); | 168 password_view_ = new PasswordBox(); |
| 170 password_view_->Init(controller_->password(), | 169 password_view_->Init(controller_->password(), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 DoUpdateBoundsAndRedrawPopup(); | 204 DoUpdateBoundsAndRedrawPopup(); |
| 206 } | 205 } |
| 207 | 206 |
| 208 void PasswordGenerationPopupViewViews::PasswordSelectionUpdated() { | 207 void PasswordGenerationPopupViewViews::PasswordSelectionUpdated() { |
| 209 if (!password_view_) | 208 if (!password_view_) |
| 210 return; | 209 return; |
| 211 | 210 |
| 212 if (controller_->password_selected()) | 211 if (controller_->password_selected()) |
| 213 NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); | 212 NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); |
| 214 | 213 |
| 215 password_view_->set_background( | 214 password_view_->set_background(views::Background::CreateThemedSolidBackground( |
| 216 views::Background::CreateSolidBackground( | 215 password_view_, |
| 217 GetNativeTheme()->GetSystemColor( | 216 controller_->password_selected() |
| 218 controller_->password_selected() ? | 217 ? ui::NativeTheme::kColorId_ResultsTableHoveredBackground |
| 219 ui::NativeTheme::kColorId_ResultsTableHoveredBackground : | 218 : ui::NativeTheme::kColorId_ResultsTableNormalBackground)); |
| 220 ui::NativeTheme::kColorId_ResultsTableNormalBackground))); | |
| 221 } | 219 } |
| 222 | 220 |
| 223 void PasswordGenerationPopupViewViews::Layout() { | 221 void PasswordGenerationPopupViewViews::Layout() { |
| 224 // Need to leave room for the border. | 222 // Need to leave room for the border. |
| 225 int y = kPopupBorderThickness; | 223 int y = kPopupBorderThickness; |
| 226 int popup_width = bounds().width() - 2 * kPopupBorderThickness; | 224 int popup_width = bounds().width() - 2 * kPopupBorderThickness; |
| 227 if (controller_->display_password()) { | 225 if (controller_->display_password()) { |
| 228 // 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 |
| 229 // 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 |
| 230 // 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... |
| 285 return new PasswordGenerationPopupViewViews(controller, observing_widget); | 283 return new PasswordGenerationPopupViewViews(controller, observing_widget); |
| 286 } | 284 } |
| 287 | 285 |
| 288 void PasswordGenerationPopupViewViews::GetAccessibleNodeData( | 286 void PasswordGenerationPopupViewViews::GetAccessibleNodeData( |
| 289 ui::AXNodeData* node_data) { | 287 ui::AXNodeData* node_data) { |
| 290 node_data->SetName(controller_->SuggestedText()); | 288 node_data->SetName(controller_->SuggestedText()); |
| 291 node_data->role = ui::AX_ROLE_MENU_ITEM; | 289 node_data->role = ui::AX_ROLE_MENU_ITEM; |
| 292 } | 290 } |
| 293 | 291 |
| 294 } // namespace autofill | 292 } // namespace autofill |
| OLD | NEW |