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

Unified Diff: ash/session_state_delegate_stub.cc

Issue 200483004: Show avatar icon on V2 app's frame (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
Index: ash/session_state_delegate_stub.cc
diff --git a/ash/session_state_delegate_stub.cc b/ash/session_state_delegate_stub.cc
index 7fc01da402071a79f67c67504e5895b8eb4b883d..75173203513fd2e9ad154a5e50dde96c87d9511d 100644
--- a/ash/session_state_delegate_stub.cc
+++ b/ash/session_state_delegate_stub.cc
@@ -4,14 +4,36 @@
#include "ash/session_state_delegate_stub.h"
+#include "ash/ash_switches.h"
#include "ash/shell.h"
#include "ash/shell/example_factory.h"
+#include "ash/shell_delegate.h"
+#include "base/command_line.h"
+#include "base/file_util.h"
+#include "base/files/file_path.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
+#include "ui/gfx/codec/png_codec.h"
+#include "ui/gfx/image/image_skia.h"
namespace ash {
SessionStateDelegateStub::SessionStateDelegateStub() : screen_locked_(false) {
Mr4D (OOO till 08-26) 2014/03/14 22:01:30 I am not quite sure why we need this command line
oshima 2014/03/15 01:32:32 This is to test in ash_shell.
Mr4D (OOO till 08-26) 2014/03/17 23:17:47 But couldn't you create a dummy image in a non zer
oshima 2014/03/17 23:30:28 Alternative one is to add debug accelerator to tur
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kAshUserImagePath)) {
+ base::FilePath path =
+ command_line->GetSwitchValuePath(switches::kAshUserImagePath);
+ std::string data;
+ if (!ReadFileToString(path, &data))
+ LOG(FATAL) << "Could not read user image: path=" << path.value();
+ SkBitmap bitmap;
+ if (!gfx::PNGCodec::Decode(
+ reinterpret_cast<const unsigned char*>(data.c_str()),
+ data.size(), &bitmap)) {
+ LOG(FATAL) << "Could not decode user image: path=" << path.value();
+ }
+ user_image_ = gfx::ImageSkia(gfx::ImageSkiaRep(bitmap, 1.0f));
+ }
}
SessionStateDelegateStub::~SessionStateDelegateStub() {
@@ -20,7 +42,13 @@ SessionStateDelegateStub::~SessionStateDelegateStub() {
content::BrowserContext*
SessionStateDelegateStub::GetBrowserContextByIndex(
MultiProfileIndex index) {
- return NULL;
+ return Shell::GetInstance()->delegate()->GetActiveBrowserContext();
+}
+
+content::BrowserContext*
+SessionStateDelegateStub::GetBrowserContextForWindow(
+ aura::Window* window) {
+ return Shell::GetInstance()->delegate()->GetActiveBrowserContext();
}
int SessionStateDelegateStub::GetMaximumNumberOfLoggedInUsers() const {
@@ -79,11 +107,11 @@ const std::string SessionStateDelegateStub::GetUserID(
const gfx::ImageSkia& SessionStateDelegateStub::GetUserImage(
content::BrowserContext* context) const {
- return null_image_;
+ return user_image_;
}
bool SessionStateDelegateStub::ShouldShowAvatar(aura::Window* window) {
- return false;
+ return !user_image_.isNull();
}
void SessionStateDelegateStub::SwitchActiveUser(const std::string& user_id) {

Powered by Google App Engine
This is Rietveld 408576698