Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: chrome/browser/sync/glue/autofill_change_processor.cc

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/sync/glue/autofill_change_processor.h" 5 #include "chrome/browser/sync/glue/autofill_change_processor.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/autofill/personal_data_manager.h" 13 #include "chrome/browser/autofill/personal_data_manager.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/sync/glue/autofill_model_associator.h" 15 #include "chrome/browser/sync/glue/autofill_model_associator.h"
16 #include "chrome/browser/sync/internal_api/change_record.h" 16 #include "chrome/browser/sync/internal_api/change_record.h"
17 #include "chrome/browser/sync/internal_api/read_node.h" 17 #include "chrome/browser/sync/internal_api/read_node.h"
18 #include "chrome/browser/sync/internal_api/write_node.h" 18 #include "chrome/browser/sync/internal_api/write_node.h"
19 #include "chrome/browser/sync/internal_api/write_transaction.h" 19 #include "chrome/browser/sync/internal_api/write_transaction.h"
20 #include "chrome/browser/sync/profile_sync_service.h" 20 #include "chrome/browser/sync/profile_sync_service.h"
21 #include "chrome/browser/webdata/autofill_change.h" 21 #include "chrome/browser/webdata/autofill_change.h"
22 #include "chrome/browser/webdata/autofill_table.h" 22 #include "chrome/browser/webdata/autofill_table.h"
23 #include "chrome/browser/webdata/web_database.h" 23 #include "chrome/browser/webdata/web_database.h"
24 #include "chrome/browser/webdata/web_data_service.h" 24 #include "chrome/browser/webdata/web_data_service.h"
25 #include "chrome/common/chrome_notification_types.h" 25 #include "chrome/common/chrome_notification_types.h"
26 #include "chrome/common/guid.h" 26 #include "chrome/common/guid.h"
27 #include "content/common/notification_service.h" 27 #include "content/public/browser/notification_service.h"
28 28
29 namespace browser_sync { 29 namespace browser_sync {
30 30
31 struct AutofillChangeProcessor::AutofillChangeRecord { 31 struct AutofillChangeProcessor::AutofillChangeRecord {
32 sync_api::ChangeRecord::Action action_; 32 sync_api::ChangeRecord::Action action_;
33 int64 id_; 33 int64 id_;
34 sync_pb::AutofillSpecifics autofill_; 34 sync_pb::AutofillSpecifics autofill_;
35 AutofillChangeRecord(sync_api::ChangeRecord::Action action, 35 AutofillChangeRecord(sync_api::ChangeRecord::Action action,
36 int64 id, const sync_pb::AutofillSpecifics& autofill) 36 int64 id, const sync_pb::AutofillSpecifics& autofill)
37 : action_(action), 37 : action_(action),
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 void AutofillChangeProcessor::StopImpl() { 415 void AutofillChangeProcessor::StopImpl() {
416 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 416 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
417 observing_ = false; 417 observing_ = false;
418 } 418 }
419 419
420 420
421 void AutofillChangeProcessor::StartObserving() { 421 void AutofillChangeProcessor::StartObserving() {
422 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 422 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
423 notification_registrar_.Add(this, 423 notification_registrar_.Add(this,
424 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, 424 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
425 NotificationService::AllSources()); 425 content::NotificationService::AllSources());
426 } 426 }
427 427
428 void AutofillChangeProcessor::StopObserving() { 428 void AutofillChangeProcessor::StopObserving() {
429 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 429 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
430 notification_registrar_.RemoveAll(); 430 notification_registrar_.RemoveAll();
431 } 431 }
432 432
433 // static 433 // static
434 void AutofillChangeProcessor::WriteAutofillEntry( 434 void AutofillChangeProcessor::WriteAutofillEntry(
435 const AutofillEntry& entry, 435 const AutofillEntry& entry,
436 sync_api::WriteNode* node) { 436 sync_api::WriteNode* node) {
437 sync_pb::AutofillSpecifics autofill; 437 sync_pb::AutofillSpecifics autofill;
438 autofill.set_name(UTF16ToUTF8(entry.key().name())); 438 autofill.set_name(UTF16ToUTF8(entry.key().name()));
439 autofill.set_value(UTF16ToUTF8(entry.key().value())); 439 autofill.set_value(UTF16ToUTF8(entry.key().value()));
440 const std::vector<base::Time>& ts(entry.timestamps()); 440 const std::vector<base::Time>& ts(entry.timestamps());
441 for (std::vector<base::Time>::const_iterator timestamp = ts.begin(); 441 for (std::vector<base::Time>::const_iterator timestamp = ts.begin();
442 timestamp != ts.end(); ++timestamp) { 442 timestamp != ts.end(); ++timestamp) {
443 autofill.add_usage_timestamp(timestamp->ToInternalValue()); 443 autofill.add_usage_timestamp(timestamp->ToInternalValue());
444 } 444 }
445 node->SetAutofillSpecifics(autofill); 445 node->SetAutofillSpecifics(autofill);
446 } 446 }
447 447
448 } // namespace browser_sync 448 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/backend_migrator_unittest.cc ('k') | chrome/browser/sync/glue/autofill_data_type_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698