| 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 CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ | 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.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/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/memory/scoped_vector.h" | 19 #include "base/memory/scoped_vector.h" |
| 20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 21 #include "base/string16.h" | 21 #include "base/string16.h" |
| 22 #include "base/time.h" | 22 #include "base/time.h" |
| 23 #include "chrome/browser/autofill/autofill_download.h" | 23 #include "chrome/browser/autofill/autofill_download.h" |
| 24 #include "chrome/browser/autofill/field_types.h" | 24 #include "chrome/browser/autofill/field_types.h" |
| 25 #include "chrome/browser/autofill/form_structure.h" | 25 #include "chrome/browser/autofill/form_structure.h" |
| 26 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 26 #include "chrome/browser/sync/profile_sync_service_observer.h" | 27 #include "chrome/browser/sync/profile_sync_service_observer.h" |
| 28 #include "content/public/browser/notification_observer.h" |
| 27 #include "content/public/browser/web_contents_observer.h" | 29 #include "content/public/browser/web_contents_observer.h" |
| 28 | 30 |
| 29 class AutofillExternalDelegate; | 31 class AutofillExternalDelegate; |
| 30 class AutofillField; | 32 class AutofillField; |
| 31 class AutofillProfile; | 33 class AutofillProfile; |
| 32 class AutofillMetrics; | 34 class AutofillMetrics; |
| 33 class CreditCard; | 35 class CreditCard; |
| 34 class PersonalDataManager; | 36 class PersonalDataManager; |
| 35 class PrefService; | 37 class PrefService; |
| 36 class ProfileSyncService; | 38 class ProfileSyncService; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 53 namespace webkit { | 55 namespace webkit { |
| 54 namespace forms { | 56 namespace forms { |
| 55 struct FormData; | 57 struct FormData; |
| 56 struct FormField; | 58 struct FormField; |
| 57 struct PasswordFormFillData; | 59 struct PasswordFormFillData; |
| 58 } | 60 } |
| 59 } | 61 } |
| 60 | 62 |
| 61 // Manages saving and restoring the user's personal information entered into web | 63 // Manages saving and restoring the user's personal information entered into web |
| 62 // forms. | 64 // forms. |
| 63 class AutofillManager : public content::WebContentsObserver, | 65 class AutofillManager : public content::NotificationObserver, |
| 66 public content::WebContentsObserver, |
| 64 public AutofillDownloadManager::Observer, | 67 public AutofillDownloadManager::Observer, |
| 65 public ProfileSyncServiceObserver, | 68 public ProfileSyncServiceObserver, |
| 66 public base::RefCounted<AutofillManager> { | 69 public base::RefCounted<AutofillManager> { |
| 67 public: | 70 public: |
| 68 explicit AutofillManager(TabContentsWrapper* tab_contents); | 71 explicit AutofillManager(TabContentsWrapper* tab_contents); |
| 69 | 72 |
| 70 // Registers our Enable/Disable Autofill pref. | 73 // Registers our Enable/Disable Autofill pref. |
| 71 static void RegisterUserPrefs(PrefService* prefs); | 74 static void RegisterUserPrefs(PrefService* prefs); |
| 72 | 75 |
| 73 // Set our external delegate. | 76 // Set our external delegate. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // AutofillDownloadManager::Observer: | 173 // AutofillDownloadManager::Observer: |
| 171 virtual void OnLoadedServerPredictions( | 174 virtual void OnLoadedServerPredictions( |
| 172 const std::string& response_xml) OVERRIDE; | 175 const std::string& response_xml) OVERRIDE; |
| 173 | 176 |
| 174 // ProfileSyncServiceObserver: | 177 // ProfileSyncServiceObserver: |
| 175 virtual void OnStateChanged() OVERRIDE; | 178 virtual void OnStateChanged() OVERRIDE; |
| 176 | 179 |
| 177 // Register as an observer with the sync service. | 180 // Register as an observer with the sync service. |
| 178 void RegisterWithSyncService(); | 181 void RegisterWithSyncService(); |
| 179 | 182 |
| 183 // content::NotificationObserver override |
| 184 virtual void Observe(int type, |
| 185 const content::NotificationSource& source, |
| 186 const content::NotificationDetails& details) OVERRIDE; |
| 187 |
| 180 // Determines what the current state of password generation is, and if it has | 188 // Determines what the current state of password generation is, and if it has |
| 181 // changed from |password_generation_enabled_|. If it has changed or if | 189 // changed from |password_generation_enabled_|. If it has changed or if |
| 182 // |new_renderer| is true, it notifies the renderer of this change via | 190 // |new_renderer| is true, it notifies the renderer of this change via |
| 183 // SendPasswordGenerationStateToRenderer. | 191 // SendPasswordGenerationStateToRenderer. |
| 184 void UpdatePasswordGenerationState(content::RenderViewHost* host, | 192 void UpdatePasswordGenerationState(content::RenderViewHost* host, |
| 185 bool new_renderer); | 193 bool new_renderer); |
| 186 | 194 |
| 187 void OnFormsSeen(const std::vector<webkit::forms::FormData>& forms, | 195 void OnFormsSeen(const std::vector<webkit::forms::FormData>& forms, |
| 188 const base::TimeTicks& timestamp); | 196 const base::TimeTicks& timestamp); |
| 189 void OnTextFieldDidChange(const webkit::forms::FormData& form, | 197 void OnTextFieldDidChange(const webkit::forms::FormData& form, |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 // When the user first interacted with a potentially fillable form on this | 349 // When the user first interacted with a potentially fillable form on this |
| 342 // page. | 350 // page. |
| 343 base::TimeTicks initial_interaction_timestamp_; | 351 base::TimeTicks initial_interaction_timestamp_; |
| 344 // If password generation is enabled. We cache this value so that we don't | 352 // If password generation is enabled. We cache this value so that we don't |
| 345 // spam the renderer with messages during startup when the sync state | 353 // spam the renderer with messages during startup when the sync state |
| 346 // is changing rapidly. | 354 // is changing rapidly. |
| 347 bool password_generation_enabled_; | 355 bool password_generation_enabled_; |
| 348 // The ProfileSyncService associated with this tab. This may be NULL in | 356 // The ProfileSyncService associated with this tab. This may be NULL in |
| 349 // testing. | 357 // testing. |
| 350 base::WeakPtr<ProfileSyncService> sync_service_; | 358 base::WeakPtr<ProfileSyncService> sync_service_; |
| 359 // Listens for changes to the 'enabled' state for password generation. |
| 360 PrefChangeRegistrar registrar_; |
| 351 | 361 |
| 352 // Our copy of the form data. | 362 // Our copy of the form data. |
| 353 ScopedVector<FormStructure> form_structures_; | 363 ScopedVector<FormStructure> form_structures_; |
| 354 | 364 |
| 355 // GUID to ID mapping. We keep two maps to convert back and forth. | 365 // GUID to ID mapping. We keep two maps to convert back and forth. |
| 356 mutable std::map<GUIDPair, int> guid_id_map_; | 366 mutable std::map<GUIDPair, int> guid_id_map_; |
| 357 mutable std::map<int, GUIDPair> id_guid_map_; | 367 mutable std::map<int, GUIDPair> id_guid_map_; |
| 358 | 368 |
| 359 // Delegate to perform external processing (display, selection) on | 369 // Delegate to perform external processing (display, selection) on |
| 360 // our behalf. Weak. | 370 // our behalf. Weak. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 379 TestTabContentsWithExternalDelegate); | 389 TestTabContentsWithExternalDelegate); |
| 380 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, | 390 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, |
| 381 UserHappinessFormLoadAndSubmission); | 391 UserHappinessFormLoadAndSubmission); |
| 382 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); | 392 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); |
| 383 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); | 393 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); |
| 384 | 394 |
| 385 DISALLOW_COPY_AND_ASSIGN(AutofillManager); | 395 DISALLOW_COPY_AND_ASSIGN(AutofillManager); |
| 386 }; | 396 }; |
| 387 | 397 |
| 388 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ | 398 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
| OLD | NEW |