Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: chrome/browser/chromeos/policy/device_local_account_browsertest.cc

Issue 22986010: Add policy for fullscreen mode; disallow fullscreen in public sessions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix browser test compilation after rebase. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 22 matching lines...) Expand all
33 #include "chrome/browser/chromeos/policy/device_local_account.h" 33 #include "chrome/browser/chromeos/policy/device_local_account.h"
34 #include "chrome/browser/chromeos/policy/device_policy_builder.h" 34 #include "chrome/browser/chromeos/policy/device_policy_builder.h"
35 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" 35 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
36 #include "chrome/browser/lifetime/application_lifetime.h" 36 #include "chrome/browser/lifetime/application_lifetime.h"
37 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" 37 #include "chrome/browser/policy/cloud/cloud_policy_constants.h"
38 #include "chrome/browser/policy/cloud/policy_builder.h" 38 #include "chrome/browser/policy/cloud/policy_builder.h"
39 #include "chrome/browser/policy/policy_service.h" 39 #include "chrome/browser/policy/policy_service.h"
40 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" 40 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h"
41 #include "chrome/browser/policy/test/local_policy_test_server.h" 41 #include "chrome/browser/policy/test/local_policy_test_server.h"
42 #include "chrome/browser/prefs/session_startup_pref.h" 42 #include "chrome/browser/prefs/session_startup_pref.h"
43 #include "chrome/browser/profiles/profile.h"
44 #include "chrome/browser/profiles/profile_manager.h"
43 #include "chrome/browser/ui/browser.h" 45 #include "chrome/browser/ui/browser.h"
46 #include "chrome/browser/ui/browser_commands.h"
44 #include "chrome/browser/ui/browser_finder.h" 47 #include "chrome/browser/ui/browser_finder.h"
45 #include "chrome/browser/ui/browser_list.h" 48 #include "chrome/browser/ui/browser_list.h"
49 #include "chrome/browser/ui/browser_window.h"
46 #include "chrome/browser/ui/host_desktop.h" 50 #include "chrome/browser/ui/host_desktop.h"
47 #include "chrome/browser/ui/tabs/tab_strip_model.h" 51 #include "chrome/browser/ui/tabs/tab_strip_model.h"
48 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" 52 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
49 #include "chrome/common/chrome_paths.h" 53 #include "chrome/common/chrome_paths.h"
50 #include "chrome/common/chrome_switches.h" 54 #include "chrome/common/chrome_switches.h"
51 #include "chromeos/chromeos_switches.h" 55 #include "chromeos/chromeos_switches.h"
52 #include "chromeos/dbus/cryptohome_client.h" 56 #include "chromeos/dbus/cryptohome_client.h"
53 #include "chromeos/dbus/dbus_method_call_status.h" 57 #include "chromeos/dbus/dbus_method_call_status.h"
54 #include "chromeos/dbus/fake_cryptohome_client.h" 58 #include "chromeos/dbus/fake_cryptohome_client.h"
55 #include "chromeos/dbus/fake_session_manager_client.h" 59 #include "chromeos/dbus/fake_session_manager_client.h"
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 TabStripModel* tabs = browser->tab_strip_model(); 358 TabStripModel* tabs = browser->tab_strip_model();
355 ASSERT_TRUE(tabs); 359 ASSERT_TRUE(tabs);
356 int expected_tab_count = static_cast<int>(arraysize(kStartupURLs)); 360 int expected_tab_count = static_cast<int>(arraysize(kStartupURLs));
357 EXPECT_EQ(expected_tab_count, tabs->count()); 361 EXPECT_EQ(expected_tab_count, tabs->count());
358 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) { 362 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) {
359 EXPECT_EQ(GURL(kStartupURLs[i]), 363 EXPECT_EQ(GURL(kStartupURLs[i]),
360 tabs->GetWebContentsAt(i)->GetVisibleURL()); 364 tabs->GetWebContentsAt(i)->GetVisibleURL());
361 } 365 }
362 } 366 }
363 367
368 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, FullscreenDisallowed) {
369 UploadAndInstallDeviceLocalAccountPolicy();
370 AddPublicSessionToDevicePolicy(kAccountId1);
371
372 // This observes the display name becoming available as this indicates
373 // device-local account policy is fully loaded, which is a prerequisite for
374 // successful login.
375 content::WindowedNotificationObserver(
376 chrome::NOTIFICATION_USER_LIST_CHANGED,
377 base::Bind(&DisplayNameMatches, user_id_1_, kDisplayName)).Wait();
378
379 // Wait for the login UI to be ready.
380 chromeos::LoginDisplayHostImpl* host =
381 reinterpret_cast<chromeos::LoginDisplayHostImpl*>(
382 chromeos::LoginDisplayHostImpl::default_host());
383 ASSERT_TRUE(host);
384 chromeos::OobeUI* oobe_ui = host->GetOobeUI();
385 ASSERT_TRUE(oobe_ui);
386 base::RunLoop run_loop;
387 const bool oobe_ui_ready = oobe_ui->IsJSReady(run_loop.QuitClosure());
388 if (!oobe_ui_ready)
389 run_loop.Run();
390
391 // Ensure that the browser stays alive, even though no windows are opened
392 // during session start.
393 chrome::StartKeepAlive();
394
395 // Start login into the device-local account.
396 host->StartSignInScreen();
397 chromeos::ExistingUserController* controller =
398 chromeos::ExistingUserController::current_controller();
399 ASSERT_TRUE(controller);
400 controller->LoginAsPublicAccount(user_id_1_);
401
402 // Wait for the session to start.
403 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED,
404 base::Bind(IsSessionStarted)).Wait();
405
406 // Open a browser window.
407 chrome::NewEmptyWindow(ProfileManager::GetDefaultProfile(),
408 chrome::HOST_DESKTOP_TYPE_ASH);
409 BrowserList* browser_list =
410 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
411 EXPECT_EQ(1U, browser_list->size());
412 Browser* browser = browser_list->get(0);
413 ASSERT_TRUE(browser);
414 BrowserWindow* browser_window = browser->window();
415 ASSERT_TRUE(browser_window);
416 chrome::EndKeepAlive();
417
418 // Verify that an attempt to enter fullscreen mode is denied.
419 EXPECT_FALSE(browser_window->IsFullscreen());
420 chrome::ToggleFullscreenMode(browser);
421 EXPECT_FALSE(browser_window->IsFullscreen());
422 }
423
364 class TermsOfServiceTest : public DeviceLocalAccountTest, 424 class TermsOfServiceTest : public DeviceLocalAccountTest,
365 public testing::WithParamInterface<bool> { 425 public testing::WithParamInterface<bool> {
366 }; 426 };
367 427
368 IN_PROC_BROWSER_TEST_P(TermsOfServiceTest, TermsOfServiceScreen) { 428 IN_PROC_BROWSER_TEST_P(TermsOfServiceTest, TermsOfServiceScreen) {
369 // Specify Terms of Service URL. 429 // Specify Terms of Service URL.
370 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 430 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
371 device_local_account_policy_.payload().mutable_termsofserviceurl()->set_value( 431 device_local_account_policy_.payload().mutable_termsofserviceurl()->set_value(
372 embedded_test_server()->GetURL( 432 embedded_test_server()->GetURL(
373 std::string("/") + 433 std::string("/") +
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 if (!IsSessionStarted()) { 575 if (!IsSessionStarted()) {
516 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, 576 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED,
517 base::Bind(IsSessionStarted)).Wait(); 577 base::Bind(IsSessionStarted)).Wait();
518 } 578 }
519 } 579 }
520 580
521 INSTANTIATE_TEST_CASE_P(TermsOfServiceTestInstance, 581 INSTANTIATE_TEST_CASE_P(TermsOfServiceTestInstance,
522 TermsOfServiceTest, testing::Bool()); 582 TermsOfServiceTest, testing::Bool());
523 583
524 } // namespace policy 584 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698