Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1 | // Copyright (c) 2012 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. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_UI_AUTOFILL_TAB_AUTOFILL_MANAGER_DELEGATE_H_ |
| 6 | #define CHROME_BROWSER_UI_AUTOFILL_TAB_AUTOFILL_MANAGER_DELEGATE_H_ |
| 7 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 8 | #include "base/callback.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 9 | #include "base/compiler_specific.h" |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 10 | #include "base/i18n/rtl.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 11 | #include "base/memory/weak_ptr.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 12 | #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 13 | #include "components/autofill/content/browser/autocheckout_steps.h" |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 14 | #include "components/autofill/core/browser/autocheckout_bubble_state.h" |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 15 | #include "components/autofill/core/browser/autofill_manager_delegate.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 16 | #include "content/public/browser/web_contents_observer.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 17 | #include "content/public/browser/web_contents_user_data.h" |
| 18 | |
| 19 | namespace content { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 20 | struct FrameNavigateParams; |
| 21 | struct LoadCommittedDetails; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 22 | class WebContents; |
| 23 | } |
| 24 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 25 | namespace autofill { |
| 26 | |
| 27 | class AutocheckoutBubble; |
| 28 | class AutofillDialogControllerImpl; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 29 | class AutofillPopupControllerImpl; |
| 30 | struct FormData; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 31 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 32 | // Chrome implementation of AutofillManagerDelegate. |
| 33 | class TabAutofillManagerDelegate |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 34 | : public AutofillManagerDelegate, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 35 | public content::WebContentsUserData<TabAutofillManagerDelegate>, |
| 36 | public content::WebContentsObserver { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 37 | public: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 38 | virtual ~TabAutofillManagerDelegate(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 39 | |
Ben Murdoch | 58e6fbe | 2013-07-26 10:20:38 +0100 | [diff] [blame] | 40 | // Called when the tab corresponding to |this| instance is activated. |
| 41 | void TabActivated(int reason); |
| 42 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 43 | // AutofillManagerDelegate implementation. |
| 44 | virtual PersonalDataManager* GetPersonalDataManager() OVERRIDE; |
| 45 | virtual PrefService* GetPrefs() OVERRIDE; |
| 46 | virtual autocheckout::WhitelistManager* |
| 47 | GetAutocheckoutWhitelistManager() const OVERRIDE; |
| 48 | virtual void HideRequestAutocompleteDialog() OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 49 | virtual void OnAutocheckoutError() OVERRIDE; |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 50 | virtual void OnAutocheckoutSuccess() OVERRIDE; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 51 | virtual void ShowAutofillSettings() OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 52 | virtual void ConfirmSaveCreditCard( |
| 53 | const AutofillMetrics& metric_logger, |
| 54 | const CreditCard& credit_card, |
| 55 | const base::Closure& save_card_callback) OVERRIDE; |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 56 | virtual bool ShowAutocheckoutBubble( |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 57 | const gfx::RectF& bounds, |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 58 | bool is_google_user, |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 59 | const base::Callback<void(AutocheckoutBubbleState)>& callback) OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 60 | virtual void HideAutocheckoutBubble() OVERRIDE; |
| 61 | virtual void ShowRequestAutocompleteDialog( |
| 62 | const FormData& form, |
| 63 | const GURL& source_url, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 64 | DialogType dialog_type, |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 65 | const base::Callback<void(const FormStructure*, |
| 66 | const std::string&)>& callback) OVERRIDE; |
| 67 | virtual void ShowAutofillPopup( |
| 68 | const gfx::RectF& element_bounds, |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 69 | base::i18n::TextDirection text_direction, |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 70 | const std::vector<string16>& values, |
| 71 | const std::vector<string16>& labels, |
| 72 | const std::vector<string16>& icons, |
| 73 | const std::vector<int>& identifiers, |
| 74 | base::WeakPtr<AutofillPopupDelegate> delegate) OVERRIDE; |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 75 | virtual void UpdateAutofillPopupDataListValues( |
| 76 | const std::vector<base::string16>& values, |
| 77 | const std::vector<base::string16>& labels) OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 78 | virtual void HideAutofillPopup() OVERRIDE; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 79 | virtual bool IsAutocompleteEnabled() OVERRIDE; |
| 80 | |
| 81 | virtual void AddAutocheckoutStep(AutocheckoutStepType step_type) OVERRIDE; |
| 82 | virtual void UpdateAutocheckoutStep( |
| 83 | AutocheckoutStepType step_type, |
| 84 | AutocheckoutStepStatus step_status) OVERRIDE; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 85 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 86 | // content::WebContentsObserver implementation. |
| 87 | virtual void DidNavigateMainFrame( |
| 88 | const content::LoadCommittedDetails& details, |
| 89 | const content::FrameNavigateParams& params) OVERRIDE; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 90 | virtual void WebContentsDestroyed( |
| 91 | content::WebContents* web_contents) OVERRIDE; |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 92 | virtual void WasShown() OVERRIDE; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 93 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 94 | // Exposed for testing. |
| 95 | AutofillDialogControllerImpl* GetDialogControllerForTesting() { |
| 96 | return dialog_controller_.get(); |
| 97 | } |
| 98 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 99 | private: |
| 100 | explicit TabAutofillManagerDelegate(content::WebContents* web_contents); |
| 101 | friend class content::WebContentsUserData<TabAutofillManagerDelegate>; |
| 102 | |
| 103 | content::WebContents* const web_contents_; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 104 | base::WeakPtr<AutofillDialogControllerImpl> dialog_controller_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 105 | base::WeakPtr<AutocheckoutBubble> autocheckout_bubble_; |
| 106 | base::WeakPtr<AutofillPopupControllerImpl> popup_controller_; |
| 107 | |
| 108 | DISALLOW_COPY_AND_ASSIGN(TabAutofillManagerDelegate); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 109 | }; |
| 110 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 111 | } // namespace autofill |
| 112 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 113 | #endif // CHROME_BROWSER_UI_AUTOFILL_TAB_AUTOFILL_MANAGER_DELEGATE_H_ |