OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ |
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/scoped_vector.h" | 18 #include "base/memory/scoped_vector.h" |
19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
20 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
22 #include "components/autofill/content/browser/autocheckout_manager.h" | |
23 #include "components/autofill/core/browser/autocomplete_history_manager.h" | 22 #include "components/autofill/core/browser/autocomplete_history_manager.h" |
24 #include "components/autofill/core/browser/autofill_download.h" | 23 #include "components/autofill/core/browser/autofill_download.h" |
25 #include "components/autofill/core/browser/autofill_manager_delegate.h" | 24 #include "components/autofill/core/browser/autofill_manager_delegate.h" |
26 #include "components/autofill/core/browser/form_structure.h" | 25 #include "components/autofill/core/browser/form_structure.h" |
27 #include "components/autofill/core/browser/personal_data_manager.h" | 26 #include "components/autofill/core/browser/personal_data_manager.h" |
28 #include "components/autofill/core/common/autocheckout_status.h" | |
29 #include "components/autofill/core/common/form_data.h" | 27 #include "components/autofill/core/common/form_data.h" |
30 #include "components/autofill/core/common/forms_seen_state.h" | 28 #include "components/autofill/core/common/forms_seen_state.h" |
31 #include "third_party/WebKit/public/web/WebFormElement.h" | 29 #include "third_party/WebKit/public/web/WebFormElement.h" |
32 | 30 |
33 class GURL; | 31 class GURL; |
34 | 32 |
35 namespace content { | 33 namespace content { |
36 class RenderViewHost; | 34 class RenderViewHost; |
37 class WebContents; | 35 class WebContents; |
38 } | 36 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 const gfx::RectF& bounds, | 158 const gfx::RectF& bounds, |
161 const std::vector<base::string16>& suggestions, | 159 const std::vector<base::string16>& suggestions, |
162 const std::vector<base::string16>& realms); | 160 const std::vector<base::string16>& realms); |
163 void OnSetDataList(const std::vector<base::string16>& values, | 161 void OnSetDataList(const std::vector<base::string16>& values, |
164 const std::vector<base::string16>& labels); | 162 const std::vector<base::string16>& labels); |
165 | 163 |
166 // Requests an interactive autocomplete UI be shown. | 164 // Requests an interactive autocomplete UI be shown. |
167 void OnRequestAutocomplete(const FormData& form, | 165 void OnRequestAutocomplete(const FormData& form, |
168 const GURL& frame_url); | 166 const GURL& frame_url); |
169 | 167 |
170 // Called to signal a page is completed in renderer in the Autocheckout flow. | |
171 void OnAutocheckoutPageCompleted(autofill::AutocheckoutStatus status); | |
172 | |
173 // Shows the Autocheckout bubble if conditions are right. See comments for | |
174 // AutocheckoutManager::MaybeShowAutocheckoutBubble. Input element requesting | |
175 // bubble belongs to |form|. |bounding_box| is the bounding box of the input | |
176 // field in focus. | |
177 virtual void OnMaybeShowAutocheckoutBubble(const FormData& form, | |
178 const gfx::RectF& bounding_box); | |
179 | |
180 // Resets cache. | 168 // Resets cache. |
181 virtual void Reset(); | 169 virtual void Reset(); |
182 | 170 |
183 autofill::AutocheckoutManager* autocheckout_manager() { | |
184 return &autocheckout_manager_; | |
185 } | |
186 | |
187 protected: | 171 protected: |
188 // Test code should prefer to use this constructor. | 172 // Test code should prefer to use this constructor. |
189 AutofillManager(AutofillDriver* driver, | 173 AutofillManager(AutofillDriver* driver, |
190 autofill::AutofillManagerDelegate* delegate, | 174 autofill::AutofillManagerDelegate* delegate, |
191 PersonalDataManager* personal_data); | 175 PersonalDataManager* personal_data); |
192 | 176 |
193 // Returns the value of the AutofillEnabled pref. | 177 // Returns the value of the AutofillEnabled pref. |
194 virtual bool IsAutofillEnabled() const; | 178 virtual bool IsAutofillEnabled() const; |
195 | 179 |
196 // Uploads the form data to the Autofill server. | 180 // Uploads the form data to the Autofill server. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 private: | 219 private: |
236 | 220 |
237 // AutofillDownloadManager::Observer: | 221 // AutofillDownloadManager::Observer: |
238 virtual void OnLoadedServerPredictions( | 222 virtual void OnLoadedServerPredictions( |
239 const std::string& response_xml) OVERRIDE; | 223 const std::string& response_xml) OVERRIDE; |
240 | 224 |
241 // Passes return data for an OnRequestAutocomplete call back to the page. | 225 // Passes return data for an OnRequestAutocomplete call back to the page. |
242 void ReturnAutocompleteData(const FormStructure* result, | 226 void ReturnAutocompleteData(const FormStructure* result, |
243 const std::string& unused_transaction_id); | 227 const std::string& unused_transaction_id); |
244 | 228 |
245 // Returns the matched whitelist URL prefix for the current tab's url. | |
246 virtual std::string GetAutocheckoutURLPrefix() const; | |
247 | |
248 // Fills |host| with the RenderViewHost for this tab. | 229 // Fills |host| with the RenderViewHost for this tab. |
249 // Returns false if Autofill is disabled or if the host is unavailable. | 230 // Returns false if Autofill is disabled or if the host is unavailable. |
250 bool GetHost(content::RenderViewHost** host) const WARN_UNUSED_RESULT; | 231 bool GetHost(content::RenderViewHost** host) const WARN_UNUSED_RESULT; |
251 | 232 |
252 // Unpacks |unique_id| and fills |form_group| and |variant| with the | 233 // Unpacks |unique_id| and fills |form_group| and |variant| with the |
253 // appropriate data source and variant index. Returns false if the unpacked | 234 // appropriate data source and variant index. Returns false if the unpacked |
254 // id cannot be found. | 235 // id cannot be found. |
255 bool GetProfileOrCreditCard(int unique_id, | 236 bool GetProfileOrCreditCard(int unique_id, |
256 const AutofillDataModel** data_model, | 237 const AutofillDataModel** data_model, |
257 size_t* variant) const WARN_UNUSED_RESULT; | 238 size_t* variant) const WARN_UNUSED_RESULT; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 307 |
327 std::list<std::string> autofilled_form_signatures_; | 308 std::list<std::string> autofilled_form_signatures_; |
328 | 309 |
329 // Handles queries and uploads to Autofill servers. Will be NULL if | 310 // Handles queries and uploads to Autofill servers. Will be NULL if |
330 // the download manager functionality is disabled. | 311 // the download manager functionality is disabled. |
331 scoped_ptr<AutofillDownloadManager> download_manager_; | 312 scoped_ptr<AutofillDownloadManager> download_manager_; |
332 | 313 |
333 // Handles single-field autocomplete form data. | 314 // Handles single-field autocomplete form data. |
334 scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_; | 315 scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_; |
335 | 316 |
336 // Handles autocheckout flows. | |
337 autofill::AutocheckoutManager autocheckout_manager_; | |
338 | |
339 // For logging UMA metrics. Overridden by metrics tests. | 317 // For logging UMA metrics. Overridden by metrics tests. |
340 scoped_ptr<const AutofillMetrics> metric_logger_; | 318 scoped_ptr<const AutofillMetrics> metric_logger_; |
341 // Have we logged whether Autofill is enabled for this page load? | 319 // Have we logged whether Autofill is enabled for this page load? |
342 bool has_logged_autofill_enabled_; | 320 bool has_logged_autofill_enabled_; |
343 // Have we logged an address suggestions count metric for this page? | 321 // Have we logged an address suggestions count metric for this page? |
344 bool has_logged_address_suggestions_count_; | 322 bool has_logged_address_suggestions_count_; |
345 // Have we shown Autofill suggestions at least once? | 323 // Have we shown Autofill suggestions at least once? |
346 bool did_show_suggestions_; | 324 bool did_show_suggestions_; |
347 // Has the user manually edited at least one form field among the autofillable | 325 // Has the user manually edited at least one form field among the autofillable |
348 // ones? | 326 // ones? |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 UserHappinessFormLoadAndSubmission); | 376 UserHappinessFormLoadAndSubmission); |
399 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); | 377 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); |
400 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, | 378 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, |
401 FormSubmittedAutocompleteEnabled); | 379 FormSubmittedAutocompleteEnabled); |
402 DISALLOW_COPY_AND_ASSIGN(AutofillManager); | 380 DISALLOW_COPY_AND_ASSIGN(AutofillManager); |
403 }; | 381 }; |
404 | 382 |
405 } // namespace autofill | 383 } // namespace autofill |
406 | 384 |
407 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ | 385 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ |
OLD | NEW |