| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/values.h" |
| 14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 15 #include "chrome/browser/apps/drive/drive_app_provider.h" | 16 #include "chrome/browser/apps/drive/drive_app_provider.h" |
| 17 #include "chrome/browser/chromeos/arc/arc_util.h" |
| 18 #include "chrome/browser/chromeos/file_manager/app_id.h" |
| 19 #include "chrome/browser/chromeos/genius_app/app_id.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/app_list/app_list_service.h" | 22 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 23 #include "chrome/browser/ui/app_list/arc/arc_app_item.h" |
| 24 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 25 #include "chrome/browser/ui/app_list/arc/arc_app_model_builder.h" |
| 19 #include "chrome/browser/ui/app_list/extension_app_item.h" | 26 #include "chrome/browser/ui/app_list/extension_app_item.h" |
| 20 #include "chrome/browser/ui/app_list/extension_app_model_builder.h" | 27 #include "chrome/browser/ui/app_list/extension_app_model_builder.h" |
| 21 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/extensions/extension_constants.h" | 29 #include "chrome/common/extensions/extension_constants.h" |
| 23 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 24 #include "chrome/grit/generated_resources.h" | 31 #include "chrome/grit/generated_resources.h" |
| 25 #include "components/pref_registry/pref_registry_syncable.h" | 32 #include "components/pref_registry/pref_registry_syncable.h" |
| 26 #include "components/sync/model/sync_change_processor.h" | 33 #include "components/sync/model/sync_change_processor.h" |
| 27 #include "components/sync/model/sync_data.h" | 34 #include "components/sync/model/sync_data.h" |
| 28 #include "components/sync/model/sync_merge_result.h" | 35 #include "components/sync/model/sync_merge_result.h" |
| 29 #include "components/sync/protocol/sync.pb.h" | 36 #include "components/sync/protocol/sync.pb.h" |
| 30 #include "extensions/browser/extension_prefs.h" | 37 #include "extensions/browser/extension_prefs.h" |
| 31 #include "extensions/browser/extension_system.h" | 38 #include "extensions/browser/extension_system.h" |
| 32 #include "extensions/browser/uninstall_reason.h" | 39 #include "extensions/browser/uninstall_reason.h" |
| 33 #include "extensions/common/constants.h" | 40 #include "extensions/common/constants.h" |
| 34 #include "extensions/common/one_shot_event.h" | 41 #include "extensions/common/one_shot_event.h" |
| 35 #include "ui/app_list/app_list_folder_item.h" | 42 #include "ui/app_list/app_list_folder_item.h" |
| 36 #include "ui/app_list/app_list_item.h" | 43 #include "ui/app_list/app_list_item.h" |
| 37 #include "ui/app_list/app_list_model.h" | 44 #include "ui/app_list/app_list_model.h" |
| 38 #include "ui/app_list/app_list_model_observer.h" | 45 #include "ui/app_list/app_list_model_observer.h" |
| 39 #include "ui/app_list/app_list_switches.h" | 46 #include "ui/app_list/app_list_switches.h" |
| 40 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
| 41 #include "chrome/browser/chromeos/arc/arc_util.h" | |
| 42 #include "chrome/browser/chromeos/file_manager/app_id.h" | |
| 43 #include "chrome/browser/chromeos/genius_app/app_id.h" | |
| 44 #include "chrome/browser/ui/app_list/arc/arc_app_item.h" | |
| 45 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | |
| 46 #include "chrome/browser/ui/app_list/arc/arc_app_model_builder.h" | |
| 47 | 48 |
| 48 using syncer::SyncChange; | 49 using syncer::SyncChange; |
| 49 | 50 |
| 50 namespace app_list { | 51 namespace app_list { |
| 51 | 52 |
| 52 namespace { | 53 namespace { |
| 53 | 54 |
| 54 const char kNameKey[] = "name"; | 55 const char kNameKey[] = "name"; |
| 55 const char kParentIdKey[] = "parent_id"; | 56 const char kParentIdKey[] = "parent_id"; |
| 56 const char kPositionKey[] = "position"; | 57 const char kPositionKey[] = "position"; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 } | 179 } |
| 179 | 180 |
| 180 void UpdateSyncItemInLocalStorage( | 181 void UpdateSyncItemInLocalStorage( |
| 181 Profile* profile, | 182 Profile* profile, |
| 182 const AppListSyncableService::SyncItem* sync_item) { | 183 const AppListSyncableService::SyncItem* sync_item) { |
| 183 DictionaryPrefUpdate pref_update(profile->GetPrefs(), | 184 DictionaryPrefUpdate pref_update(profile->GetPrefs(), |
| 184 prefs::kAppListLocalState); | 185 prefs::kAppListLocalState); |
| 185 base::DictionaryValue* dict_item = nullptr; | 186 base::DictionaryValue* dict_item = nullptr; |
| 186 if (!pref_update->GetDictionaryWithoutPathExpansion(sync_item->item_id, | 187 if (!pref_update->GetDictionaryWithoutPathExpansion(sync_item->item_id, |
| 187 &dict_item)) { | 188 &dict_item)) { |
| 188 dict_item = new base::DictionaryValue(); | 189 dict_item = pref_update->SetDictionaryWithoutPathExpansion( |
| 189 pref_update->SetWithoutPathExpansion(sync_item->item_id, dict_item); | 190 sync_item->item_id, base::MakeUnique<base::DictionaryValue>()); |
| 190 } | 191 } |
| 191 | 192 |
| 192 dict_item->SetString(kNameKey, sync_item->item_name); | 193 dict_item->SetString(kNameKey, sync_item->item_name); |
| 193 dict_item->SetString(kParentIdKey, sync_item->parent_id); | 194 dict_item->SetString(kParentIdKey, sync_item->parent_id); |
| 194 dict_item->SetString(kPositionKey,sync_item->item_ordinal.IsValid() ? | 195 dict_item->SetString(kPositionKey,sync_item->item_ordinal.IsValid() ? |
| 195 sync_item->item_ordinal.ToInternalValue() : std::string()); | 196 sync_item->item_ordinal.ToInternalValue() : std::string()); |
| 196 dict_item->SetString(kPinPositionKey, sync_item->item_pin_ordinal.IsValid() ? | 197 dict_item->SetString(kPinPositionKey, sync_item->item_pin_ordinal.IsValid() ? |
| 197 sync_item->item_pin_ordinal.ToInternalValue() : std::string()); | 198 sync_item->item_pin_ordinal.ToInternalValue() : std::string()); |
| 198 dict_item->SetInteger(kTypeKey, static_cast<int>(sync_item->item_type)); | 199 dict_item->SetInteger(kTypeKey, static_cast<int>(sync_item->item_type)); |
| 199 } | 200 } |
| (...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 res += " { " + item_name + " }"; | 1232 res += " { " + item_name + " }"; |
| 1232 res += " [" + item_ordinal.ToDebugString() + "]"; | 1233 res += " [" + item_ordinal.ToDebugString() + "]"; |
| 1233 if (!parent_id.empty()) | 1234 if (!parent_id.empty()) |
| 1234 res += " <" + parent_id.substr(0, 8) + ">"; | 1235 res += " <" + parent_id.substr(0, 8) + ">"; |
| 1235 res += " [" + item_pin_ordinal.ToDebugString() + "]"; | 1236 res += " [" + item_pin_ordinal.ToDebugString() + "]"; |
| 1236 } | 1237 } |
| 1237 return res; | 1238 return res; |
| 1238 } | 1239 } |
| 1239 | 1240 |
| 1240 } // namespace app_list | 1241 } // namespace app_list |
| OLD | NEW |