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" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/shell_port.h" | 12 #include "ash/shell_port.h" |
13 #include "ash/strings/grit/ash_strings.h" | 13 #include "ash/strings/grit/ash_strings.h" |
14 #include "ash/wallpaper/wallpaper_delegate.h" | 14 #include "ash/wallpaper/wallpaper_delegate.h" |
15 #include "ash/wm_window.h" | 15 #include "ash/wm_window.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 17 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
18 #include "chrome/browser/fullscreen.h" | 18 #include "chrome/browser/fullscreen.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 20 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
21 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 21 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
22 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" | 22 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" |
23 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" | 23 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
24 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" | 24 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" |
25 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" | 25 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" |
26 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" | 26 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" |
27 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
28 #include "chrome/grit/generated_resources.h" | 28 #include "chrome/grit/generated_resources.h" |
29 #include "components/prefs/pref_service.h" | 29 #include "components/prefs/pref_service.h" |
30 #include "components/session_manager/core/session_manager.h" | 30 #include "components/session_manager/core/session_manager.h" |
31 #include "content/public/common/context_menu_params.h" | 31 #include "content/public/common/context_menu_params.h" |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 // Returns true if the user can modify the |shelf|'s auto-hide behavior. | 35 // Returns true if the user can modify the |shelf|'s auto-hide behavior. |
36 bool CanUserModifyShelfAutoHideBehavior(const Profile* profile) { | 36 bool CanUserModifyShelfAutoHideBehavior(const Profile* profile) { |
37 const std::string& pref = prefs::kShelfAutoHideBehaviorLocal; | 37 const std::string& pref = prefs::kShelfAutoHideBehaviorLocal; |
38 return profile->GetPrefs()->FindPreference(pref)->IsUserModifiable(); | 38 return profile->GetPrefs()->FindPreference(pref)->IsUserModifiable(); |
39 } | 39 } |
40 | 40 |
41 } // namespace | 41 } // namespace |
42 | 42 |
43 // static | 43 // static |
44 LauncherContextMenu* LauncherContextMenu::Create( | 44 LauncherContextMenu* LauncherContextMenu::Create( |
45 ChromeLauncherControllerImpl* 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 == 0) |
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 } |
62 | 62 |
63 LauncherContextMenu::LauncherContextMenu( | 63 LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller, |
64 ChromeLauncherControllerImpl* controller, | 64 const ash::ShelfItem* item, |
65 const ash::ShelfItem* item, | 65 ash::WmShelf* wm_shelf) |
66 ash::WmShelf* wm_shelf) | |
67 : ui::SimpleMenuModel(nullptr), | 66 : ui::SimpleMenuModel(nullptr), |
68 controller_(controller), | 67 controller_(controller), |
69 item_(item ? *item : ash::ShelfItem()), | 68 item_(item ? *item : ash::ShelfItem()), |
70 shelf_alignment_menu_(wm_shelf), | 69 shelf_alignment_menu_(wm_shelf), |
71 wm_shelf_(wm_shelf) { | 70 wm_shelf_(wm_shelf) { |
72 set_delegate(this); | 71 set_delegate(this); |
73 } | 72 } |
74 | 73 |
75 LauncherContextMenu::~LauncherContextMenu() {} | 74 LauncherContextMenu::~LauncherContextMenu() {} |
76 | 75 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 case MENU_PIN: | 200 case MENU_PIN: |
202 case MENU_AUTO_HIDE: | 201 case MENU_AUTO_HIDE: |
203 case MENU_ALIGNMENT_MENU: | 202 case MENU_ALIGNMENT_MENU: |
204 case MENU_CHANGE_WALLPAPER: | 203 case MENU_CHANGE_WALLPAPER: |
205 LauncherContextMenu::ExecuteCommand(command_id, event_flags); | 204 LauncherContextMenu::ExecuteCommand(command_id, event_flags); |
206 return true; | 205 return true; |
207 default: | 206 default: |
208 return false; | 207 return false; |
209 } | 208 } |
210 } | 209 } |
OLD | NEW |