| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 em::ChromeSettingsProto chrome_settings; | 477 em::ChromeSettingsProto chrome_settings; |
| 478 chrome_settings.mutable_homepagelocation()->set_homepagelocation( | 478 chrome_settings.mutable_homepagelocation()->set_homepagelocation( |
| 479 "chromium.org"); | 479 "chromium.org"); |
| 480 chrome_settings.mutable_showhomebutton()->set_showhomebutton(true); | 480 chrome_settings.mutable_showhomebutton()->set_showhomebutton(true); |
| 481 chrome_settings.mutable_restoreonstartup()->set_restoreonstartup(4); | 481 chrome_settings.mutable_restoreonstartup()->set_restoreonstartup(4); |
| 482 em::StringList* list = | 482 em::StringList* list = |
| 483 chrome_settings.mutable_disabledschemes()->mutable_disabledschemes(); | 483 chrome_settings.mutable_disabledschemes()->mutable_disabledschemes(); |
| 484 list->add_entries("ftp"); | 484 list->add_entries("ftp"); |
| 485 list->add_entries("mailto"); | 485 list->add_entries("mailto"); |
| 486 // Try explicitly setting a policy mode too. | 486 // Try explicitly setting a policy mode too. |
| 487 chrome_settings.mutable_disablespdy()->set_disablespdy(false); | 487 chrome_settings.mutable_searchsuggestenabled()->set_searchsuggestenabled( |
| 488 chrome_settings.mutable_disablespdy()->mutable_policy_options()->set_mode( | 488 false); |
| 489 em::PolicyOptions::MANDATORY); | 489 chrome_settings.mutable_searchsuggestenabled() |
| 490 ->mutable_policy_options() |
| 491 ->set_mode(em::PolicyOptions::MANDATORY); |
| 490 chrome_settings.mutable_syncdisabled()->set_syncdisabled(true); | 492 chrome_settings.mutable_syncdisabled()->set_syncdisabled(true); |
| 491 chrome_settings.mutable_syncdisabled()->mutable_policy_options()->set_mode( | 493 chrome_settings.mutable_syncdisabled()->mutable_policy_options()->set_mode( |
| 492 em::PolicyOptions::RECOMMENDED); | 494 em::PolicyOptions::RECOMMENDED); |
| 493 | 495 |
| 494 // Build an equivalent CloudPolicySettings message. | 496 // Build an equivalent CloudPolicySettings message. |
| 495 em::CloudPolicySettings cloud_policy; | 497 em::CloudPolicySettings cloud_policy; |
| 496 cloud_policy.mutable_homepagelocation()->set_value("chromium.org"); | 498 cloud_policy.mutable_homepagelocation()->set_value("chromium.org"); |
| 497 cloud_policy.mutable_showhomebutton()->set_value(true); | 499 cloud_policy.mutable_showhomebutton()->set_value(true); |
| 498 cloud_policy.mutable_restoreonstartup()->set_value(4); | 500 cloud_policy.mutable_restoreonstartup()->set_value(4); |
| 499 list = cloud_policy.mutable_disabledschemes()->mutable_value(); | 501 list = cloud_policy.mutable_disabledschemes()->mutable_value(); |
| 500 list->add_entries("ftp"); | 502 list->add_entries("ftp"); |
| 501 list->add_entries("mailto"); | 503 list->add_entries("mailto"); |
| 502 cloud_policy.mutable_disablespdy()->set_value(false); | 504 cloud_policy.mutable_searchsuggestenabled()->set_value(false); |
| 503 cloud_policy.mutable_disablespdy()->mutable_policy_options()->set_mode( | 505 cloud_policy.mutable_searchsuggestenabled() |
| 504 em::PolicyOptions::MANDATORY); | 506 ->mutable_policy_options() |
| 507 ->set_mode(em::PolicyOptions::MANDATORY); |
| 505 cloud_policy.mutable_syncdisabled()->set_value(true); | 508 cloud_policy.mutable_syncdisabled()->set_value(true); |
| 506 cloud_policy.mutable_syncdisabled()->mutable_policy_options()->set_mode( | 509 cloud_policy.mutable_syncdisabled()->mutable_policy_options()->set_mode( |
| 507 em::PolicyOptions::RECOMMENDED); | 510 em::PolicyOptions::RECOMMENDED); |
| 508 | 511 |
| 509 // They should now serialize to the same bytes. | 512 // They should now serialize to the same bytes. |
| 510 std::string chrome_settings_serialized; | 513 std::string chrome_settings_serialized; |
| 511 std::string cloud_policy_serialized; | 514 std::string cloud_policy_serialized; |
| 512 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); | 515 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); |
| 513 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); | 516 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); |
| 514 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); | 517 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); |
| 515 } | 518 } |
| 516 | 519 |
| 517 } // namespace policy | 520 } // namespace policy |
| OLD | NEW |