| 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" | 9 #include "ash/common/session/session_state_delegate.h" |
| 10 #include "ash/common/shelf/shelf_model.h" | 10 #include "ash/common/shelf/shelf_model.h" |
| 11 #include "ash/common/shelf/wm_shelf.h" | 11 #include "ash/common/shelf/wm_shelf.h" |
| 12 #include "ash/common/strings/grit/ash_strings.h" | 12 #include "ash/common/strings/grit/ash_strings.h" |
| 13 #include "ash/common/wallpaper/wallpaper_delegate.h" | 13 #include "ash/common/wallpaper/wallpaper_delegate.h" |
| 14 #include "ash/common/wm_shell.h" | 14 #include "ash/common/wm_shell.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/fullscreen.h" | 16 #include "chrome/browser/fullscreen.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 18 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 19 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" | 19 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" |
| 20 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" | 20 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
| 21 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" | 21 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" |
| 22 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" | 22 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" |
| 23 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" | 23 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" |
| 24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/grit/generated_resources.h" | 25 #include "chrome/grit/generated_resources.h" |
| 26 #include "components/prefs/pref_service.h" | 26 #include "components/prefs/pref_service.h" |
| 27 #include "content/public/common/context_menu_params.h" | 27 #include "content/public/common/context_menu_params.h" |
| 28 | 28 |
| 29 #if defined(OS_CHROMEOS) |
| 30 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 31 #endif // defined(OS_CHROMEOS) |
| 32 |
| 29 namespace { | 33 namespace { |
| 30 | 34 |
| 31 // 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. |
| 32 bool CanUserModifyShelfAutoHideBehavior(const Profile* profile) { | 36 bool CanUserModifyShelfAutoHideBehavior(const Profile* profile) { |
| 33 const std::string& pref = prefs::kShelfAutoHideBehaviorLocal; | 37 const std::string& pref = prefs::kShelfAutoHideBehaviorLocal; |
| 34 return profile->GetPrefs()->FindPreference(pref)->IsUserModifiable(); | 38 return profile->GetPrefs()->FindPreference(pref)->IsUserModifiable(); |
| 35 } | 39 } |
| 36 | 40 |
| 37 } // namespace | 41 } // namespace |
| 38 | 42 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 92 } |
| 89 DCHECK(command_id < MENU_ITEM_COUNT); | 93 DCHECK(command_id < MENU_ITEM_COUNT); |
| 90 return false; | 94 return false; |
| 91 } | 95 } |
| 92 | 96 |
| 93 bool LauncherContextMenu::IsCommandIdEnabled(int command_id) const { | 97 bool LauncherContextMenu::IsCommandIdEnabled(int command_id) const { |
| 94 switch (command_id) { | 98 switch (command_id) { |
| 95 case MENU_PIN: | 99 case MENU_PIN: |
| 96 return controller_->IsPinnable(item_.id); | 100 return controller_->IsPinnable(item_.id); |
| 97 case MENU_CHANGE_WALLPAPER: | 101 case MENU_CHANGE_WALLPAPER: |
| 102 #if defined(OS_CHROMEOS) |
| 98 return ash::WmShell::Get() | 103 return ash::WmShell::Get() |
| 99 ->wallpaper_delegate() | 104 ->wallpaper_delegate() |
| 100 ->CanOpenSetWallpaperPage(); | 105 ->CanOpenSetWallpaperPage(); |
| 106 #else |
| 107 return false; |
| 108 #endif // defined(OS_CHROMEOS) |
| 101 case MENU_AUTO_HIDE: | 109 case MENU_AUTO_HIDE: |
| 102 return CanUserModifyShelfAutoHideBehavior(controller_->profile()); | 110 return CanUserModifyShelfAutoHideBehavior(controller_->profile()); |
| 103 default: | 111 default: |
| 104 DCHECK(command_id < MENU_ITEM_COUNT); | 112 DCHECK(command_id < MENU_ITEM_COUNT); |
| 105 return true; | 113 return true; |
| 106 } | 114 } |
| 107 } | 115 } |
| 108 | 116 |
| 109 void LauncherContextMenu::ExecuteCommand(int command_id, int event_flags) { | 117 void LauncherContextMenu::ExecuteCommand(int command_id, int event_flags) { |
| 110 switch (static_cast<MenuItem>(command_id)) { | 118 switch (static_cast<MenuItem>(command_id)) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 130 case MENU_AUTO_HIDE: | 138 case MENU_AUTO_HIDE: |
| 131 wm_shelf_->SetAutoHideBehavior( | 139 wm_shelf_->SetAutoHideBehavior( |
| 132 wm_shelf_->auto_hide_behavior() == | 140 wm_shelf_->auto_hide_behavior() == |
| 133 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS | 141 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS |
| 134 ? ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER | 142 ? ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER |
| 135 : ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 143 : ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 136 break; | 144 break; |
| 137 case MENU_ALIGNMENT_MENU: | 145 case MENU_ALIGNMENT_MENU: |
| 138 break; | 146 break; |
| 139 case MENU_CHANGE_WALLPAPER: | 147 case MENU_CHANGE_WALLPAPER: |
| 140 ash::WmShell::Get()->wallpaper_delegate()->OpenSetWallpaperPage(); | 148 #if defined(OS_CHROMEOS) |
| 149 chromeos::WallpaperManager::Get()->Open(); |
| 150 #endif // defined(OS_CHROMEOS) |
| 141 break; | 151 break; |
| 142 default: | 152 default: |
| 143 NOTREACHED(); | 153 NOTREACHED(); |
| 144 } | 154 } |
| 145 } | 155 } |
| 146 | 156 |
| 147 void LauncherContextMenu::AddPinMenu() { | 157 void LauncherContextMenu::AddPinMenu() { |
| 148 // Expect an item with a none zero id to add pin/unpin menu item. | 158 // Expect an item with a none zero id to add pin/unpin menu item. |
| 149 DCHECK(item_.id); | 159 DCHECK(item_.id); |
| 150 int menu_pin_string_id; | 160 int menu_pin_string_id; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 case MENU_PIN: | 205 case MENU_PIN: |
| 196 case MENU_AUTO_HIDE: | 206 case MENU_AUTO_HIDE: |
| 197 case MENU_ALIGNMENT_MENU: | 207 case MENU_ALIGNMENT_MENU: |
| 198 case MENU_CHANGE_WALLPAPER: | 208 case MENU_CHANGE_WALLPAPER: |
| 199 LauncherContextMenu::ExecuteCommand(command_id, event_flags); | 209 LauncherContextMenu::ExecuteCommand(command_id, event_flags); |
| 200 return true; | 210 return true; |
| 201 default: | 211 default: |
| 202 return false; | 212 return false; |
| 203 } | 213 } |
| 204 } | 214 } |
| OLD | NEW |