Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #import "chrome/browser/ui/cocoa/autofill/autofill_section_container.h" | 5 #import "chrome/browser/ui/cocoa/autofill/autofill_section_container.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" | 12 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" |
| 13 #include "chrome/browser/ui/chrome_style.h" | 13 #include "chrome/browser/ui/chrome_style.h" |
| 14 #import "chrome/browser/ui/cocoa/autofill/autofill_pop_up_button.h" | 14 #import "chrome/browser/ui/cocoa/autofill/autofill_pop_up_button.h" |
| 15 #import "chrome/browser/ui/cocoa/autofill/autofill_section_view.h" | 15 #import "chrome/browser/ui/cocoa/autofill/autofill_section_view.h" |
| 16 #import "chrome/browser/ui/cocoa/autofill/autofill_suggestion_container.h" | 16 #import "chrome/browser/ui/cocoa/autofill/autofill_suggestion_container.h" |
| 17 #import "chrome/browser/ui/cocoa/autofill/autofill_textfield.h" | 17 #import "chrome/browser/ui/cocoa/autofill/autofill_textfield.h" |
| 18 #import "chrome/browser/ui/cocoa/autofill/layout_view.h" | 18 #import "chrome/browser/ui/cocoa/autofill/layout_view.h" |
| 19 #include "chrome/browser/ui/cocoa/autofill/simple_grid_layout.h" | 19 #include "chrome/browser/ui/cocoa/autofill/simple_grid_layout.h" |
| 20 #import "chrome/browser/ui/cocoa/image_button_cell.h" | 20 #import "chrome/browser/ui/cocoa/image_button_cell.h" |
| 21 #import "chrome/browser/ui/cocoa/menu_button.h" | 21 #import "chrome/browser/ui/cocoa/menu_button.h" |
| 22 #include "components/autofill/core/browser/autofill_type.h" | 22 #include "components/autofill/core/browser/autofill_type.h" |
| 23 #include "content/public/browser/native_web_keyboard_event.h" | |
| 23 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
| 24 #import "ui/base/cocoa/menu_controller.h" | 25 #import "ui/base/cocoa/menu_controller.h" |
| 25 #include "ui/base/l10n/l10n_util_mac.h" | 26 #include "ui/base/l10n/l10n_util_mac.h" |
| 26 #include "ui/base/models/combobox_model.h" | 27 #include "ui/base/models/combobox_model.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 // Constants used for layouting controls. These variables are copied from | 32 // Constants used for layouting controls. These variables are copied from |
| 32 // "ui/views/layout/layout_constants.h". | 33 // "ui/views/layout/layout_constants.h". |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 } else { | 245 } else { |
| 245 [inputs_ setFrame:controlFrame]; | 246 [inputs_ setFrame:controlFrame]; |
| 246 } | 247 } |
| 247 [label_ setFrame:labelFrame]; | 248 [label_ setFrame:labelFrame]; |
| 248 [suggestButton_ setFrame:buttonFrame]; | 249 [suggestButton_ setFrame:buttonFrame]; |
| 249 [inputs_ setHidden:showSuggestions_]; | 250 [inputs_ setHidden:showSuggestions_]; |
| 250 [[suggestContainer_ view] setHidden:!showSuggestions_]; | 251 [[suggestContainer_ view] setHidden:!showSuggestions_]; |
| 251 [view_ setFrameSize:viewFrame.size]; | 252 [view_ setFrameSize:viewFrame.size]; |
| 252 } | 253 } |
| 253 | 254 |
| 255 - (KeyEventHandled)keyEvent:(NSEvent*)event forInput:(id)sender { | |
| 256 content::NativeWebKeyboardEvent webEvent(event); | |
| 257 | |
| 258 // Only handle keyDown, to handle key repeats without duplicates. | |
|
Robert Sesek
2013/11/22 16:52:39
This isn't only handling keyDown. This is merely n
groby-ooo-7-16
2013/11/22 21:31:32
Done.
| |
| 259 if (webEvent.type == content::NativeWebKeyboardEvent::KeyUp) | |
| 260 return kKeyEventNotHandled; | |
| 261 | |
| 262 // Allow the delegate to intercept key messages. | |
| 263 if (delegate_->HandleKeyPressEventInInput(webEvent)) | |
| 264 return kKeyEventHandled; | |
| 265 return kKeyEventNotHandled; | |
| 266 } | |
| 267 | |
| 254 - (void)onMouseDown:(NSControl<AutofillInputField>*)field { | 268 - (void)onMouseDown:(NSControl<AutofillInputField>*)field { |
| 255 [self textfieldEditedOrActivated:field edited:NO]; | 269 [self textfieldEditedOrActivated:field edited:NO]; |
| 256 [validationDelegate_ updateMessageForField:field]; | 270 [validationDelegate_ updateMessageForField:field]; |
| 257 } | 271 } |
| 258 | 272 |
| 259 - (void)fieldBecameFirstResponder:(NSControl<AutofillInputField>*)field { | 273 - (void)fieldBecameFirstResponder:(NSControl<AutofillInputField>*)field { |
| 260 [validationDelegate_ updateMessageForField:field]; | 274 [validationDelegate_ updateMessageForField:field]; |
| 261 } | 275 } |
| 262 | 276 |
| 263 - (void)didChange:(id)sender { | 277 - (void)didChange:(id)sender { |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 638 - (void)activateFieldForInput:(const autofill::DetailInput&)input { | 652 - (void)activateFieldForInput:(const autofill::DetailInput&)input { |
| 639 if ([self detailInputForType:input.type] != &input) | 653 if ([self detailInputForType:input.type] != &input) |
| 640 return; | 654 return; |
| 641 | 655 |
| 642 NSControl<AutofillInputField>* field = [inputs_ viewWithTag:input.type]; | 656 NSControl<AutofillInputField>* field = [inputs_ viewWithTag:input.type]; |
| 643 [[field window] makeFirstResponder:field]; | 657 [[field window] makeFirstResponder:field]; |
| 644 [self textfieldEditedOrActivated:field edited:NO]; | 658 [self textfieldEditedOrActivated:field edited:NO]; |
| 645 } | 659 } |
| 646 | 660 |
| 647 @end | 661 @end |
| OLD | NEW |