| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/ash/launcher/launcher_context_menu.h" | 5 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "ash/shelf/shelf_model.h" | 9 #include "ash/shelf/shelf_model.h" |
| 10 #include "ash/shelf/wm_shelf.h" | 10 #include "ash/shelf/wm_shelf.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 // static | 43 // static |
| 44 LauncherContextMenu* LauncherContextMenu::Create( | 44 LauncherContextMenu* LauncherContextMenu::Create( |
| 45 ChromeLauncherController* controller, | 45 ChromeLauncherController* controller, |
| 46 const ash::ShelfItem* item, | 46 const ash::ShelfItem* item, |
| 47 ash::WmShelf* wm_shelf) { | 47 ash::WmShelf* wm_shelf) { |
| 48 DCHECK(controller); | 48 DCHECK(controller); |
| 49 DCHECK(wm_shelf); | 49 DCHECK(wm_shelf); |
| 50 // Create DesktopShellLauncherContextMenu if no item is selected. | 50 // Create DesktopShellLauncherContextMenu if no item is selected. |
| 51 if (!item || item->id == 0) | 51 if (!item || item->id.IsNull()) |
| 52 return new DesktopShellLauncherContextMenu(controller, item, wm_shelf); | 52 return new DesktopShellLauncherContextMenu(controller, item, wm_shelf); |
| 53 | 53 |
| 54 // Create ArcLauncherContextMenu if the item is an ARC app. | 54 // Create ArcLauncherContextMenu if the item is an ARC app. |
| 55 const std::string& app_id = controller->GetAppIDForShelfID(item->id); | 55 const std::string& app_id = controller->GetAppIDForShelfID(item->id); |
| 56 if (arc::IsArcItem(controller->profile(), app_id)) | 56 if (arc::IsArcItem(controller->profile(), app_id)) |
| 57 return new ArcLauncherContextMenu(controller, item, wm_shelf); | 57 return new ArcLauncherContextMenu(controller, item, wm_shelf); |
| 58 | 58 |
| 59 // Create ExtensionLauncherContextMenu for the item. | 59 // Create ExtensionLauncherContextMenu for the item. |
| 60 return new ExtensionLauncherContextMenu(controller, item, wm_shelf); | 60 return new ExtensionLauncherContextMenu(controller, item, wm_shelf); |
| 61 } | 61 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 DCHECK(item_delegate); | 119 DCHECK(item_delegate); |
| 120 item_delegate->Close(); | 120 item_delegate->Close(); |
| 121 } else { | 121 } else { |
| 122 // TODO(simonhong): Use ShelfItemDelegate::Close(). | 122 // TODO(simonhong): Use ShelfItemDelegate::Close(). |
| 123 controller_->Close(item_.id); | 123 controller_->Close(item_.id); |
| 124 } | 124 } |
| 125 ash::ShellPort::Get()->RecordUserMetricsAction( | 125 ash::ShellPort::Get()->RecordUserMetricsAction( |
| 126 ash::UMA_CLOSE_THROUGH_CONTEXT_MENU); | 126 ash::UMA_CLOSE_THROUGH_CONTEXT_MENU); |
| 127 break; | 127 break; |
| 128 case MENU_PIN: | 128 case MENU_PIN: |
| 129 if (controller_->IsAppPinned(item_.app_launch_id.app_id())) | 129 if (controller_->IsAppPinned(item_.id.app_id)) |
| 130 controller_->UnpinAppWithID(item_.app_launch_id.app_id()); | 130 controller_->UnpinAppWithID(item_.id.app_id); |
| 131 else | 131 else |
| 132 controller_->PinAppWithID(item_.app_launch_id.app_id()); | 132 controller_->PinAppWithID(item_.id.app_id); |
| 133 break; | 133 break; |
| 134 case MENU_AUTO_HIDE: | 134 case MENU_AUTO_HIDE: |
| 135 wm_shelf_->SetAutoHideBehavior( | 135 wm_shelf_->SetAutoHideBehavior( |
| 136 wm_shelf_->auto_hide_behavior() == | 136 wm_shelf_->auto_hide_behavior() == |
| 137 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS | 137 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS |
| 138 ? ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER | 138 ? ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER |
| 139 : ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 139 : ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 140 break; | 140 break; |
| 141 case MENU_ALIGNMENT_MENU: | 141 case MENU_ALIGNMENT_MENU: |
| 142 break; | 142 break; |
| 143 case MENU_CHANGE_WALLPAPER: | 143 case MENU_CHANGE_WALLPAPER: |
| 144 chromeos::WallpaperManager::Get()->Open(); | 144 chromeos::WallpaperManager::Get()->Open(); |
| 145 break; | 145 break; |
| 146 default: | 146 default: |
| 147 NOTREACHED(); | 147 NOTREACHED(); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 void LauncherContextMenu::AddPinMenu() { | 151 void LauncherContextMenu::AddPinMenu() { |
| 152 // Expect an item with a none zero id to add pin/unpin menu item. | 152 // Expect a valid ShelfID to add pin/unpin menu item. |
| 153 DCHECK(item_.id); | 153 DCHECK(!item_.id.IsNull()); |
| 154 int menu_pin_string_id; | 154 int menu_pin_string_id; |
| 155 const std::string app_id = controller_->GetAppIDForShelfID(item_.id); | 155 const std::string app_id = controller_->GetAppIDForShelfID(item_.id); |
| 156 switch (GetPinnableForAppID(app_id, controller_->profile())) { | 156 switch (GetPinnableForAppID(app_id, controller_->profile())) { |
| 157 case AppListControllerDelegate::PIN_EDITABLE: | 157 case AppListControllerDelegate::PIN_EDITABLE: |
| 158 menu_pin_string_id = controller_->IsPinned(item_.id) | 158 menu_pin_string_id = controller_->IsPinned(item_.id) |
| 159 ? IDS_LAUNCHER_CONTEXT_MENU_UNPIN | 159 ? IDS_LAUNCHER_CONTEXT_MENU_UNPIN |
| 160 : IDS_LAUNCHER_CONTEXT_MENU_PIN; | 160 : IDS_LAUNCHER_CONTEXT_MENU_PIN; |
| 161 break; | 161 break; |
| 162 case AppListControllerDelegate::PIN_FIXED: | 162 case AppListControllerDelegate::PIN_FIXED: |
| 163 menu_pin_string_id = IDS_LAUNCHER_CONTEXT_MENU_PIN_ENFORCED_BY_POLICY; | 163 menu_pin_string_id = IDS_LAUNCHER_CONTEXT_MENU_PIN_ENFORCED_BY_POLICY; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 case MENU_PIN: | 200 case MENU_PIN: |
| 201 case MENU_AUTO_HIDE: | 201 case MENU_AUTO_HIDE: |
| 202 case MENU_ALIGNMENT_MENU: | 202 case MENU_ALIGNMENT_MENU: |
| 203 case MENU_CHANGE_WALLPAPER: | 203 case MENU_CHANGE_WALLPAPER: |
| 204 LauncherContextMenu::ExecuteCommand(command_id, event_flags); | 204 LauncherContextMenu::ExecuteCommand(command_id, event_flags); |
| 205 return true; | 205 return true; |
| 206 default: | 206 default: |
| 207 return false; | 207 return false; |
| 208 } | 208 } |
| 209 } | 209 } |
| OLD | NEW |