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

Side by Side Diff: chrome/browser/ui/views/frame/system_menu_model_builder.cc

Issue 2111443002: mash: Migrate SessionStateDelegate access to WmShell. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 5 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/views/frame/system_menu_model_builder.h" 5 #include "chrome/browser/ui/views/frame/system_menu_model_builder.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
11 #include "chrome/browser/ui/browser_commands.h" 11 #include "chrome/browser/ui/browser_commands.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/browser/ui/toolbar/app_menu_model.h" 13 #include "chrome/browser/ui/toolbar/app_menu_model.h"
14 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
16 #include "chrome/grit/generated_resources.h" 16 #include "chrome/grit/generated_resources.h"
17 #include "grit/components_strings.h" 17 #include "grit/components_strings.h"
18 #include "ui/base/accelerators/accelerator.h" 18 #include "ui/base/accelerators/accelerator.h"
19 #include "ui/base/models/simple_menu_model.h" 19 #include "ui/base/models/simple_menu_model.h"
20 20
21 #if defined(OS_CHROMEOS) 21 #if defined(OS_CHROMEOS)
22 #include "ash/common/session/session_state_delegate.h" 22 #include "ash/common/session/session_state_delegate.h"
23 #include "ash/shell.h" 23 #include "ash/common/wm_shell.h"
24 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 24 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
25 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 25 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
26 #include "chrome/browser/ui/browser_window.h" 26 #include "chrome/browser/ui/browser_window.h"
27 #include "components/signin/core/account_id/account_id.h" 27 #include "components/signin/core/account_id/account_id.h"
28 #include "components/user_manager/user_info.h" 28 #include "components/user_manager/user_info.h"
29 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
30 #endif 30 #endif
31 31
32 namespace { 32 namespace {
33 33
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 if (chrome::MultiUserWindowManager::GetMultiProfileMode() != 153 if (chrome::MultiUserWindowManager::GetMultiProfileMode() !=
154 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) 154 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED)
155 return; 155 return;
156 156
157 // Don't show the menu for incognito windows. 157 // Don't show the menu for incognito windows.
158 if (browser()->profile()->IsOffTheRecord()) 158 if (browser()->profile()->IsOffTheRecord())
159 return; 159 return;
160 160
161 // To show the menu we need at least two logged in users. 161 // To show the menu we need at least two logged in users.
162 ash::SessionStateDelegate* delegate = 162 ash::SessionStateDelegate* delegate =
163 ash::Shell::GetInstance()->session_state_delegate(); 163 ash::WmShell::Get()->GetSessionStateDelegate();
164 int logged_in_users = delegate->NumberOfLoggedInUsers(); 164 int logged_in_users = delegate->NumberOfLoggedInUsers();
165 if (logged_in_users <= 1) 165 if (logged_in_users <= 1)
166 return; 166 return;
167 167
168 // If this does not belong to a profile or there is no window, or the window 168 // If this does not belong to a profile or there is no window, or the window
169 // is not owned by anyone, we don't show the menu addition. 169 // is not owned by anyone, we don't show the menu addition.
170 chrome::MultiUserWindowManager* manager = 170 chrome::MultiUserWindowManager* manager =
171 chrome::MultiUserWindowManager::GetInstance(); 171 chrome::MultiUserWindowManager::GetInstance();
172 const AccountId account_id = 172 const AccountId account_id =
173 multi_user_util::GetAccountIdFromProfile(browser()->profile()); 173 multi_user_util::GetAccountIdFromProfile(browser()->profile());
174 aura::Window* window = browser()->window()->GetNativeWindow(); 174 aura::Window* window = browser()->window()->GetNativeWindow();
175 if (!account_id.is_valid() || !window || 175 if (!account_id.is_valid() || !window ||
176 !manager->GetWindowOwner(window).is_valid()) 176 !manager->GetWindowOwner(window).is_valid())
177 return; 177 return;
178 178
179 model->AddSeparator(ui::NORMAL_SEPARATOR); 179 model->AddSeparator(ui::NORMAL_SEPARATOR);
180 DCHECK(logged_in_users <= 3); 180 DCHECK(logged_in_users <= 3);
181 for (int user_index = 1; user_index < logged_in_users; ++user_index) { 181 for (int user_index = 1; user_index < logged_in_users; ++user_index) {
182 const user_manager::UserInfo* user_info = delegate->GetUserInfo(user_index); 182 const user_manager::UserInfo* user_info = delegate->GetUserInfo(user_index);
183 model->AddItem( 183 model->AddItem(
184 user_index == 1 ? IDC_VISIT_DESKTOP_OF_LRU_USER_2 184 user_index == 1 ? IDC_VISIT_DESKTOP_OF_LRU_USER_2
185 : IDC_VISIT_DESKTOP_OF_LRU_USER_3, 185 : IDC_VISIT_DESKTOP_OF_LRU_USER_3,
186 l10n_util::GetStringFUTF16(IDS_VISIT_DESKTOP_OF_LRU_USER, 186 l10n_util::GetStringFUTF16(IDS_VISIT_DESKTOP_OF_LRU_USER,
187 user_info->GetDisplayName(), 187 user_info->GetDisplayName(),
188 base::ASCIIToUTF16(user_info->GetEmail()))); 188 base::ASCIIToUTF16(user_info->GetEmail())));
189 } 189 }
190 #endif 190 #endif
191 } 191 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698