| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "sync/util/get_session_name.h" | 5 #include "sync/util/get_session_name.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/sys_info.h" | 11 #include "base/sys_info.h" |
| 12 #include "base/task_runner.h" | 12 #include "base/task_runner.h" |
| 13 | 13 |
| 14 #if defined(OS_CHROMEOS) | 14 #if defined(OS_CHROMEOS) |
| 15 #include "chrome/browser/chromeos/system/statistics_provider.h" | 15 #include "chrome/browser/chromeos/system/statistics_provider.h" |
| 16 #elif defined(OS_LINUX) | 16 #elif defined(OS_LINUX) |
| 17 #include "base/linux_util.h" | 17 #include "base/linux_util.h" |
| 18 #elif defined(OS_IOS) |
| 19 #include "sync/util/get_session_name_ios.h" |
| 18 #elif defined(OS_MACOSX) | 20 #elif defined(OS_MACOSX) |
| 19 #include "sync/util/get_session_name_mac.h" | 21 #include "sync/util/get_session_name_mac.h" |
| 20 #elif defined(OS_WIN) | 22 #elif defined(OS_WIN) |
| 21 #include "sync/util/get_session_name_win.h" | 23 #include "sync/util/get_session_name_win.h" |
| 22 #elif defined(OS_ANDROID) | 24 #elif defined(OS_ANDROID) |
| 23 #include "sync/util/session_utils_android.h" | 25 #include "sync/util/session_utils_android.h" |
| 24 #endif | 26 #endif |
| 25 | 27 |
| 26 namespace syncer { | 28 namespace syncer { |
| 27 | 29 |
| 28 namespace { | 30 namespace { |
| 29 | 31 |
| 30 std::string GetSessionNameSynchronously() { | 32 std::string GetSessionNameSynchronously() { |
| 31 std::string session_name; | 33 std::string session_name; |
| 32 #if defined(OS_CHROMEOS) | 34 #if defined(OS_CHROMEOS) |
| 33 // TODO(kochi): This is very ad hoc and fragile. http://crbug.com/126732. | 35 // TODO(kochi): This is very ad hoc and fragile. http://crbug.com/126732. |
| 34 std::string board; | 36 std::string board; |
| 35 const char kMachineInfoBoard[] = "CHROMEOS_RELEASE_BOARD"; | 37 const char kMachineInfoBoard[] = "CHROMEOS_RELEASE_BOARD"; |
| 36 chromeos::system::StatisticsProvider* provider = | 38 chromeos::system::StatisticsProvider* provider = |
| 37 chromeos::system::StatisticsProvider::GetInstance(); | 39 chromeos::system::StatisticsProvider::GetInstance(); |
| 38 if (!provider->GetMachineStatistic(kMachineInfoBoard, &board)) | 40 if (!provider->GetMachineStatistic(kMachineInfoBoard, &board)) |
| 39 LOG(ERROR) << "Failed to get board information"; | 41 LOG(ERROR) << "Failed to get board information"; |
| 40 // Currently, only "stumpy" type of board is considered Chromebox, and | 42 // Currently, only "stumpy" type of board is considered Chromebox, and |
| 41 // anything else is Chromebook. On these devices, session_name should look | 43 // anything else is Chromebook. On these devices, session_name should look |
| 42 // like "stumpy-signed-mp-v2keys" etc. The information can be checked on | 44 // like "stumpy-signed-mp-v2keys" etc. The information can be checked on |
| 43 // "CHROMEOS_RELEASE_BOARD" line in chrome://system. | 45 // "CHROMEOS_RELEASE_BOARD" line in chrome://system. |
| 44 session_name = board.substr(0, 6) == "stumpy" ? "Chromebox" : "Chromebook"; | 46 session_name = board.substr(0, 6) == "stumpy" ? "Chromebox" : "Chromebook"; |
| 45 #elif defined(OS_LINUX) | 47 #elif defined(OS_LINUX) |
| 46 session_name = base::GetLinuxDistro(); | 48 session_name = base::GetLinuxDistro(); |
| 49 #elif defined(OS_IOS) |
| 50 session_name = internal::GetComputerName(); |
| 47 #elif defined(OS_MACOSX) | 51 #elif defined(OS_MACOSX) |
| 48 session_name = internal::GetHardwareModelName(); | 52 session_name = internal::GetHardwareModelName(); |
| 49 #elif defined(OS_WIN) | 53 #elif defined(OS_WIN) |
| 50 session_name = internal::GetComputerName(); | 54 session_name = internal::GetComputerName(); |
| 51 #elif defined(OS_ANDROID) | 55 #elif defined(OS_ANDROID) |
| 52 session_name = internal::GetModel(); | 56 session_name = internal::GetModel(); |
| 53 #endif | 57 #endif |
| 54 | 58 |
| 55 if (session_name == "Unknown" || session_name.empty()) | 59 if (session_name == "Unknown" || session_name.empty()) |
| 56 session_name = base::SysInfo::OperatingSystemName(); | 60 session_name = base::SysInfo::OperatingSystemName(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 81 base::Bind(&OnSessionNameFilled, | 85 base::Bind(&OnSessionNameFilled, |
| 82 done_callback, | 86 done_callback, |
| 83 base::Owned(session_name))); | 87 base::Owned(session_name))); |
| 84 } | 88 } |
| 85 | 89 |
| 86 std::string GetSessionNameSynchronouslyForTesting() { | 90 std::string GetSessionNameSynchronouslyForTesting() { |
| 87 return GetSessionNameSynchronously(); | 91 return GetSessionNameSynchronously(); |
| 88 } | 92 } |
| 89 | 93 |
| 90 } // namespace syncer | 94 } // namespace syncer |
| OLD | NEW |