GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / android_webview / native / aw_autofill_client.h
blob00ed40e3bdfdedde3d79314e73aba5d099d19da1
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 CardUnmaskDelegate;
23 class CreditCard;
24 class FormStructure;
25 class PasswordGenerator;
26 class PersonalDataManager;
27 struct FormData;
30 namespace content {
31 class WebContents;
34 namespace gfx {
35 class RectF;
38 class PersonalDataManager;
39 class PrefService;
41 namespace android_webview {
43 // Manager delegate for the autofill functionality. Android webview
44 // supports enabling autocomplete feature for each webview instance
45 // (different than the browser which supports enabling/disabling for
46 // a profile). Since there is only one pref service for a given browser
47 // context, we cannot enable this feature via UserPrefs. Rather, we always
48 // keep the feature enabled at the pref service, and control it via
49 // the delegates.
50 class AwAutofillClient : public autofill::AutofillClient,
51 public content::WebContentsUserData<AwAutofillClient> {
52 public:
53 ~AwAutofillClient() override;
55 void SetSaveFormData(bool enabled);
56 bool GetSaveFormData();
58 // AutofillClient:
59 autofill::PersonalDataManager* GetPersonalDataManager() override;
60 scoped_refptr<autofill::AutofillWebDataService> GetDatabase() override;
61 PrefService* GetPrefs() override;
62 IdentityProvider* GetIdentityProvider() override;
63 rappor::RapporService* GetRapporService() override;
64 void HideRequestAutocompleteDialog() override;
65 void ShowAutofillSettings() override;
66 void ShowUnmaskPrompt(
67 const autofill::CreditCard& card,
68 base::WeakPtr<autofill::CardUnmaskDelegate> delegate) override;
69 void OnUnmaskVerificationResult(GetRealPanResult result) override;
70 void ConfirmSaveCreditCard(const base::Closure& save_card_callback) override;
71 bool HasCreditCardScanFeature() override;
72 void ScanCreditCard(const CreditCardScanCallback& callback) override;
73 void ShowRequestAutocompleteDialog(const autofill::FormData& form,
74 content::RenderFrameHost* rfh,
75 const ResultCallback& callback) override;
76 void ShowAutofillPopup(
77 const gfx::RectF& element_bounds,
78 base::i18n::TextDirection text_direction,
79 const std::vector<autofill::Suggestion>& suggestions,
80 base::WeakPtr<autofill::AutofillPopupDelegate> delegate) override;
81 void UpdateAutofillPopupDataListValues(
82 const std::vector<base::string16>& values,
83 const std::vector<base::string16>& labels) override;
84 void HideAutofillPopup() override;
85 bool IsAutocompleteEnabled() override;
86 void PropagateAutofillPredictions(
87 content::RenderFrameHost* rfh,
88 const std::vector<autofill::FormStructure*>& forms) override;
89 void DidFillOrPreviewField(const base::string16& autofilled_value,
90 const base::string16& profile_full_name) override;
91 void OnFirstUserGestureObserved() override;
92 void LinkClicked(const GURL& url, WindowOpenDisposition disposition) override;
94 void SuggestionSelected(JNIEnv* env, jobject obj, jint position);
96 private:
97 AwAutofillClient(content::WebContents* web_contents);
98 friend class content::WebContentsUserData<AwAutofillClient>;
100 void ShowAutofillPopupImpl(
101 const gfx::RectF& element_bounds,
102 bool is_rtl,
103 const std::vector<autofill::Suggestion>& suggestions);
105 // The web_contents associated with this delegate.
106 content::WebContents* web_contents_;
107 bool save_form_data_;
108 JavaObjectWeakGlobalRef java_ref_;
110 // The current Autofill query values.
111 std::vector<autofill::Suggestion> suggestions_;
112 base::WeakPtr<autofill::AutofillPopupDelegate> delegate_;
114 DISALLOW_COPY_AND_ASSIGN(AwAutofillClient);
117 bool RegisterAwAutofillClient(JNIEnv* env);
119 } // namespace android_webview
121 #endif // ANDROID_WEBVIEW_NATIVE_AW_AUTOFILL_CLIENT_H_