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

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

Issue 2899253002: chromeos: Rename ash::WmShelf to Shelf (Closed)
Patch Set: rebase Created 3 years, 7 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/shelf/shelf.h"
9 #include "ash/shelf/shelf_model.h" 10 #include "ash/shelf/shelf_model.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"
(...skipping 16 matching lines...) Expand all
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 ChromeLauncherController* controller, 45 ChromeLauncherController* controller,
46 const ash::ShelfItem* item, 46 const ash::ShelfItem* item,
47 ash::WmShelf* wm_shelf) { 47 ash::Shelf* shelf) {
48 DCHECK(controller); 48 DCHECK(controller);
49 DCHECK(wm_shelf); 49 DCHECK(shelf);
50 // Create DesktopShellLauncherContextMenu if no item is selected. 50 // Create DesktopShellLauncherContextMenu if no item is selected.
51 if (!item || item->id.IsNull()) 51 if (!item || item->id.IsNull())
52 return new DesktopShellLauncherContextMenu(controller, item, wm_shelf); 52 return new DesktopShellLauncherContextMenu(controller, item, shelf);
53 53
54 // Create ArcLauncherContextMenu if the item is an ARC app. 54 // Create ArcLauncherContextMenu if the item is an ARC app.
55 if (arc::IsArcItem(controller->profile(), item->id.app_id)) 55 if (arc::IsArcItem(controller->profile(), item->id.app_id))
56 return new ArcLauncherContextMenu(controller, item, wm_shelf); 56 return new ArcLauncherContextMenu(controller, item, shelf);
57 57
58 // Create ExtensionLauncherContextMenu for the item. 58 // Create ExtensionLauncherContextMenu for the item.
59 return new ExtensionLauncherContextMenu(controller, item, wm_shelf); 59 return new ExtensionLauncherContextMenu(controller, item, shelf);
60 } 60 }
61 61
62 LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller, 62 LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller,
63 const ash::ShelfItem* item, 63 const ash::ShelfItem* item,
64 ash::WmShelf* wm_shelf) 64 ash::Shelf* shelf)
65 : ui::SimpleMenuModel(nullptr), 65 : ui::SimpleMenuModel(nullptr),
66 controller_(controller), 66 controller_(controller),
67 item_(item ? *item : ash::ShelfItem()), 67 item_(item ? *item : ash::ShelfItem()),
68 shelf_alignment_menu_(wm_shelf), 68 shelf_alignment_menu_(shelf),
69 wm_shelf_(wm_shelf) { 69 shelf_(shelf) {
70 set_delegate(this); 70 set_delegate(this);
71 } 71 }
72 72
73 LauncherContextMenu::~LauncherContextMenu() {} 73 LauncherContextMenu::~LauncherContextMenu() {}
74 74
75 bool LauncherContextMenu::IsItemForCommandIdDynamic(int command_id) const { 75 bool LauncherContextMenu::IsItemForCommandIdDynamic(int command_id) const {
76 return false; 76 return false;
77 } 77 }
78 78
79 base::string16 LauncherContextMenu::GetLabelForCommandId(int command_id) const { 79 base::string16 LauncherContextMenu::GetLabelForCommandId(int command_id) const {
80 NOTREACHED(); 80 NOTREACHED();
81 return base::string16(); 81 return base::string16();
82 } 82 }
83 83
84 bool LauncherContextMenu::IsCommandIdChecked(int command_id) const { 84 bool LauncherContextMenu::IsCommandIdChecked(int command_id) const {
85 if (command_id == MENU_AUTO_HIDE) { 85 if (command_id == MENU_AUTO_HIDE) {
86 return wm_shelf_->auto_hide_behavior() == 86 return shelf_->auto_hide_behavior() == ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
87 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
88 } 87 }
89 DCHECK(command_id < MENU_ITEM_COUNT); 88 DCHECK(command_id < MENU_ITEM_COUNT);
90 return false; 89 return false;
91 } 90 }
92 91
93 bool LauncherContextMenu::IsCommandIdEnabled(int command_id) const { 92 bool LauncherContextMenu::IsCommandIdEnabled(int command_id) const {
94 switch (command_id) { 93 switch (command_id) {
95 case MENU_PIN: 94 case MENU_PIN:
96 // Users cannot modify the pinned state of apps pinned by policy. 95 // Users cannot modify the pinned state of apps pinned by policy.
97 return !item_.pinned_by_policy && (item_.type == ash::TYPE_PINNED_APP || 96 return !item_.pinned_by_policy && (item_.type == ash::TYPE_PINNED_APP ||
(...skipping 26 matching lines...) Expand all
124 ash::ShellPort::Get()->RecordUserMetricsAction( 123 ash::ShellPort::Get()->RecordUserMetricsAction(
125 ash::UMA_CLOSE_THROUGH_CONTEXT_MENU); 124 ash::UMA_CLOSE_THROUGH_CONTEXT_MENU);
126 break; 125 break;
127 case MENU_PIN: 126 case MENU_PIN:
128 if (controller_->IsAppPinned(item_.id.app_id)) 127 if (controller_->IsAppPinned(item_.id.app_id))
129 controller_->UnpinAppWithID(item_.id.app_id); 128 controller_->UnpinAppWithID(item_.id.app_id);
130 else 129 else
131 controller_->PinAppWithID(item_.id.app_id); 130 controller_->PinAppWithID(item_.id.app_id);
132 break; 131 break;
133 case MENU_AUTO_HIDE: 132 case MENU_AUTO_HIDE:
134 wm_shelf_->SetAutoHideBehavior( 133 shelf_->SetAutoHideBehavior(shelf_->auto_hide_behavior() ==
135 wm_shelf_->auto_hide_behavior() == 134 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS
136 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS 135 ? ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER
137 ? ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER 136 : ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
138 : ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
139 break; 137 break;
140 case MENU_ALIGNMENT_MENU: 138 case MENU_ALIGNMENT_MENU:
141 break; 139 break;
142 case MENU_CHANGE_WALLPAPER: 140 case MENU_CHANGE_WALLPAPER:
143 chromeos::WallpaperManager::Get()->Open(); 141 chromeos::WallpaperManager::Get()->Open();
144 break; 142 break;
145 default: 143 default:
146 NOTREACHED(); 144 NOTREACHED();
147 } 145 }
148 } 146 }
(...skipping 18 matching lines...) Expand all
167 return; 165 return;
168 } 166 }
169 AddItemWithStringId(MENU_PIN, menu_pin_string_id); 167 AddItemWithStringId(MENU_PIN, menu_pin_string_id);
170 } 168 }
171 169
172 void LauncherContextMenu::AddShelfOptionsMenu() { 170 void LauncherContextMenu::AddShelfOptionsMenu() {
173 // In fullscreen, the launcher is either hidden or auto hidden depending 171 // In fullscreen, the launcher is either hidden or auto hidden depending
174 // on the type of fullscreen. Do not show the auto-hide menu item while in 172 // on the type of fullscreen. Do not show the auto-hide menu item while in
175 // fullscreen per display because it is confusing when the preference appears 173 // fullscreen per display because it is confusing when the preference appears
176 // not to apply. 174 // not to apply.
177 int64_t display_id = wm_shelf_->GetWindow()->GetDisplayNearestWindow().id(); 175 int64_t display_id = shelf_->GetWindow()->GetDisplayNearestWindow().id();
178 if (!IsFullScreenMode(display_id) && 176 if (!IsFullScreenMode(display_id) &&
179 CanUserModifyShelfAutoHideBehavior(controller_->profile())) { 177 CanUserModifyShelfAutoHideBehavior(controller_->profile())) {
180 AddCheckItemWithStringId(MENU_AUTO_HIDE, 178 AddCheckItemWithStringId(MENU_AUTO_HIDE,
181 IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE); 179 IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE);
182 } 180 }
183 if (ash::WmShelf::CanChangeShelfAlignment() && 181 if (ash::Shelf::CanChangeShelfAlignment() &&
184 !session_manager::SessionManager::Get()->IsScreenLocked()) { 182 !session_manager::SessionManager::Get()->IsScreenLocked()) {
185 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU, 183 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU,
186 IDS_ASH_SHELF_CONTEXT_MENU_POSITION, 184 IDS_ASH_SHELF_CONTEXT_MENU_POSITION,
187 &shelf_alignment_menu_); 185 &shelf_alignment_menu_);
188 } 186 }
189 if (!controller_->profile()->IsGuestSession()) 187 if (!controller_->profile()->IsGuestSession())
190 AddItemWithStringId(MENU_CHANGE_WALLPAPER, IDS_AURA_SET_DESKTOP_WALLPAPER); 188 AddItemWithStringId(MENU_CHANGE_WALLPAPER, IDS_AURA_SET_DESKTOP_WALLPAPER);
191 } 189 }
192 190
193 bool LauncherContextMenu::ExecuteCommonCommand(int command_id, 191 bool LauncherContextMenu::ExecuteCommonCommand(int command_id,
194 int event_flags) { 192 int event_flags) {
195 switch (command_id) { 193 switch (command_id) {
196 case MENU_OPEN_NEW: 194 case MENU_OPEN_NEW:
197 case MENU_CLOSE: 195 case MENU_CLOSE:
198 case MENU_PIN: 196 case MENU_PIN:
199 case MENU_AUTO_HIDE: 197 case MENU_AUTO_HIDE:
200 case MENU_ALIGNMENT_MENU: 198 case MENU_ALIGNMENT_MENU:
201 case MENU_CHANGE_WALLPAPER: 199 case MENU_CHANGE_WALLPAPER:
202 LauncherContextMenu::ExecuteCommand(command_id, event_flags); 200 LauncherContextMenu::ExecuteCommand(command_id, event_flags);
203 return true; 201 return true;
204 default: 202 default:
205 return false; 203 return false;
206 } 204 }
207 } 205 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698