- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / autofill / tab_autofill_manager_delegate.h
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
8 #include "base/callback.h"
9 #include "base/compiler_specific.h"
10 #include "base/i18n/rtl.h"
11 #include "base/memory/weak_ptr.h"
12 #include "components/autofill/core/browser/autofill_manager_delegate.h"
13 #include "content/public/browser/web_contents_observer.h"
14 #include "content/public/browser/web_contents_user_data.h"
15
16 namespace content {
17 struct FrameNavigateParams;
18 struct LoadCommittedDetails;
19 class WebContents;
20 }
21
22 namespace autofill {
23
24 class AutofillDialogController;
25 class AutofillPopupControllerImpl;
26 struct FormData;
27
28 // Chrome implementation of AutofillManagerDelegate.
29 class TabAutofillManagerDelegate
30     : public AutofillManagerDelegate,
31       public content::WebContentsUserData<TabAutofillManagerDelegate>,
32       public content::WebContentsObserver {
33  public:
34   virtual ~TabAutofillManagerDelegate();
35
36   // Called when the tab corresponding to |this| instance is activated.
37   void TabActivated(int reason);
38
39   // AutofillManagerDelegate implementation.
40   virtual PersonalDataManager* GetPersonalDataManager() OVERRIDE;
41   virtual PrefService* GetPrefs() OVERRIDE;
42   virtual void HideRequestAutocompleteDialog() OVERRIDE;
43   virtual void ShowAutofillSettings() OVERRIDE;
44   virtual void ConfirmSaveCreditCard(
45       const AutofillMetrics& metric_logger,
46       const CreditCard& credit_card,
47       const base::Closure& save_card_callback) OVERRIDE;
48   virtual void ShowRequestAutocompleteDialog(
49       const FormData& form,
50       const GURL& source_url,
51       const base::Callback<void(const FormStructure*)>& callback) OVERRIDE;
52   virtual void ShowAutofillPopup(
53       const gfx::RectF& element_bounds,
54       base::i18n::TextDirection text_direction,
55       const std::vector<string16>& values,
56       const std::vector<string16>& labels,
57       const std::vector<string16>& icons,
58       const std::vector<int>& identifiers,
59       base::WeakPtr<AutofillPopupDelegate> delegate) OVERRIDE;
60   virtual void UpdateAutofillPopupDataListValues(
61       const std::vector<base::string16>& values,
62       const std::vector<base::string16>& labels) OVERRIDE;
63   virtual void HideAutofillPopup() OVERRIDE;
64   virtual bool IsAutocompleteEnabled() OVERRIDE;
65
66   virtual void DetectAccountCreationForms(
67       const std::vector<autofill::FormStructure*>& forms) OVERRIDE;
68
69   // content::WebContentsObserver implementation.
70   virtual void DidNavigateMainFrame(
71       const content::LoadCommittedDetails& details,
72       const content::FrameNavigateParams& params) OVERRIDE;
73   virtual void WebContentsDestroyed(
74       content::WebContents* web_contents) OVERRIDE;
75   virtual void WasShown() OVERRIDE;
76
77   // Exposed for testing.
78   AutofillDialogController* GetDialogControllerForTesting() {
79     return dialog_controller_.get();
80   }
81
82  private:
83   explicit TabAutofillManagerDelegate(content::WebContents* web_contents);
84   friend class content::WebContentsUserData<TabAutofillManagerDelegate>;
85
86   content::WebContents* const web_contents_;
87   base::WeakPtr<AutofillDialogController> dialog_controller_;
88   base::WeakPtr<AutofillPopupControllerImpl> popup_controller_;
89
90   DISALLOW_COPY_AND_ASSIGN(TabAutofillManagerDelegate);
91 };
92
93 }  // namespace autofill
94
95 #endif  // CHROME_BROWSER_UI_AUTOFILL_TAB_AUTOFILL_MANAGER_DELEGATE_H_