Skip OwnerSettingsServiceChromeOS with --stub-cros-settings.
[chromium-blink-merge.git] / ash / frame / frame_util.cc
blobc4b1be9f328acc4f5db99b03e83364b7a16987eb
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/frame/frame_util.h"
7 #include "ash/session/session_state_delegate.h"
8 #include "ash/shell.h"
9 #include "components/user_manager/user_info.h"
10 #include "grit/ash_resources.h"
11 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/gfx/image/image_skia.h"
13 #include "ui/gfx/image/image_skia_operations.h"
15 namespace ash {
17 gfx::Image GetAvatarImageForContext(content::BrowserContext* context) {
18 static const gfx::ImageSkia* holder =
19 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
20 IDR_AVATAR_HOLDER);
21 static const gfx::ImageSkia* holder_mask =
22 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
23 IDR_AVATAR_HOLDER_MASK);
24 gfx::ImageSkia user_image = Shell::GetInstance()
25 ->session_state_delegate()
26 ->GetUserInfo(context)
27 ->GetImage();
28 gfx::ImageSkia resized = gfx::ImageSkiaOperations::CreateResizedImage(
29 user_image, skia::ImageOperations::RESIZE_BEST, holder->size());
30 gfx::ImageSkia masked =
31 gfx::ImageSkiaOperations::CreateMaskedImage(resized, *holder_mask);
32 gfx::ImageSkia result =
33 gfx::ImageSkiaOperations::CreateSuperimposedImage(*holder, masked);
34 return gfx::Image(result);
37 } // namespace ash