summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/components.gyp2
-rw-r--r--components/user_manager.gypi28
-rw-r--r--components/user_manager/DEPS3
-rw-r--r--components/user_manager/empty_user_info.cc44
-rw-r--r--components/user_manager/empty_user_info.h39
-rw-r--r--components/user_manager/user_info.cc15
-rw-r--r--components/user_manager/user_info.h46
-rw-r--r--components/user_manager/user_info_impl.cc38
-rw-r--r--components/user_manager/user_info_impl.h38
9 files changed, 246 insertions, 7 deletions
diff --git a/components/components.gyp b/components/components.gyp
index 49254a2..e6e6b4c 100644
--- a/components/components.gyp
+++ b/components/components.gyp
@@ -82,7 +82,7 @@
'wifi.gypi',
],
}],
- ['chromeos==1', {
+ ['use_ash==1', {
'includes': [
'user_manager.gypi',
],
diff --git a/components/user_manager.gypi b/components/user_manager.gypi
index f10edf2..7b22938 100644
--- a/components/user_manager.gypi
+++ b/components/user_manager.gypi
@@ -3,6 +3,24 @@
# found in the LICENSE file.
{
+ 'variables': {
+ # Cross-platform user_manager sources.
+ 'user_manager_shared_sources': [
+ 'user_manager/empty_user_info.cc',
+ 'user_manager/empty_user_info.h',
+ 'user_manager/user_info.h',
+ 'user_manager/user_info.cc',
+ 'user_manager/user_info_impl.cc',
+ 'user_manager/user_info_impl.h',
+ 'user_manager/user_manager_export.h',
+ ],
+ # Chrome OS user_manager sources.
+ 'user_manager_chromeos_sources': [
+ 'user_manager/user_image/user_image.cc',
+ 'user_manager/user_image/user_image.h',
+ 'user_manager/user_type.h',
+ ],
+ },
'targets': [{
'target_name': 'user_manager',
'type': '<(component)',
@@ -18,11 +36,11 @@
'include_dirs': [
'..',
],
- 'sources': [
- 'user_manager/user_image/user_image.cc',
- 'user_manager/user_image/user_image.h',
- 'user_manager/user_type.h',
- 'user_manager/user_manager_export.h',
+ 'sources': [ '<@(user_manager_shared_sources)' ],
+ 'conditions': [
+ ['chromeos == 1', {
+ 'sources': [ '<@(user_manager_chromeos_sources)' ],
+ }],
],
}],
}
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_