| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/strings/grit/ash_strings.h" | 9 #include "ash/strings/grit/ash_strings.h" |
| 10 #include "ash/system/date/date_default_view.h" | 10 #include "ash/system/date/date_default_view.h" |
| 11 #include "ash/system/date/tray_date.h" | 11 #include "ash/system/date/tray_date.h" |
| 12 #include "ash/system/tray/system_tray.h" | 12 #include "ash/system/tray/system_tray.h" |
| 13 #include "ash/system/tray/tray_popup_header_button.h" | 13 #include "ash/system/tray/tray_popup_header_button.h" |
| 14 #include "ash/system/user/login_status.h" | 14 #include "ash/system/user/login_status.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/message_loop/message_loop.h" | |
| 19 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
| 19 #include "base/single_thread_task_runner.h" |
| 20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 21 #include "base/threading/thread_task_runner_handle.h" |
| 21 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
| 22 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 23 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 23 #include "chrome/browser/chromeos/login/lock/screen_locker_tester.h" | 24 #include "chrome/browser/chromeos/login/lock/screen_locker_tester.h" |
| 24 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" | 25 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" |
| 25 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 26 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 26 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 27 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
| 27 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | 28 #include "chrome/browser/chromeos/policy/device_policy_builder.h" |
| 28 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 29 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
| 29 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 30 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 30 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 31 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 contents_ = web_ui->GetWebContents(); | 300 contents_ = web_ui->GetWebContents(); |
| 300 ASSERT_TRUE(contents_); | 301 ASSERT_TRUE(contents_); |
| 301 | 302 |
| 302 // Wait for the login UI to be ready. | 303 // Wait for the login UI to be ready. |
| 303 WaitUntilOobeUIIsReady(host->GetOobeUI()); | 304 WaitUntilOobeUIIsReady(host->GetOobeUI()); |
| 304 } | 305 } |
| 305 | 306 |
| 306 void TearDownOnMainThread() override { | 307 void TearDownOnMainThread() override { |
| 307 // If the login display is still showing, exit gracefully. | 308 // If the login display is still showing, exit gracefully. |
| 308 if (LoginDisplayHost::default_host()) { | 309 if (LoginDisplayHost::default_host()) { |
| 309 base::MessageLoop::current()->PostTask(FROM_HERE, | 310 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 310 base::Bind(&chrome::AttemptExit)); | 311 FROM_HERE, base::Bind(&chrome::AttemptExit)); |
| 311 content::RunMessageLoop(); | 312 content::RunMessageLoop(); |
| 312 } | 313 } |
| 313 } | 314 } |
| 314 | 315 |
| 315 private: | 316 private: |
| 316 DISALLOW_COPY_AND_ASSIGN(ShutdownPolicyLoginTest); | 317 DISALLOW_COPY_AND_ASSIGN(ShutdownPolicyLoginTest); |
| 317 }; | 318 }; |
| 318 | 319 |
| 319 IN_PROC_BROWSER_TEST_F(ShutdownPolicyLoginTest, PolicyNotSet) { | 320 IN_PROC_BROWSER_TEST_F(ShutdownPolicyLoginTest, PolicyNotSet) { |
| 320 PrepareAndRunScript("restart-header-bar-item", true); | 321 PrepareAndRunScript("restart-header-bar-item", true); |
| 321 PrepareAndRunScript("shutdown-header-bar-item", false); | 322 PrepareAndRunScript("shutdown-header-bar-item", false); |
| 322 } | 323 } |
| 323 | 324 |
| 324 IN_PROC_BROWSER_TEST_F(ShutdownPolicyLoginTest, PolicyChange) { | 325 IN_PROC_BROWSER_TEST_F(ShutdownPolicyLoginTest, PolicyChange) { |
| 325 UpdateRebootOnShutdownPolicy(true); | 326 UpdateRebootOnShutdownPolicy(true); |
| 326 RefreshDevicePolicy(); | 327 RefreshDevicePolicy(); |
| 327 PrepareAndRunScript("restart-header-bar-item", false); | 328 PrepareAndRunScript("restart-header-bar-item", false); |
| 328 PrepareAndRunScript("shutdown-header-bar-item", true); | 329 PrepareAndRunScript("shutdown-header-bar-item", true); |
| 329 | 330 |
| 330 UpdateRebootOnShutdownPolicy(false); | 331 UpdateRebootOnShutdownPolicy(false); |
| 331 RefreshDevicePolicy(); | 332 RefreshDevicePolicy(); |
| 332 PrepareAndRunScript("restart-header-bar-item", true); | 333 PrepareAndRunScript("restart-header-bar-item", true); |
| 333 PrepareAndRunScript("shutdown-header-bar-item", false); | 334 PrepareAndRunScript("shutdown-header-bar-item", false); |
| 334 } | 335 } |
| 335 | 336 |
| 336 } // namespace chromeos | 337 } // namespace chromeos |
| OLD | NEW |