| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <map> | 5 #include <map> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
| 9 #include "apps/ui/native_app_window.h" | 9 #include "apps/ui/native_app_window.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 std::string(), proto.SerializeAsString()); | 414 std::string(), proto.SerializeAsString()); |
| 415 } | 415 } |
| 416 | 416 |
| 417 void CheckPublicSessionPresent(const std::string& id) { | 417 void CheckPublicSessionPresent(const std::string& id) { |
| 418 const chromeos::User* user = chromeos::UserManager::Get()->FindUser(id); | 418 const chromeos::User* user = chromeos::UserManager::Get()->FindUser(id); |
| 419 ASSERT_TRUE(user); | 419 ASSERT_TRUE(user); |
| 420 EXPECT_EQ(id, user->email()); | 420 EXPECT_EQ(id, user->email()); |
| 421 EXPECT_EQ(chromeos::User::USER_TYPE_PUBLIC_ACCOUNT, user->GetType()); | 421 EXPECT_EQ(chromeos::User::USER_TYPE_PUBLIC_ACCOUNT, user->GetType()); |
| 422 } | 422 } |
| 423 | 423 |
| 424 base::FilePath GetCacheDirectoryForAccountID(const std::string& account_id) { | 424 base::FilePath GetExtensionCacheDirectoryForAccountID( |
| 425 const std::string& account_id) { |
| 425 base::FilePath extension_cache_root_dir; | 426 base::FilePath extension_cache_root_dir; |
| 426 PathService::Get(chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS, | 427 if (!PathService::Get(chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS, |
| 427 &extension_cache_root_dir); | 428 &extension_cache_root_dir)) { |
| 429 ADD_FAILURE(); |
| 430 } |
| 428 return extension_cache_root_dir.Append( | 431 return extension_cache_root_dir.Append( |
| 429 base::HexEncode(account_id.c_str(), account_id.size())); | 432 base::HexEncode(account_id.c_str(), account_id.size())); |
| 430 } | 433 } |
| 431 | 434 |
| 432 base::FilePath GetCacheCRXFile(const std::string& account_id, | 435 base::FilePath GetCacheCRXFile(const std::string& account_id, |
| 433 const std::string& id, | 436 const std::string& id, |
| 434 const std::string& version) { | 437 const std::string& version) { |
| 435 return GetCacheDirectoryForAccountID(account_id) | 438 return GetExtensionCacheDirectoryForAccountID(account_id) |
| 436 .Append(base::StringPrintf("%s-%s.crx", id.c_str(), version.c_str())); | 439 .Append(base::StringPrintf("%s-%s.crx", id.c_str(), version.c_str())); |
| 437 } | 440 } |
| 438 | 441 |
| 439 // Returns a profile which can be used for testing. | 442 // Returns a profile which can be used for testing. |
| 440 Profile* GetProfileForTest() { | 443 Profile* GetProfileForTest() { |
| 441 // Any profile can be used here since this test does not test multi profile. | 444 // Any profile can be used here since this test does not test multi profile. |
| 442 return ProfileManager::GetActiveUserProfile(); | 445 return ProfileManager::GetActiveUserProfile(); |
| 443 } | 446 } |
| 444 | 447 |
| 445 const std::string user_id_1_; | 448 const std::string user_id_1_; |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 EXPECT_FALSE(PathExists(GetCacheCRXFile( | 760 EXPECT_FALSE(PathExists(GetCacheCRXFile( |
| 758 kAccountId1, kGoodExtensionID, kGoodExtensionVersion))); | 761 kAccountId1, kGoodExtensionID, kGoodExtensionVersion))); |
| 759 } | 762 } |
| 760 | 763 |
| 761 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionsCached) { | 764 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionsCached) { |
| 762 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 765 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 763 | 766 |
| 764 // Pre-populate the device local account's extension cache with a hosted app | 767 // Pre-populate the device local account's extension cache with a hosted app |
| 765 // and an extension. | 768 // and an extension. |
| 766 EXPECT_TRUE(base::CreateDirectory( | 769 EXPECT_TRUE(base::CreateDirectory( |
| 767 GetCacheDirectoryForAccountID(kAccountId1))); | 770 GetExtensionCacheDirectoryForAccountID(kAccountId1))); |
| 768 base::FilePath test_dir; | 771 base::FilePath test_dir; |
| 769 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); | 772 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); |
| 770 const base::FilePath cached_hosted_app = | 773 const base::FilePath cached_hosted_app = |
| 771 GetCacheCRXFile(kAccountId1, kHostedAppID, kHostedAppVersion); | 774 GetCacheCRXFile(kAccountId1, kHostedAppID, kHostedAppVersion); |
| 772 EXPECT_TRUE(CopyFile(test_dir.Append(kHostedAppCRXPath), | 775 EXPECT_TRUE(CopyFile(test_dir.Append(kHostedAppCRXPath), |
| 773 cached_hosted_app)); | 776 cached_hosted_app)); |
| 774 const base::FilePath cached_extension = | 777 const base::FilePath cached_extension = |
| 775 GetCacheCRXFile(kAccountId1, kGoodExtensionID, kGoodExtensionVersion); | 778 GetCacheCRXFile(kAccountId1, kGoodExtensionID, kGoodExtensionVersion); |
| 776 EXPECT_TRUE(CopyFile(test_dir.Append(kGoodExtensionCRXPath), | 779 EXPECT_TRUE(CopyFile(test_dir.Append(kGoodExtensionCRXPath), |
| 777 cached_extension)); | 780 cached_extension)); |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 if (!IsSessionStarted()) { | 1384 if (!IsSessionStarted()) { |
| 1382 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, | 1385 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, |
| 1383 base::Bind(IsSessionStarted)).Wait(); | 1386 base::Bind(IsSessionStarted)).Wait(); |
| 1384 } | 1387 } |
| 1385 } | 1388 } |
| 1386 | 1389 |
| 1387 INSTANTIATE_TEST_CASE_P(TermsOfServiceTestInstance, | 1390 INSTANTIATE_TEST_CASE_P(TermsOfServiceTestInstance, |
| 1388 TermsOfServiceTest, testing::Bool()); | 1391 TermsOfServiceTest, testing::Bool()); |
| 1389 | 1392 |
| 1390 } // namespace policy | 1393 } // namespace policy |
| OLD | NEW |