• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_INPUT_FIELD_H_
6 #define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_INPUT_FIELD_H_
7 
8 #import <Cocoa/Cocoa.h>
9 
10 @protocol AutofillInputField;
11 
12 // Access to cell state for autofill input controls.
13 @protocol AutofillInputCell<NSObject>
14 
15 @property(nonatomic, assign) BOOL invalid;
16 @property(nonatomic, copy) NSString* fieldValue;
17 @property(nonatomic, copy) NSString* defaultValue;
18 
19 @end
20 
21 // Delegate to handle editing events on the AutofillInputFields.
22 @protocol AutofillInputDelegate<NSObject>
23 
24 // Indicates if an event should be forwarded on.
25 enum KeyEventHandled {
26   kKeyEventNotHandled,
27   kKeyEventHandled
28 };
29 
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;
34 
35 // Input field or its editor received a mouseDown: message.
36 - (void)onMouseDown:(NSControl<AutofillInputField>*)sender;
37 
38 // An input field just became first responder.
39 - (void)fieldBecameFirstResponder:(NSControl<AutofillInputField>*)field;
40 
41 // The user made changes to the value in the field. This is only invoked by
42 // AutofillTextFields.
43 - (void)didChange:(id)sender;
44 
45 // The user is done with this field. This indicates a loss of firstResponder
46 // status.
47 - (void)didEndEditing:(id)sender;
48 
49 @end
50 
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
55 
56 @property(nonatomic, assign) id<AutofillInputDelegate> inputDelegate;
57 
58 @property(nonatomic, copy) NSString* fieldValue;
59 @property(nonatomic, copy) NSString* defaultValue;
60 
61 // Indicates if the field is at its default setting.
62 @property(nonatomic, readonly) BOOL isDefault;
63 
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;
68 
69 // A reflection of the state of the validityMessage described above.
70 @property(nonatomic, readonly) BOOL invalid;
71 
72 @end
73 
74 #endif  // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_INPUT_FIELD_H_
75