| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/sync/test/integration/sync_arc_package_helper.h" | 5 #include "chrome/browser/sync/test/integration/sync_arc_package_helper.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/run_loop.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "chrome/browser/chromeos/arc/arc_auth_service.h" | 15 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
| 15 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 16 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 16 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 17 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" | 20 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
| 20 #include "chrome/browser/sync/test/integration/sync_test.h" | 21 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 21 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 22 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 22 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" | 23 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 DVLOG(1) << "Profile2: " | 141 DVLOG(1) << "Profile2: " |
| 141 << ArcPackageSyncableService::Get(profiles.front()); | 142 << ArcPackageSyncableService::Get(profiles.front()); |
| 142 return false; | 143 return false; |
| 143 } | 144 } |
| 144 } | 145 } |
| 145 return true; | 146 return true; |
| 146 } | 147 } |
| 147 | 148 |
| 148 void SyncArcPackageHelper::SetupArcService(Profile* profile, size_t id) { | 149 void SyncArcPackageHelper::SetupArcService(Profile* profile, size_t id) { |
| 149 DCHECK(profile); | 150 DCHECK(profile); |
| 151 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 152 chromeos::switches::kEnableArc); |
| 150 const user_manager::User* user = CreateUserAndLogin(profile, id); | 153 const user_manager::User* user = CreateUserAndLogin(profile, id); |
| 151 // Have the user-to-profile mapping ready to avoid using the real profile | 154 // Have the user-to-profile mapping ready to avoid using the real profile |
| 152 // manager (which is null). | 155 // manager (which is null). |
| 153 chromeos::ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, | 156 chromeos::ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, |
| 154 profile); | 157 profile); |
| 155 | 158 |
| 156 ArcAuthService* auth_service = ArcAuthService::Get(); | 159 ArcAuthService* auth_service = ArcAuthService::Get(); |
| 157 DCHECK(auth_service); | 160 DCHECK(auth_service); |
| 158 ArcAuthService::DisableUIForTesting(); | 161 ArcAuthService::DisableUIForTesting(); |
| 159 auth_service->OnPrimaryUserProfilePrepared(profile); | 162 auth_service->OnPrimaryUserProfilePrepared(profile); |
| 160 auth_service->EnableArc(); | 163 auth_service->EnableArc(); |
| 161 | 164 |
| 162 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); | 165 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); |
| 163 DCHECK(arc_app_list_prefs); | 166 DCHECK(arc_app_list_prefs); |
| 167 |
| 168 base::RunLoop run_loop; |
| 169 arc_app_list_prefs->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); |
| 170 run_loop.Run(); |
| 171 |
| 164 instance_map_[profile].reset(new FakeAppInstance(arc_app_list_prefs)); | 172 instance_map_[profile].reset(new FakeAppInstance(arc_app_list_prefs)); |
| 165 DCHECK(instance_map_[profile].get()); | 173 DCHECK(instance_map_[profile].get()); |
| 166 arc_app_list_prefs->app_instance_holder()->SetInstance( | 174 arc_app_list_prefs->app_instance_holder()->SetInstance( |
| 167 instance_map_[profile].get()); | 175 instance_map_[profile].get()); |
| 168 } | 176 } |
| 169 | 177 |
| 170 void SyncArcPackageHelper::InstallPackage( | 178 void SyncArcPackageHelper::InstallPackage( |
| 171 Profile* profile, | 179 Profile* profile, |
| 172 const mojom::ArcPackageInfo& package) { | 180 const mojom::ArcPackageInfo& package) { |
| 173 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); | 181 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 if (package1_info->last_backup_android_id != | 247 if (package1_info->last_backup_android_id != |
| 240 package2_info->last_backup_android_id) | 248 package2_info->last_backup_android_id) |
| 241 return false; | 249 return false; |
| 242 if (package1_info->last_backup_time != package2_info->last_backup_time) | 250 if (package1_info->last_backup_time != package2_info->last_backup_time) |
| 243 return false; | 251 return false; |
| 244 } | 252 } |
| 245 return true; | 253 return true; |
| 246 } | 254 } |
| 247 | 255 |
| 248 } // namespace arc | 256 } // namespace arc |
| OLD | NEW |