Skip to content

Commit

Permalink
Fix the issue of cursor being shown at startup.
Browse files Browse the repository at this point in the history
Cursor was shown by MagnificationController when it's enabled in chrome::OpenAsh.
This CL makes MagnificationController not to show cursor if unnecessary.
Also makes cursor initially hidden when the host window is not using full screen
for testing ChromeOS build on desktop.

BUG=157918
TEST=Manually on device and desktop

Review URL: https://chromiumcodereview.appspot.com/11364003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168830 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mazda@chromium.org committed Nov 20, 2012
1 parent 5c52247 commit 86e38e4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 7 deletions.
2 changes: 2 additions & 0 deletions ash/magnifier/magnification_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ void MagnificationControllerImpl::ValidateScale(float* scale) {
}

void MagnificationControllerImpl::OnImplicitAnimationsCompleted() {
if (!is_on_zooming_)
return;
aura::client::CursorClient* cursor_client =
aura::client::GetCursorClient(root_window_);
if (cursor_client)
Expand Down
1 change: 1 addition & 0 deletions ash/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ void Shell::Init() {

if (initially_hide_cursor_)
cursor_manager_.ShowCursor(false);
cursor_manager_.SetCursor(ui::kCursorPointer);

// Cursor might have been hidden by somethign other than chrome.
// Let the first mouse event show the cursor.
Expand Down
34 changes: 34 additions & 0 deletions chrome/browser/chromeos/login/login_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/shell.h"
#include "ash/wm/cursor_manager.h"
#include "base/command_line.h"
#include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h"
#include "chrome/browser/chromeos/cros/mock_cryptohome_library.h"
#include "chrome/browser/chromeos/cros/mock_network_library.h"
#include "chrome/browser/chromeos/login/login_wizard.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
Expand Down Expand Up @@ -74,6 +78,13 @@ class LoginGuestTest : public LoginTestBase {
}
};

class LoginCursorTest : public LoginTestBase {
protected:
virtual void SetUpCommandLine(CommandLine* command_line) {
command_line->AppendSwitch(switches::kLoginManager);
}
};

// After a chrome crash, the session manager will restart chrome with
// the -login-user flag indicating that the user is already logged in.
// This profile should NOT be an OTR profile.
Expand All @@ -83,6 +94,11 @@ IN_PROC_BROWSER_TEST_F(LoginUserTest, UserPassed) {
EXPECT_FALSE(profile->IsOffTheRecord());
}

// Verifies the cursor is not hidden at startup when user is logged in.
IN_PROC_BROWSER_TEST_F(LoginUserTest, CursorShown) {
EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->cursor_visible());
}

// After a guest login, we should get the OTR default profile.
IN_PROC_BROWSER_TEST_F(LoginGuestTest, GuestIsOTR) {
Profile* profile = browser()->profile();
Expand All @@ -92,4 +108,22 @@ IN_PROC_BROWSER_TEST_F(LoginGuestTest, GuestIsOTR) {
EXPECT_TRUE(profile->GetExtensionService());
}

// Verifies the cursor is not hidden at startup when running guest session.
IN_PROC_BROWSER_TEST_F(LoginGuestTest, CursorShown) {
EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->cursor_visible());
}

// Verifies the cursor is hidden at startup on login screen.
IN_PROC_BROWSER_TEST_F(LoginCursorTest, CursorHidden) {
// Login screen needs to be shown explicitly when running test.
ShowLoginWizard(WizardController::kLoginScreenName, gfx::Size());

// Cursor should be hidden at startup
EXPECT_FALSE(ash::Shell::GetInstance()->cursor_manager()->cursor_visible());

// Cursor should be shown after cursor is moved.
EXPECT_TRUE(ui_test_utils::SendMouseMoveSync(gfx::Point()));
EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->cursor_visible());
}

} // namespace chromeos
24 changes: 17 additions & 7 deletions chrome/browser/ui/ash/ash_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ bool ShouldOpenAshOnStartup() {
return false;
}

#if defined(OS_CHROMEOS)
// Returns true if the cursor should be initially hidden.
bool ShouldInitiallyHideCursor() {
if (base::chromeos::IsRunningOnChromeOS())
return !chromeos::UserManager::Get()->IsUserLoggedIn();
else
return CommandLine::ForCurrentProcess()->HasSwitch(switches::kLoginManager);
}
#endif

void OpenAsh() {
bool use_fullscreen = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAuraHostWindowUseFullscreen);
Expand All @@ -56,15 +66,15 @@ void OpenAsh() {
// Aura window is closed.
ui::HideHostCursor();
}

// Hide the mouse cursor completely at boot.
if (ShouldInitiallyHideCursor())
ash::Shell::set_initially_hide_cursor(true);
#endif
if (use_fullscreen) {

if (use_fullscreen)
aura::SetUseFullscreenHostWindow(true);
#if defined(OS_CHROMEOS)
// Hide the mouse cursor completely at boot.
if (!chromeos::UserManager::Get()->IsUserLoggedIn())
ash::Shell::set_initially_hide_cursor(true);
#endif
}

// Its easier to mark all windows as persisting and exclude the ones we care
// about (browser windows), rather than explicitly excluding certain windows.
ash::SetDefaultPersistsAcrossAllWorkspaces(true);
Expand Down

0 comments on commit 86e38e4

Please sign in to comment.