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

Unified Diff: ash/frame/frame_util.cc

Issue 197773004: Move avatar holder code to ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang fix Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/frame/frame_util.h ('k') | ash/resources/ash_resources.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/frame/frame_util.cc
diff --git a/ash/frame/frame_util.cc b/ash/frame/frame_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bfa8c33548608c76c900bdc7d24a2a27690924b7
--- /dev/null
+++ b/ash/frame/frame_util.cc
@@ -0,0 +1,35 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/frame/frame_util.h"
+
+#include "ash/session_state_delegate.h"
+#include "ash/shell.h"
+#include "grit/ash_resources.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/image/image_skia_operations.h"
+
+namespace ash {
+
+gfx::Image GetAvatarImageForContext(content::BrowserContext* context) {
+ static const gfx::ImageSkia* holder =
+ ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
+ IDR_AVATAR_HOLDER);
+ static const gfx::ImageSkia* holder_mask =
+ ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
+ IDR_AVATAR_HOLDER_MASK);
+ gfx::ImageSkia user_image =
+ Shell::GetInstance()->session_state_delegate()->GetUserImage(context);
+ gfx::ImageSkia resized = gfx::ImageSkiaOperations::CreateResizedImage(
+ user_image, skia::ImageOperations::RESIZE_BEST, holder->size());
+ gfx::ImageSkia masked =
+ gfx::ImageSkiaOperations::CreateMaskedImage(resized, *holder_mask);
+ gfx::ImageSkia result =
+ gfx::ImageSkiaOperations::CreateSuperimposedImage(*holder, masked);
+ return gfx::Image(result);
+}
+
+} // namespace ash
+
« no previous file with comments | « ash/frame/frame_util.h ('k') | ash/resources/ash_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698