Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / autofill / chrome_autofill_client.h
blobd46bed28020eb858db3d6fc3ffcfcb3b19a2064e
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 CHROME_BROWSER_UI_AUTOFILL_CHROME_AUTOFILL_CLIENT_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_CHROME_AUTOFILL_CLIENT_H_
8 #include "base/callback.h"
9 #include "base/compiler_specific.h"
10 #include "base/i18n/rtl.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller_impl.h"
14 #include "components/autofill/core/browser/autofill_client.h"
15 #include "components/ui/zoom/zoom_observer.h"
16 #include "content/public/browser/web_contents_observer.h"
17 #include "content/public/browser/web_contents_user_data.h"
19 namespace content {
20 struct FrameNavigateParams;
21 struct LoadCommittedDetails;
22 class WebContents;
25 namespace autofill {
27 class AutofillDialogController;
28 class AutofillKeystoneBridgeWrapper;
29 class AutofillPopupControllerImpl;
30 class CreditCardScannerController;
31 struct FormData;
33 // Chrome implementation of AutofillClient.
34 class ChromeAutofillClient
35 : public AutofillClient,
36 public content::WebContentsUserData<ChromeAutofillClient>,
37 public content::WebContentsObserver,
38 public ui_zoom::ZoomObserver {
39 public:
40 ~ChromeAutofillClient() override;
42 // Called when the tab corresponding to |this| instance is activated.
43 void TabActivated();
45 // AutofillClient:
46 PersonalDataManager* GetPersonalDataManager() override;
47 scoped_refptr<AutofillWebDataService> GetDatabase() override;
48 PrefService* GetPrefs() override;
49 IdentityProvider* GetIdentityProvider() override;
50 rappor::RapporService* GetRapporService() override;
51 void HideRequestAutocompleteDialog() override;
52 void ShowAutofillSettings() override;
53 void ShowUnmaskPrompt(const CreditCard& card,
54 base::WeakPtr<CardUnmaskDelegate> delegate) override;
55 void OnUnmaskVerificationResult(GetRealPanResult result) override;
56 void ConfirmSaveCreditCard(const base::Closure& save_card_callback) override;
57 bool HasCreditCardScanFeature() override;
58 void ScanCreditCard(const CreditCardScanCallback& callback) override;
59 void ShowRequestAutocompleteDialog(
60 const FormData& form,
61 content::RenderFrameHost* render_frame_host,
62 const ResultCallback& callback) override;
63 void ShowAutofillPopup(
64 const gfx::RectF& element_bounds,
65 base::i18n::TextDirection text_direction,
66 const std::vector<autofill::Suggestion>& suggestions,
67 base::WeakPtr<AutofillPopupDelegate> delegate) override;
68 void UpdateAutofillPopupDataListValues(
69 const std::vector<base::string16>& values,
70 const std::vector<base::string16>& labels) override;
71 void HideAutofillPopup() override;
72 bool IsAutocompleteEnabled() override;
73 void PropagateAutofillPredictions(
74 content::RenderFrameHost* rfh,
75 const std::vector<autofill::FormStructure*>& forms) override;
76 void DidFillOrPreviewField(const base::string16& autofilled_value,
77 const base::string16& profile_full_name) override;
78 void OnFirstUserGestureObserved() override;
79 void LinkClicked(const GURL& url, WindowOpenDisposition disposition) override;
81 // content::WebContentsObserver implementation.
82 void RenderFrameDeleted(content::RenderFrameHost* rfh) override;
83 void DidNavigateAnyFrame(
84 content::RenderFrameHost* render_frame_host,
85 const content::LoadCommittedDetails& details,
86 const content::FrameNavigateParams& params) override;
87 void MainFrameWasResized(bool width_changed) override;
88 void WebContentsDestroyed() override;
90 // ZoomObserver implementation.
91 void OnZoomChanged(
92 const ui_zoom::ZoomController::ZoomChangedEventData& data) override;
94 // Exposed for testing.
95 AutofillDialogController* GetDialogControllerForTesting() {
96 return dialog_controller_.get();
98 void SetDialogControllerForTesting(
99 const base::WeakPtr<AutofillDialogController>& dialog_controller) {
100 dialog_controller_ = dialog_controller;
103 private:
104 #if defined(OS_MACOSX) && !defined(OS_IOS)
105 // Creates |bridge_wrapper_|, which is responsible for dealing with Keystone
106 // notifications.
107 void RegisterForKeystoneNotifications();
109 // Deletes |bridge_wrapper_|.
110 void UnregisterFromKeystoneNotifications();
111 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
113 explicit ChromeAutofillClient(content::WebContents* web_contents);
114 friend class content::WebContentsUserData<ChromeAutofillClient>;
116 base::WeakPtr<AutofillDialogController> dialog_controller_;
117 base::WeakPtr<AutofillPopupControllerImpl> popup_controller_;
118 CardUnmaskPromptControllerImpl unmask_controller_;
120 #if defined(OS_MACOSX) && !defined(OS_IOS)
121 // Listens to Keystone notifications and passes relevant ones on to the
122 // PersonalDataManager.
124 // The class of this member must remain a forward declaration, even in the
125 // .cc implementation file, since the class is defined in a Mac-only
126 // implementation file. This means that the pointer cannot be wrapped in a
127 // scoped_ptr.
128 AutofillKeystoneBridgeWrapper* bridge_wrapper_;
129 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
131 // The last render frame that called requestAutocomplete.
132 content::RenderFrameHost* last_rfh_to_rac_;
134 // The identity provider, used for Wallet integration.
135 scoped_ptr<IdentityProvider> identity_provider_;
137 DISALLOW_COPY_AND_ASSIGN(ChromeAutofillClient);
140 } // namespace autofill
142 #endif // CHROME_BROWSER_UI_AUTOFILL_CHROME_AUTOFILL_CLIENT_H_