Commit bed3c3d1 authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Make LockScreenActionTray item visible only with show-md-login flag

The entry point for note taking on lock screen has been added to the
lock screen UI for webui lock screen implementation - this means that
the item in the system tray is not longer needed in this case.

Keep the tray item around for views based lock screen (i.e.
when show-md-login flag is set) - in this case the lock screen UI
has yet to be updated, so there is still a need for an entry point in
the tray.

BUG=737067

Change-Id: I53c53c7154c1dfec165c6a9898359b29b366db3f
Reviewed-on: https://chromium-review.googlesource.com/578647
Commit-Queue: Toni Barzic <tbarzic@chromium.org>
Reviewed-by: default avatarTerry Anderson <tdanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488355}
parent c4700d5a
......@@ -12,7 +12,9 @@
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_container.h"
#include "ash/tray_action/tray_action.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "chromeos/chromeos_switches.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/paint_vector_icon.h"
......@@ -21,12 +23,33 @@
namespace ash {
namespace {
bool IsLockScreenActionTrayEnabled() {
// The lock screen action entry point will be move from system tray to the
// lock screen UI - for current incarnation of lock screen UI, this has
// already been done, so the tray action button is not needed in this case.
// For views base lock screen (used when show-md-login is set), this is not
// the case.
// TODO(tbarzic): Replace LockScreenActionTray item with a button in the lock
// screen UI for views base lock screen implementation.
// http://crbug.com/746596
return base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kShowMdLogin);
}
} // namespace
LockScreenActionTray::LockScreenActionTray(Shelf* shelf)
: TrayBackgroundView(shelf),
session_observer_(this),
tray_action_observer_(this) {
SetInkDropMode(InkDropMode::ON);
SetVisible(false);
if (!IsLockScreenActionTrayEnabled())
return;
SetInkDropMode(InkDropMode::ON);
new_note_action_view_ = new views::ImageView();
new_note_action_view_->SetImage(
CreateVectorIcon(kTrayActionNewLockScreenNoteIcon, kShelfIconColor));
......@@ -42,6 +65,9 @@ LockScreenActionTray::~LockScreenActionTray() {}
void LockScreenActionTray::Initialize() {
TrayBackgroundView::Initialize();
if (!IsLockScreenActionTrayEnabled())
return;
session_observer_.Add(Shell::Get()->session_controller());
TrayAction* controller = Shell::Get()->tray_action();
......@@ -80,7 +106,8 @@ void LockScreenActionTray::OnLockScreenNoteStateChanged(
}
bool LockScreenActionTray::IsStateVisible() const {
return Shell::Get()->session_controller()->IsScreenLocked() &&
return IsLockScreenActionTrayEnabled() &&
Shell::Get()->session_controller()->IsScreenLocked() &&
(new_note_state_ == mojom::TrayActionState::kAvailable ||
new_note_state_ == mojom::TrayActionState::kLaunching);
}
......
......@@ -12,7 +12,9 @@
#include "ash/system/status_area_widget_test_helper.h"
#include "ash/test/ash_test_base.h"
#include "ash/tray_action/tray_action.h"
#include "base/command_line.h"
#include "base/macros.h"
#include "chromeos/chromeos_switches.h"
#include "components/session_manager/session_manager_types.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/image/image_skia.h"
......@@ -58,6 +60,12 @@ class LockScreenActionTrayTest : public AshTestBase {
LockScreenActionTrayTest() = default;
~LockScreenActionTrayTest() override = default;
void SetUp() override {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
chromeos::switches::kShowMdLogin);
AshTestBase::SetUp();
}
void ClickOnTray() {
// Perform click on the tray view.
ui::test::EventGenerator& generator = GetEventGenerator();
......@@ -72,6 +80,8 @@ class LockScreenActionTrayTest : public AshTestBase {
DISALLOW_COPY_AND_ASSIGN(LockScreenActionTrayTest);
};
using LockScreenActionTrayWithoutMdLoginTest = AshTestBase;
} // namespace
TEST_F(LockScreenActionTrayTest, NoClient) {
......@@ -229,4 +239,27 @@ TEST_F(LockScreenActionTrayTest, TrayNotVisibleWhenSessionNotLocked) {
EXPECT_FALSE(GetTray()->visible());
}
TEST_F(LockScreenActionTrayWithoutMdLoginTest, NotVisible) {
SetUserLoggedIn(true);
TrayAction* tray_action = Shell::Get()->tray_action();
TestTrayActionClient tray_action_client;
tray_action->SetClient(tray_action_client.CreateInterfacePtrAndBind(),
mojom::TrayActionState::kNotAvailable);
EXPECT_FALSE(GetTray()->visible());
tray_action->UpdateLockScreenNoteState(mojom::TrayActionState::kAvailable);
EXPECT_FALSE(GetTray()->visible());
tray_action->UpdateLockScreenNoteState(mojom::TrayActionState::kLaunching);
EXPECT_FALSE(GetTray()->visible());
tray_action->UpdateLockScreenNoteState(mojom::TrayActionState::kActive);
EXPECT_FALSE(GetTray()->visible());
tray_action->UpdateLockScreenNoteState(mojom::TrayActionState::kBackground);
EXPECT_FALSE(GetTray()->visible());
}
} // namespace ash
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment