Commit 781cca34 authored by Wenzhao Zang's avatar Wenzhao Zang Committed by Commit Bot

cros: 'Set wallpaper' should be consistent for context menu and setting

The criteria of opening wallpaper picker should be consistent between
the settings page [1] and the shelf context menu [2]. Another pending
CL [3] will combine these two places to avoid duplicate logic.

The criteria of whether to show the 'shelf position' option remains
unchanged and it should be separate from the logic of wallpaper picker.

[1] https://cs.chromium.org/chromium/src/chrome/browser/ui/webui/settings/appearance_handler.cc?q=appearance_handler&sq=package:chromium&dr=C&l=76
[2] https://cs.chromium.org/chromium/src/chrome/browser/chromeos/background/ash_wallpaper_delegate.cc?dr=C&q=ash_wallpaper&sq=package:chromium&l=73
[3] https://chromium-review.googlesource.com/c/chromium/src/+/848193

Bug: 806051
Change-Id: I99da5e9bfef4dc02a2cdc53b33862d6310d88e14
Reviewed-on: https://chromium-review.googlesource.com/887251
Commit-Queue: Wenzhao (Colin) Zang <wzang@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532026}
parent 79121dad
...@@ -103,45 +103,44 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) { ...@@ -103,45 +103,44 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) {
menu->push_back(std::move(auto_hide)); menu->push_back(std::move(auto_hide));
} }
// Only allow alignment and wallpaper modifications by the owner or user. // Only allow shelf alignment modifications by the owner or user.
LoginStatus status = Shell::Get()->session_controller()->login_status(); LoginStatus status = Shell::Get()->session_controller()->login_status();
if (status != LoginStatus::USER && status != LoginStatus::OWNER) if (status == LoginStatus::USER || status == LoginStatus::OWNER) {
return; const ShelfAlignment alignment = GetShelfAlignmentPref(prefs, display_id);
mojom::MenuItemPtr alignment_menu(mojom::MenuItem::New());
const ShelfAlignment alignment = GetShelfAlignmentPref(prefs, display_id); alignment_menu->type = ui::MenuModel::TYPE_SUBMENU;
mojom::MenuItemPtr alignment_menu(mojom::MenuItem::New()); alignment_menu->command_id = ShelfContextMenuModel::MENU_ALIGNMENT_MENU;
alignment_menu->type = ui::MenuModel::TYPE_SUBMENU; alignment_menu->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_POSITION);
alignment_menu->command_id = ShelfContextMenuModel::MENU_ALIGNMENT_MENU; alignment_menu->submenu = MenuItemList();
alignment_menu->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_POSITION); alignment_menu->enabled = !is_tablet_mode;
alignment_menu->submenu = MenuItemList();
alignment_menu->enabled = !is_tablet_mode;
mojom::MenuItemPtr left(mojom::MenuItem::New()); mojom::MenuItemPtr left(mojom::MenuItem::New());
left->type = ui::MenuModel::TYPE_RADIO; left->type = ui::MenuModel::TYPE_RADIO;
left->command_id = ShelfContextMenuModel::MENU_ALIGNMENT_LEFT; left->command_id = ShelfContextMenuModel::MENU_ALIGNMENT_LEFT;
left->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_LEFT); left->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_LEFT);
left->checked = alignment == SHELF_ALIGNMENT_LEFT; left->checked = alignment == SHELF_ALIGNMENT_LEFT;
left->enabled = true; left->enabled = true;
alignment_menu->submenu->push_back(std::move(left)); alignment_menu->submenu->push_back(std::move(left));
mojom::MenuItemPtr bottom(mojom::MenuItem::New()); mojom::MenuItemPtr bottom(mojom::MenuItem::New());
bottom->type = ui::MenuModel::TYPE_RADIO; bottom->type = ui::MenuModel::TYPE_RADIO;
bottom->command_id = ShelfContextMenuModel::MENU_ALIGNMENT_BOTTOM; bottom->command_id = ShelfContextMenuModel::MENU_ALIGNMENT_BOTTOM;
bottom->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_BOTTOM); bottom->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_BOTTOM);
bottom->checked = alignment == SHELF_ALIGNMENT_BOTTOM || bottom->checked = alignment == SHELF_ALIGNMENT_BOTTOM ||
alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED; alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED;
bottom->enabled = true; bottom->enabled = true;
alignment_menu->submenu->push_back(std::move(bottom)); alignment_menu->submenu->push_back(std::move(bottom));
mojom::MenuItemPtr right(mojom::MenuItem::New()); mojom::MenuItemPtr right(mojom::MenuItem::New());
right->type = ui::MenuModel::TYPE_RADIO; right->type = ui::MenuModel::TYPE_RADIO;
right->command_id = ShelfContextMenuModel::MENU_ALIGNMENT_RIGHT; right->command_id = ShelfContextMenuModel::MENU_ALIGNMENT_RIGHT;
right->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_RIGHT); right->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_RIGHT);
right->checked = alignment == SHELF_ALIGNMENT_RIGHT; right->checked = alignment == SHELF_ALIGNMENT_RIGHT;
right->enabled = true; right->enabled = true;
alignment_menu->submenu->push_back(std::move(right)); alignment_menu->submenu->push_back(std::move(right));
menu->push_back(std::move(alignment_menu)); menu->push_back(std::move(alignment_menu));
}
if (Shell::Get()->wallpaper_delegate()->CanOpenSetWallpaperPage()) { if (Shell::Get()->wallpaper_delegate()->CanOpenSetWallpaperPage()) {
mojom::MenuItemPtr wallpaper(mojom::MenuItem::New()); mojom::MenuItemPtr wallpaper(mojom::MenuItem::New());
......
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