Mention the platform in the extension manifest documentation.
[chromium-blink-merge.git] / android_webview / native / aw_autofill_client.h
bloba6158fa769bc87c44c4f8c441e080da5d0aa2ea5
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
3 // found in the LICENSE file.
5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_AUTOFILL_CLIENT_H_
6 #define ANDROID_WEBVIEW_NATIVE_AW_AUTOFILL_CLIENT_H_
8 #include <jni.h>
9 #include <vector>
11 #include "base/android/jni_weak_ref.h"
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "base/prefs/pref_registry_simple.h"
15 #include "base/prefs/pref_service_factory.h"
16 #include "components/autofill/core/browser/autofill_client.h"
17 #include "content/public/browser/web_contents_user_data.h"
19 namespace autofill {
20 class AutofillMetrics;
21 class AutofillPopupDelegate;
22 class CreditCard;
23 class FormStructure;
24 class PasswordGenerator;
25 class PersonalDataManager;
26 struct FormData;
29 namespace content {
30 class WebContents;
33 namespace gfx {
34 class RectF;
37 class PersonalDataManager;
38 class PrefService;
40 namespace android_webview {
42 // Manager delegate for the autofill functionality. Android webview
43 // supports enabling autocomplete feature for each webview instance
44 // (different than the browser which supports enabling/disabling for
45 // a profile). Since there is only one pref service for a given browser
46 // context, we cannot enable this feature via UserPrefs. Rather, we always
47 // keep the feature enabled at the pref service, and control it via
48 // the delegates.
49 class AwAutofillClient : public autofill::AutofillClient,
50 public content::WebContentsUserData<AwAutofillClient> {
51 public:
52 virtual ~AwAutofillClient();
54 void SetSaveFormData(bool enabled);
55 bool GetSaveFormData();
57 // AutofillClient:
58 virtual autofill::PersonalDataManager* GetPersonalDataManager() override;
59 virtual scoped_refptr<autofill::AutofillWebDataService> GetDatabase()
60 override;
61 virtual PrefService* GetPrefs() override;
62 virtual void HideRequestAutocompleteDialog() override;
63 virtual void ShowAutofillSettings() override;
64 virtual void ShowUnmaskPrompt() override;
65 virtual void ConfirmSaveCreditCard(
66 const base::Closure& save_card_callback) override;
67 virtual bool HasCreditCardScanFeature() override;
68 virtual void ScanCreditCard(const CreditCardScanCallback& callback) override;
69 virtual void ShowRequestAutocompleteDialog(
70 const autofill::FormData& form,
71 const GURL& source_url,
72 const ResultCallback& callback) override;
73 virtual void ShowAutofillPopup(
74 const gfx::RectF& element_bounds,
75 base::i18n::TextDirection text_direction,
76 const std::vector<autofill::Suggestion>& suggestions,
77 base::WeakPtr<autofill::AutofillPopupDelegate> delegate) override;
78 virtual void UpdateAutofillPopupDataListValues(
79 const std::vector<base::string16>& values,
80 const std::vector<base::string16>& labels) override;
81 virtual void HideAutofillPopup() override;
82 virtual bool IsAutocompleteEnabled() override;
83 virtual void DetectAccountCreationForms(
84 content::RenderFrameHost* rfh,
85 const std::vector<autofill::FormStructure*>& forms) override;
86 virtual void DidFillOrPreviewField(
87 const base::string16& autofilled_value,
88 const base::string16& profile_full_name) override;
89 virtual void OnFirstUserGestureObserved() override;
91 void SuggestionSelected(JNIEnv* env, jobject obj, jint position);
93 private:
94 AwAutofillClient(content::WebContents* web_contents);
95 friend class content::WebContentsUserData<AwAutofillClient>;
97 void ShowAutofillPopupImpl(
98 const gfx::RectF& element_bounds,
99 bool is_rtl,
100 const std::vector<autofill::Suggestion>& suggestions);
102 // The web_contents associated with this delegate.
103 content::WebContents* web_contents_;
104 bool save_form_data_;
105 JavaObjectWeakGlobalRef java_ref_;
107 // The current Autofill query values.
108 std::vector<autofill::Suggestion> suggestions_;
109 base::WeakPtr<autofill::AutofillPopupDelegate> delegate_;
111 DISALLOW_COPY_AND_ASSIGN(AwAutofillClient);
114 bool RegisterAwAutofillClient(JNIEnv* env);
116 } // namespace android_webview
118 #endif // ANDROID_WEBVIEW_NATIVE_AW_AUTOFILL_CLIENT_H_