Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "ash/session_state_delegate_stub.h" | 5 #include "ash/session_state_delegate_stub.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | |
| 7 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 8 #include "ash/shell/example_factory.h" | 9 #include "ash/shell/example_factory.h" |
| 10 #include "ash/shell_delegate.h" | |
| 11 #include "base/command_line.h" | |
| 12 #include "base/file_util.h" | |
| 13 #include "base/files/file_path.h" | |
| 9 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "ui/gfx/codec/png_codec.h" | |
| 17 #include "ui/gfx/image/image_skia.h" | |
| 11 | 18 |
| 12 namespace ash { | 19 namespace ash { |
| 13 | 20 |
| 14 SessionStateDelegateStub::SessionStateDelegateStub() : screen_locked_(false) { | 21 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
| |
| 22 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 23 if (command_line->HasSwitch(switches::kAshUserImagePath)) { | |
| 24 base::FilePath path = | |
| 25 command_line->GetSwitchValuePath(switches::kAshUserImagePath); | |
| 26 std::string data; | |
| 27 if (!ReadFileToString(path, &data)) | |
| 28 LOG(FATAL) << "Could not read user image: path=" << path.value(); | |
| 29 SkBitmap bitmap; | |
| 30 if (!gfx::PNGCodec::Decode( | |
| 31 reinterpret_cast<const unsigned char*>(data.c_str()), | |
| 32 data.size(), &bitmap)) { | |
| 33 LOG(FATAL) << "Could not decode user image: path=" << path.value(); | |
| 34 } | |
| 35 user_image_ = gfx::ImageSkia(gfx::ImageSkiaRep(bitmap, 1.0f)); | |
| 36 } | |
| 15 } | 37 } |
| 16 | 38 |
| 17 SessionStateDelegateStub::~SessionStateDelegateStub() { | 39 SessionStateDelegateStub::~SessionStateDelegateStub() { |
| 18 } | 40 } |
| 19 | 41 |
| 20 content::BrowserContext* | 42 content::BrowserContext* |
| 21 SessionStateDelegateStub::GetBrowserContextByIndex( | 43 SessionStateDelegateStub::GetBrowserContextByIndex( |
| 22 MultiProfileIndex index) { | 44 MultiProfileIndex index) { |
| 23 return NULL; | 45 return Shell::GetInstance()->delegate()->GetActiveBrowserContext(); |
| 46 } | |
| 47 | |
| 48 content::BrowserContext* | |
| 49 SessionStateDelegateStub::GetBrowserContextForWindow( | |
| 50 aura::Window* window) { | |
| 51 return Shell::GetInstance()->delegate()->GetActiveBrowserContext(); | |
| 24 } | 52 } |
| 25 | 53 |
| 26 int SessionStateDelegateStub::GetMaximumNumberOfLoggedInUsers() const { | 54 int SessionStateDelegateStub::GetMaximumNumberOfLoggedInUsers() const { |
| 27 return 3; | 55 return 3; |
| 28 } | 56 } |
| 29 | 57 |
| 30 int SessionStateDelegateStub::NumberOfLoggedInUsers() const { | 58 int SessionStateDelegateStub::NumberOfLoggedInUsers() const { |
| 31 return 1; | 59 return 1; |
| 32 } | 60 } |
| 33 | 61 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 return "stub-user@domain.com"; | 100 return "stub-user@domain.com"; |
| 73 } | 101 } |
| 74 | 102 |
| 75 const std::string SessionStateDelegateStub::GetUserID( | 103 const std::string SessionStateDelegateStub::GetUserID( |
| 76 MultiProfileIndex index) const { | 104 MultiProfileIndex index) const { |
| 77 return GetUserEmail(index); | 105 return GetUserEmail(index); |
| 78 } | 106 } |
| 79 | 107 |
| 80 const gfx::ImageSkia& SessionStateDelegateStub::GetUserImage( | 108 const gfx::ImageSkia& SessionStateDelegateStub::GetUserImage( |
| 81 content::BrowserContext* context) const { | 109 content::BrowserContext* context) const { |
| 82 return null_image_; | 110 return user_image_; |
| 83 } | 111 } |
| 84 | 112 |
| 85 bool SessionStateDelegateStub::ShouldShowAvatar(aura::Window* window) { | 113 bool SessionStateDelegateStub::ShouldShowAvatar(aura::Window* window) { |
| 86 return false; | 114 return !user_image_.isNull(); |
| 87 } | 115 } |
| 88 | 116 |
| 89 void SessionStateDelegateStub::SwitchActiveUser(const std::string& user_id) { | 117 void SessionStateDelegateStub::SwitchActiveUser(const std::string& user_id) { |
| 90 } | 118 } |
| 91 | 119 |
| 92 void SessionStateDelegateStub::CycleActiveUser(CycleUser cycle_user) { | 120 void SessionStateDelegateStub::CycleActiveUser(CycleUser cycle_user) { |
| 93 } | 121 } |
| 94 | 122 |
| 95 void SessionStateDelegateStub::AddSessionStateObserver( | 123 void SessionStateDelegateStub::AddSessionStateObserver( |
| 96 ash::SessionStateObserver* observer) { | 124 ash::SessionStateObserver* observer) { |
| 97 } | 125 } |
| 98 | 126 |
| 99 void SessionStateDelegateStub::RemoveSessionStateObserver( | 127 void SessionStateDelegateStub::RemoveSessionStateObserver( |
| 100 ash::SessionStateObserver* observer) { | 128 ash::SessionStateObserver* observer) { |
| 101 } | 129 } |
| 102 | 130 |
| 103 } // namespace ash | 131 } // namespace ash |
| OLD | NEW |