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 #ifndef CHROME_BROWSER_UI_ANDROID_AUTOFILL_AUTOFILL_DIALOG_VIEW_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_COCOA_H_ |
6 #define CHROME_BROWSER_UI_ANDROID_AUTOFILL_AUTOFILL_DIALOG_VIEW_ANDROID_H_ | 6 #define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_COCOA_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include "base/memory/scoped_ptr.h" |
9 | |
10 #include "base/android/jni_string.h" | |
11 #include "base/android/scoped_java_ref.h" | |
12 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" | 9 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" |
13 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" | 10 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" |
| 11 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" |
| 12 |
| 13 namespace content { |
| 14 class NavigationController; |
| 15 } |
| 16 |
| 17 @class AutofillDialogWindowController; |
| 18 @class GTMWidthBasedTweaker; |
14 | 19 |
15 namespace autofill { | 20 namespace autofill { |
16 | 21 |
17 // Android implementation of the Autofill dialog that handles the imperative | 22 class AutofillDialogCocoa : public AutofillDialogView, |
18 // autocomplete API call. | 23 public ConstrainedWindowMacDelegate { |
19 class AutofillDialogViewAndroid : public AutofillDialogView { | |
20 public: | 24 public: |
21 explicit AutofillDialogViewAndroid(AutofillDialogController* controller); | 25 explicit AutofillDialogCocoa(AutofillDialogController* controller); |
22 virtual ~AutofillDialogViewAndroid(); | 26 virtual ~AutofillDialogCocoa(); |
23 | 27 |
24 // AutofillDialogView implementation: | 28 // AutofillDialogView implementation: |
25 virtual void Show() OVERRIDE; | 29 virtual void Show() OVERRIDE; |
26 virtual void Hide() OVERRIDE; | 30 virtual void Hide() OVERRIDE; |
27 virtual void UpdateNotificationArea() OVERRIDE; | |
28 virtual void UpdateAccountChooser() OVERRIDE; | 31 virtual void UpdateAccountChooser() OVERRIDE; |
29 virtual void UpdateButtonStrip() OVERRIDE; | 32 virtual void UpdateButtonStrip() OVERRIDE; |
| 33 virtual void UpdateNotificationArea() OVERRIDE; |
30 virtual void UpdateSection(DialogSection section, | 34 virtual void UpdateSection(DialogSection section, |
31 UserInputAction action) OVERRIDE; | 35 UserInputAction action) OVERRIDE; |
32 virtual void GetUserInput(DialogSection section, | 36 virtual void GetUserInput(DialogSection section, |
33 DetailOutputMap* output) OVERRIDE; | 37 DetailOutputMap* output) OVERRIDE; |
34 virtual string16 GetCvc() OVERRIDE; | 38 virtual string16 GetCvc() OVERRIDE; |
35 virtual bool UseBillingForShipping() OVERRIDE; | 39 virtual bool UseBillingForShipping() OVERRIDE; |
36 virtual bool SaveDetailsLocally() OVERRIDE; | 40 virtual bool SaveDetailsLocally() OVERRIDE; |
37 virtual const content::NavigationController* ShowSignIn() OVERRIDE; | 41 virtual const content::NavigationController* ShowSignIn() OVERRIDE; |
38 virtual void HideSignIn() OVERRIDE; | 42 virtual void HideSignIn() OVERRIDE; |
39 virtual void UpdateProgressBar(double value) OVERRIDE; | 43 virtual void UpdateProgressBar(double value) OVERRIDE; |
40 virtual void ModelChanged() OVERRIDE; | 44 virtual void ModelChanged() OVERRIDE; |
41 virtual void SubmitForTesting() OVERRIDE; | 45 virtual void SubmitForTesting() OVERRIDE; |
42 virtual void CancelForTesting() OVERRIDE; | 46 virtual void CancelForTesting() OVERRIDE; |
43 | 47 |
44 // Java to C++ calls | 48 // ConstrainedWindowMacDelegate implementation. |
45 void ItemSelected(JNIEnv* env, jobject obj, jint section, jint index); | 49 virtual void OnConstrainedWindowClosed( |
46 void AccountSelected(JNIEnv* env, jobject obj, jint index); | 50 ConstrainedWindowMac* window) OVERRIDE; |
47 void EditingStart(JNIEnv* env, jobject obj, jint section); | |
48 jboolean EditingComplete(JNIEnv* env, jobject obj, jint section); | |
49 void EditingCancel(JNIEnv* env, jobject obj, jint section); | |
50 base::android::ScopedJavaLocalRef<jstring> ValidateField( | |
51 JNIEnv* env, jobject obj, jint type, jstring value); | |
52 void ValidateSection(JNIEnv* env, jobject obj, jint section); | |
53 void DialogSubmit(JNIEnv* env, jobject obj); | |
54 void DialogCancel(JNIEnv* env, jobject obj); | |
55 base::android::ScopedJavaLocalRef<jstring> GetLabelForSection( | |
56 JNIEnv* env, | |
57 jobject obj, | |
58 jint section); | |
59 base::android::ScopedJavaLocalRef<jobjectArray> GetListForField(JNIEnv* env, | |
60 jobject obj, | |
61 jint field); | |
62 void ContinueAutomaticSignin(JNIEnv* env, jobject obj, | |
63 jstring account_name, jstring sid, jstring lsid); | |
64 base::android::ScopedJavaLocalRef<jobject> GetIconForField( | |
65 JNIEnv* env, | |
66 jobject obj, | |
67 jint field_id, | |
68 jstring jinput); | |
69 base::android::ScopedJavaLocalRef<jstring> GetPlaceholderForField( | |
70 JNIEnv* env, | |
71 jobject obj, | |
72 jint section, | |
73 jint field_id); | |
74 | 51 |
75 static bool RegisterAutofillDialogViewAndroid(JNIEnv* env); | 52 void PerformClose(); |
76 | 53 |
77 private: | 54 private: |
78 // Returns the list of available user accounts. | |
79 std::vector<std::string> GetAvailableUserAccounts(); | |
80 bool ValidateSection(DialogSection section, | |
81 AutofillDialogController::ValidationType type); | |
82 | 55 |
83 // Starts an automatic sign-in attempt for a given account. | 56 scoped_ptr<ConstrainedWindowMac> constrained_window_; |
84 bool StartAutomaticSignIn(const std::string& username); | 57 scoped_nsobject<AutofillDialogWindowController> sheet_controller_; |
85 | 58 |
86 // Updates the visibility of the checkbox to save the edited information | 59 // The controller |this| queries for logic and state. |
87 // locally. | 60 AutofillDialogController* controller_; |
88 void UpdateSaveLocallyCheckBox(); | |
89 | |
90 // The controller that drives this view. Weak pointer, always non-NULL. | |
91 AutofillDialogController* const controller_; | |
92 | |
93 // The corresponding java object. | |
94 base::android::ScopedJavaGlobalRef<jobject> java_object_; | |
95 | |
96 DISALLOW_COPY_AND_ASSIGN(AutofillDialogViewAndroid); | |
97 }; | 61 }; |
98 | 62 |
99 } // namespace autofill | 63 } // autofill |
100 | 64 |
101 #endif // CHROME_BROWSER_UI_ANDROID_AUTOFILL_AUTOFILL_DIALOG_VIEW_ANDROID_H_ | 65 @interface AutofillDialogWindowController : NSWindowController |
| 66 <NSWindowDelegate> { |
| 67 @private |
| 68 content::WebContents* webContents_; // weak. |
| 69 autofill::AutofillDialogCocoa* autofillDialog_; // weak. |
| 70 |
| 71 scoped_nsobject<GTMWidthBasedTweaker> buttonContainer_; |
| 72 } |
| 73 |
| 74 // Designated initializer. The WebContents cannot be NULL. |
| 75 - (id)initWithWebContents:(content::WebContents*)webContents |
| 76 autofillDialog:(autofill::AutofillDialogCocoa*)autofillDialog; |
| 77 |
| 78 // Closes the sheet and ends the modal loop. This will also clean up the memory. |
| 79 - (IBAction)closeSheet:(id)sender; |
| 80 |
| 81 @end |
| 82 |
| 83 #endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_COCOA_H_ |
OLD | NEW |