blob: 40588b5eb1695238724c64ab3626a7304f0b93d8 [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// 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)2a99a7e2013-03-28 15:31:22 +00008#include "base/callback.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +00009#include "base/compiler_specific.h"
Torne (Richard Coles)7d4cd472013-06-19 11:58:07 +010010#include "base/i18n/rtl.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000011#include "base/memory/weak_ptr.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000012#include "chrome/browser/ui/autofill/autofill_dialog_types.h"
Ben Murdocheb525c52013-07-10 11:40:50 +010013#include "components/autofill/content/browser/autocheckout_steps.h"
Ben Murdoch7dbb3d52013-07-17 14:55:54 +010014#include "components/autofill/core/browser/autocheckout_bubble_state.h"
Ben Murdocheb525c52013-07-10 11:40:50 +010015#include "components/autofill/core/browser/autofill_manager_delegate.h"
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000016#include "content/public/browser/web_contents_observer.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000017#include "content/public/browser/web_contents_user_data.h"
18
19namespace content {
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000020struct FrameNavigateParams;
21struct LoadCommittedDetails;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000022class WebContents;
23}
24
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000025namespace autofill {
26
27class AutocheckoutBubble;
28class AutofillDialogControllerImpl;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010029class AutofillPopupControllerImpl;
30struct FormData;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000031
Torne (Richard Coles)58218062012-11-14 11:43:16 +000032// Chrome implementation of AutofillManagerDelegate.
33class TabAutofillManagerDelegate
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000034 : public AutofillManagerDelegate,
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000035 public content::WebContentsUserData<TabAutofillManagerDelegate>,
36 public content::WebContentsObserver {
Torne (Richard Coles)58218062012-11-14 11:43:16 +000037 public:
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000038 virtual ~TabAutofillManagerDelegate();
Torne (Richard Coles)58218062012-11-14 11:43:16 +000039
Ben Murdoch58e6fbe2013-07-26 10:20:38 +010040 // Called when the tab corresponding to |this| instance is activated.
41 void TabActivated(int reason);
42
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000043 // 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)2a99a7e2013-03-28 15:31:22 +000049 virtual void OnAutocheckoutError() OVERRIDE;
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010050 virtual void OnAutocheckoutSuccess() OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000051 virtual void ShowAutofillSettings() OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000052 virtual void ConfirmSaveCreditCard(
53 const AutofillMetrics& metric_logger,
54 const CreditCard& credit_card,
55 const base::Closure& save_card_callback) OVERRIDE;
Ben Murdochbb1529c2013-08-08 10:24:53 +010056 virtual bool ShowAutocheckoutBubble(
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000057 const gfx::RectF& bounds,
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010058 bool is_google_user,
Ben Murdoch7dbb3d52013-07-17 14:55:54 +010059 const base::Callback<void(AutocheckoutBubbleState)>& callback) OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000060 virtual void HideAutocheckoutBubble() OVERRIDE;
61 virtual void ShowRequestAutocompleteDialog(
62 const FormData& form,
63 const GURL& source_url,
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000064 DialogType dialog_type,
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010065 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)7d4cd472013-06-19 11:58:07 +010069 base::i18n::TextDirection text_direction,
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010070 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 Murdochca12bfa2013-07-23 11:17:05 +010075 virtual void UpdateAutofillPopupDataListValues(
76 const std::vector<base::string16>& values,
77 const std::vector<base::string16>& labels) OVERRIDE;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000078 virtual void HideAutofillPopup() OVERRIDE;
Ben Murdocheb525c52013-07-10 11:40:50 +010079 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)2a99a7e2013-03-28 15:31:22 +000085
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000086 // content::WebContentsObserver implementation.
87 virtual void DidNavigateMainFrame(
88 const content::LoadCommittedDetails& details,
89 const content::FrameNavigateParams& params) OVERRIDE;
Ben Murdoch7dbb3d52013-07-17 14:55:54 +010090 virtual void WebContentsDestroyed(
91 content::WebContents* web_contents) OVERRIDE;
Ben Murdochbb1529c2013-08-08 10:24:53 +010092 virtual void WasShown() OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000093
Ben Murdocheb525c52013-07-10 11:40:50 +010094 // Exposed for testing.
95 AutofillDialogControllerImpl* GetDialogControllerForTesting() {
96 return dialog_controller_.get();
97 }
98
Torne (Richard Coles)58218062012-11-14 11:43:16 +000099 private:
100 explicit TabAutofillManagerDelegate(content::WebContents* web_contents);
101 friend class content::WebContentsUserData<TabAutofillManagerDelegate>;
102
103 content::WebContents* const web_contents_;
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +0100104 base::WeakPtr<AutofillDialogControllerImpl> dialog_controller_;
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000105 base::WeakPtr<AutocheckoutBubble> autocheckout_bubble_;
106 base::WeakPtr<AutofillPopupControllerImpl> popup_controller_;
107
108 DISALLOW_COPY_AND_ASSIGN(TabAutofillManagerDelegate);
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000109};
110
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +0000111} // namespace autofill
112
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000113#endif // CHROME_BROWSER_UI_AUTOFILL_TAB_AUTOFILL_MANAGER_DELEGATE_H_