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

Side by Side Diff: chrome/browser/extensions/extension_sync_data.cc

Issue 10698014: [Sync] Rename csync namespace to syncer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 5 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) 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/extensions/extension_sync_data.h" 5 #include "chrome/browser/extensions/extension_sync_data.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/extensions/app_sync_data.h" 8 #include "chrome/browser/extensions/app_sync_data.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
11 #include "sync/api/sync_data.h" 11 #include "sync/api/sync_data.h"
12 #include "sync/protocol/extension_specifics.pb.h" 12 #include "sync/protocol/extension_specifics.pb.h"
13 #include "sync/protocol/sync.pb.h" 13 #include "sync/protocol/sync.pb.h"
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 ExtensionSyncData::ExtensionSyncData() 17 ExtensionSyncData::ExtensionSyncData()
18 : uninstalled_(false), 18 : uninstalled_(false),
19 enabled_(false), 19 enabled_(false),
20 incognito_enabled_(false) { 20 incognito_enabled_(false) {
21 } 21 }
22 22
23 ExtensionSyncData::ExtensionSyncData(const csync::SyncData& sync_data) 23 ExtensionSyncData::ExtensionSyncData(const syncer::SyncData& sync_data)
24 : uninstalled_(false), 24 : uninstalled_(false),
25 enabled_(false), 25 enabled_(false),
26 incognito_enabled_(false) { 26 incognito_enabled_(false) {
27 PopulateFromSyncData(sync_data); 27 PopulateFromSyncData(sync_data);
28 } 28 }
29 29
30 ExtensionSyncData::ExtensionSyncData(const csync::SyncChange& sync_change) 30 ExtensionSyncData::ExtensionSyncData(const syncer::SyncChange& sync_change)
31 : uninstalled_( 31 : uninstalled_(
32 sync_change.change_type() == csync::SyncChange::ACTION_DELETE), 32 sync_change.change_type() == syncer::SyncChange::ACTION_DELETE),
33 enabled_(false), 33 enabled_(false),
34 incognito_enabled_(false) { 34 incognito_enabled_(false) {
35 PopulateFromSyncData(sync_change.sync_data()); 35 PopulateFromSyncData(sync_change.sync_data());
36 } 36 }
37 37
38 ExtensionSyncData::ExtensionSyncData(const Extension& extension, 38 ExtensionSyncData::ExtensionSyncData(const Extension& extension,
39 bool enabled, 39 bool enabled,
40 bool incognito_enabled) 40 bool incognito_enabled)
41 : id_(extension.id()), 41 : id_(extension.id()),
42 uninstalled_(false), 42 uninstalled_(false),
43 enabled_(enabled), 43 enabled_(enabled),
44 incognito_enabled_(incognito_enabled), 44 incognito_enabled_(incognito_enabled),
45 version_(*extension.version()), 45 version_(*extension.version()),
46 update_url_(extension.update_url()), 46 update_url_(extension.update_url()),
47 name_(extension.non_localized_name()) { 47 name_(extension.non_localized_name()) {
48 } 48 }
49 49
50 ExtensionSyncData::~ExtensionSyncData() {} 50 ExtensionSyncData::~ExtensionSyncData() {}
51 51
52 csync::SyncData ExtensionSyncData::GetSyncData() const { 52 syncer::SyncData ExtensionSyncData::GetSyncData() const {
53 sync_pb::EntitySpecifics specifics; 53 sync_pb::EntitySpecifics specifics;
54 PopulateExtensionSpecifics(specifics.mutable_extension()); 54 PopulateExtensionSpecifics(specifics.mutable_extension());
55 55
56 return csync::SyncData::CreateLocalData(id_, name_, specifics); 56 return syncer::SyncData::CreateLocalData(id_, name_, specifics);
57 } 57 }
58 58
59 csync::SyncChange ExtensionSyncData::GetSyncChange( 59 syncer::SyncChange ExtensionSyncData::GetSyncChange(
60 csync::SyncChange::SyncChangeType change_type) const { 60 syncer::SyncChange::SyncChangeType change_type) const {
61 return csync::SyncChange(change_type, GetSyncData()); 61 return syncer::SyncChange(change_type, GetSyncData());
62 } 62 }
63 63
64 void ExtensionSyncData::PopulateExtensionSpecifics( 64 void ExtensionSyncData::PopulateExtensionSpecifics(
65 sync_pb::ExtensionSpecifics* specifics) const { 65 sync_pb::ExtensionSpecifics* specifics) const {
66 DCHECK(Extension::IdIsValid(id_)); 66 DCHECK(Extension::IdIsValid(id_));
67 specifics->set_id(id_); 67 specifics->set_id(id_);
68 specifics->set_update_url(update_url_.spec()); 68 specifics->set_update_url(update_url_.spec());
69 specifics->set_version(version_.GetString()); 69 specifics->set_version(version_.GetString());
70 specifics->set_enabled(enabled_); 70 specifics->set_enabled(enabled_);
71 specifics->set_incognito_enabled(incognito_enabled_); 71 specifics->set_incognito_enabled(incognito_enabled_);
(...skipping 21 matching lines...) Expand all
93 version_ = specifics_version; 93 version_ = specifics_version;
94 enabled_ = specifics.enabled(); 94 enabled_ = specifics.enabled();
95 incognito_enabled_ = specifics.incognito_enabled(); 95 incognito_enabled_ = specifics.incognito_enabled();
96 name_ = specifics.name(); 96 name_ = specifics.name();
97 } 97 }
98 98
99 void ExtensionSyncData::set_uninstalled(bool uninstalled) { 99 void ExtensionSyncData::set_uninstalled(bool uninstalled) {
100 uninstalled_ = uninstalled; 100 uninstalled_ = uninstalled;
101 } 101 }
102 102
103 void ExtensionSyncData::PopulateFromSyncData(const csync::SyncData& sync_data) { 103 void ExtensionSyncData::PopulateFromSyncData(
104 const syncer::SyncData& sync_data) {
104 const sync_pb::EntitySpecifics& entity_specifics = sync_data.GetSpecifics(); 105 const sync_pb::EntitySpecifics& entity_specifics = sync_data.GetSpecifics();
105 106
106 if (entity_specifics.has_extension()) { 107 if (entity_specifics.has_extension()) {
107 PopulateFromExtensionSpecifics(entity_specifics.extension()); 108 PopulateFromExtensionSpecifics(entity_specifics.extension());
108 } else { 109 } else {
109 LOG(FATAL) << "Attempt to sync bad EntitySpecifics."; 110 LOG(FATAL) << "Attempt to sync bad EntitySpecifics.";
110 } 111 }
111 } 112 }
112 113
113 } // namespace extensions 114 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_sync_data.h ('k') | chrome/browser/extensions/extension_sync_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698