| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool AppContextMenu::IsCommandIdEnabled(int command_id) const { | 79 bool AppContextMenu::IsCommandIdEnabled(int command_id) const { |
| 80 if (command_id == TOGGLE_PIN) { | 80 if (command_id == TOGGLE_PIN) { |
| 81 return controller_->GetPinnable(app_id_) == | 81 return controller_->GetPinnable(app_id_) == |
| 82 AppListControllerDelegate::PIN_EDITABLE; | 82 AppListControllerDelegate::PIN_EDITABLE; |
| 83 } | 83 } |
| 84 return true; | 84 return true; |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool AppContextMenu::GetAcceleratorForCommandId(int command_id, | 87 bool AppContextMenu::GetAcceleratorForCommandId( |
| 88 ui::Accelerator* accelerator) { | 88 int command_id, |
| 89 ui::Accelerator* accelerator) const { |
| 89 return false; | 90 return false; |
| 90 } | 91 } |
| 91 | 92 |
| 92 void AppContextMenu::TogglePin(const std::string& shelf_app_id) { | 93 void AppContextMenu::TogglePin(const std::string& shelf_app_id) { |
| 93 DCHECK_EQ(AppListControllerDelegate::PIN_EDITABLE, | 94 DCHECK_EQ(AppListControllerDelegate::PIN_EDITABLE, |
| 94 controller_->GetPinnable(shelf_app_id)); | 95 controller_->GetPinnable(shelf_app_id)); |
| 95 if (controller_->IsAppPinned(shelf_app_id)) | 96 if (controller_->IsAppPinned(shelf_app_id)) |
| 96 controller_->UnpinApp(shelf_app_id); | 97 controller_->UnpinApp(shelf_app_id); |
| 97 else | 98 else |
| 98 controller_->PinApp(shelf_app_id); | 99 controller_->PinApp(shelf_app_id); |
| 99 } | 100 } |
| 100 | 101 |
| 101 void AppContextMenu::ExecuteCommand(int command_id, int event_flags) { | 102 void AppContextMenu::ExecuteCommand(int command_id, int event_flags) { |
| 102 switch (command_id) { | 103 switch (command_id) { |
| 103 case TOGGLE_PIN: | 104 case TOGGLE_PIN: |
| 104 TogglePin(app_id_); | 105 TogglePin(app_id_); |
| 105 break; | 106 break; |
| 106 case CREATE_SHORTCUTS: | 107 case CREATE_SHORTCUTS: |
| 107 controller_->DoCreateShortcutsFlow(profile_, app_id_); | 108 controller_->DoCreateShortcutsFlow(profile_, app_id_); |
| 108 break; | 109 break; |
| 109 } | 110 } |
| 110 } | 111 } |
| 111 | 112 |
| 112 } // namespace app_list | 113 } // namespace app_list |
| OLD | NEW |