Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: chrome/browser/ui/ash/launcher/launcher_context_menu.cc

Issue 1869063002: Arc integration in shelf launcher context menu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ash/launcher/arc_launcher_context_menu.h"
stevenjb 2016/04/07 18:58:12 If we are only using this on Chrome OS then we sho
lgcheng 2016/04/07 19:40:51 Done.
17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 18 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
18 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" 19 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h"
19 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" 20 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h"
20 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
21 #include "chrome/grit/generated_resources.h" 22 #include "chrome/grit/generated_resources.h"
22 #include "components/prefs/pref_service.h" 23 #include "components/prefs/pref_service.h"
23 #include "content/public/common/context_menu_params.h" 24 #include "content/public/common/context_menu_params.h"
24 #include "grit/ash_strings.h" 25 #include "grit/ash_strings.h"
25 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
26 27
28 #if defined(OS_CHROMEOS)
29 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
30 #endif // defined(OS_CHROMEOS)
31
27 namespace { 32 namespace {
28 33
29 // Returns true if the user can modify the |shelf|'s auto-hide behavior. 34 // Returns true if the user can modify the |shelf|'s auto-hide behavior.
30 bool CanUserModifyShelfAutoHideBehavior(const Profile* profile) { 35 bool CanUserModifyShelfAutoHideBehavior(const Profile* profile) {
31 const std::string& pref = prefs::kShelfAutoHideBehaviorLocal; 36 const std::string& pref = prefs::kShelfAutoHideBehaviorLocal;
32 return profile->GetPrefs()->FindPreference(pref)->IsUserModifiable(); 37 return profile->GetPrefs()->FindPreference(pref)->IsUserModifiable();
33 } 38 }
34 39
35 } // namespace 40 } // namespace
36 41
37 // static 42 // static
38 LauncherContextMenu* LauncherContextMenu::Create( 43 LauncherContextMenu* LauncherContextMenu::Create(
39 ChromeLauncherController* controller, 44 ChromeLauncherController* controller,
40 const ash::ShelfItem* item, 45 const ash::ShelfItem* item,
41 ash::Shelf* shelf) { 46 ash::Shelf* shelf) {
42 DCHECK(controller); 47 DCHECK(controller);
43 DCHECK(shelf); 48 DCHECK(shelf);
44 // Create DesktopShellLauncherContextMenu if no item is selected. 49 // Create DesktopShellLauncherContextMenu if no item is selected.
45 if (!item || item->id == 0) 50 if (!item || item->id == 0)
46 return new DesktopShellLauncherContextMenu(controller, item, shelf); 51 return new DesktopShellLauncherContextMenu(controller, item, shelf);
47 52
53 // Create ArcLauncherContextMenu if the item is an Arc app.
54 #if defined(OS_CHROMEOS)
55 const std::string& app_id = controller->GetAppIDForShelfID(item->id);
56 ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(controller->profile());
57 DCHECK(arc_prefs);
58 if (arc_prefs->IsRegistered(app_id))
59 return new ArcLauncherContextMenu(controller, item, shelf);
60 #endif // defined(OS_CHROMEOS)
61
48 // Create ExtensionLauncherContextMenu for the item. 62 // Create ExtensionLauncherContextMenu for the item.
49 return new ExtensionLauncherContextMenu(controller, item, shelf); 63 return new ExtensionLauncherContextMenu(controller, item, shelf);
50 } 64 }
51 65
52 LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller, 66 LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller,
53 const ash::ShelfItem* item, 67 const ash::ShelfItem* item,
54 ash::Shelf* shelf) 68 ash::Shelf* shelf)
55 : ui::SimpleMenuModel(nullptr), 69 : ui::SimpleMenuModel(nullptr),
56 controller_(controller), 70 controller_(controller),
57 item_(item ? *item : ash::ShelfItem()), 71 item_(item ? *item : ash::ShelfItem()),
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 case MENU_PIN: 201 case MENU_PIN:
188 case MENU_AUTO_HIDE: 202 case MENU_AUTO_HIDE:
189 case MENU_ALIGNMENT_MENU: 203 case MENU_ALIGNMENT_MENU:
190 case MENU_CHANGE_WALLPAPER: 204 case MENU_CHANGE_WALLPAPER:
191 ExecuteCommand(command_id, event_flags); 205 ExecuteCommand(command_id, event_flags);
192 return true; 206 return true;
193 default: 207 default:
194 return false; 208 return false;
195 } 209 }
196 } 210 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698