Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / toolbar / bookmark_sub_menu_model.cc
blobae94d2c5d5cdd31a56ab81bc4ed9b406429465e4
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/toolbar/bookmark_sub_menu_model.h"
7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/grit/generated_resources.h"
10 // For views and cocoa, we have complex delegate systems to handle
11 // injecting the bookmarks to the bookmark submenu. This is done to support
12 // advanced interactions with the menu contents, like right click context menus.
14 BookmarkSubMenuModel::BookmarkSubMenuModel(
15 ui::SimpleMenuModel::Delegate* delegate, Browser* browser)
16 : SimpleMenuModel(delegate) {
17 Build(browser);
20 BookmarkSubMenuModel::~BookmarkSubMenuModel() {}
22 void BookmarkSubMenuModel::Build(Browser* browser) {
23 bool is_submenu_visible =
24 delegate()->IsCommandIdVisible(IDC_BOOKMARK_PAGE) ||
25 delegate()->IsCommandIdVisible(IDC_BOOKMARK_ALL_TABS);
26 #if defined(OS_WIN)
27 is_submenu_visible |=
28 delegate()->IsCommandIdVisible(IDC_PIN_TO_START_SCREEN);
29 #endif
31 if (is_submenu_visible) {
32 AddItemWithStringId(IDC_BOOKMARK_PAGE, IDS_BOOKMARK_THIS_PAGE);
33 AddItemWithStringId(IDC_BOOKMARK_ALL_TABS, IDS_BOOKMARK_OPEN_PAGES);
35 #if defined(OS_WIN)
36 AddItemWithStringId(IDC_PIN_TO_START_SCREEN, IDS_PIN_TO_START_SCREEN);
37 #endif
38 AddSeparator(ui::NORMAL_SEPARATOR);
40 AddCheckItemWithStringId(IDC_SHOW_BOOKMARK_BAR, IDS_SHOW_BOOKMARK_BAR);
41 AddItemWithStringId(IDC_SHOW_BOOKMARK_MANAGER, IDS_BOOKMARK_MANAGER);
42 #if !defined(OS_CHROMEOS)
43 AddItemWithStringId(IDC_IMPORT_SETTINGS, IDS_IMPORT_SETTINGS_MENU_LABEL);
44 #endif