1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cloud_print/service/win/service_utils.h"
6 #include "google_apis/gaia/gaia_switches.h"
9 #include <security.h> // NOLINT
11 #include "base/command_line.h"
12 #include "base/strings/string_util.h"
13 #include "chrome/common/chrome_switches.h"
15 string16
GetLocalComputerName() {
18 ::GetComputerName(NULL
, &size
);
22 if (!::GetComputerName(&result
[0], &size
))
28 string16
ReplaceLocalHostInName(const string16
& user_name
) {
29 static const wchar_t kLocalDomain
[] = L
".\\";
30 if (StartsWith(user_name
, kLocalDomain
, true)) {
31 return GetLocalComputerName() +
32 user_name
.substr(arraysize(kLocalDomain
) - 2);
37 string16
GetCurrentUserName() {
40 ::GetUserNameEx(::NameSamCompatible
, NULL
, &size
);
44 if (!::GetUserNameEx(::NameSamCompatible
, &result
[0], &size
))
50 void CopyChromeSwitchesFromCurrentProcess(CommandLine
* destination
) {
51 static const char* const kSwitchesToCopy
[] = {
52 switches::kCloudPrintServiceURL
,
53 switches::kEnableLogging
,
54 switches::kIgnoreUrlFetcherCertRequests
,
58 destination
->CopySwitchesFrom(*CommandLine::ForCurrentProcess(),
60 arraysize(kSwitchesToCopy
));