| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_AUTOFILL_CHROME_AUTOFILL_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_CHROME_AUTOFILL_CLIENT_H_ |
| 6 #define CHROME_BROWSER_UI_AUTOFILL_CHROME_AUTOFILL_CLIENT_H_ | 6 #define CHROME_BROWSER_UI_AUTOFILL_CHROME_AUTOFILL_CLIENT_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "components/autofill/core/browser/autofill_client.h" | 16 #include "components/autofill/core/browser/autofill_client.h" |
| 17 #include "components/autofill/core/browser/ui/card_unmask_prompt_controller_impl
.h" | 17 #include "components/autofill/core/browser/ui/card_unmask_prompt_controller_impl
.h" |
| 18 #include "components/ui/zoom/zoom_observer.h" | 18 #include "components/ui/zoom/zoom_observer.h" |
| 19 #include "content/public/browser/web_contents_observer.h" | 19 #include "content/public/browser/web_contents_observer.h" |
| 20 #include "content/public/browser/web_contents_user_data.h" | 20 #include "content/public/browser/web_contents_user_data.h" |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 struct FrameNavigateParams; | 23 struct FrameNavigateParams; |
| 24 struct LoadCommittedDetails; | 24 struct LoadCommittedDetails; |
| 25 class WebContents; | 25 class WebContents; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace autofill { | 28 namespace autofill { |
| 29 | 29 |
| 30 class AutofillDialogController; | |
| 31 class AutofillPopupControllerImpl; | 30 class AutofillPopupControllerImpl; |
| 32 class CreditCardScannerController; | 31 class CreditCardScannerController; |
| 33 struct FormData; | 32 struct FormData; |
| 34 | 33 |
| 35 // Chrome implementation of AutofillClient. | 34 // Chrome implementation of AutofillClient. |
| 36 class ChromeAutofillClient | 35 class ChromeAutofillClient |
| 37 : public AutofillClient, | 36 : public AutofillClient, |
| 38 public content::WebContentsUserData<ChromeAutofillClient>, | 37 public content::WebContentsUserData<ChromeAutofillClient>, |
| 39 public content::WebContentsObserver, | 38 public content::WebContentsObserver, |
| 40 public ui_zoom::ZoomObserver { | 39 public ui_zoom::ZoomObserver { |
| 41 public: | 40 public: |
| 42 ~ChromeAutofillClient() override; | 41 ~ChromeAutofillClient() override; |
| 43 | 42 |
| 44 // Called when the tab corresponding to |this| instance is activated. | |
| 45 void TabActivated(); | |
| 46 | |
| 47 // AutofillClient: | 43 // AutofillClient: |
| 48 PersonalDataManager* GetPersonalDataManager() override; | 44 PersonalDataManager* GetPersonalDataManager() override; |
| 49 scoped_refptr<AutofillWebDataService> GetDatabase() override; | 45 scoped_refptr<AutofillWebDataService> GetDatabase() override; |
| 50 PrefService* GetPrefs() override; | 46 PrefService* GetPrefs() override; |
| 51 sync_driver::SyncService* GetSyncService() override; | 47 sync_driver::SyncService* GetSyncService() override; |
| 52 IdentityProvider* GetIdentityProvider() override; | 48 IdentityProvider* GetIdentityProvider() override; |
| 53 rappor::RapporService* GetRapporService() override; | 49 rappor::RapporService* GetRapporService() override; |
| 54 void HideRequestAutocompleteDialog() override; | |
| 55 void ShowAutofillSettings() override; | 50 void ShowAutofillSettings() override; |
| 56 void ShowUnmaskPrompt(const CreditCard& card, | 51 void ShowUnmaskPrompt(const CreditCard& card, |
| 57 UnmaskCardReason reason, | 52 UnmaskCardReason reason, |
| 58 base::WeakPtr<CardUnmaskDelegate> delegate) override; | 53 base::WeakPtr<CardUnmaskDelegate> delegate) override; |
| 59 void OnUnmaskVerificationResult(PaymentsRpcResult result) override; | 54 void OnUnmaskVerificationResult(PaymentsRpcResult result) override; |
| 60 void ConfirmSaveCreditCardLocally(const CreditCard& card, | 55 void ConfirmSaveCreditCardLocally(const CreditCard& card, |
| 61 const base::Closure& callback) override; | 56 const base::Closure& callback) override; |
| 62 void ConfirmSaveCreditCardToCloud( | 57 void ConfirmSaveCreditCardToCloud( |
| 63 const CreditCard& card, | 58 const CreditCard& card, |
| 64 std::unique_ptr<base::DictionaryValue> legal_message, | 59 std::unique_ptr<base::DictionaryValue> legal_message, |
| 65 const base::Closure& callback) override; | 60 const base::Closure& callback) override; |
| 66 void LoadRiskData( | 61 void LoadRiskData( |
| 67 const base::Callback<void(const std::string&)>& callback) override; | 62 const base::Callback<void(const std::string&)>& callback) override; |
| 68 bool HasCreditCardScanFeature() override; | 63 bool HasCreditCardScanFeature() override; |
| 69 void ScanCreditCard(const CreditCardScanCallback& callback) override; | 64 void ScanCreditCard(const CreditCardScanCallback& callback) override; |
| 70 void ShowRequestAutocompleteDialog( | |
| 71 const FormData& form, | |
| 72 content::RenderFrameHost* render_frame_host, | |
| 73 const ResultCallback& callback) override; | |
| 74 void ShowAutofillPopup( | 65 void ShowAutofillPopup( |
| 75 const gfx::RectF& element_bounds, | 66 const gfx::RectF& element_bounds, |
| 76 base::i18n::TextDirection text_direction, | 67 base::i18n::TextDirection text_direction, |
| 77 const std::vector<autofill::Suggestion>& suggestions, | 68 const std::vector<autofill::Suggestion>& suggestions, |
| 78 base::WeakPtr<AutofillPopupDelegate> delegate) override; | 69 base::WeakPtr<AutofillPopupDelegate> delegate) override; |
| 79 void UpdateAutofillPopupDataListValues( | 70 void UpdateAutofillPopupDataListValues( |
| 80 const std::vector<base::string16>& values, | 71 const std::vector<base::string16>& values, |
| 81 const std::vector<base::string16>& labels) override; | 72 const std::vector<base::string16>& labels) override; |
| 82 void HideAutofillPopup() override; | 73 void HideAutofillPopup() override; |
| 83 bool IsAutocompleteEnabled() override; | 74 bool IsAutocompleteEnabled() override; |
| 84 void PropagateAutofillPredictions( | 75 void PropagateAutofillPredictions( |
| 85 content::RenderFrameHost* rfh, | 76 content::RenderFrameHost* rfh, |
| 86 const std::vector<autofill::FormStructure*>& forms) override; | 77 const std::vector<autofill::FormStructure*>& forms) override; |
| 87 void DidFillOrPreviewField(const base::string16& autofilled_value, | 78 void DidFillOrPreviewField(const base::string16& autofilled_value, |
| 88 const base::string16& profile_full_name) override; | 79 const base::string16& profile_full_name) override; |
| 89 void OnFirstUserGestureObserved() override; | 80 void OnFirstUserGestureObserved() override; |
| 90 bool IsContextSecure(const GURL& form_origin) override; | 81 bool IsContextSecure(const GURL& form_origin) override; |
| 91 | 82 |
| 92 // content::WebContentsObserver implementation. | 83 // content::WebContentsObserver implementation. |
| 93 void RenderFrameDeleted(content::RenderFrameHost* rfh) override; | |
| 94 void DidNavigateAnyFrame( | |
| 95 content::RenderFrameHost* render_frame_host, | |
| 96 const content::LoadCommittedDetails& details, | |
| 97 const content::FrameNavigateParams& params) override; | |
| 98 void MainFrameWasResized(bool width_changed) override; | 84 void MainFrameWasResized(bool width_changed) override; |
| 99 void WebContentsDestroyed() override; | 85 void WebContentsDestroyed() override; |
| 100 | 86 |
| 101 // ZoomObserver implementation. | 87 // ZoomObserver implementation. |
| 102 void OnZoomChanged( | 88 void OnZoomChanged( |
| 103 const ui_zoom::ZoomController::ZoomChangedEventData& data) override; | 89 const ui_zoom::ZoomController::ZoomChangedEventData& data) override; |
| 104 | 90 |
| 105 // Exposed for testing. | |
| 106 AutofillDialogController* GetDialogControllerForTesting() { | |
| 107 return dialog_controller_.get(); | |
| 108 } | |
| 109 void SetDialogControllerForTesting( | |
| 110 const base::WeakPtr<AutofillDialogController>& dialog_controller) { | |
| 111 dialog_controller_ = dialog_controller; | |
| 112 } | |
| 113 | |
| 114 private: | 91 private: |
| 115 explicit ChromeAutofillClient(content::WebContents* web_contents); | 92 explicit ChromeAutofillClient(content::WebContents* web_contents); |
| 116 friend class content::WebContentsUserData<ChromeAutofillClient>; | 93 friend class content::WebContentsUserData<ChromeAutofillClient>; |
| 117 | 94 |
| 118 base::WeakPtr<AutofillDialogController> dialog_controller_; | |
| 119 base::WeakPtr<AutofillPopupControllerImpl> popup_controller_; | 95 base::WeakPtr<AutofillPopupControllerImpl> popup_controller_; |
| 120 CardUnmaskPromptControllerImpl unmask_controller_; | 96 CardUnmaskPromptControllerImpl unmask_controller_; |
| 121 | 97 |
| 122 // The last render frame that called requestAutocomplete. | |
| 123 content::RenderFrameHost* last_rfh_to_rac_; | |
| 124 | |
| 125 // The identity provider, used for Payments integration. | 98 // The identity provider, used for Payments integration. |
| 126 std::unique_ptr<IdentityProvider> identity_provider_; | 99 std::unique_ptr<IdentityProvider> identity_provider_; |
| 127 | 100 |
| 128 DISALLOW_COPY_AND_ASSIGN(ChromeAutofillClient); | 101 DISALLOW_COPY_AND_ASSIGN(ChromeAutofillClient); |
| 129 }; | 102 }; |
| 130 | 103 |
| 131 } // namespace autofill | 104 } // namespace autofill |
| 132 | 105 |
| 133 #endif // CHROME_BROWSER_UI_AUTOFILL_CHROME_AUTOFILL_CLIENT_H_ | 106 #endif // CHROME_BROWSER_UI_AUTOFILL_CHROME_AUTOFILL_CLIENT_H_ |
| OLD | NEW |