| 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/desktop_background/user_wallpaper_delegate.h" | 9 #include "ash/desktop_background/user_wallpaper_delegate.h" |
| 10 #include "ash/metrics/user_metrics_recorder.h" | 10 #include "ash/metrics/user_metrics_recorder.h" |
| 11 #include "ash/session/session_state_delegate.h" | 11 #include "ash/session/session_state_delegate.h" |
| 12 #include "ash/shelf/shelf.h" | 12 #include "ash/shelf/shelf.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/fullscreen.h" | 15 #include "chrome/browser/fullscreen.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 18 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" |
| 17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 19 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 18 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" | 20 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" |
| 19 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" | 21 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" |
| 20 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
| 22 #include "components/prefs/pref_service.h" | 24 #include "components/prefs/pref_service.h" |
| 23 #include "content/public/common/context_menu_params.h" | 25 #include "content/public/common/context_menu_params.h" |
| 24 #include "grit/ash_strings.h" | 26 #include "grit/ash_strings.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 26 | 28 |
| 27 #if defined(OS_CHROMEOS) | |
| 28 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | |
| 29 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" | |
| 30 #endif // defined(OS_CHROMEOS) | |
| 31 | |
| 32 namespace { | 29 namespace { |
| 33 | 30 |
| 34 // Returns true if the user can modify the |shelf|'s auto-hide behavior. | 31 // Returns true if the user can modify the |shelf|'s auto-hide behavior. |
| 35 bool CanUserModifyShelfAutoHideBehavior(const Profile* profile) { | 32 bool CanUserModifyShelfAutoHideBehavior(const Profile* profile) { |
| 36 const std::string& pref = prefs::kShelfAutoHideBehaviorLocal; | 33 const std::string& pref = prefs::kShelfAutoHideBehaviorLocal; |
| 37 return profile->GetPrefs()->FindPreference(pref)->IsUserModifiable(); | 34 return profile->GetPrefs()->FindPreference(pref)->IsUserModifiable(); |
| 38 } | 35 } |
| 39 | 36 |
| 40 } // namespace | 37 } // namespace |
| 41 | 38 |
| 42 // static | 39 // static |
| 43 LauncherContextMenu* LauncherContextMenu::Create( | 40 LauncherContextMenu* LauncherContextMenu::Create( |
| 44 ChromeLauncherController* controller, | 41 ChromeLauncherController* controller, |
| 45 const ash::ShelfItem* item, | 42 const ash::ShelfItem* item, |
| 46 ash::Shelf* shelf) { | 43 ash::Shelf* shelf) { |
| 47 DCHECK(controller); | 44 DCHECK(controller); |
| 48 DCHECK(shelf); | 45 DCHECK(shelf); |
| 49 // Create DesktopShellLauncherContextMenu if no item is selected. | 46 // Create DesktopShellLauncherContextMenu if no item is selected. |
| 50 if (!item || item->id == 0) | 47 if (!item || item->id == 0) |
| 51 return new DesktopShellLauncherContextMenu(controller, item, shelf); | 48 return new DesktopShellLauncherContextMenu(controller, item, shelf); |
| 52 | 49 |
| 53 // Create ArcLauncherContextMenu if the item is an Arc app. | 50 // Create ArcLauncherContextMenu if the item is an Arc app. |
| 54 #if defined(OS_CHROMEOS) | |
| 55 const std::string& app_id = controller->GetAppIDForShelfID(item->id); | 51 const std::string& app_id = controller->GetAppIDForShelfID(item->id); |
| 56 ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(controller->profile()); | 52 ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(controller->profile()); |
| 57 DCHECK(arc_prefs); | 53 DCHECK(arc_prefs); |
| 58 if (arc_prefs->IsRegistered(app_id)) | 54 if (arc_prefs->IsRegistered(app_id)) |
| 59 return new ArcLauncherContextMenu(controller, item, shelf); | 55 return new ArcLauncherContextMenu(controller, item, shelf); |
| 60 #endif // defined(OS_CHROMEOS) | |
| 61 | 56 |
| 62 // Create ExtensionLauncherContextMenu for the item. | 57 // Create ExtensionLauncherContextMenu for the item. |
| 63 return new ExtensionLauncherContextMenu(controller, item, shelf); | 58 return new ExtensionLauncherContextMenu(controller, item, shelf); |
| 64 } | 59 } |
| 65 | 60 |
| 66 LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller, | 61 LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller, |
| 67 const ash::ShelfItem* item, | 62 const ash::ShelfItem* item, |
| 68 ash::Shelf* shelf) | 63 ash::Shelf* shelf) |
| 69 : ui::SimpleMenuModel(nullptr), | 64 : ui::SimpleMenuModel(nullptr), |
| 70 controller_(controller), | 65 controller_(controller), |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 CanUserModifyShelfAutoHideBehavior(controller_->profile())) { | 184 CanUserModifyShelfAutoHideBehavior(controller_->profile())) { |
| 190 AddCheckItemWithStringId(MENU_AUTO_HIDE, | 185 AddCheckItemWithStringId(MENU_AUTO_HIDE, |
| 191 IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE); | 186 IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE); |
| 192 } | 187 } |
| 193 if (ash::ShelfWidget::ShelfAlignmentAllowed() && | 188 if (ash::ShelfWidget::ShelfAlignmentAllowed() && |
| 194 !ash::Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) { | 189 !ash::Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) { |
| 195 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU, | 190 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU, |
| 196 IDS_ASH_SHELF_CONTEXT_MENU_POSITION, | 191 IDS_ASH_SHELF_CONTEXT_MENU_POSITION, |
| 197 &shelf_alignment_menu_); | 192 &shelf_alignment_menu_); |
| 198 } | 193 } |
| 199 #if defined(OS_CHROMEOS) | |
| 200 if (!controller_->IsLoggedInAsGuest()) | 194 if (!controller_->IsLoggedInAsGuest()) |
| 201 AddItemWithStringId(MENU_CHANGE_WALLPAPER, IDS_AURA_SET_DESKTOP_WALLPAPER); | 195 AddItemWithStringId(MENU_CHANGE_WALLPAPER, IDS_AURA_SET_DESKTOP_WALLPAPER); |
| 202 #endif | |
| 203 } | 196 } |
| 204 | 197 |
| 205 bool LauncherContextMenu::ExecuteCommonCommand(int command_id, | 198 bool LauncherContextMenu::ExecuteCommonCommand(int command_id, |
| 206 int event_flags) { | 199 int event_flags) { |
| 207 switch (command_id) { | 200 switch (command_id) { |
| 208 case MENU_OPEN_NEW: | 201 case MENU_OPEN_NEW: |
| 209 case MENU_CLOSE: | 202 case MENU_CLOSE: |
| 210 case MENU_PIN: | 203 case MENU_PIN: |
| 211 case MENU_AUTO_HIDE: | 204 case MENU_AUTO_HIDE: |
| 212 case MENU_ALIGNMENT_MENU: | 205 case MENU_ALIGNMENT_MENU: |
| 213 case MENU_CHANGE_WALLPAPER: | 206 case MENU_CHANGE_WALLPAPER: |
| 214 LauncherContextMenu::ExecuteCommand(command_id, event_flags); | 207 LauncherContextMenu::ExecuteCommand(command_id, event_flags); |
| 215 return true; | 208 return true; |
| 216 default: | 209 default: |
| 217 return false; | 210 return false; |
| 218 } | 211 } |
| 219 } | 212 } |
| OLD | NEW |