| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/app_list/app_context_menu.h" | 5 #include "chrome/browser/ui/app_list/app_context_menu.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/app_list/app_context_menu_delegate.h" | 7 #include "chrome/browser/ui/app_list/app_context_menu_delegate.h" |
| 8 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" | 8 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" |
| 9 #include "chrome/grit/generated_resources.h" | 9 #include "chrome/grit/generated_resources.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 void AppContextMenu::BuildMenu(ui::SimpleMenuModel* menu_model) { | 36 void AppContextMenu::BuildMenu(ui::SimpleMenuModel* menu_model) { |
| 37 // Show Pin/Unpin option if shelf is available. | 37 // Show Pin/Unpin option if shelf is available. |
| 38 if (controller_->GetPinnable(app_id()) != AppListControllerDelegate::NO_PIN) { | 38 if (controller_->GetPinnable(app_id()) != AppListControllerDelegate::NO_PIN) { |
| 39 menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); | 39 menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); |
| 40 menu_model_->AddItemWithStringId( | 40 menu_model_->AddItemWithStringId( |
| 41 TOGGLE_PIN, | 41 TOGGLE_PIN, |
| 42 controller_->IsAppPinned(app_id_) ? | 42 controller_->IsAppPinned(app_id_) ? |
| 43 IDS_APP_LIST_CONTEXT_MENU_UNPIN : | 43 IDS_APP_LIST_CONTEXT_MENU_UNPIN : |
| 44 IDS_APP_LIST_CONTEXT_MENU_PIN); | 44 IDS_APP_LIST_CONTEXT_MENU_PIN); |
| 45 } | 45 } |
| 46 | |
| 47 if (controller_->CanDoCreateShortcutsFlow()) { | |
| 48 menu_model_->AddItemWithStringId(CREATE_SHORTCUTS, | |
| 49 IDS_NEW_TAB_APP_CREATE_SHORTCUT); | |
| 50 } | |
| 51 } | 46 } |
| 52 | 47 |
| 53 bool AppContextMenu::IsItemForCommandIdDynamic(int command_id) const { | 48 bool AppContextMenu::IsItemForCommandIdDynamic(int command_id) const { |
| 54 return command_id == TOGGLE_PIN; | 49 return command_id == TOGGLE_PIN; |
| 55 } | 50 } |
| 56 | 51 |
| 57 base::string16 AppContextMenu::GetLabelForCommandId(int command_id) const { | 52 base::string16 AppContextMenu::GetLabelForCommandId(int command_id) const { |
| 58 if (command_id == TOGGLE_PIN) { | 53 if (command_id == TOGGLE_PIN) { |
| 59 // Return "{Pin to, Unpin from} shelf" or "Pinned by administrator". | 54 // Return "{Pin to, Unpin from} shelf" or "Pinned by administrator". |
| 60 // Note this only exists on Ash desktops. | 55 // Note this only exists on Ash desktops. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 91 controller_->UnpinApp(shelf_app_id); | 86 controller_->UnpinApp(shelf_app_id); |
| 92 else | 87 else |
| 93 controller_->PinApp(shelf_app_id); | 88 controller_->PinApp(shelf_app_id); |
| 94 } | 89 } |
| 95 | 90 |
| 96 void AppContextMenu::ExecuteCommand(int command_id, int event_flags) { | 91 void AppContextMenu::ExecuteCommand(int command_id, int event_flags) { |
| 97 switch (command_id) { | 92 switch (command_id) { |
| 98 case TOGGLE_PIN: | 93 case TOGGLE_PIN: |
| 99 TogglePin(app_id_); | 94 TogglePin(app_id_); |
| 100 break; | 95 break; |
| 101 case CREATE_SHORTCUTS: | |
| 102 controller_->DoCreateShortcutsFlow(profile_, app_id_); | |
| 103 break; | |
| 104 } | 96 } |
| 105 } | 97 } |
| 106 | 98 |
| 107 } // namespace app_list | 99 } // namespace app_list |
| OLD | NEW |