blob: 8a450da2c98d2e6bfeb89f444d717f61a608dc5f [file] [log] [blame]
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/location_bar/star_menu_model.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/grit/generated_resources.h"
#include "components/omnibox/browser/vector_icons.h"
#include "ui/base/models/image_model.h"
#include "ui/color/color_id.h"
StarMenuModel::StarMenuModel(ui::SimpleMenuModel::Delegate* delegate,
bool bookmarked,
bool can_move_to_read_later,
bool exists_as_unread_in_read_later)
: SimpleMenuModel(delegate) {
Build(bookmarked, can_move_to_read_later, exists_as_unread_in_read_later);
}
StarMenuModel::~StarMenuModel() = default;
void StarMenuModel::Build(bool bookmarked,
bool can_move_to_read_later,
bool exists_as_unread_in_read_later) {
AddItemWithStringIdAndIcon(
CommandBookmark,
bookmarked ? IDS_STAR_VIEW_MENU_EDIT_BOOKMARK
: IDS_STAR_VIEW_MENU_ADD_BOOKMARK,
ui::ImageModel::FromVectorIcon(omnibox::kStarIcon, ui::kColorIcon));
AddItemWithStringIdAndIcon(
exists_as_unread_in_read_later ? CommandMarkAsRead
: CommandMoveToReadLater,
exists_as_unread_in_read_later ? IDS_STAR_VIEW_MENU_MARK_AS_READ
: IDS_STAR_VIEW_MENU_MOVE_TO_READ_LATER,
ui::ImageModel::FromVectorIcon(
exists_as_unread_in_read_later ? kReadLaterIcon : kReadLaterAddIcon,
can_move_to_read_later ? ui::kColorIcon : ui::kColorIconDisabled));
int index = GetIndexOfCommandId(CommandMoveToReadLater);
if (index != -1) {
SetEnabledAt(index, can_move_to_read_later);
}
}