OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/autofill/personal_data_manager.h" | 5 #include "chrome/browser/autofill/personal_data_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/autofill/autofill-inl.h" | 13 #include "chrome/browser/autofill/autofill-inl.h" |
14 #include "chrome/browser/autofill/autofill_field.h" | 14 #include "chrome/browser/autofill/autofill_field.h" |
15 #include "chrome/browser/autofill/autofill_metrics.h" | 15 #include "chrome/browser/autofill/autofill_metrics.h" |
16 #include "chrome/browser/autofill/autofill_regexes.h" | 16 #include "chrome/browser/autofill/autofill_regexes.h" |
17 #include "chrome/browser/autofill/form_structure.h" | 17 #include "chrome/browser/autofill/form_structure.h" |
| 18 #include "chrome/browser/autofill/personal_data_manager_observer.h" |
18 #include "chrome/browser/autofill/phone_number.h" | 19 #include "chrome/browser/autofill/phone_number.h" |
19 #include "chrome/browser/autofill/phone_number_i18n.h" | 20 #include "chrome/browser/autofill/phone_number_i18n.h" |
20 #include "chrome/browser/autofill/select_control_handler.h" | 21 #include "chrome/browser/autofill/select_control_handler.h" |
21 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/sync/profile_sync_service.h" | 24 #include "chrome/browser/sync/profile_sync_service.h" |
24 #include "chrome/browser/webdata/web_data_service.h" | 25 #include "chrome/browser/webdata/web_data_service.h" |
25 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
26 #include "content/browser/browser_thread.h" | 27 #include "content/browser/browser_thread.h" |
27 | 28 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 NOTREACHED(); | 152 NOTREACHED(); |
152 } | 153 } |
153 | 154 |
154 // If both requests have responded, then all personal data is loaded. | 155 // If both requests have responded, then all personal data is loaded. |
155 if (pending_profiles_query_ == 0 && pending_creditcards_query_ == 0) { | 156 if (pending_profiles_query_ == 0 && pending_creditcards_query_ == 0) { |
156 is_data_loaded_ = true; | 157 is_data_loaded_ = true; |
157 std::vector<AutofillProfile*> profile_pointers(web_profiles_.size()); | 158 std::vector<AutofillProfile*> profile_pointers(web_profiles_.size()); |
158 std::copy(web_profiles_.begin(), web_profiles_.end(), | 159 std::copy(web_profiles_.begin(), web_profiles_.end(), |
159 profile_pointers.begin()); | 160 profile_pointers.begin()); |
160 AutofillProfile::AdjustInferredLabels(&profile_pointers); | 161 AutofillProfile::AdjustInferredLabels(&profile_pointers); |
161 FOR_EACH_OBSERVER(Observer, observers_, OnPersonalDataChanged()); | 162 FOR_EACH_OBSERVER(PersonalDataManagerObserver, observers_, |
| 163 OnPersonalDataChanged()); |
162 } | 164 } |
163 } | 165 } |
164 | 166 |
165 ///////////////////////////////////////////////////////////////////////////// | 167 void PersonalDataManager::SetObserver(PersonalDataManagerObserver* observer) { |
166 // PersonalDataManager, | |
167 // views::ButtonListener implementations | |
168 void PersonalDataManager::SetObserver(PersonalDataManager::Observer* observer) { | |
169 // TODO(dhollowa): RemoveObserver is for compatibility with old code, it | 168 // TODO(dhollowa): RemoveObserver is for compatibility with old code, it |
170 // should be nuked. | 169 // should be nuked. |
171 observers_.RemoveObserver(observer); | 170 observers_.RemoveObserver(observer); |
172 observers_.AddObserver(observer); | 171 observers_.AddObserver(observer); |
173 } | 172 } |
174 | 173 |
175 void PersonalDataManager::RemoveObserver( | 174 void PersonalDataManager::RemoveObserver( |
176 PersonalDataManager::Observer* observer) { | 175 PersonalDataManagerObserver* observer) { |
177 observers_.RemoveObserver(observer); | 176 observers_.RemoveObserver(observer); |
178 } | 177 } |
179 | 178 |
180 // The |PersonalDataManager| is set up as a listener of the sync service in | 179 // The |PersonalDataManager| is set up as a listener of the sync service in |
181 // |EmptyMigrationTrash| in the case where sync is not yet ready to receive | 180 // |EmptyMigrationTrash| in the case where sync is not yet ready to receive |
182 // changes. This method, |OnStateChange| acts as a deferred call to | 181 // changes. This method, |OnStateChange| acts as a deferred call to |
183 // |EmptyMigrationTrash| once the sync service becomes available. | 182 // |EmptyMigrationTrash| once the sync service becomes available. |
184 void PersonalDataManager::OnStateChanged() { | 183 void PersonalDataManager::OnStateChanged() { |
185 if (!profile_ || profile_->IsOffTheRecord()) | 184 if (!profile_ || profile_->IsOffTheRecord()) |
186 return; | 185 return; |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 } | 914 } |
916 | 915 |
917 const AutofillMetrics* PersonalDataManager::metric_logger() const { | 916 const AutofillMetrics* PersonalDataManager::metric_logger() const { |
918 return metric_logger_.get(); | 917 return metric_logger_.get(); |
919 } | 918 } |
920 | 919 |
921 void PersonalDataManager::set_metric_logger( | 920 void PersonalDataManager::set_metric_logger( |
922 const AutofillMetrics* metric_logger) { | 921 const AutofillMetrics* metric_logger) { |
923 metric_logger_.reset(metric_logger); | 922 metric_logger_.reset(metric_logger); |
924 } | 923 } |
OLD | NEW |