| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" | 31 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" |
| 32 #include "chrome/browser/policy/cloud/policy_builder.h" | 32 #include "chrome/browser/policy/cloud/policy_builder.h" |
| 33 #include "chrome/browser/policy/policy_service.h" | 33 #include "chrome/browser/policy/policy_service.h" |
| 34 #include "chrome/browser/policy/test/local_policy_test_server.h" | 34 #include "chrome/browser/policy/test/local_policy_test_server.h" |
| 35 #include "chrome/browser/prefs/session_startup_pref.h" | 35 #include "chrome/browser/prefs/session_startup_pref.h" |
| 36 #include "chrome/browser/ui/browser.h" | 36 #include "chrome/browser/ui/browser.h" |
| 37 #include "chrome/browser/ui/browser_finder.h" | 37 #include "chrome/browser/ui/browser_finder.h" |
| 38 #include "chrome/browser/ui/host_desktop.h" | 38 #include "chrome/browser/ui/host_desktop.h" |
| 39 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 39 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 40 #include "chrome/common/chrome_notification_types.h" | 40 #include "chrome/common/chrome_notification_types.h" |
| 41 #include "chrome/common/chrome_paths.h" | |
| 42 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
| 43 #include "chrome/test/base/in_process_browser_test.h" | 42 #include "chrome/test/base/in_process_browser_test.h" |
| 43 #include "chromeos/chromeos_paths.h" |
| 44 #include "chromeos/chromeos_switches.h" | 44 #include "chromeos/chromeos_switches.h" |
| 45 #include "chromeos/dbus/cryptohome_client.h" | 45 #include "chromeos/dbus/cryptohome_client.h" |
| 46 #include "chromeos/dbus/dbus_method_call_status.h" | 46 #include "chromeos/dbus/dbus_method_call_status.h" |
| 47 #include "chromeos/dbus/dbus_thread_manager.h" | 47 #include "chromeos/dbus/dbus_thread_manager.h" |
| 48 #include "chromeos/dbus/mock_dbus_thread_manager.h" | 48 #include "chromeos/dbus/mock_dbus_thread_manager.h" |
| 49 #include "chromeos/dbus/mock_update_engine_client.h" | 49 #include "chromeos/dbus/mock_update_engine_client.h" |
| 50 #include "chromeos/dbus/session_manager_client.h" | 50 #include "chromeos/dbus/session_manager_client.h" |
| 51 #include "content/public/browser/notification_observer.h" | 51 #include "content/public/browser/notification_observer.h" |
| 52 #include "content/public/browser/notification_registrar.h" | 52 #include "content/public/browser/notification_registrar.h" |
| 53 #include "content/public/browser/notification_service.h" | 53 #include "content/public/browser/notification_service.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 attribute->set_value(PolicyBuilder::kFakeUsername); | 452 attribute->set_value(PolicyBuilder::kFakeUsername); |
| 453 | 453 |
| 454 base::FilePath install_attrs_file = | 454 base::FilePath install_attrs_file = |
| 455 temp_dir_.path().AppendASCII("install_attributes.pb"); | 455 temp_dir_.path().AppendASCII("install_attributes.pb"); |
| 456 const std::string install_attrs_blob( | 456 const std::string install_attrs_blob( |
| 457 install_attrs_proto.SerializeAsString()); | 457 install_attrs_proto.SerializeAsString()); |
| 458 ASSERT_EQ(static_cast<int>(install_attrs_blob.size()), | 458 ASSERT_EQ(static_cast<int>(install_attrs_blob.size()), |
| 459 file_util::WriteFile(install_attrs_file, | 459 file_util::WriteFile(install_attrs_file, |
| 460 install_attrs_blob.c_str(), | 460 install_attrs_blob.c_str(), |
| 461 install_attrs_blob.size())); | 461 install_attrs_blob.size())); |
| 462 ASSERT_TRUE(PathService::Override(chrome::FILE_INSTALL_ATTRIBUTES, | 462 ASSERT_TRUE(PathService::Override(chromeos::FILE_INSTALL_ATTRIBUTES, |
| 463 install_attrs_file)); | 463 install_attrs_file)); |
| 464 } | 464 } |
| 465 | 465 |
| 466 void SetUpPolicy() { | 466 void SetUpPolicy() { |
| 467 // Configure two device-local accounts in device settings. | 467 // Configure two device-local accounts in device settings. |
| 468 DevicePolicyBuilder device_policy; | 468 DevicePolicyBuilder device_policy; |
| 469 device_policy.policy_data().set_public_key_version(1); | 469 device_policy.policy_data().set_public_key_version(1); |
| 470 em::ChromeDeviceSettingsProto& proto(device_policy.payload()); | 470 em::ChromeDeviceSettingsProto& proto(device_policy.payload()); |
| 471 proto.mutable_show_user_names()->set_show_user_names(true); | 471 proto.mutable_show_user_names()->set_show_user_names(true); |
| 472 proto.mutable_device_local_accounts()->add_account()->set_id(kAccountId1); | 472 proto.mutable_device_local_accounts()->add_account()->set_id(kAccountId1); |
| 473 proto.mutable_device_local_accounts()->add_account()->set_id(kAccountId2); | 473 proto.mutable_device_local_accounts()->add_account()->set_id(kAccountId2); |
| 474 device_policy.Build(); | 474 device_policy.Build(); |
| 475 session_manager_client_.set_device_policy(device_policy.GetBlob()); | 475 session_manager_client_.set_device_policy(device_policy.GetBlob()); |
| 476 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, | 476 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, |
| 477 std::string(), proto.SerializeAsString()); | 477 std::string(), proto.SerializeAsString()); |
| 478 | 478 |
| 479 // Install the owner key. | 479 // Install the owner key. |
| 480 base::FilePath owner_key_file = temp_dir_.path().AppendASCII("owner.key"); | 480 base::FilePath owner_key_file = temp_dir_.path().AppendASCII("owner.key"); |
| 481 std::vector<uint8> owner_key_bits; | 481 std::vector<uint8> owner_key_bits; |
| 482 ASSERT_TRUE(device_policy.signing_key()->ExportPublicKey(&owner_key_bits)); | 482 ASSERT_TRUE(device_policy.signing_key()->ExportPublicKey(&owner_key_bits)); |
| 483 ASSERT_EQ( | 483 ASSERT_EQ( |
| 484 static_cast<int>(owner_key_bits.size()), | 484 static_cast<int>(owner_key_bits.size()), |
| 485 file_util::WriteFile( | 485 file_util::WriteFile( |
| 486 owner_key_file, | 486 owner_key_file, |
| 487 reinterpret_cast<const char*>(vector_as_array(&owner_key_bits)), | 487 reinterpret_cast<const char*>(vector_as_array(&owner_key_bits)), |
| 488 owner_key_bits.size())); | 488 owner_key_bits.size())); |
| 489 ASSERT_TRUE(PathService::Override(chrome::FILE_OWNER_KEY, owner_key_file)); | 489 ASSERT_TRUE( |
| 490 PathService::Override(chromeos::FILE_OWNER_KEY, owner_key_file)); |
| 490 | 491 |
| 491 // Configure device-local account policy for the first device-local account. | 492 // Configure device-local account policy for the first device-local account. |
| 492 UserPolicyBuilder device_local_account_policy; | 493 UserPolicyBuilder device_local_account_policy; |
| 493 device_local_account_policy.policy_data().set_policy_type( | 494 device_local_account_policy.policy_data().set_policy_type( |
| 494 dm_protocol::kChromePublicAccountPolicyType); | 495 dm_protocol::kChromePublicAccountPolicyType); |
| 495 device_local_account_policy.policy_data().set_username(kAccountId1); | 496 device_local_account_policy.policy_data().set_username(kAccountId1); |
| 496 device_local_account_policy.policy_data().set_settings_entity_id( | 497 device_local_account_policy.policy_data().set_settings_entity_id( |
| 497 kAccountId1); | 498 kAccountId1); |
| 498 device_local_account_policy.policy_data().set_public_key_version(1); | 499 device_local_account_policy.policy_data().set_public_key_version(1); |
| 499 device_local_account_policy.payload().mutable_restoreonstartup()->set_value( | 500 device_local_account_policy.payload().mutable_restoreonstartup()->set_value( |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 | 637 |
| 637 TabStripModel* tabs = browser->tab_strip_model(); | 638 TabStripModel* tabs = browser->tab_strip_model(); |
| 638 ASSERT_TRUE(tabs); | 639 ASSERT_TRUE(tabs); |
| 639 int expected_tab_count = static_cast<int>(arraysize(kStartupURLs)); | 640 int expected_tab_count = static_cast<int>(arraysize(kStartupURLs)); |
| 640 EXPECT_EQ(expected_tab_count, tabs->count()); | 641 EXPECT_EQ(expected_tab_count, tabs->count()); |
| 641 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) | 642 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) |
| 642 EXPECT_EQ(GURL(kStartupURLs[i]), tabs->GetWebContentsAt(i)->GetURL()); | 643 EXPECT_EQ(GURL(kStartupURLs[i]), tabs->GetWebContentsAt(i)->GetURL()); |
| 643 } | 644 } |
| 644 | 645 |
| 645 } // namespace policy | 646 } // namespace policy |
| OLD | NEW |