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

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

Issue 1428213004: This CL replaces std::string user_id in ash/* with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after review. Created 5 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/views/frame/browser_non_client_frame_view_ash_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/ui/browser_commands.h" 10 #include "chrome/browser/ui/browser_commands.h"
11 #include "chrome/browser/ui/host_desktop.h" 11 #include "chrome/browser/ui/host_desktop.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 "ui/base/accelerators/accelerator.h" 17 #include "ui/base/accelerators/accelerator.h"
18 #include "ui/base/models/simple_menu_model.h" 18 #include "ui/base/models/simple_menu_model.h"
19 19
20 #if defined(OS_CHROMEOS) 20 #if defined(OS_CHROMEOS)
21 #include "ash/session/session_state_delegate.h" 21 #include "ash/session/session_state_delegate.h"
22 #include "ash/shell.h" 22 #include "ash/shell.h"
23 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 23 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
24 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 24 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
25 #include "chrome/browser/ui/browser_window.h" 25 #include "chrome/browser/ui/browser_window.h"
26 #include "components/signin/core/account_id/account_id.h"
26 #include "components/user_manager/user_info.h" 27 #include "components/user_manager/user_info.h"
27 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
28 #endif 29 #endif
29 30
30 namespace { 31 namespace {
31 32
32 // Given a |browser| that's an app or popup window, checks if it's hosting the 33 // Given a |browser| that's an app or popup window, checks if it's hosting the
33 // settings page. 34 // settings page.
34 bool IsChromeSettingsAppOrPopupWindow(Browser* browser) { 35 bool IsChromeSettingsAppOrPopupWindow(Browser* browser) {
35 DCHECK(browser); 36 DCHECK(browser);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 ash::SessionStateDelegate* delegate = 163 ash::SessionStateDelegate* delegate =
163 ash::Shell::GetInstance()->session_state_delegate(); 164 ash::Shell::GetInstance()->session_state_delegate();
164 int logged_in_users = delegate->NumberOfLoggedInUsers(); 165 int logged_in_users = delegate->NumberOfLoggedInUsers();
165 if (logged_in_users <= 1) 166 if (logged_in_users <= 1)
166 return; 167 return;
167 168
168 // If this does not belong to a profile or there is no window, or the window 169 // 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. 170 // is not owned by anyone, we don't show the menu addition.
170 chrome::MultiUserWindowManager* manager = 171 chrome::MultiUserWindowManager* manager =
171 chrome::MultiUserWindowManager::GetInstance(); 172 chrome::MultiUserWindowManager::GetInstance();
172 const std::string user_id = 173 const AccountId account_id =
173 multi_user_util::GetUserIDFromProfile(browser()->profile()); 174 multi_user_util::GetAccountIdFromProfile(browser()->profile());
174 aura::Window* window = browser()->window()->GetNativeWindow(); 175 aura::Window* window = browser()->window()->GetNativeWindow();
175 if (user_id.empty() || !window || manager->GetWindowOwner(window).empty()) 176 if (!account_id.is_valid() || !window ||
177 !manager->GetWindowOwner(window).is_valid())
176 return; 178 return;
177 179
178 model->AddSeparator(ui::NORMAL_SEPARATOR); 180 model->AddSeparator(ui::NORMAL_SEPARATOR);
179 DCHECK(logged_in_users <= 3); 181 DCHECK(logged_in_users <= 3);
180 for (int user_index = 1; user_index < logged_in_users; ++user_index) { 182 for (int user_index = 1; user_index < logged_in_users; ++user_index) {
181 const user_manager::UserInfo* user_info = delegate->GetUserInfo(user_index); 183 const user_manager::UserInfo* user_info = delegate->GetUserInfo(user_index);
182 model->AddItem( 184 model->AddItem(
183 user_index == 1 ? IDC_VISIT_DESKTOP_OF_LRU_USER_2 185 user_index == 1 ? IDC_VISIT_DESKTOP_OF_LRU_USER_2
184 : IDC_VISIT_DESKTOP_OF_LRU_USER_3, 186 : IDC_VISIT_DESKTOP_OF_LRU_USER_3,
185 l10n_util::GetStringFUTF16(IDS_VISIT_DESKTOP_OF_LRU_USER, 187 l10n_util::GetStringFUTF16(IDS_VISIT_DESKTOP_OF_LRU_USER,
186 user_info->GetDisplayName(), 188 user_info->GetDisplayName(),
187 base::ASCIIToUTF16(user_info->GetEmail()))); 189 base::ASCIIToUTF16(user_info->GetEmail())));
188 } 190 }
189 #endif 191 #endif
190 } 192 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_non_client_frame_view_ash_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698