| 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 proto.mutable_device_local_accounts()->add_account(); | 409 proto.mutable_device_local_accounts()->add_account(); |
| 410 account->set_account_id(username); | 410 account->set_account_id(username); |
| 411 account->set_type( | 411 account->set_type( |
| 412 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); | 412 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); |
| 413 RefreshDevicePolicy(); | 413 RefreshDevicePolicy(); |
| 414 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, | 414 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, |
| 415 std::string(), proto.SerializeAsString()); | 415 std::string(), proto.SerializeAsString()); |
| 416 } | 416 } |
| 417 | 417 |
| 418 void CheckPublicSessionPresent(const std::string& id) { | 418 void CheckPublicSessionPresent(const std::string& id) { |
| 419 const chromeos::User* user = chromeos::UserManager::Get()->FindUser(id); | 419 const chromeos::User* user = chromeos::GetUserManager()->FindUser(id); |
| 420 ASSERT_TRUE(user); | 420 ASSERT_TRUE(user); |
| 421 EXPECT_EQ(id, user->email()); | 421 EXPECT_EQ(id, user->email()); |
| 422 EXPECT_EQ(user_manager::USER_TYPE_PUBLIC_ACCOUNT, user->GetType()); | 422 EXPECT_EQ(user_manager::USER_TYPE_PUBLIC_ACCOUNT, user->GetType()); |
| 423 } | 423 } |
| 424 | 424 |
| 425 base::FilePath GetExtensionCacheDirectoryForAccountID( | 425 base::FilePath GetExtensionCacheDirectoryForAccountID( |
| 426 const std::string& account_id) { | 426 const std::string& account_id) { |
| 427 base::FilePath extension_cache_root_dir; | 427 base::FilePath extension_cache_root_dir; |
| 428 if (!PathService::Get(chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS, | 428 if (!PathService::Get(chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS, |
| 429 &extension_cache_root_dir)) { | 429 &extension_cache_root_dir)) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 452 scoped_ptr<base::RunLoop> run_loop_; | 452 scoped_ptr<base::RunLoop> run_loop_; |
| 453 | 453 |
| 454 UserPolicyBuilder device_local_account_policy_; | 454 UserPolicyBuilder device_local_account_policy_; |
| 455 LocalPolicyTestServer test_server_; | 455 LocalPolicyTestServer test_server_; |
| 456 | 456 |
| 457 private: | 457 private: |
| 458 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountTest); | 458 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountTest); |
| 459 }; | 459 }; |
| 460 | 460 |
| 461 static bool IsKnownUser(const std::string& account_id) { | 461 static bool IsKnownUser(const std::string& account_id) { |
| 462 return chromeos::UserManager::Get()->IsKnownUser(account_id); | 462 return chromeos::GetUserManager()->IsKnownUser(account_id); |
| 463 } | 463 } |
| 464 | 464 |
| 465 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, LoginScreen) { | 465 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, LoginScreen) { |
| 466 AddPublicSessionToDevicePolicy(kAccountId1); | 466 AddPublicSessionToDevicePolicy(kAccountId1); |
| 467 AddPublicSessionToDevicePolicy(kAccountId2); | 467 AddPublicSessionToDevicePolicy(kAccountId2); |
| 468 | 468 |
| 469 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, | 469 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, |
| 470 base::Bind(&IsKnownUser, user_id_1_)) | 470 base::Bind(&IsKnownUser, user_id_1_)) |
| 471 .Wait(); | 471 .Wait(); |
| 472 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, | 472 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, |
| 473 base::Bind(&IsKnownUser, user_id_2_)) | 473 base::Bind(&IsKnownUser, user_id_2_)) |
| 474 .Wait(); | 474 .Wait(); |
| 475 | 475 |
| 476 CheckPublicSessionPresent(user_id_1_); | 476 CheckPublicSessionPresent(user_id_1_); |
| 477 CheckPublicSessionPresent(user_id_2_); | 477 CheckPublicSessionPresent(user_id_2_); |
| 478 } | 478 } |
| 479 | 479 |
| 480 static bool DisplayNameMatches(const std::string& account_id, | 480 static bool DisplayNameMatches(const std::string& account_id, |
| 481 const std::string& display_name) { | 481 const std::string& display_name) { |
| 482 const chromeos::User* user = | 482 const chromeos::User* user = chromeos::GetUserManager()->FindUser(account_id); |
| 483 chromeos::UserManager::Get()->FindUser(account_id); | |
| 484 if (!user || user->display_name().empty()) | 483 if (!user || user->display_name().empty()) |
| 485 return false; | 484 return false; |
| 486 EXPECT_EQ(base::UTF8ToUTF16(display_name), user->display_name()); | 485 EXPECT_EQ(base::UTF8ToUTF16(display_name), user->display_name()); |
| 487 return true; | 486 return true; |
| 488 } | 487 } |
| 489 | 488 |
| 490 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DisplayName) { | 489 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DisplayName) { |
| 491 UploadAndInstallDeviceLocalAccountPolicy(); | 490 UploadAndInstallDeviceLocalAccountPolicy(); |
| 492 AddPublicSessionToDevicePolicy(kAccountId1); | 491 AddPublicSessionToDevicePolicy(kAccountId1); |
| 493 | 492 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 policy.SerializeAsString()); | 544 policy.SerializeAsString()); |
| 546 g_browser_process->policy_service()->RefreshPolicies(base::Closure()); | 545 g_browser_process->policy_service()->RefreshPolicies(base::Closure()); |
| 547 | 546 |
| 548 // Make sure the second device-local account disappears. | 547 // Make sure the second device-local account disappears. |
| 549 content::WindowedNotificationObserver( | 548 content::WindowedNotificationObserver( |
| 550 chrome::NOTIFICATION_USER_LIST_CHANGED, | 549 chrome::NOTIFICATION_USER_LIST_CHANGED, |
| 551 base::Bind(&IsNotKnownUser, user_id_2_)).Wait(); | 550 base::Bind(&IsNotKnownUser, user_id_2_)).Wait(); |
| 552 } | 551 } |
| 553 | 552 |
| 554 static bool IsSessionStarted() { | 553 static bool IsSessionStarted() { |
| 555 return chromeos::UserManager::Get()->IsSessionStarted(); | 554 return chromeos::GetUserManager()->IsSessionStarted(); |
| 556 } | 555 } |
| 557 | 556 |
| 558 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, StartSession) { | 557 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, StartSession) { |
| 559 // Specify startup pages. | 558 // Specify startup pages. |
| 560 device_local_account_policy_.payload().mutable_restoreonstartup()->set_value( | 559 device_local_account_policy_.payload().mutable_restoreonstartup()->set_value( |
| 561 SessionStartupPref::kPrefValueURLs); | 560 SessionStartupPref::kPrefValueURLs); |
| 562 em::StringListPolicyProto* startup_urls_proto = | 561 em::StringListPolicyProto* startup_urls_proto = |
| 563 device_local_account_policy_.payload().mutable_restoreonstartupurls(); | 562 device_local_account_policy_.payload().mutable_restoreonstartupurls(); |
| 564 for (size_t i = 0; i < arraysize(kStartupURLs); ++i) | 563 for (size_t i = 0; i < arraysize(kStartupURLs); ++i) |
| 565 startup_urls_proto->mutable_value()->add_entries(kStartupURLs[i]); | 564 startup_urls_proto->mutable_value()->add_entries(kStartupURLs[i]); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 // Verify that the extension was removed from the account's extension cache. | 849 // Verify that the extension was removed from the account's extension cache. |
| 851 EXPECT_FALSE(PathExists(cached_extension)); | 850 EXPECT_FALSE(PathExists(cached_extension)); |
| 852 } | 851 } |
| 853 | 852 |
| 854 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExternalData) { | 853 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExternalData) { |
| 855 // chromeos::UserManager requests an external data fetch whenever | 854 // chromeos::UserManager requests an external data fetch whenever |
| 856 // the key::kUserAvatarImage policy is set. Since this test wants to | 855 // the key::kUserAvatarImage policy is set. Since this test wants to |
| 857 // verify that the underlying policy subsystem will start a fetch | 856 // verify that the underlying policy subsystem will start a fetch |
| 858 // without this request as well, the chromeos::UserManager must be | 857 // without this request as well, the chromeos::UserManager must be |
| 859 // prevented from seeing the policy change. | 858 // prevented from seeing the policy change. |
| 860 reinterpret_cast<chromeos::UserManagerImpl*>(chromeos::UserManager::Get())-> | 859 reinterpret_cast<chromeos::UserManagerImpl*>(chromeos::GetUserManager()) |
| 861 StopPolicyObserverForTesting(); | 860 ->StopPolicyObserverForTesting(); |
| 862 | 861 |
| 863 UploadDeviceLocalAccountPolicy(); | 862 UploadDeviceLocalAccountPolicy(); |
| 864 AddPublicSessionToDevicePolicy(kAccountId1); | 863 AddPublicSessionToDevicePolicy(kAccountId1); |
| 865 | 864 |
| 866 // This observes the display name becoming available as this indicates | 865 // This observes the display name becoming available as this indicates |
| 867 // device-local account policy is fully loaded. | 866 // device-local account policy is fully loaded. |
| 868 content::WindowedNotificationObserver( | 867 content::WindowedNotificationObserver( |
| 869 chrome::NOTIFICATION_USER_LIST_CHANGED, | 868 chrome::NOTIFICATION_USER_LIST_CHANGED, |
| 870 base::Bind(&DisplayNameMatches, user_id_1_, kDisplayName)).Wait(); | 869 base::Bind(&DisplayNameMatches, user_id_1_, kDisplayName)).Wait(); |
| 871 | 870 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 policy); | 1001 policy); |
| 1003 UploadAndInstallDeviceLocalAccountPolicy(); | 1002 UploadAndInstallDeviceLocalAccountPolicy(); |
| 1004 policy::BrowserPolicyConnectorChromeOS* connector = | 1003 policy::BrowserPolicyConnectorChromeOS* connector = |
| 1005 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 1004 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 1006 DeviceLocalAccountPolicyBroker* broker = | 1005 DeviceLocalAccountPolicyBroker* broker = |
| 1007 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( | 1006 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser( |
| 1008 user_id_1_); | 1007 user_id_1_); |
| 1009 ASSERT_TRUE(broker); | 1008 ASSERT_TRUE(broker); |
| 1010 | 1009 |
| 1011 run_loop_.reset(new base::RunLoop); | 1010 run_loop_.reset(new base::RunLoop); |
| 1012 chromeos::UserManager::Get()->AddObserver(this); | 1011 chromeos::GetUserManager()->AddObserver(this); |
| 1013 broker->core()->store()->Load(); | 1012 broker->core()->store()->Load(); |
| 1014 run_loop_->Run(); | 1013 run_loop_->Run(); |
| 1015 chromeos::UserManager::Get()->RemoveObserver(this); | 1014 chromeos::GetUserManager()->RemoveObserver(this); |
| 1016 | 1015 |
| 1017 scoped_ptr<gfx::ImageSkia> policy_image = chromeos::test::ImageLoader( | 1016 scoped_ptr<gfx::ImageSkia> policy_image = chromeos::test::ImageLoader( |
| 1018 test_dir.Append(chromeos::test::kUserAvatarImage1RelativePath)).Load(); | 1017 test_dir.Append(chromeos::test::kUserAvatarImage1RelativePath)).Load(); |
| 1019 ASSERT_TRUE(policy_image); | 1018 ASSERT_TRUE(policy_image); |
| 1020 | 1019 |
| 1021 const chromeos::User* user = | 1020 const chromeos::User* user = chromeos::GetUserManager()->FindUser(user_id_1_); |
| 1022 chromeos::UserManager::Get()->FindUser(user_id_1_); | |
| 1023 ASSERT_TRUE(user); | 1021 ASSERT_TRUE(user); |
| 1024 | 1022 |
| 1025 base::FilePath user_data_dir; | 1023 base::FilePath user_data_dir; |
| 1026 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); | 1024 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); |
| 1027 const base::FilePath saved_image_path = | 1025 const base::FilePath saved_image_path = |
| 1028 user_data_dir.Append(user_id_1_).AddExtension("jpg"); | 1026 user_data_dir.Append(user_id_1_).AddExtension("jpg"); |
| 1029 | 1027 |
| 1030 EXPECT_FALSE(user->HasDefaultImage()); | 1028 EXPECT_FALSE(user->HasDefaultImage()); |
| 1031 EXPECT_EQ(chromeos::User::kExternalImageIndex, user->image_index()); | 1029 EXPECT_EQ(chromeos::User::kExternalImageIndex, user->image_index()); |
| 1032 EXPECT_TRUE(chromeos::test::AreImagesEqual(*policy_image, user->GetImage())); | 1030 EXPECT_TRUE(chromeos::test::AreImagesEqual(*policy_image, user->GetImage())); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1385 if (!IsSessionStarted()) { | 1383 if (!IsSessionStarted()) { |
| 1386 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, | 1384 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, |
| 1387 base::Bind(IsSessionStarted)).Wait(); | 1385 base::Bind(IsSessionStarted)).Wait(); |
| 1388 } | 1386 } |
| 1389 } | 1387 } |
| 1390 | 1388 |
| 1391 INSTANTIATE_TEST_CASE_P(TermsOfServiceTestInstance, | 1389 INSTANTIATE_TEST_CASE_P(TermsOfServiceTestInstance, |
| 1392 TermsOfServiceTest, testing::Bool()); | 1390 TermsOfServiceTest, testing::Bool()); |
| 1393 | 1391 |
| 1394 } // namespace policy | 1392 } // namespace policy |
| OLD | NEW |