| 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/extensions/app_sync_data.h" | 5 #include "chrome/browser/extensions/app_sync_data.h" |
| 6 | 6 |
| 7 #include "chrome/common/extensions/extension.h" | 7 #include "chrome/common/extensions/extension.h" |
| 8 #include "sync/api/sync_data.h" | 8 #include "sync/api/sync_data.h" |
| 9 #include "sync/protocol/app_specifics.pb.h" | 9 #include "sync/protocol/app_specifics.pb.h" |
| 10 #include "sync/protocol/sync.pb.h" | 10 #include "sync/protocol/sync.pb.h" |
| 11 | 11 |
| 12 namespace extensions { | 12 namespace extensions { |
| 13 | 13 |
| 14 AppSyncData::AppSyncData() : notifications_disabled_(false) {} | 14 AppSyncData::AppSyncData() : notifications_disabled_(false) {} |
| 15 | 15 |
| 16 AppSyncData::AppSyncData(const SyncData& sync_data) | 16 AppSyncData::AppSyncData(const csync::SyncData& sync_data) |
| 17 : notifications_disabled_(false) { | 17 : notifications_disabled_(false) { |
| 18 PopulateFromSyncData(sync_data); | 18 PopulateFromSyncData(sync_data); |
| 19 } | 19 } |
| 20 | 20 |
| 21 AppSyncData::AppSyncData(const SyncChange& sync_change) | 21 AppSyncData::AppSyncData(const csync::SyncChange& sync_change) |
| 22 : notifications_disabled_(false) { | 22 : notifications_disabled_(false) { |
| 23 PopulateFromSyncData(sync_change.sync_data()); | 23 PopulateFromSyncData(sync_change.sync_data()); |
| 24 extension_sync_data_.set_uninstalled( | 24 extension_sync_data_.set_uninstalled( |
| 25 sync_change.change_type() == SyncChange::ACTION_DELETE); | 25 sync_change.change_type() == csync::SyncChange::ACTION_DELETE); |
| 26 } | 26 } |
| 27 | 27 |
| 28 AppSyncData::AppSyncData(const Extension& extension, | 28 AppSyncData::AppSyncData(const Extension& extension, |
| 29 bool enabled, | 29 bool enabled, |
| 30 bool incognito_enabled, | 30 bool incognito_enabled, |
| 31 const std::string& notifications_client_id, | 31 const std::string& notifications_client_id, |
| 32 bool notifications_disabled, | 32 bool notifications_disabled, |
| 33 const StringOrdinal& app_launch_ordinal, | 33 const StringOrdinal& app_launch_ordinal, |
| 34 const StringOrdinal& page_ordinal) | 34 const StringOrdinal& page_ordinal) |
| 35 : extension_sync_data_(extension, enabled, incognito_enabled), | 35 : extension_sync_data_(extension, enabled, incognito_enabled), |
| 36 notifications_client_id_(notifications_client_id), | 36 notifications_client_id_(notifications_client_id), |
| 37 notifications_disabled_(notifications_disabled), | 37 notifications_disabled_(notifications_disabled), |
| 38 app_launch_ordinal_(app_launch_ordinal), | 38 app_launch_ordinal_(app_launch_ordinal), |
| 39 page_ordinal_(page_ordinal) { | 39 page_ordinal_(page_ordinal) { |
| 40 } | 40 } |
| 41 | 41 |
| 42 AppSyncData::~AppSyncData() {} | 42 AppSyncData::~AppSyncData() {} |
| 43 | 43 |
| 44 SyncData AppSyncData::GetSyncData() const { | 44 csync::SyncData AppSyncData::GetSyncData() const { |
| 45 sync_pb::EntitySpecifics specifics; | 45 sync_pb::EntitySpecifics specifics; |
| 46 PopulateAppSpecifics(specifics.mutable_app()); | 46 PopulateAppSpecifics(specifics.mutable_app()); |
| 47 | 47 |
| 48 return SyncData::CreateLocalData(extension_sync_data_.id(), | 48 return csync::SyncData::CreateLocalData(extension_sync_data_.id(), |
| 49 extension_sync_data_.name(), | 49 extension_sync_data_.name(), |
| 50 specifics); | 50 specifics); |
| 51 } | 51 } |
| 52 | 52 |
| 53 SyncChange AppSyncData::GetSyncChange(SyncChange::SyncChangeType change_type) | 53 csync::SyncChange AppSyncData::GetSyncChange( |
| 54 const { | 54 csync::SyncChange::SyncChangeType change_type) const { |
| 55 return SyncChange(change_type, GetSyncData()); | 55 return csync::SyncChange(change_type, GetSyncData()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void AppSyncData::PopulateAppSpecifics(sync_pb::AppSpecifics* specifics) const { | 58 void AppSyncData::PopulateAppSpecifics(sync_pb::AppSpecifics* specifics) const { |
| 59 DCHECK(specifics); | 59 DCHECK(specifics); |
| 60 sync_pb::AppNotificationSettings* notification_settings = | 60 sync_pb::AppNotificationSettings* notification_settings = |
| 61 specifics->mutable_notification_settings(); | 61 specifics->mutable_notification_settings(); |
| 62 if (!notifications_client_id_.empty()) | 62 if (!notifications_client_id_.empty()) |
| 63 notification_settings->set_oauth_client_id(notifications_client_id_); | 63 notification_settings->set_oauth_client_id(notifications_client_id_); |
| 64 notification_settings->set_disabled(notifications_disabled_); | 64 notification_settings->set_disabled(notifications_disabled_); |
| 65 | 65 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 85 | 85 |
| 86 notifications_disabled_ = | 86 notifications_disabled_ = |
| 87 specifics.has_notification_settings() && | 87 specifics.has_notification_settings() && |
| 88 specifics.notification_settings().has_disabled() && | 88 specifics.notification_settings().has_disabled() && |
| 89 specifics.notification_settings().disabled(); | 89 specifics.notification_settings().disabled(); |
| 90 | 90 |
| 91 app_launch_ordinal_ = StringOrdinal(specifics.app_launch_ordinal()); | 91 app_launch_ordinal_ = StringOrdinal(specifics.app_launch_ordinal()); |
| 92 page_ordinal_ = StringOrdinal(specifics.page_ordinal()); | 92 page_ordinal_ = StringOrdinal(specifics.page_ordinal()); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void AppSyncData::PopulateFromSyncData(const SyncData& sync_data) { | 95 void AppSyncData::PopulateFromSyncData(const csync::SyncData& sync_data) { |
| 96 PopulateFromAppSpecifics(sync_data.GetSpecifics().app()); | 96 PopulateFromAppSpecifics(sync_data.GetSpecifics().app()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace extensions | 99 } // namespace extensions |
| OLD | NEW |