OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_BROWSER_AUTOFILL_MANAGER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_MANAGER_H_ |
6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_MANAGER_H_ | 6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_MANAGER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 72 } |
73 | 73 |
74 // Manages saving and restoring the user's personal information entered into web | 74 // Manages saving and restoring the user's personal information entered into web |
75 // forms. | 75 // forms. |
76 class AutofillManager : public content::WebContentsObserver, | 76 class AutofillManager : public content::WebContentsObserver, |
77 public AutofillDownloadManager::Observer, | 77 public AutofillDownloadManager::Observer, |
78 public base::SupportsUserData::Data { | 78 public base::SupportsUserData::Data { |
79 public: | 79 public: |
80 static void CreateForWebContentsAndDelegate( | 80 static void CreateForWebContentsAndDelegate( |
81 content::WebContents* contents, | 81 content::WebContents* contents, |
82 autofill::AutofillManagerDelegate* delegate); | 82 autofill::AutofillManagerDelegate* delegate, |
| 83 const std::string& app_locale); |
83 static AutofillManager* FromWebContents(content::WebContents* contents); | 84 static AutofillManager* FromWebContents(content::WebContents* contents); |
84 | 85 |
85 // Registers our Enable/Disable Autofill pref. | 86 // Registers our Enable/Disable Autofill pref. |
86 static void RegisterUserPrefs(PrefRegistrySyncable* registry); | 87 static void RegisterUserPrefs(PrefRegistrySyncable* registry); |
87 | 88 |
88 // Set an external delegate. | 89 // Set an external delegate. |
89 void SetExternalDelegate(AutofillExternalDelegate* delegate); | 90 void SetExternalDelegate(AutofillExternalDelegate* delegate); |
90 | 91 |
91 // Whether browser process will create and own the Autofill popup UI. | 92 // Whether browser process will create and own the Autofill popup UI. |
92 bool IsNativeUiEnabled(); | 93 bool IsNativeUiEnabled(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 const base::Callback<void(const FormStructure*, | 126 const base::Callback<void(const FormStructure*, |
126 const std::string&)>& callback); | 127 const std::string&)>& callback); |
127 | 128 |
128 // Happens when the autocomplete dialog runs its callback when being closed. | 129 // Happens when the autocomplete dialog runs its callback when being closed. |
129 void RequestAutocompleteDialogClosed(); | 130 void RequestAutocompleteDialogClosed(); |
130 | 131 |
131 autofill::AutofillManagerDelegate* delegate() const { | 132 autofill::AutofillManagerDelegate* delegate() const { |
132 return manager_delegate_; | 133 return manager_delegate_; |
133 } | 134 } |
134 | 135 |
| 136 const std::string& app_locale() const { return app_locale_; } |
| 137 |
135 // Only for testing. | 138 // Only for testing. |
136 void SetTestDelegate(autofill::AutofillManagerTestDelegate* delegate); | 139 void SetTestDelegate(autofill::AutofillManagerTestDelegate* delegate); |
137 | 140 |
138 protected: | 141 protected: |
139 // Only test code should subclass AutofillManager. | 142 // Only test code should subclass AutofillManager. |
140 AutofillManager(content::WebContents* web_contents, | 143 AutofillManager(content::WebContents* web_contents, |
141 autofill::AutofillManagerDelegate* delegate); | 144 autofill::AutofillManagerDelegate* delegate, |
| 145 const std::string& app_locale); |
142 virtual ~AutofillManager(); | 146 virtual ~AutofillManager(); |
143 | 147 |
144 // Test code should prefer to use this constructor. | 148 // Test code should prefer to use this constructor. |
145 AutofillManager(content::WebContents* web_contents, | 149 AutofillManager(content::WebContents* web_contents, |
146 autofill::AutofillManagerDelegate* delegate, | 150 autofill::AutofillManagerDelegate* delegate, |
147 PersonalDataManager* personal_data); | 151 PersonalDataManager* personal_data); |
148 | 152 |
149 // Returns the value of the AutofillEnabled pref. | 153 // Returns the value of the AutofillEnabled pref. |
150 virtual bool IsAutofillEnabled() const; | 154 virtual bool IsAutofillEnabled() const; |
151 | 155 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 void UpdateInitialInteractionTimestamp( | 355 void UpdateInitialInteractionTimestamp( |
352 const base::TimeTicks& interaction_timestamp); | 356 const base::TimeTicks& interaction_timestamp); |
353 | 357 |
354 // Send our current field type predictions to the renderer. This is a no-op if | 358 // Send our current field type predictions to the renderer. This is a no-op if |
355 // the appropriate command-line flag is not set. | 359 // the appropriate command-line flag is not set. |
356 void SendAutofillTypePredictions( | 360 void SendAutofillTypePredictions( |
357 const std::vector<FormStructure*>& forms) const; | 361 const std::vector<FormStructure*>& forms) const; |
358 | 362 |
359 autofill::AutofillManagerDelegate* const manager_delegate_; | 363 autofill::AutofillManagerDelegate* const manager_delegate_; |
360 | 364 |
| 365 std::string app_locale_; |
| 366 |
361 // The personal data manager, used to save and load personal data to/from the | 367 // The personal data manager, used to save and load personal data to/from the |
362 // web database. This is overridden by the AutofillManagerTest. | 368 // web database. This is overridden by the AutofillManagerTest. |
363 // Weak reference. | 369 // Weak reference. |
364 // May be NULL. NULL indicates OTR. | 370 // May be NULL. NULL indicates OTR. |
365 PersonalDataManager* personal_data_; | 371 PersonalDataManager* personal_data_; |
366 | 372 |
367 std::list<std::string> autofilled_form_signatures_; | 373 std::list<std::string> autofilled_form_signatures_; |
368 | 374 |
369 // Handles queries and uploads to Autofill servers. | 375 // Handles queries and uploads to Autofill servers. |
370 AutofillDownloadManager download_manager_; | 376 AutofillDownloadManager download_manager_; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, | 455 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, |
450 TestTabContentsWithExternalDelegate); | 456 TestTabContentsWithExternalDelegate); |
451 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, | 457 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, |
452 UserHappinessFormLoadAndSubmission); | 458 UserHappinessFormLoadAndSubmission); |
453 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); | 459 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); |
454 | 460 |
455 DISALLOW_COPY_AND_ASSIGN(AutofillManager); | 461 DISALLOW_COPY_AND_ASSIGN(AutofillManager); |
456 }; | 462 }; |
457 | 463 |
458 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_MANAGER_H_ | 464 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_MANAGER_H_ |
OLD | NEW |