1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_INPUT_FIELD_H_
6 #define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_INPUT_FIELD_H_
8 #import <Cocoa/Cocoa.h>
10 @protocol AutofillInputField
;
12 // Access to cell state for autofill input controls.
13 @protocol AutofillInputCell
<NSObject
>
15 @
property(nonatomic
, assign
) BOOL invalid
;
16 @
property(nonatomic
, copy
) NSString
* fieldValue
;
17 @
property(nonatomic
, copy
) NSString
* defaultValue
;
21 // Delegate to handle editing events on the AutofillInputFields.
22 @protocol AutofillInputDelegate
<NSObject
>
24 // Indicates if an event should be forwarded on.
25 enum KeyEventHandled
{
30 // The input field received a key event. This should return kKeyEventHandled if
31 // it handled the event, or kEventNotHandled if it should be forwarded to the
32 // input's super class.
33 - (KeyEventHandled
)keyEvent
:(NSEvent
*)event forInput
:(id
)sender
;
35 // Input field or its editor received a mouseDown: message.
36 - (void)onMouseDown
:(NSControl
<AutofillInputField
>*)sender
;
38 // An input field just became first responder.
39 - (void)fieldBecameFirstResponder
:(NSControl
<AutofillInputField
>*)field
;
41 // The user made changes to the value in the field. This is only invoked by
42 // AutofillTextFields.
43 - (void)didChange
:(id
)sender
;
45 // The user is done with this field. This indicates a loss of firstResponder
47 - (void)didEndEditing
:(id
)sender
;
51 // Protocol to allow access to any given input field in an Autofill dialog, no
52 // matter what the underlying control is. All controls act as proxies for their
53 // cells, so inherits from AutofillInputCell.
54 @protocol AutofillInputField
56 @
property(nonatomic
, assign
) id
<AutofillInputDelegate
> inputDelegate
;
58 @
property(nonatomic
, copy
) NSString
* fieldValue
;
59 @
property(nonatomic
, copy
) NSString
* defaultValue
;
61 // Indicates if the field is at its default setting.
62 @
property(nonatomic
, readonly
) BOOL isDefault
;
64 // Indicates if the field is valid. Empty string or nil indicates a valid
65 // field, everything else is a message to be displayed to the user when the
66 // field has firstResponder status.
67 @
property(nonatomic
, copy
) NSString
* validityMessage
;
69 // A reflection of the state of the validityMessage described above.
70 @
property(nonatomic
, readonly
) BOOL invalid
;
74 #endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_INPUT_FIELD_H_