diff options
author | stanisc <stanisc@chromium.org> | 2014-09-25 23:17:36 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-26 06:17:51 +0000 |
commit | d0df01813574affc20bb17dfac783ad325d4bb06 (patch) | |
tree | 6f104952581c8098b4d7d4d156e43e18c9b447f3 /components/sync_driver/device_info.cc | |
parent | 3cc3a684c62e2344aaa5a6a84f9300926330e4d3 (diff) | |
download | chromium_src-d0df01813574affc20bb17dfac783ad325d4bb06.zip chromium_src-d0df01813574affc20bb17dfac783ad325d4bb06.tar.gz chromium_src-d0df01813574affc20bb17dfac783ad325d4bb06.tar.bz2 |
Device info datatype should be moved to components/sync_driver.
Moving device_info* and local_device_info_provider.h to components/sync_driver
and updating namespaces for the related classes from browsing_sync to sync_driver.
Most of the changes are mechanical - trivial changes of header files and namespaces.
There are just few less trivial changes:
1) I've removed GetClientName from DeviceInfo because it depended on content/public.
Instead I've inlined GetClientName code (which is rather trivial) in two places where
it was used, including supervised_user_registration_utility.cc.
That required me to update DEPS file for supervised_user. There isn't anything new
in reality - these dependencies already existed indirectly.
2) Added two extra parameters to DeviceInfoDataTypeController to avoid having
direct dependencies on the browser.
TBR=pkasting@chromium.org,yoz@chromium.org
BUG=396136
Review URL: https://codereview.chromium.org/597423002
Cr-Commit-Position: refs/heads/master@{#296895}
Diffstat (limited to 'components/sync_driver/device_info.cc')
-rw-r--r-- | components/sync_driver/device_info.cc | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/components/sync_driver/device_info.cc b/components/sync_driver/device_info.cc new file mode 100644 index 0000000..c80a157 --- /dev/null +++ b/components/sync_driver/device_info.cc @@ -0,0 +1,113 @@ +// Copyright (c) 2012 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 "base/values.h" +#include "components/sync_driver/device_info.h" + +namespace sync_driver { + +DeviceInfo::DeviceInfo(const std::string& guid, + const std::string& client_name, + const std::string& chrome_version, + const std::string& sync_user_agent, + const sync_pb::SyncEnums::DeviceType device_type, + const std::string& signin_scoped_device_id) + : guid_(guid), + client_name_(client_name), + chrome_version_(chrome_version), + sync_user_agent_(sync_user_agent), + device_type_(device_type), + signin_scoped_device_id_(signin_scoped_device_id) { +} + +DeviceInfo::~DeviceInfo() { } + +const std::string& DeviceInfo::guid() const { + return guid_; +} + +const std::string& DeviceInfo::client_name() const { + return client_name_; +} + +const std::string& DeviceInfo::chrome_version() const { + return chrome_version_; +} + +const std::string& DeviceInfo::sync_user_agent() const { + return sync_user_agent_; +} + +const std::string& DeviceInfo::public_id() const { + return public_id_; +} + +sync_pb::SyncEnums::DeviceType DeviceInfo::device_type() const { + return device_type_; +} + +const std::string& DeviceInfo::signin_scoped_device_id() const { + return signin_scoped_device_id_; +} + +std::string DeviceInfo::GetOSString() const { + switch (device_type_) { + case sync_pb::SyncEnums_DeviceType_TYPE_WIN: + return "win"; + case sync_pb::SyncEnums_DeviceType_TYPE_MAC: + return "mac"; + case sync_pb::SyncEnums_DeviceType_TYPE_LINUX: + return "linux"; + case sync_pb::SyncEnums_DeviceType_TYPE_CROS: + return "chrome_os"; + case sync_pb::SyncEnums_DeviceType_TYPE_PHONE: + case sync_pb::SyncEnums_DeviceType_TYPE_TABLET: + // TODO(lipalani): crbug.com/170375. Add support for ios + // phones and tablets. + return "android"; + default: + return "unknown"; + } +} + +std::string DeviceInfo::GetDeviceTypeString() const { + switch (device_type_) { + case sync_pb::SyncEnums_DeviceType_TYPE_WIN: + case sync_pb::SyncEnums_DeviceType_TYPE_MAC: + case sync_pb::SyncEnums_DeviceType_TYPE_LINUX: + case sync_pb::SyncEnums_DeviceType_TYPE_CROS: + return "desktop_or_laptop"; + case sync_pb::SyncEnums_DeviceType_TYPE_PHONE: + return "phone"; + case sync_pb::SyncEnums_DeviceType_TYPE_TABLET: + return "tablet"; + default: + return "unknown"; + } +} + +bool DeviceInfo::Equals(const DeviceInfo& other) const { + return this->guid() == other.guid() && + this->client_name() == other.client_name() && + this->chrome_version() == other.chrome_version() && + this->sync_user_agent() == other.sync_user_agent() && + this->device_type() == other.device_type() && + this->signin_scoped_device_id() == other.signin_scoped_device_id(); +} + +base::DictionaryValue* DeviceInfo::ToValue() { + base::DictionaryValue* value = new base::DictionaryValue(); + value->SetString("name", client_name_); + value->SetString("id", public_id_); + value->SetString("os", GetOSString()); + value->SetString("type", GetDeviceTypeString()); + value->SetString("chromeVersion", chrome_version_); + return value; +} + +void DeviceInfo::set_public_id(std::string id) { + public_id_ = id; +} + +} // namespace sync_driver |