Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: sync/util/get_session_name.cc

Issue 32043003: Replace kChromeOSReleaseBoard with SysInfo::GetLsbReleaseBoard() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix DEPS Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/util/DEPS ('k') | sync/util/get_session_name_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_LINUX)
15 #include "base/command_line.h"
16 #include "chromeos/chromeos_switches.h"
17 #elif defined(OS_LINUX)
18 #include "sync/util/get_session_name_linux.h" 15 #include "sync/util/get_session_name_linux.h"
19 #elif defined(OS_IOS) 16 #elif defined(OS_IOS)
20 #include "sync/util/get_session_name_ios.h" 17 #include "sync/util/get_session_name_ios.h"
21 #elif defined(OS_MACOSX) 18 #elif defined(OS_MACOSX)
22 #include "sync/util/get_session_name_mac.h" 19 #include "sync/util/get_session_name_mac.h"
23 #elif defined(OS_WIN) 20 #elif defined(OS_WIN)
24 #include "sync/util/get_session_name_win.h" 21 #include "sync/util/get_session_name_win.h"
25 #elif defined(OS_ANDROID) 22 #elif defined(OS_ANDROID)
26 #include "base/android/build_info.h" 23 #include "base/android/build_info.h"
27 #endif 24 #endif
28 25
29 namespace syncer { 26 namespace syncer {
30 27
31 namespace { 28 namespace {
32 29
33 std::string GetSessionNameSynchronously() { 30 std::string GetSessionNameSynchronously() {
34 std::string session_name; 31 std::string session_name;
35 #if defined(OS_CHROMEOS) 32 #if defined(OS_CHROMEOS)
36 // The approach below is similar to that used by the CrOs implementation of 33 std::string board = base::SysInfo::GetLsbReleaseBoard();
37 // StatisticsProvider::GetMachineStatistic(CHROMEOS_RELEASE_BOARD).
38 // See chromeos/system/statistics_provider.{h|cc}.
39 //
40 // We cannot use StatisticsProvider here because of the mutual dependency
41 // it creates between sync.gyp:sync and chrome.gyp:browser.
42 //
43 // Even though this code is ad hoc and fragile, it remains the only means of
44 // determining the Chrome OS hardware platform so we can display the right
45 // device name in the "Other devices" section of the new tab page.
46 // TODO(rsimha): Change this once a better alternative is available.
47 // See http://crbug.com/126732.
48 std::string board;
49 const CommandLine* command_line = CommandLine::ForCurrentProcess();
50 if (command_line->HasSwitch(chromeos::switches::kChromeOSReleaseBoard)) {
51 board = command_line->
52 GetSwitchValueASCII(chromeos::switches::kChromeOSReleaseBoard);
53 } else {
54 LOG(ERROR) << "Failed to get board information";
55 }
56
57 // Currently, only "stumpy" type of board is considered Chromebox, and 34 // Currently, only "stumpy" type of board is considered Chromebox, and
58 // anything else is Chromebook. On these devices, session_name should look 35 // anything else is Chromebook. On these devices, session_name should look
59 // like "stumpy-signed-mp-v2keys" etc. The information can be checked on 36 // like "stumpy-signed-mp-v2keys" etc. The information can be checked on
60 // "CHROMEOS_RELEASE_BOARD" line in chrome://system. 37 // "CHROMEOS_RELEASE_BOARD" line in chrome://system.
61 session_name = board.substr(0, 6) == "stumpy" ? "Chromebox" : "Chromebook"; 38 session_name = board.substr(0, 6) == "stumpy" ? "Chromebox" : "Chromebook";
62 #elif defined(OS_LINUX) 39 #elif defined(OS_LINUX)
63 session_name = internal::GetHostname(); 40 session_name = internal::GetHostname();
64 #elif defined(OS_IOS) 41 #elif defined(OS_IOS)
65 session_name = internal::GetComputerName(); 42 session_name = internal::GetComputerName();
66 #elif defined(OS_MACOSX) 43 #elif defined(OS_MACOSX)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 base::Bind(&OnSessionNameFilled, 79 base::Bind(&OnSessionNameFilled,
103 done_callback, 80 done_callback,
104 base::Owned(session_name))); 81 base::Owned(session_name)));
105 } 82 }
106 83
107 std::string GetSessionNameSynchronouslyForTesting() { 84 std::string GetSessionNameSynchronouslyForTesting() {
108 return GetSessionNameSynchronously(); 85 return GetSessionNameSynchronously();
109 } 86 }
110 87
111 } // namespace syncer 88 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/util/DEPS ('k') | sync/util/get_session_name_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698