| 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/common/session/session_state_delegate.h" | |
| 10 #include "ash/common/shelf/shelf_model.h" | 9 #include "ash/common/shelf/shelf_model.h" |
| 11 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
| 12 #include "ash/common/strings/grit/ash_strings.h" | 11 #include "ash/common/strings/grit/ash_strings.h" |
| 13 #include "ash/common/wallpaper/wallpaper_delegate.h" | 12 #include "ash/common/wallpaper/wallpaper_delegate.h" |
| 14 #include "ash/common/wm_shell.h" | 13 #include "ash/common/wm_shell.h" |
| 15 #include "ash/common/wm_window.h" | 14 #include "ash/common/wm_window.h" |
| 16 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 17 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 16 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 18 #include "chrome/browser/fullscreen.h" | 17 #include "chrome/browser/fullscreen.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 19 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 21 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 20 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 22 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" | 21 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" |
| 23 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" | 22 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
| 24 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" | 23 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" |
| 25 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" | 24 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" |
| 26 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" | 25 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" |
| 27 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 28 #include "chrome/grit/generated_resources.h" | 27 #include "chrome/grit/generated_resources.h" |
| 29 #include "components/prefs/pref_service.h" | 28 #include "components/prefs/pref_service.h" |
| 29 #include "components/session_manager/core/session_manager.h" |
| 30 #include "content/public/common/context_menu_params.h" | 30 #include "content/public/common/context_menu_params.h" |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 // 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. |
| 35 bool CanUserModifyShelfAutoHideBehavior(const Profile* profile) { | 35 bool CanUserModifyShelfAutoHideBehavior(const Profile* profile) { |
| 36 const std::string& pref = prefs::kShelfAutoHideBehaviorLocal; | 36 const std::string& pref = prefs::kShelfAutoHideBehaviorLocal; |
| 37 return profile->GetPrefs()->FindPreference(pref)->IsUserModifiable(); | 37 return profile->GetPrefs()->FindPreference(pref)->IsUserModifiable(); |
| 38 } | 38 } |
| 39 | 39 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // on the type of fullscreen. Do not show the auto-hide menu item while in | 175 // on the type of fullscreen. Do not show the auto-hide menu item while in |
| 176 // fullscreen per display because it is confusing when the preference appears | 176 // fullscreen per display because it is confusing when the preference appears |
| 177 // not to apply. | 177 // not to apply. |
| 178 int64_t display_id = wm_shelf_->GetWindow()->GetDisplayNearestWindow().id(); | 178 int64_t display_id = wm_shelf_->GetWindow()->GetDisplayNearestWindow().id(); |
| 179 if (!IsFullScreenMode(display_id) && | 179 if (!IsFullScreenMode(display_id) && |
| 180 CanUserModifyShelfAutoHideBehavior(controller_->profile())) { | 180 CanUserModifyShelfAutoHideBehavior(controller_->profile())) { |
| 181 AddCheckItemWithStringId(MENU_AUTO_HIDE, | 181 AddCheckItemWithStringId(MENU_AUTO_HIDE, |
| 182 IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE); | 182 IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE); |
| 183 } | 183 } |
| 184 if (ash::WmShelf::CanChangeShelfAlignment() && | 184 if (ash::WmShelf::CanChangeShelfAlignment() && |
| 185 !ash::WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked()) { | 185 !session_manager::SessionManager::Get()->IsScreenLocked()) { |
| 186 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU, | 186 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU, |
| 187 IDS_ASH_SHELF_CONTEXT_MENU_POSITION, | 187 IDS_ASH_SHELF_CONTEXT_MENU_POSITION, |
| 188 &shelf_alignment_menu_); | 188 &shelf_alignment_menu_); |
| 189 } | 189 } |
| 190 if (!controller_->profile()->IsGuestSession()) | 190 if (!controller_->profile()->IsGuestSession()) |
| 191 AddItemWithStringId(MENU_CHANGE_WALLPAPER, IDS_AURA_SET_DESKTOP_WALLPAPER); | 191 AddItemWithStringId(MENU_CHANGE_WALLPAPER, IDS_AURA_SET_DESKTOP_WALLPAPER); |
| 192 } | 192 } |
| 193 | 193 |
| 194 bool LauncherContextMenu::ExecuteCommonCommand(int command_id, | 194 bool LauncherContextMenu::ExecuteCommonCommand(int command_id, |
| 195 int event_flags) { | 195 int event_flags) { |
| 196 switch (command_id) { | 196 switch (command_id) { |
| 197 case MENU_OPEN_NEW: | 197 case MENU_OPEN_NEW: |
| 198 case MENU_CLOSE: | 198 case MENU_CLOSE: |
| 199 case MENU_PIN: | 199 case MENU_PIN: |
| 200 case MENU_AUTO_HIDE: | 200 case MENU_AUTO_HIDE: |
| 201 case MENU_ALIGNMENT_MENU: | 201 case MENU_ALIGNMENT_MENU: |
| 202 case MENU_CHANGE_WALLPAPER: | 202 case MENU_CHANGE_WALLPAPER: |
| 203 LauncherContextMenu::ExecuteCommand(command_id, event_flags); | 203 LauncherContextMenu::ExecuteCommand(command_id, event_flags); |
| 204 return true; | 204 return true; |
| 205 default: | 205 default: |
| 206 return false; | 206 return false; |
| 207 } | 207 } |
| 208 } | 208 } |
| OLD | NEW |