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

Side by Side Diff: chrome/browser/ui/ash/session_util.cc

Issue 1960293003: Remove OS_CHROMEOS from ui/ash code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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 (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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/session_util.h" 5 #include "chrome/browser/ui/ash/session_util.h"
6 6
7 #include "ash/content/shell_content_state.h" 7 #include "ash/content/shell_content_state.h"
8 #include "ash/session/session_state_delegate.h" 8 #include "ash/session/session_state_delegate.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/browser/chromeos/profiles/profile_helper.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "components/user_manager/user_manager.h"
13 #include "content/public/browser/browser_context.h" 15 #include "content/public/browser/browser_context.h"
14 #include "grit/ash_resources.h" 16 #include "grit/ash_resources.h"
15 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
16 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/image/image_skia_operations.h" 19 #include "ui/gfx/image/image_skia_operations.h"
18 20
19 #if defined(OS_CHROMEOS)
20 #include "chrome/browser/chromeos/profiles/profile_helper.h"
21 #include "components/user_manager/user_manager.h"
22 #endif
23
24 content::BrowserContext* GetActiveBrowserContext() { 21 content::BrowserContext* GetActiveBrowserContext() {
25 #if defined(OS_CHROMEOS)
26 DCHECK(user_manager::UserManager::Get()->GetLoggedInUsers().size()); 22 DCHECK(user_manager::UserManager::Get()->GetLoggedInUsers().size());
27 #endif
28 return ProfileManager::GetActiveUserProfile(); 23 return ProfileManager::GetActiveUserProfile();
29 } 24 }
30 25
31 bool CanShowWindowForUser( 26 bool CanShowWindowForUser(
32 aura::Window* window, 27 aura::Window* window,
33 const GetActiveBrowserContextCallback& get_context_callback) { 28 const GetActiveBrowserContextCallback& get_context_callback) {
34 ash::SessionStateDelegate* delegate = 29 ash::SessionStateDelegate* delegate =
35 ash::Shell::GetInstance()->session_state_delegate(); 30 ash::Shell::GetInstance()->session_state_delegate();
36 if (delegate->NumberOfLoggedInUsers() > 1) { 31 if (delegate->NumberOfLoggedInUsers() > 1) {
37 content::BrowserContext* active_browser_context = 32 content::BrowserContext* active_browser_context =
38 get_context_callback.Run(); 33 get_context_callback.Run();
39 ash::ShellContentState* state = ash::ShellContentState::GetInstance(); 34 ash::ShellContentState* state = ash::ShellContentState::GetInstance();
40 content::BrowserContext* owner_browser_context = 35 content::BrowserContext* owner_browser_context =
41 state->GetBrowserContextForWindow(window); 36 state->GetBrowserContextForWindow(window);
42 content::BrowserContext* shown_browser_context = 37 content::BrowserContext* shown_browser_context =
43 state->GetUserPresentingBrowserContextForWindow(window); 38 state->GetUserPresentingBrowserContextForWindow(window);
44 39
45 if (owner_browser_context && active_browser_context && 40 if (owner_browser_context && active_browser_context &&
46 owner_browser_context != active_browser_context && 41 owner_browser_context != active_browser_context &&
47 shown_browser_context != active_browser_context) { 42 shown_browser_context != active_browser_context) {
48 return false; 43 return false;
49 } 44 }
50 } 45 }
51 return true; 46 return true;
52 } 47 }
53 48
54 namespace {
55 #if defined(OS_CHROMEOS)
56 user_manager::UserInfo* GetUserInfoForContext(
57 content::BrowserContext* context) {
58 return chromeos::ProfileHelper::Get()->GetUserByProfile(
59 Profile::FromBrowserContext(context));
60 }
61 #endif
62
63 } // namespace
64
65 gfx::ImageSkia GetAvatarImageForContext(content::BrowserContext* context) { 49 gfx::ImageSkia GetAvatarImageForContext(content::BrowserContext* context) {
66 #if defined(OS_CHROMEOS)
67 static const gfx::ImageSkia* holder = 50 static const gfx::ImageSkia* holder =
68 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 51 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
69 IDR_AVATAR_HOLDER); 52 IDR_AVATAR_HOLDER);
70 static const gfx::ImageSkia* holder_mask = 53 static const gfx::ImageSkia* holder_mask =
71 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 54 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
72 IDR_AVATAR_HOLDER_MASK); 55 IDR_AVATAR_HOLDER_MASK);
73 56
74 gfx::ImageSkia user_image = GetUserInfoForContext(context)->GetImage(); 57 gfx::ImageSkia user_image =
58 chromeos::ProfileHelper::Get()
59 ->GetUserByProfile(Profile::FromBrowserContext(context))
60 ->GetImage();
61
75 gfx::ImageSkia resized = gfx::ImageSkiaOperations::CreateResizedImage( 62 gfx::ImageSkia resized = gfx::ImageSkiaOperations::CreateResizedImage(
76 user_image, skia::ImageOperations::RESIZE_BEST, holder->size()); 63 user_image, skia::ImageOperations::RESIZE_BEST, holder->size());
77 gfx::ImageSkia masked = 64 gfx::ImageSkia masked =
78 gfx::ImageSkiaOperations::CreateMaskedImage(resized, *holder_mask); 65 gfx::ImageSkiaOperations::CreateMaskedImage(resized, *holder_mask);
79 return gfx::ImageSkiaOperations::CreateSuperimposedImage(*holder, masked); 66 return gfx::ImageSkiaOperations::CreateSuperimposedImage(*holder, masked);
80 #else
81 return gfx::ImageSkia();
82 #endif
83 } 67 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/session_state_delegate_views.cc ('k') | chrome/browser/ui/ash/system_tray_delegate_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698