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 | 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/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.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/prefs/public/pref_change_registrar.h" | 20 #include "base/prefs/public/pref_change_registrar.h" |
| 21 #include "base/prefs/public/pref_observer.h" |
21 #include "base/string16.h" | 22 #include "base/string16.h" |
22 #include "base/time.h" | 23 #include "base/time.h" |
23 #include "chrome/browser/api/sync/profile_sync_service_observer.h" | 24 #include "chrome/browser/api/sync/profile_sync_service_observer.h" |
24 #include "chrome/browser/autofill/autocomplete_history_manager.h" | 25 #include "chrome/browser/autofill/autocomplete_history_manager.h" |
25 #include "chrome/browser/autofill/autofill_download.h" | 26 #include "chrome/browser/autofill/autofill_download.h" |
26 #include "chrome/browser/autofill/field_types.h" | 27 #include "chrome/browser/autofill/field_types.h" |
27 #include "chrome/browser/autofill/form_structure.h" | 28 #include "chrome/browser/autofill/form_structure.h" |
28 #include "content/public/browser/notification_observer.h" | |
29 #include "content/public/browser/web_contents_observer.h" | 29 #include "content/public/browser/web_contents_observer.h" |
30 | 30 |
31 class AutofillExternalDelegate; | 31 class AutofillExternalDelegate; |
32 class AutofillField; | 32 class AutofillField; |
33 class AutofillProfile; | 33 class AutofillProfile; |
34 class AutofillMetrics; | 34 class AutofillMetrics; |
35 class CreditCard; | 35 class CreditCard; |
36 class PersonalDataManager; | 36 class PersonalDataManager; |
37 class PrefService; | 37 class PrefService; |
38 class ProfileSyncService; | 38 class ProfileSyncService; |
(...skipping 18 matching lines...) Expand all Loading... |
57 namespace gfx { | 57 namespace gfx { |
58 class Rect; | 58 class Rect; |
59 } | 59 } |
60 | 60 |
61 namespace IPC { | 61 namespace IPC { |
62 class Message; | 62 class Message; |
63 } | 63 } |
64 | 64 |
65 // Manages saving and restoring the user's personal information entered into web | 65 // Manages saving and restoring the user's personal information entered into web |
66 // forms. | 66 // forms. |
67 class AutofillManager : public content::NotificationObserver, | 67 class AutofillManager : public content::WebContentsObserver, |
68 public content::WebContentsObserver, | |
69 public AutofillDownloadManager::Observer, | 68 public AutofillDownloadManager::Observer, |
70 public ProfileSyncServiceObserver, | 69 public ProfileSyncServiceObserver, |
| 70 public PrefObserver, |
71 public base::RefCounted<AutofillManager> { | 71 public base::RefCounted<AutofillManager> { |
72 public: | 72 public: |
73 static void CreateForWebContentsAndDelegate( | 73 static void CreateForWebContentsAndDelegate( |
74 content::WebContents* contents, | 74 content::WebContents* contents, |
75 autofill::AutofillManagerDelegate* delegate); | 75 autofill::AutofillManagerDelegate* delegate); |
76 static AutofillManager* FromWebContents(content::WebContents* contents); | 76 static AutofillManager* FromWebContents(content::WebContents* contents); |
77 | 77 |
78 // Registers our Enable/Disable Autofill pref. | 78 // Registers our Enable/Disable Autofill pref. |
79 static void RegisterUserPrefs(PrefServiceBase* prefs); | 79 static void RegisterUserPrefs(PrefServiceBase* prefs); |
80 | 80 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // AutofillDownloadManager::Observer: | 184 // AutofillDownloadManager::Observer: |
185 virtual void OnLoadedServerPredictions( | 185 virtual void OnLoadedServerPredictions( |
186 const std::string& response_xml) OVERRIDE; | 186 const std::string& response_xml) OVERRIDE; |
187 | 187 |
188 // ProfileSyncServiceObserver: | 188 // ProfileSyncServiceObserver: |
189 virtual void OnStateChanged() OVERRIDE; | 189 virtual void OnStateChanged() OVERRIDE; |
190 | 190 |
191 // Register as an observer with the sync service. | 191 // Register as an observer with the sync service. |
192 void RegisterWithSyncService(); | 192 void RegisterWithSyncService(); |
193 | 193 |
194 // content::NotificationObserver override | 194 // PrefObserver. |
195 virtual void Observe(int type, | 195 virtual void OnPreferenceChanged(PrefServiceBase* service, |
196 const content::NotificationSource& source, | 196 const std::string& pref_name) OVERRIDE; |
197 const content::NotificationDetails& details) OVERRIDE; | |
198 | 197 |
199 // Determines what the current state of password generation is, and if it has | 198 // Determines what the current state of password generation is, and if it has |
200 // changed from |password_generation_enabled_|. If it has changed or if | 199 // changed from |password_generation_enabled_|. If it has changed or if |
201 // |new_renderer| is true, it notifies the renderer of this change via | 200 // |new_renderer| is true, it notifies the renderer of this change via |
202 // SendPasswordGenerationStateToRenderer. | 201 // SendPasswordGenerationStateToRenderer. |
203 void UpdatePasswordGenerationState(content::RenderViewHost* host, | 202 void UpdatePasswordGenerationState(content::RenderViewHost* host, |
204 bool new_renderer); | 203 bool new_renderer); |
205 | 204 |
206 void OnFormsSeen(const std::vector<FormData>& forms, | 205 void OnFormsSeen(const std::vector<FormData>& forms, |
207 const base::TimeTicks& timestamp); | 206 const base::TimeTicks& timestamp); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, | 407 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, |
409 TestTabContentsWithExternalDelegate); | 408 TestTabContentsWithExternalDelegate); |
410 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, | 409 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, |
411 UserHappinessFormLoadAndSubmission); | 410 UserHappinessFormLoadAndSubmission); |
412 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); | 411 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); |
413 | 412 |
414 DISALLOW_COPY_AND_ASSIGN(AutofillManager); | 413 DISALLOW_COPY_AND_ASSIGN(AutofillManager); |
415 }; | 414 }; |
416 | 415 |
417 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ | 416 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
OLD | NEW |