Skip to content

Commit

Permalink
Moved GetCurrentUserName to service_utils.*
Browse files Browse the repository at this point in the history
TBR=gene
NOTRY=True


Review URL: https://chromiumcodereview.appspot.com/12676018

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189880 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
vitalybuka@chromium.org committed Mar 22, 2013
1 parent 42814cf commit d541804
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
2 changes: 2 additions & 0 deletions cloud_print/service/service.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
'win/local_security_policy.h',
'win/service_controller.cc',
'win/service_controller.h',
'win/service_utils.cc',
'win/service_utils.h',
],
},
{
Expand Down
14 changes: 1 addition & 13 deletions cloud_print/service/win/cloud_print_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "cloud_print/service/service_switches.h"
#include "cloud_print/service/win/chrome_launcher.h"
#include "cloud_print/service/win/service_controller.h"
#include "cloud_print/service/win/service_utils.h"
#include "printing/backend/print_backend.h"

namespace {
Expand Down Expand Up @@ -110,19 +111,6 @@ bool AskUser(const std::string& request) {
}
}

string16 GetCurrentUserName() {
ULONG size = 0;
string16 result;
::GetUserNameEx(::NameSamCompatible, NULL, &size);
result.resize(size);
if (result.empty())
return result;
if (!::GetUserNameEx(::NameSamCompatible, &result[0], &size))
result.clear();
result.resize(size);
return result;
}

} // namespace

class CloudPrintServiceModule
Expand Down
23 changes: 23 additions & 0 deletions cloud_print/service/win/service_utils.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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 "cloud_print/service/win/service_utils.h"

#include <windows.h>
#include <security.h> // NOLINT

string16 GetCurrentUserName() {
ULONG size = 0;
string16 result;
::GetUserNameEx(::NameSamCompatible, NULL, &size);
result.resize(size);
if (result.empty())
return result;
if (!::GetUserNameEx(::NameSamCompatible, &result[0], &size))
result.clear();
result.resize(size);
return result;
}


13 changes: 13 additions & 0 deletions cloud_print/service/win/service_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// 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.

#ifndef CLOUD_PRINT_SERVICE_SERVICE_UTILS_H_
#define CLOUD_PRINT_SERVICE_SERVICE_UTILS_H_

#include "base/string16.h"

string16 GetCurrentUserName();

#endif // CLOUD_PRINT_SERVICE_SERVICE_UTILS_H_

0 comments on commit d541804

Please sign in to comment.