Commit e67a9299 authored by minch's avatar minch Committed by Commit Bot

Add feedback item to power menu on login screen.

NewWindowDelegate::OpenFeedbackPage can only be used to open the
feedback dialog in the active user session.
SigninScreenHandler::HandleSendFeedback is used to open the feedback
dialog in the login screen. Due to the effort to create the instance of
SigninScreenHandler, this cl triggers the same handler associated with
the feedback accelerator from the login screen to bring up the feedback
dialog.

Bug: 1107188
Change-Id: I847f96a958f50b1ebbea6f5413e80e0002155042
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2325274
Commit-Queue: Min Chen <minch@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#793225}
parent b0f71871
...@@ -799,13 +799,14 @@ TEST_F(PowerButtonControllerTest, MouseClickToDismissMenu) { ...@@ -799,13 +799,14 @@ TEST_F(PowerButtonControllerTest, MouseClickToDismissMenu) {
// Tests the menu items according to the login and screen locked status. // Tests the menu items according to the login and screen locked status.
TEST_F(PowerButtonControllerTest, MenuItemsToLoginAndLockedStatus) { TEST_F(PowerButtonControllerTest, MenuItemsToLoginAndLockedStatus) {
// No sign out, lock screen and feedback items if user is not logged in. // Should have feedback but not sign out and lock screen items if there is no
// user signed in.
ClearLogin(); ClearLogin();
Shell::Get()->UpdateAfterLoginStatusChange(LoginStatus::NOT_LOGGED_IN); Shell::Get()->UpdateAfterLoginStatusChange(LoginStatus::NOT_LOGGED_IN);
OpenPowerButtonMenu(); OpenPowerButtonMenu();
EXPECT_FALSE(power_button_test_api_->MenuHasSignOutItem()); EXPECT_FALSE(power_button_test_api_->MenuHasSignOutItem());
EXPECT_FALSE(power_button_test_api_->MenuHasLockScreenItem()); EXPECT_FALSE(power_button_test_api_->MenuHasLockScreenItem());
EXPECT_FALSE(power_button_test_api_->MenuHasFeedbackItem()); EXPECT_TRUE(power_button_test_api_->MenuHasFeedbackItem());
TapToDismissPowerButtonMenu(); TapToDismissPowerButtonMenu();
// Should have sign out and feedback items if in guest mode (or, generally, // Should have sign out and feedback items if in guest mode (or, generally,
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#include "ash/display/screen_orientation_controller.h" #include "ash/display/screen_orientation_controller.h"
#include "ash/login/login_screen_controller.h"
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/new_window_delegate.h" #include "ash/public/cpp/new_window_delegate.h"
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
...@@ -177,8 +178,7 @@ void PowerButtonMenuView::RecreateItems() { ...@@ -177,8 +178,7 @@ void PowerButtonMenuView::RecreateItems() {
const bool create_sign_out = login_status != LoginStatus::NOT_LOGGED_IN; const bool create_sign_out = login_status != LoginStatus::NOT_LOGGED_IN;
const bool create_lock_screen = login_status != LoginStatus::LOCKED && const bool create_lock_screen = login_status != LoginStatus::LOCKED &&
session_controller->CanLockScreen(); session_controller->CanLockScreen();
const bool create_feedback = login_status != LoginStatus::NOT_LOGGED_IN && const bool create_feedback = login_status != LoginStatus::LOCKED &&
login_status != LoginStatus::LOCKED &&
login_status != LoginStatus::KIOSK_APP; login_status != LoginStatus::KIOSK_APP;
add_remove_item( add_remove_item(
...@@ -212,11 +212,12 @@ void PowerButtonMenuView::Layout() { ...@@ -212,11 +212,12 @@ void PowerButtonMenuView::Layout() {
rect.Offset(x_offset, y_offset); rect.Offset(x_offset, y_offset);
power_off_item_->SetBoundsRect(rect); power_off_item_->SetBoundsRect(rect);
const int padding_between_items_with_border =
kPaddingBetweenMenuItems -
2 * PowerButtonMenuItemView::kItemBorderThickness;
x_offset = rect.width() + padding_between_items_with_border;
if (sign_out_item_) { if (sign_out_item_) {
const int padding_between_items_with_border =
kPaddingBetweenMenuItems -
2 * PowerButtonMenuItemView::kItemBorderThickness;
x_offset = rect.width() + padding_between_items_with_border;
rect.Offset(x_offset, 0); rect.Offset(x_offset, 0);
sign_out_item_->SetBoundsRect(rect); sign_out_item_->SetBoundsRect(rect);
...@@ -224,11 +225,10 @@ void PowerButtonMenuView::Layout() { ...@@ -224,11 +225,10 @@ void PowerButtonMenuView::Layout() {
rect.Offset(x_offset, 0); rect.Offset(x_offset, 0);
lock_screen_item_->SetBoundsRect(rect); lock_screen_item_->SetBoundsRect(rect);
} }
}
if (feedback_item_) { if (feedback_item_) {
rect.Offset(x_offset, 0); rect.Offset(x_offset, 0);
feedback_item_->SetBoundsRect(rect); feedback_item_->SetBoundsRect(rect);
}
} }
} }
...@@ -253,15 +253,15 @@ gfx::Size PowerButtonMenuView::CalculatePreferredSize() const { ...@@ -253,15 +253,15 @@ gfx::Size PowerButtonMenuView::CalculatePreferredSize() const {
int width = int width =
PowerButtonMenuItemView::kMenuItemWidth + 2 * kMenuItemHorizontalPadding; PowerButtonMenuItemView::kMenuItemWidth + 2 * kMenuItemHorizontalPadding;
const int one_item_x_offset =
PowerButtonMenuItemView::kMenuItemWidth + kPaddingBetweenMenuItems;
if (sign_out_item_) { if (sign_out_item_) {
const int one_item_x_offset =
PowerButtonMenuItemView::kMenuItemWidth + kPaddingBetweenMenuItems;
width += one_item_x_offset;
if (lock_screen_item_)
width += one_item_x_offset;
if (feedback_item_)
width += one_item_x_offset; width += one_item_x_offset;
if (lock_screen_item_)
width += one_item_x_offset;
} }
if (feedback_item_)
width += one_item_x_offset;
menu_size.set_width(width); menu_size.set_width(width);
return menu_size; return menu_size;
} }
...@@ -282,7 +282,16 @@ void PowerButtonMenuView::ButtonPressed(views::Button* sender, ...@@ -282,7 +282,16 @@ void PowerButtonMenuView::ButtonPressed(views::Button* sender,
shell->session_controller()->LockScreen(); shell->session_controller()->LockScreen();
} else if (sender == feedback_item_) { } else if (sender == feedback_item_) {
RecordMenuActionHistogram(PowerButtonMenuActionType::kFeedback); RecordMenuActionHistogram(PowerButtonMenuActionType::kFeedback);
NewWindowDelegate::GetInstance()->OpenFeedbackPage(); if (shell->session_controller()->login_status() ==
LoginStatus::NOT_LOGGED_IN) {
// There is a special flow for feedback while in login screen, therefore
// we trigger the same handler associated with the feedback accelerator
// from the login screen to bring up the feedback dialog.
shell->login_screen_controller()->HandleAccelerator(
LoginAcceleratorAction::kShowFeedback);
} else {
NewWindowDelegate::GetInstance()->OpenFeedbackPage();
}
} else { } else {
NOTREACHED() << "Invalid sender"; NOTREACHED() << "Invalid sender";
} }
......
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