| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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() == syncer::SyncChange::ACTION_DELETE); | 25 sync_change.change_type() == syncer::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 syncer::StringOrdinal& app_launch_ordinal, |
| 34 const StringOrdinal& page_ordinal) | 34 const syncer::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 syncer::SyncData AppSyncData::GetSyncData() const { | 44 syncer::SyncData AppSyncData::GetSyncData() const { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 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 |
| 66 // Only sync the ordinal values if they are valid. | 66 // Only sync the ordinal values if they are valid. |
| 67 if (app_launch_ordinal_.IsValid()) | 67 if (app_launch_ordinal_.IsValid()) |
| 68 specifics->set_app_launch_ordinal(app_launch_ordinal_.ToString()); | 68 specifics->set_app_launch_ordinal(app_launch_ordinal_.ToInternalValue()); |
| 69 if (page_ordinal_.IsValid()) | 69 if (page_ordinal_.IsValid()) |
| 70 specifics->set_page_ordinal(page_ordinal_.ToString()); | 70 specifics->set_page_ordinal(page_ordinal_.ToInternalValue()); |
| 71 | 71 |
| 72 extension_sync_data_.PopulateExtensionSpecifics( | 72 extension_sync_data_.PopulateExtensionSpecifics( |
| 73 specifics->mutable_extension()); | 73 specifics->mutable_extension()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void AppSyncData::PopulateFromAppSpecifics( | 76 void AppSyncData::PopulateFromAppSpecifics( |
| 77 const sync_pb::AppSpecifics& specifics) { | 77 const sync_pb::AppSpecifics& specifics) { |
| 78 extension_sync_data_.PopulateFromExtensionSpecifics(specifics.extension()); | 78 extension_sync_data_.PopulateFromExtensionSpecifics(specifics.extension()); |
| 79 | 79 |
| 80 if (specifics.has_notification_settings() && | 80 if (specifics.has_notification_settings() && |
| 81 specifics.notification_settings().has_oauth_client_id()) { | 81 specifics.notification_settings().has_oauth_client_id()) { |
| 82 notifications_client_id_ = | 82 notifications_client_id_ = |
| 83 specifics.notification_settings().oauth_client_id(); | 83 specifics.notification_settings().oauth_client_id(); |
| 84 } | 84 } |
| 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_ = syncer::StringOrdinal(specifics.app_launch_ordinal()); |
| 92 page_ordinal_ = StringOrdinal(specifics.page_ordinal()); | 92 page_ordinal_ = syncer::StringOrdinal(specifics.page_ordinal()); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void AppSyncData::PopulateFromSyncData(const syncer::SyncData& sync_data) { | 95 void AppSyncData::PopulateFromSyncData(const syncer::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 |