OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013 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_AUTOFILL_AUTOCHECKOUT_MANAGER_H_ | |
6 #define CHROME_BROWSER_AUTOFILL_AUTOCHECKOUT_MANAGER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/memory/weak_ptr.h" | |
12 #include "base/string16.h" | |
13 #include "chrome/browser/autofill/autocheckout_page_meta_data.h" | |
14 #include "ui/gfx/native_widget_types.h" | |
15 | |
16 class AutofillField; | |
17 class AutofillManager; | |
18 class AutofillProfile; | |
19 class CreditCard; | |
20 class FormStructure; | |
21 class GURL; | |
22 | |
23 struct FormData; | |
24 struct FormFieldData; | |
25 | |
26 namespace content { | |
27 struct SSLStatus; | |
28 } | |
29 | |
30 namespace gfx { | |
31 class RectF; | |
32 } | |
33 | |
34 namespace autofill { | |
35 | |
36 class AutocheckoutManager { | |
37 public: | |
38 explicit AutocheckoutManager(AutofillManager* autofill_manager); | |
39 virtual ~AutocheckoutManager(); | |
40 | |
41 // Fill all the forms seen by the Autofill manager with the information | |
42 // gathered from the requestAutocomplete dialog. | |
43 void FillForms(); | |
44 | |
45 // Sets |page_meta_data_| with the meta data for the current page. | |
46 void OnLoadedPageMetaData( | |
47 scoped_ptr<AutocheckoutPageMetaData> page_meta_data); | |
48 | |
49 // Called when a page containing forms is loaded. | |
50 void OnFormsSeen(); | |
51 | |
52 // Causes the Autocheckout bubble to be displayed if the user hasn't seen it | |
53 // yet for the current page. |frame_url| is the page where Autocheckout is | |
54 // being initiated. |ssl_status| is the SSL status of the page. |native_view| | |
55 // is the parent view of the bubble. |bounding_box| is the bounding box of the | |
56 // input field in focus. Returns true if the bubble was shown and false | |
57 // otherwise. | |
58 virtual bool MaybeShowAutocheckoutBubble(const GURL& frame_url, | |
59 const content::SSLStatus& ssl_status, | |
60 const gfx::NativeView& native_view, | |
61 const gfx::RectF& bounding_box); | |
62 | |
63 // Show the requestAutocomplete dialog. | |
64 virtual void ShowAutocheckoutDialog(const GURL& frame_url, | |
65 const content::SSLStatus& ssl_status); | |
66 | |
67 // Whether or not the current page is the start of a multipage Autofill flow. | |
68 bool IsStartOfAutofillableFlow() const; | |
69 | |
70 // Whether or not the current page is part of a multipage Autofill flow. | |
71 bool IsInAutofillableFlow() const; | |
72 | |
73 protected: | |
74 // Exposed for testing. | |
75 bool in_autocheckout_flow() const { return in_autocheckout_flow_; } | |
76 | |
77 // Exposed for testing. | |
78 bool autocheckout_bubble_shown() const { return autocheckout_bubble_shown_; } | |
79 | |
80 private: | |
81 // Callback called from AutofillDialogController on filling up the UI form. | |
82 void ReturnAutocheckoutData(const FormStructure* result); | |
83 | |
84 // Sets value of form field data |field_to_fill| based on the Autofill | |
85 // field type specified by |field|. | |
86 void SetValue(const AutofillField& field, FormFieldData* field_to_fill); | |
87 | |
88 AutofillManager* autofill_manager_; // WEAK; owns us | |
89 | |
90 // Credit card verification code. | |
91 string16 cvv_; | |
92 | |
93 // Profile built using the data supplied by requestAutocomplete dialog. | |
94 scoped_ptr<AutofillProfile> profile_; | |
95 | |
96 // Credit card built using the data supplied by requestAutocomplete dialog. | |
97 scoped_ptr<CreditCard> credit_card_; | |
98 | |
99 // Autocheckout specific page meta data. | |
100 scoped_ptr<AutocheckoutPageMetaData> page_meta_data_; | |
101 | |
102 // Whether or not the Autocheckout bubble has been displayed to the user for | |
103 // the current forms. Ensures the Autocheckout bubble is only shown to a | |
104 // user once per pageview. | |
105 bool autocheckout_bubble_shown_; | |
106 | |
107 // Whether or not the user is in an Autocheckout flow. | |
108 bool in_autocheckout_flow_; | |
109 | |
110 base::WeakPtrFactory<AutocheckoutManager> weak_ptr_factory_; | |
111 | |
112 DISALLOW_COPY_AND_ASSIGN(AutocheckoutManager); | |
113 }; | |
114 | |
115 } // namespace autofill | |
116 | |
117 #endif // CHROME_BROWSER_AUTOFILL_AUTOCHECKOUT_MANAGER_H_ | |
OLD | NEW |