| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/toolbar/bookmark_sub_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/bookmark_sub_menu_model.h" |
| 6 | 6 |
| 7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/grit/generated_resources.h" | 8 #include "chrome/grit/generated_resources.h" |
| 9 | 9 |
| 10 // For views and cocoa, we have complex delegate systems to handle | 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 | 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. | 12 // advanced interactions with the menu contents, like right click context menus. |
| 13 | 13 |
| 14 BookmarkSubMenuModel::BookmarkSubMenuModel( | 14 BookmarkSubMenuModel::BookmarkSubMenuModel( |
| 15 ui::SimpleMenuModel::Delegate* delegate, Browser* browser) | 15 ui::SimpleMenuModel::Delegate* delegate, Browser* browser) |
| 16 : SimpleMenuModel(delegate) { | 16 : SimpleMenuModel(delegate) { |
| 17 Build(browser); | 17 Build(browser); |
| 18 } | 18 } |
| 19 | 19 |
| 20 BookmarkSubMenuModel::~BookmarkSubMenuModel() {} | 20 BookmarkSubMenuModel::~BookmarkSubMenuModel() {} |
| 21 | 21 |
| 22 void BookmarkSubMenuModel::Build(Browser* browser) { | 22 void BookmarkSubMenuModel::Build(Browser* browser) { |
| 23 AddCheckItemWithStringId(IDC_SHOW_BOOKMARK_BAR, IDS_SHOW_BOOKMARK_BAR); | |
| 24 AddItemWithStringId(IDC_SHOW_BOOKMARK_MANAGER, IDS_BOOKMARK_MANAGER); | |
| 25 #if !defined(OS_CHROMEOS) | |
| 26 AddItemWithStringId(IDC_IMPORT_SETTINGS, IDS_IMPORT_SETTINGS_MENU_LABEL); | |
| 27 #endif | |
| 28 bool is_submenu_visible = | 23 bool is_submenu_visible = |
| 29 delegate()->IsCommandIdVisible(IDC_BOOKMARK_PAGE) || | 24 delegate()->IsCommandIdVisible(IDC_BOOKMARK_PAGE) || |
| 30 delegate()->IsCommandIdVisible(IDC_BOOKMARK_ALL_TABS); | 25 delegate()->IsCommandIdVisible(IDC_BOOKMARK_ALL_TABS); |
| 31 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
| 32 is_submenu_visible |= | 27 is_submenu_visible |= |
| 33 delegate()->IsCommandIdVisible(IDC_PIN_TO_START_SCREEN); | 28 delegate()->IsCommandIdVisible(IDC_PIN_TO_START_SCREEN); |
| 34 #endif | 29 #endif |
| 30 |
| 35 if (is_submenu_visible) { | 31 if (is_submenu_visible) { |
| 36 AddSeparator(ui::NORMAL_SEPARATOR); | |
| 37 | |
| 38 AddItemWithStringId(IDC_BOOKMARK_PAGE, IDS_BOOKMARK_THIS_PAGE); | 32 AddItemWithStringId(IDC_BOOKMARK_PAGE, IDS_BOOKMARK_THIS_PAGE); |
| 39 AddItemWithStringId(IDC_BOOKMARK_ALL_TABS, IDS_BOOKMARK_OPEN_PAGES); | 33 AddItemWithStringId(IDC_BOOKMARK_ALL_TABS, IDS_BOOKMARK_OPEN_PAGES); |
| 40 | 34 |
| 41 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
| 42 AddItemWithStringId(IDC_PIN_TO_START_SCREEN, IDS_PIN_TO_START_SCREEN); | 36 AddItemWithStringId(IDC_PIN_TO_START_SCREEN, IDS_PIN_TO_START_SCREEN); |
| 43 #endif | 37 #endif |
| 38 AddSeparator(ui::NORMAL_SEPARATOR); |
| 44 } | 39 } |
| 45 #if defined(OS_MACOSX) | 40 AddCheckItemWithStringId(IDC_SHOW_BOOKMARK_BAR, IDS_SHOW_BOOKMARK_BAR); |
| 46 AddSeparator(ui::NORMAL_SEPARATOR); | 41 AddItemWithStringId(IDC_SHOW_BOOKMARK_MANAGER, IDS_BOOKMARK_MANAGER); |
| 42 #if !defined(OS_CHROMEOS) |
| 43 AddItemWithStringId(IDC_IMPORT_SETTINGS, IDS_IMPORT_SETTINGS_MENU_LABEL); |
| 47 #endif | 44 #endif |
| 48 } | 45 } |
| OLD | NEW |