OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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/extension_assets_manager_chromeos.h" | 5 #include "chrome/browser/extensions/extension_assets_manager_chromeos.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 // static | 273 // static |
274 void ExtensionAssetsManagerChromeOS::CheckSharedExtension( | 274 void ExtensionAssetsManagerChromeOS::CheckSharedExtension( |
275 const std::string& id, | 275 const std::string& id, |
276 const std::string& version, | 276 const std::string& version, |
277 const base::FilePath& unpacked_extension_root, | 277 const base::FilePath& unpacked_extension_root, |
278 const base::FilePath& local_install_dir, | 278 const base::FilePath& local_install_dir, |
279 Profile* profile, | 279 Profile* profile, |
280 InstallExtensionCallback callback) { | 280 InstallExtensionCallback callback) { |
281 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 281 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
282 | 282 |
283 const std::string& user_id = profile->GetProfileUserName(); | 283 const user_manager::User* user = chromeos::ProfileHelper::Get()->GetUserByProf
ile(profile); |
284 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 284 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
285 if (!user_manager) { | 285 if (!user_manager) { |
286 NOTREACHED(); | 286 NOTREACHED(); |
287 return; | 287 return; |
288 } | 288 } |
289 | 289 |
290 if (user_manager->IsUserNonCryptohomeDataEphemeral(user_id) || | 290 if (user_manager->IsUserNonCryptohomeDataEphemeral(user->GetUserID()) || |
291 !user_manager->IsLoggedInAsUserWithGaiaAccount()) { | 291 !user_manager->IsLoggedInAsUserWithGaiaAccount()) { |
292 // Don't cache anything in shared location for ephemeral user or special | 292 // Don't cache anything in shared location for ephemeral user or special |
293 // user types. | 293 // user types. |
294 ExtensionAssetsManagerChromeOS::GetFileTaskRunner(profile)->PostTask( | 294 ExtensionAssetsManagerChromeOS::GetFileTaskRunner(profile)->PostTask( |
295 FROM_HERE, | 295 FROM_HERE, |
296 base::Bind(&ExtensionAssetsManagerChromeOS::InstallLocalExtension, | 296 base::Bind(&ExtensionAssetsManagerChromeOS::InstallLocalExtension, |
297 id, | 297 id, |
298 version, | 298 version, |
299 unpacked_extension_root, | 299 unpacked_extension_root, |
300 local_install_dir, | 300 local_install_dir, |
(...skipping 10 matching lines...) Expand all Loading... |
311 if (shared_extensions->GetDictionary(id, &extension_info) && | 311 if (shared_extensions->GetDictionary(id, &extension_info) && |
312 extension_info->GetDictionaryWithoutPathExpansion( | 312 extension_info->GetDictionaryWithoutPathExpansion( |
313 version, &version_info) && | 313 version, &version_info) && |
314 version_info->GetString(kSharedExtensionPath, &shared_path) && | 314 version_info->GetString(kSharedExtensionPath, &shared_path) && |
315 version_info->GetList(kSharedExtensionUsers, &users)) { | 315 version_info->GetList(kSharedExtensionUsers, &users)) { |
316 // This extension version already in shared location. | 316 // This extension version already in shared location. |
317 size_t users_size = users->GetSize(); | 317 size_t users_size = users->GetSize(); |
318 bool user_found = false; | 318 bool user_found = false; |
319 for (size_t i = 0; i < users_size; i++) { | 319 for (size_t i = 0; i < users_size; i++) { |
320 std::string temp; | 320 std::string temp; |
321 if (users->GetString(i, &temp) && temp == user_id) { | 321 if (users->GetString(i, &temp) && temp == user->GetUserID().GetUserEmail()
) { |
322 // Re-installation for the same user. | 322 // Re-installation for the same user. |
323 user_found = true; | 323 user_found = true; |
324 break; | 324 break; |
325 } | 325 } |
326 } | 326 } |
327 if (!user_found) | 327 if (!user_found) |
328 users->AppendString(user_id); | 328 users->AppendString(user->GetUserID().GetUserEmail()); |
329 | 329 |
330 // unpacked_extension_root will be deleted by CrxInstaller. | 330 // unpacked_extension_root will be deleted by CrxInstaller. |
331 ExtensionAssetsManagerChromeOS::GetFileTaskRunner(profile)->PostTask( | 331 ExtensionAssetsManagerChromeOS::GetFileTaskRunner(profile)->PostTask( |
332 FROM_HERE, | 332 FROM_HERE, |
333 base::Bind(callback, base::FilePath(shared_path))); | 333 base::Bind(callback, base::FilePath(shared_path))); |
334 } else { | 334 } else { |
335 // Desired version is not found in shared location. | 335 // Desired version is not found in shared location. |
336 ExtensionAssetsManagerHelper* helper = | 336 ExtensionAssetsManagerHelper* helper = |
337 ExtensionAssetsManagerHelper::GetInstance(); | 337 ExtensionAssetsManagerHelper::GetInstance(); |
338 if (helper->RecordSharedInstall(id, version, unpacked_extension_root, | 338 if (helper->RecordSharedInstall(id, version, unpacked_extension_root, |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 if (!extension_info->GetDictionaryWithoutPathExpansion(*it, | 518 if (!extension_info->GetDictionaryWithoutPathExpansion(*it, |
519 &version_info) || | 519 &version_info) || |
520 !version_info->GetList(kSharedExtensionUsers, &users) || | 520 !version_info->GetList(kSharedExtensionUsers, &users) || |
521 !version_info->GetString(kSharedExtensionPath, &shared_path)) { | 521 !version_info->GetString(kSharedExtensionPath, &shared_path)) { |
522 NOTREACHED(); | 522 NOTREACHED(); |
523 return false; | 523 return false; |
524 } | 524 } |
525 | 525 |
526 size_t num_users = users->GetSize(); | 526 size_t num_users = users->GetSize(); |
527 for (size_t i = 0; i < num_users; i++) { | 527 for (size_t i = 0; i < num_users; i++) { |
528 std::string user_id; | 528 std::string user_email; |
529 if (!users->GetString(i, &user_id)) { | 529 if (!users->GetString(i, &user_email)) { |
530 NOTREACHED(); | 530 NOTREACHED(); |
531 return false; | 531 return false; |
532 } | 532 } |
| 533 const user_manager::UserID user_id(std::string() /* gaia_id */, user_email
); |
533 const user_manager::User* user = user_manager->FindUser(user_id); | 534 const user_manager::User* user = user_manager->FindUser(user_id); |
534 bool not_used = false; | 535 bool not_used = false; |
535 if (!user) { | 536 if (!user) { |
536 not_used = true; | 537 not_used = true; |
537 } else if (user->is_logged_in()) { | 538 } else if (user->is_logged_in()) { |
538 // For logged in user also check that this path is actually used as | 539 // For logged in user also check that this path is actually used as |
539 // installed extension or as delayed install. | 540 // installed extension or as delayed install. |
540 Profile* profile = | 541 Profile* profile = |
541 chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe(user); | 542 chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe(user); |
542 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(profile); | 543 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(profile); |
(...skipping 23 matching lines...) Expand all Loading... |
566 std::make_pair(id, base::FilePath(shared_path))); | 567 std::make_pair(id, base::FilePath(shared_path))); |
567 } else { | 568 } else { |
568 extension_info->RemoveWithoutPathExpansion(*it, NULL); | 569 extension_info->RemoveWithoutPathExpansion(*it, NULL); |
569 } | 570 } |
570 } | 571 } |
571 | 572 |
572 return true; | 573 return true; |
573 } | 574 } |
574 | 575 |
575 } // namespace extensions | 576 } // namespace extensions |
OLD | NEW |