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 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h" | 5 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 9 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 OnModelLoaded(); | 47 OnModelLoaded(); |
48 } | 48 } |
49 | 49 |
50 void AutofillProfileDataTypeController::OnPersonalDataChanged() { | 50 void AutofillProfileDataTypeController::OnPersonalDataChanged() { |
51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
52 DCHECK_EQ(state(), MODEL_STARTING); | 52 DCHECK_EQ(state(), MODEL_STARTING); |
53 | 53 |
54 personal_data_->RemoveObserver(this); | 54 personal_data_->RemoveObserver(this); |
55 autofill::AutofillWebDataService* web_data_service = | 55 autofill::AutofillWebDataService* web_data_service = |
56 WebDataServiceFactory::GetAutofillWebDataForProfile( | 56 WebDataServiceFactory::GetAutofillWebDataForProfile( |
57 profile_, Profile::EXPLICIT_ACCESS).get(); | 57 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); |
58 | 58 |
59 if (!web_data_service) | 59 if (!web_data_service) |
60 return; | 60 return; |
61 | 61 |
62 if (web_data_service->IsDatabaseLoaded()) { | 62 if (web_data_service->IsDatabaseLoaded()) { |
63 OnModelLoaded(); | 63 OnModelLoaded(); |
64 } else if (!callback_registered_) { | 64 } else if (!callback_registered_) { |
65 web_data_service->RegisterDBLoadedCallback(base::Bind( | 65 web_data_service->RegisterDBLoadedCallback(base::Bind( |
66 &AutofillProfileDataTypeController::WebDatabaseLoaded, this)); | 66 &AutofillProfileDataTypeController::WebDatabaseLoaded, this)); |
67 callback_registered_ = true; | 67 callback_registered_ = true; |
(...skipping 17 matching lines...) Expand all Loading... |
85 // association, the local ids in the mappings would wind up colliding. | 85 // association, the local ids in the mappings would wind up colliding. |
86 personal_data_ = | 86 personal_data_ = |
87 autofill::PersonalDataManagerFactory::GetForProfile(profile_); | 87 autofill::PersonalDataManagerFactory::GetForProfile(profile_); |
88 if (!personal_data_->IsDataLoaded()) { | 88 if (!personal_data_->IsDataLoaded()) { |
89 personal_data_->AddObserver(this); | 89 personal_data_->AddObserver(this); |
90 return false; | 90 return false; |
91 } | 91 } |
92 | 92 |
93 autofill::AutofillWebDataService* web_data_service = | 93 autofill::AutofillWebDataService* web_data_service = |
94 WebDataServiceFactory::GetAutofillWebDataForProfile( | 94 WebDataServiceFactory::GetAutofillWebDataForProfile( |
95 profile_, Profile::EXPLICIT_ACCESS).get(); | 95 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); |
96 | 96 |
97 if (!web_data_service) | 97 if (!web_data_service) |
98 return false; | 98 return false; |
99 | 99 |
100 if (web_data_service->IsDatabaseLoaded()) | 100 if (web_data_service->IsDatabaseLoaded()) |
101 return true; | 101 return true; |
102 | 102 |
103 if (!callback_registered_) { | 103 if (!callback_registered_) { |
104 web_data_service->RegisterDBLoadedCallback(base::Bind( | 104 web_data_service->RegisterDBLoadedCallback(base::Bind( |
105 &AutofillProfileDataTypeController::WebDatabaseLoaded, this)); | 105 &AutofillProfileDataTypeController::WebDatabaseLoaded, this)); |
106 callback_registered_ = true; | 106 callback_registered_ = true; |
107 } | 107 } |
108 | 108 |
109 return false; | 109 return false; |
110 } | 110 } |
111 | 111 |
112 void AutofillProfileDataTypeController::StopModels() { | 112 void AutofillProfileDataTypeController::StopModels() { |
113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
114 personal_data_->RemoveObserver(this); | 114 personal_data_->RemoveObserver(this); |
115 } | 115 } |
116 | 116 |
117 } // namespace browser_sync | 117 } // namespace browser_sync |
OLD | NEW |