| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/app_list/app_list_syncable_service.h" | 5 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/apps/drive/drive_app_provider.h" | 8 #include "chrome/browser/apps/drive/drive_app_provider.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 namespace { | 44 namespace { |
| 45 | 45 |
| 46 const char kOemFolderId[] = "ddb1da55-d478-4243-8642-56d3041f0263"; | 46 const char kOemFolderId[] = "ddb1da55-d478-4243-8642-56d3041f0263"; |
| 47 | 47 |
| 48 void UpdateSyncItemFromSync(const sync_pb::AppListSpecifics& specifics, | 48 void UpdateSyncItemFromSync(const sync_pb::AppListSpecifics& specifics, |
| 49 AppListSyncableService::SyncItem* item) { | 49 AppListSyncableService::SyncItem* item) { |
| 50 DCHECK_EQ(item->item_id, specifics.item_id()); | 50 DCHECK_EQ(item->item_id, specifics.item_id()); |
| 51 item->item_type = specifics.item_type(); | 51 item->item_type = specifics.item_type(); |
| 52 item->item_name = specifics.item_name(); | 52 item->item_name = specifics.item_name(); |
| 53 item->parent_id = specifics.parent_id(); | 53 item->parent_id = specifics.parent_id(); |
| 54 if (!specifics.page_ordinal().empty()) | |
| 55 item->page_ordinal = syncer::StringOrdinal(specifics.page_ordinal()); | |
| 56 if (!specifics.item_ordinal().empty()) | 54 if (!specifics.item_ordinal().empty()) |
| 57 item->item_ordinal = syncer::StringOrdinal(specifics.item_ordinal()); | 55 item->item_ordinal = syncer::StringOrdinal(specifics.item_ordinal()); |
| 58 } | 56 } |
| 59 | 57 |
| 60 bool UpdateSyncItemFromAppItem(const AppListItem* app_item, | 58 bool UpdateSyncItemFromAppItem(const AppListItem* app_item, |
| 61 AppListSyncableService::SyncItem* sync_item) { | 59 AppListSyncableService::SyncItem* sync_item) { |
| 62 DCHECK_EQ(sync_item->item_id, app_item->id()); | 60 DCHECK_EQ(sync_item->item_id, app_item->id()); |
| 63 bool changed = false; | 61 bool changed = false; |
| 64 if (app_list::switches::IsFolderUIEnabled() && | 62 if (app_list::switches::IsFolderUIEnabled() && |
| 65 sync_item->parent_id != app_item->folder_id()) { | 63 sync_item->parent_id != app_item->folder_id()) { |
| 66 sync_item->parent_id = app_item->folder_id(); | 64 sync_item->parent_id = app_item->folder_id(); |
| 67 changed = true; | 65 changed = true; |
| 68 } | 66 } |
| 69 if (sync_item->item_name != app_item->name()) { | 67 if (sync_item->item_name != app_item->name()) { |
| 70 sync_item->item_name = app_item->name(); | 68 sync_item->item_name = app_item->name(); |
| 71 changed = true; | 69 changed = true; |
| 72 } | 70 } |
| 73 if (!sync_item->item_ordinal.IsValid() || | 71 if (!sync_item->item_ordinal.IsValid() || |
| 74 !app_item->position().Equals(sync_item->item_ordinal)) { | 72 !app_item->position().Equals(sync_item->item_ordinal)) { |
| 75 sync_item->item_ordinal = app_item->position(); | 73 sync_item->item_ordinal = app_item->position(); |
| 76 changed = true; | 74 changed = true; |
| 77 } | 75 } |
| 78 // TODO(stevenjb): Set page_ordinal. | |
| 79 return changed; | 76 return changed; |
| 80 } | 77 } |
| 81 | 78 |
| 82 void GetSyncSpecificsFromSyncItem(const AppListSyncableService::SyncItem* item, | 79 void GetSyncSpecificsFromSyncItem(const AppListSyncableService::SyncItem* item, |
| 83 sync_pb::AppListSpecifics* specifics) { | 80 sync_pb::AppListSpecifics* specifics) { |
| 84 DCHECK(specifics); | 81 DCHECK(specifics); |
| 85 specifics->set_item_id(item->item_id); | 82 specifics->set_item_id(item->item_id); |
| 86 specifics->set_item_type(item->item_type); | 83 specifics->set_item_type(item->item_type); |
| 87 specifics->set_item_name(item->item_name); | 84 specifics->set_item_name(item->item_name); |
| 88 specifics->set_parent_id(item->parent_id); | 85 specifics->set_parent_id(item->parent_id); |
| 89 if (item->page_ordinal.IsValid()) | |
| 90 specifics->set_page_ordinal(item->page_ordinal.ToInternalValue()); | |
| 91 if (item->item_ordinal.IsValid()) | 86 if (item->item_ordinal.IsValid()) |
| 92 specifics->set_item_ordinal(item->item_ordinal.ToInternalValue()); | 87 specifics->set_item_ordinal(item->item_ordinal.ToInternalValue()); |
| 93 } | 88 } |
| 94 | 89 |
| 95 syncer::SyncData GetSyncDataFromSyncItem( | 90 syncer::SyncData GetSyncDataFromSyncItem( |
| 96 const AppListSyncableService::SyncItem* item) { | 91 const AppListSyncableService::SyncItem* item) { |
| 97 sync_pb::EntitySpecifics specifics; | 92 sync_pb::EntitySpecifics specifics; |
| 98 GetSyncSpecificsFromSyncItem(item, specifics.mutable_app_list()); | 93 GetSyncSpecificsFromSyncItem(item, specifics.mutable_app_list()); |
| 99 return syncer::SyncData::CreateLocalData(item->item_id, | 94 return syncer::SyncData::CreateLocalData(item->item_id, |
| 100 item->item_id, | 95 item->item_id, |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 } else { | 925 } else { |
| 931 res += " { " + item_name + " }"; | 926 res += " { " + item_name + " }"; |
| 932 res += " [" + item_ordinal.ToDebugString() + "]"; | 927 res += " [" + item_ordinal.ToDebugString() + "]"; |
| 933 if (!parent_id.empty()) | 928 if (!parent_id.empty()) |
| 934 res += " <" + parent_id.substr(0, 8) + ">"; | 929 res += " <" + parent_id.substr(0, 8) + ">"; |
| 935 } | 930 } |
| 936 return res; | 931 return res; |
| 937 } | 932 } |
| 938 | 933 |
| 939 } // namespace app_list | 934 } // namespace app_list |
| OLD | NEW |