diff options
Diffstat (limited to 'components/user_manager')
-rw-r--r-- | components/user_manager/DEPS | 3 | ||||
-rw-r--r-- | components/user_manager/empty_user_info.cc | 44 | ||||
-rw-r--r-- | components/user_manager/empty_user_info.h | 39 | ||||
-rw-r--r-- | components/user_manager/user_info.cc | 15 | ||||
-rw-r--r-- | components/user_manager/user_info.h | 46 | ||||
-rw-r--r-- | components/user_manager/user_info_impl.cc | 38 | ||||
-rw-r--r-- | components/user_manager/user_info_impl.h | 38 |
7 files changed, 222 insertions, 1 deletions
diff --git a/components/user_manager/DEPS b/components/user_manager/DEPS index b8a9ee9..ee3957b 100644 --- a/components/user_manager/DEPS +++ b/components/user_manager/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+third_party/skia/include", -"+ui/gfx", +"+ui/gfx/codec", +"+ui/gfx/image", "+url", ] diff --git a/components/user_manager/empty_user_info.cc b/components/user_manager/empty_user_info.cc new file mode 100644 index 0000000..f4f3fca --- /dev/null +++ b/components/user_manager/empty_user_info.cc @@ -0,0 +1,44 @@ +// 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 "components/user_manager/empty_user_info.h" + +#include "base/logging.h" +#include "base/strings/utf_string_conversions.h" + +namespace user_manager { + +EmptyUserInfo::EmptyUserInfo() { +} + +EmptyUserInfo::~EmptyUserInfo() { +} + +base::string16 EmptyUserInfo::GetDisplayName() const { + NOTIMPLEMENTED(); + return base::UTF8ToUTF16(std::string()); +} + +base::string16 EmptyUserInfo::GetGivenName() const { + NOTIMPLEMENTED(); + return base::UTF8ToUTF16(std::string()); +} + +std::string EmptyUserInfo::GetEmail() const { + NOTIMPLEMENTED(); + return std::string(); +} + +std::string EmptyUserInfo::GetUserID() const { + NOTIMPLEMENTED(); + return std::string(); +} + +const gfx::ImageSkia& EmptyUserInfo::GetImage() const { + NOTIMPLEMENTED(); + // To make the compiler happy. + return null_image_; +} + +} // namespace user_manager diff --git a/components/user_manager/empty_user_info.h b/components/user_manager/empty_user_info.h new file mode 100644 index 0000000..4d22f45 --- /dev/null +++ b/components/user_manager/empty_user_info.h @@ -0,0 +1,39 @@ +// 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. + +#ifndef COMPONENTS_USER_MANAGER_EMPTY_USER_INFO_H_ +#define COMPONENTS_USER_MANAGER_EMPTY_USER_INFO_H_ + +#include <string> + +#include "base/strings/string16.h" +#include "components/user_manager/user_info.h" +#include "components/user_manager/user_manager_export.h" +#include "ui/gfx/image/image_skia.h" + +namespace user_manager { + +// Trivial implementation of UserInfo interface which triggers +// NOTIMPLEMENTED() for each method. +class USER_MANAGER_EXPORT EmptyUserInfo : public UserInfo { + public: + EmptyUserInfo(); + virtual ~EmptyUserInfo(); + + // UserInfo: + virtual base::string16 GetDisplayName() const OVERRIDE; + virtual base::string16 GetGivenName() const OVERRIDE; + virtual std::string GetEmail() const OVERRIDE; + virtual std::string GetUserID() const OVERRIDE; + virtual const gfx::ImageSkia& GetImage() const OVERRIDE; + + private: + const gfx::ImageSkia null_image_; + + DISALLOW_COPY_AND_ASSIGN(EmptyUserInfo); +}; + +} // namespace user_manager + +#endif // COMPONENTS_USER_MANAGER_EMPTY_USER_INFO_H_ diff --git a/components/user_manager/user_info.cc b/components/user_manager/user_info.cc new file mode 100644 index 0000000..adfeb72 --- /dev/null +++ b/components/user_manager/user_info.cc @@ -0,0 +1,15 @@ +// 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 "components/user_manager/user_info.h" + +namespace user_manager { + +UserInfo::UserInfo() { +} + +UserInfo::~UserInfo() { +} + +} // namespace user_manager diff --git a/components/user_manager/user_info.h b/components/user_manager/user_info.h new file mode 100644 index 0000000..9540946 --- /dev/null +++ b/components/user_manager/user_info.h @@ -0,0 +1,46 @@ +// 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. + +#ifndef COMPONENTS_USER_MANAGER_USER_INFO_H_ +#define COMPONENTS_USER_MANAGER_USER_INFO_H_ + +#include <string> + +#include "base/strings/string16.h" +#include "components/user_manager/user_manager_export.h" + +namespace gfx { +class ImageSkia; +} + +namespace user_manager { + +// A class that represents user related info. +class USER_MANAGER_EXPORT UserInfo { + public: + UserInfo(); + virtual ~UserInfo(); + + // Gets the display name for the user. + virtual base::string16 GetDisplayName() const = 0; + + // Gets the given name of the user. + virtual base::string16 GetGivenName() const = 0; + + // Gets the display email address for the user. + // The display email address might contains some periods in the email name + // as well as capitalized letters. For example: "Foo.Bar@mock.com". + virtual std::string GetEmail() const = 0; + + // Gets the user id (sanitized email address) for the user. + // The function would return something like "foobar@mock.com". + virtual std::string GetUserID() const = 0; + + // Gets the avatar image for the user. + virtual const gfx::ImageSkia& GetImage() const = 0; +}; + +} // namespace user_manager + +#endif // COMPONENTS_USER_MANAGER_USER_INFO_H_ diff --git a/components/user_manager/user_info_impl.cc b/components/user_manager/user_info_impl.cc new file mode 100644 index 0000000..6aa21a8 --- /dev/null +++ b/components/user_manager/user_info_impl.cc @@ -0,0 +1,38 @@ +// 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 "components/user_manager/user_info_impl.h" + +#include "base/logging.h" +#include "base/strings/utf_string_conversions.h" + +namespace user_manager { + +UserInfoImpl::UserInfoImpl() { +} + +UserInfoImpl::~UserInfoImpl() { +} + +base::string16 UserInfoImpl::GetDisplayName() const { + return base::UTF8ToUTF16("stub-user"); +} + +base::string16 UserInfoImpl::GetGivenName() const { + return base::UTF8ToUTF16("Stub"); +} + +std::string UserInfoImpl::GetEmail() const { + return "stub-user@domain.com"; +} + +std::string UserInfoImpl::GetUserID() const { + return GetEmail(); +} + +const gfx::ImageSkia& UserInfoImpl::GetImage() const { + return user_image_; +} + +} // namespace user_manager diff --git a/components/user_manager/user_info_impl.h b/components/user_manager/user_info_impl.h new file mode 100644 index 0000000..f024910 --- /dev/null +++ b/components/user_manager/user_info_impl.h @@ -0,0 +1,38 @@ +// 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. + +#ifndef COMPONENTS_USER_MANAGER_USER_INFO_IMPL_H_ +#define COMPONENTS_USER_MANAGER_USER_INFO_IMPL_H_ + +#include <string> + +#include "base/strings/string16.h" +#include "components/user_manager/user_info.h" +#include "components/user_manager/user_manager_export.h" +#include "ui/gfx/image/image_skia.h" + +namespace user_manager { + +// Stub implementation of UserInfo interface. Used in tests. +class USER_MANAGER_EXPORT UserInfoImpl : public UserInfo { + public: + UserInfoImpl(); + virtual ~UserInfoImpl(); + + // UserInfo: + virtual base::string16 GetDisplayName() const OVERRIDE; + virtual base::string16 GetGivenName() const OVERRIDE; + virtual std::string GetEmail() const OVERRIDE; + virtual std::string GetUserID() const OVERRIDE; + virtual const gfx::ImageSkia& GetImage() const OVERRIDE; + + private: + gfx::ImageSkia user_image_; + + DISALLOW_COPY_AND_ASSIGN(UserInfoImpl); +}; + +} // namespace user_manager + +#endif // COMPONENTS_USER_MANAGER_USER_INFO_IMPL_H_ |