| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/strings/grit/ash_strings.h" | 8 #include "ash/strings/grit/ash_strings.h" |
| 9 #include "ash/system/date/date_default_view.h" | 9 #include "ash/system/date/date_default_view.h" |
| 10 #include "ash/system/date/tray_date.h" | 10 #include "ash/system/date/tray_date.h" |
| 11 #include "ash/system/tray/system_tray.h" | 11 #include "ash/system/tray/system_tray.h" |
| 12 #include "ash/system/tray/tray_popup_header_button.h" | 12 #include "ash/system/tray/tray_popup_header_button.h" |
| 13 #include "ash/system/user/login_status.h" | 13 #include "ash/system/user/login_status.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
| 20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 21 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
| 22 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 22 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 23 #include "chrome/browser/chromeos/login/lock/screen_locker_tester.h" | 23 #include "chrome/browser/chromeos/login/lock/screen_locker_tester.h" |
| 24 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" | 24 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" |
| 25 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 25 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 26 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 26 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
| 27 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | 27 #include "chrome/browser/chromeos/policy/device_policy_builder.h" |
| 28 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 28 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
| 29 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 29 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 30 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 30 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 31 #include "chrome/browser/lifetime/application_lifetime.h" | 31 #include "chrome/browser/lifetime/application_lifetime.h" |
| 32 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 32 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 33 #include "chromeos/chromeos_switches.h" | 33 #include "chromeos/chromeos_switches.h" |
| 34 #include "chromeos/dbus/dbus_thread_manager.h" | 34 #include "chromeos/dbus/dbus_thread_manager.h" |
| 35 #include "chromeos/dbus/fake_session_manager_client.h" | 35 #include "chromeos/dbus/fake_session_manager_client.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 InstallOwnerKey(); | 283 InstallOwnerKey(); |
| 284 MarkAsEnterpriseOwned(); | 284 MarkAsEnterpriseOwned(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 void SetUpOnMainThread() override { | 287 void SetUpOnMainThread() override { |
| 288 ShutdownPolicyBaseTest::SetUpOnMainThread(); | 288 ShutdownPolicyBaseTest::SetUpOnMainThread(); |
| 289 | 289 |
| 290 content::WindowedNotificationObserver( | 290 content::WindowedNotificationObserver( |
| 291 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 291 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
| 292 content::NotificationService::AllSources()).Wait(); | 292 content::NotificationService::AllSources()).Wait(); |
| 293 LoginDisplayHostImpl* host = | 293 LoginDisplayHost* host = LoginDisplayHost::default_host(); |
| 294 static_cast<LoginDisplayHostImpl*>( | |
| 295 LoginDisplayHostImpl::default_host()); | |
| 296 ASSERT_TRUE(host); | 294 ASSERT_TRUE(host); |
| 297 WebUILoginView* web_ui_login_view = host->GetWebUILoginView(); | 295 WebUILoginView* web_ui_login_view = host->GetWebUILoginView(); |
| 298 ASSERT_TRUE(web_ui_login_view); | 296 ASSERT_TRUE(web_ui_login_view); |
| 299 content::WebUI* web_ui = web_ui_login_view->GetWebUI(); | 297 content::WebUI* web_ui = web_ui_login_view->GetWebUI(); |
| 300 ASSERT_TRUE(web_ui); | 298 ASSERT_TRUE(web_ui); |
| 301 contents_ = web_ui->GetWebContents(); | 299 contents_ = web_ui->GetWebContents(); |
| 302 ASSERT_TRUE(contents_); | 300 ASSERT_TRUE(contents_); |
| 303 | 301 |
| 304 // Wait for the login UI to be ready. | 302 // Wait for the login UI to be ready. |
| 305 WaitUntilOobeUIIsReady(host->GetOobeUI()); | 303 WaitUntilOobeUIIsReady(host->GetOobeUI()); |
| 306 } | 304 } |
| 307 | 305 |
| 308 void TearDownOnMainThread() override { | 306 void TearDownOnMainThread() override { |
| 309 // If the login display is still showing, exit gracefully. | 307 // If the login display is still showing, exit gracefully. |
| 310 if (LoginDisplayHostImpl::default_host()) { | 308 if (LoginDisplayHost::default_host()) { |
| 311 base::MessageLoop::current()->PostTask(FROM_HERE, | 309 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 312 base::Bind(&chrome::AttemptExit)); | 310 base::Bind(&chrome::AttemptExit)); |
| 313 content::RunMessageLoop(); | 311 content::RunMessageLoop(); |
| 314 } | 312 } |
| 315 } | 313 } |
| 316 | 314 |
| 317 private: | 315 private: |
| 318 DISALLOW_COPY_AND_ASSIGN(ShutdownPolicyLoginTest); | 316 DISALLOW_COPY_AND_ASSIGN(ShutdownPolicyLoginTest); |
| 319 }; | 317 }; |
| 320 | 318 |
| 321 IN_PROC_BROWSER_TEST_F(ShutdownPolicyLoginTest, PolicyNotSet) { | 319 IN_PROC_BROWSER_TEST_F(ShutdownPolicyLoginTest, PolicyNotSet) { |
| 322 PrepareAndRunScript("restart-header-bar-item", true); | 320 PrepareAndRunScript("restart-header-bar-item", true); |
| 323 PrepareAndRunScript("shutdown-header-bar-item", false); | 321 PrepareAndRunScript("shutdown-header-bar-item", false); |
| 324 } | 322 } |
| 325 | 323 |
| 326 IN_PROC_BROWSER_TEST_F(ShutdownPolicyLoginTest, PolicyChange) { | 324 IN_PROC_BROWSER_TEST_F(ShutdownPolicyLoginTest, PolicyChange) { |
| 327 UpdateRebootOnShutdownPolicy(true); | 325 UpdateRebootOnShutdownPolicy(true); |
| 328 RefreshDevicePolicy(); | 326 RefreshDevicePolicy(); |
| 329 PrepareAndRunScript("restart-header-bar-item", false); | 327 PrepareAndRunScript("restart-header-bar-item", false); |
| 330 PrepareAndRunScript("shutdown-header-bar-item", true); | 328 PrepareAndRunScript("shutdown-header-bar-item", true); |
| 331 | 329 |
| 332 UpdateRebootOnShutdownPolicy(false); | 330 UpdateRebootOnShutdownPolicy(false); |
| 333 RefreshDevicePolicy(); | 331 RefreshDevicePolicy(); |
| 334 PrepareAndRunScript("restart-header-bar-item", true); | 332 PrepareAndRunScript("restart-header-bar-item", true); |
| 335 PrepareAndRunScript("shutdown-header-bar-item", false); | 333 PrepareAndRunScript("shutdown-header-bar-item", false); |
| 336 } | 334 } |
| 337 | 335 |
| 338 } // namespace chromeos | 336 } // namespace chromeos |
| OLD | NEW |