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/webdata/autofill_profile_syncable_service.h" | 5 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 std::string LimitData(const std::string& data) { | 29 std::string LimitData(const std::string& data) { |
30 std::string sanitized_value(data); | 30 std::string sanitized_value(data); |
31 if (sanitized_value.length() > AutofillTable::kMaxDataLength) | 31 if (sanitized_value.length() > AutofillTable::kMaxDataLength) |
32 sanitized_value.resize(AutofillTable::kMaxDataLength); | 32 sanitized_value.resize(AutofillTable::kMaxDataLength); |
33 return sanitized_value; | 33 return sanitized_value; |
34 } | 34 } |
35 | 35 |
36 void* UserDataKey() { | |
37 return reinterpret_cast<void*>( | |
38 &AutofillProfileSyncableService::CreateForWebDataService); | |
39 } | |
40 | |
36 } // namespace | 41 } // namespace |
37 | 42 |
38 const char kAutofillProfileTag[] = "google_chrome_autofill_profiles"; | 43 const char kAutofillProfileTag[] = "google_chrome_autofill_profiles"; |
39 | 44 |
40 AutofillProfileSyncableService::AutofillProfileSyncableService( | 45 AutofillProfileSyncableService::AutofillProfileSyncableService( |
41 WebDataService* web_data_service) | 46 WebDataService* web_data_service) |
42 : web_data_service_(web_data_service) { | 47 : web_data_service_(web_data_service) { |
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
44 DCHECK(web_data_service_); | 49 DCHECK(web_data_service_); |
45 notification_registrar_.Add( | 50 notification_registrar_.Add( |
46 this, | 51 this, |
47 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 52 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
48 content::Source<WebDataService>(web_data_service_)); | 53 content::Source<WebDataService>(web_data_service_)); |
49 } | 54 } |
50 | 55 |
51 AutofillProfileSyncableService::~AutofillProfileSyncableService() { | 56 AutofillProfileSyncableService::~AutofillProfileSyncableService() { |
52 DCHECK(CalledOnValidThread()); | 57 DCHECK(CalledOnValidThread()); |
53 } | 58 } |
54 | 59 |
60 // static | |
61 void AutofillProfileSyncableService::CreateForWebDataService( | |
62 WebDataService* web_data) { | |
Cait (Slow)
2013/03/19 19:49:46
It seems like the syncable services should be hung
Cait (Slow)
2013/03/19 20:24:24
Just saw your TODOs on this -- I'll work on conver
| |
63 web_data->GetDBUserData()->SetUserData( | |
64 UserDataKey(), new AutofillProfileSyncableService(web_data)); | |
65 } | |
66 | |
67 // static | |
68 AutofillProfileSyncableService* | |
69 AutofillProfileSyncableService::FromWebDataService( | |
70 WebDataService* service) { | |
71 return static_cast<AutofillProfileSyncableService*>( | |
72 service->GetDBUserData()->GetUserData(UserDataKey())); | |
73 } | |
74 | |
55 AutofillProfileSyncableService::AutofillProfileSyncableService() | 75 AutofillProfileSyncableService::AutofillProfileSyncableService() |
56 : web_data_service_(NULL) { | 76 : web_data_service_(NULL) { |
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 77 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
58 } | 78 } |
59 | 79 |
60 syncer::SyncMergeResult | 80 syncer::SyncMergeResult |
61 AutofillProfileSyncableService::MergeDataAndStartSyncing( | 81 AutofillProfileSyncableService::MergeDataAndStartSyncing( |
62 syncer::ModelType type, | 82 syncer::ModelType type, |
63 const syncer::SyncDataList& initial_sync_data, | 83 const syncer::SyncDataList& initial_sync_data, |
64 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 84 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
546 } | 566 } |
547 | 567 |
548 AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const { | 568 AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const { |
549 return AutofillTable::FromWebDatabase(web_data_service_->GetDatabase()); | 569 return AutofillTable::FromWebDatabase(web_data_service_->GetDatabase()); |
550 } | 570 } |
551 | 571 |
552 AutofillProfileSyncableService::DataBundle::DataBundle() {} | 572 AutofillProfileSyncableService::DataBundle::DataBundle() {} |
553 | 573 |
554 AutofillProfileSyncableService::DataBundle::~DataBundle() { | 574 AutofillProfileSyncableService::DataBundle::~DataBundle() { |
555 } | 575 } |
OLD | NEW |