Skip to content

Commit

Permalink
Add base:: to string16 components/.
Browse files Browse the repository at this point in the history
R=joi@chromium.org
BUG=329295

Review URL: https://codereview.chromium.org/105463003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241904 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
dbeam@chromium.org committed Dec 19, 2013
1 parent a67a111 commit 50ea6da
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 65 deletions.
9 changes: 5 additions & 4 deletions components/policy/core/browser/cloud/message_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,19 @@ int GetIDSForStoreStatus(CloudPolicyStore::Status status) {

} // namespace

string16 FormatDeviceManagementStatus(DeviceManagementStatus status) {
base::string16 FormatDeviceManagementStatus(DeviceManagementStatus status) {
return l10n_util::GetStringUTF16(GetIDSForDMStatus(status));
}

string16 FormatValidationStatus(
base::string16 FormatValidationStatus(
CloudPolicyValidatorBase::Status validation_status) {
return l10n_util::GetStringUTF16(
GetIDSForValidationStatus(validation_status));
}

string16 FormatStoreStatus(CloudPolicyStore::Status store_status,
CloudPolicyValidatorBase::Status validation_status) {
base::string16 FormatStoreStatus(
CloudPolicyStore::Status store_status,
CloudPolicyValidatorBase::Status validation_status) {
if (store_status == CloudPolicyStore::STATUS_VALIDATION_ERROR) {
return l10n_util::GetStringFUTF16(
IDS_POLICY_STORE_STATUS_VALIDATION_ERROR,
Expand Down
6 changes: 3 additions & 3 deletions components/policy/core/browser/cloud/message_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
namespace policy {

// Returns a string describing |status| suitable for display in UI.
POLICY_EXPORT string16 FormatDeviceManagementStatus(
POLICY_EXPORT base::string16 FormatDeviceManagementStatus(
DeviceManagementStatus status);

// Returns a string describing |validation_status| suitable for display in UI.
POLICY_EXPORT string16 FormatValidationStatus(
POLICY_EXPORT base::string16 FormatValidationStatus(
CloudPolicyValidatorBase::Status validation_status);

// Returns a textual description of |store_status| for display in the UI. If
// |store_status| is STATUS_VALIDATION_FAILED, |validation_status| will be
// consulted to create a description of the validation failure.
POLICY_EXPORT string16 FormatStoreStatus(
POLICY_EXPORT base::string16 FormatStoreStatus(
CloudPolicyStore::Status store_status,
CloudPolicyValidatorBase::Status validation_status);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace {
void LogErrors(PolicyErrorMap* errors) {
PolicyErrorMap::const_iterator iter;
for (iter = errors->begin(); iter != errors->end(); ++iter) {
string16 policy = ASCIIToUTF16(iter->first);
base::string16 policy = ASCIIToUTF16(iter->first);
DLOG(WARNING) << "Policy " << policy << ": " << iter->second;
}
}
Expand Down
4 changes: 2 additions & 2 deletions components/policy/core/common/policy_loader_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ const base::FilePath::CharType PolicyLoaderWin::kPRegFileName[] =

PolicyLoaderWin::PolicyLoaderWin(
scoped_refptr<base::SequencedTaskRunner> task_runner,
const string16& chrome_policy_key,
const base::string16& chrome_policy_key,
AppliedGPOListProvider* gpo_provider)
: AsyncPolicyLoader(task_runner),
is_initialized_(false),
Expand Down Expand Up @@ -318,7 +318,7 @@ PolicyLoaderWin::~PolicyLoaderWin() {
// static
scoped_ptr<PolicyLoaderWin> PolicyLoaderWin::Create(
scoped_refptr<base::SequencedTaskRunner> task_runner,
const string16& chrome_policy_key) {
const base::string16& chrome_policy_key) {
return make_scoped_ptr(
new PolicyLoaderWin(task_runner,
chrome_policy_key,
Expand Down
6 changes: 3 additions & 3 deletions components/policy/core/common/policy_loader_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ class POLICY_EXPORT PolicyLoaderWin
static const base::FilePath::CharType kPRegFileName[];

PolicyLoaderWin(scoped_refptr<base::SequencedTaskRunner> task_runner,
const string16& chrome_policy_key,
const base::string16& chrome_policy_key,
AppliedGPOListProvider* gpo_provider);
virtual ~PolicyLoaderWin();

// Creates a policy loader that uses the Win API to access GPO.
static scoped_ptr<PolicyLoaderWin> Create(
scoped_refptr<base::SequencedTaskRunner> task_runner,
const string16& chrome_policy_key);
const base::string16& chrome_policy_key);

// AsyncPolicyLoader implementation.
virtual void InitOnBackgroundThread() OVERRIDE;
Expand Down Expand Up @@ -107,7 +107,7 @@ class POLICY_EXPORT PolicyLoaderWin
virtual void OnObjectSignaled(HANDLE object) OVERRIDE;

bool is_initialized_;
const string16 chrome_policy_key_;
const base::string16 chrome_policy_key_;
class AppliedGPOListProvider* gpo_provider_;

base::WaitableEvent user_policy_changed_event_;
Expand Down
73 changes: 37 additions & 36 deletions components/policy/core/common/policy_loader_win_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const wchar_t kTestPolicyKey[] = L"chrome.policy.key";
// is written.
bool InstallValue(const base::Value& value,
HKEY hive,
const string16& path,
const string16& name) {
const base::string16& path,
const base::string16& name) {
// KEY_ALL_ACCESS causes the ctor to create the key if it does not exist yet.
RegKey key(hive, path.c_str(), KEY_ALL_ACCESS);
EXPECT_TRUE(key.Valid());
Expand All @@ -85,12 +85,13 @@ bool InstallValue(const base::Value& value,
double double_value;
if (!value.GetAsDouble(&double_value))
return false;
string16 str_value = UTF8ToUTF16(base::DoubleToString(double_value));
base::string16 str_value =
UTF8ToUTF16(base::DoubleToString(double_value));
return key.WriteValue(name.c_str(), str_value.c_str()) == ERROR_SUCCESS;
}

case base::Value::TYPE_STRING: {
string16 str_value;
base::string16 str_value;
if (!value.GetAsString(&str_value))
return false;
return key.WriteValue(name.c_str(), str_value.c_str()) == ERROR_SUCCESS;
Expand Down Expand Up @@ -254,29 +255,30 @@ class PRegTestHarness : public PolicyProviderTestHarness,
static PolicyProviderTestHarness* Create();

private:
// Helper to append a string16 to an uint8 buffer.
static void AppendChars(std::vector<uint8>* buffer, const string16& chars);
// Helper to append a base::string16 to an uint8 buffer.
static void AppendChars(std::vector<uint8>* buffer,
const base::string16& chars);

// Appends a record with the given fields to the PReg file.
void AppendRecordToPRegFile(const string16& path,
void AppendRecordToPRegFile(const base::string16& path,
const std::string& key,
DWORD type,
DWORD size,
uint8* data);

// Appends the given DWORD |value| for |path| + |key| to the PReg file.
void AppendDWORDToPRegFile(const string16& path,
void AppendDWORDToPRegFile(const base::string16& path,
const std::string& key,
DWORD value);

// Appends the given string |value| for |path| + |key| to the PReg file.
void AppendStringToPRegFile(const string16& path,
void AppendStringToPRegFile(const base::string16& path,
const std::string& key,
const std::string& value);

// Appends the given policy |value| for |path| + |key| to the PReg file,
// converting and recursing as necessary.
void AppendPolicyToPRegFile(const string16& path,
void AppendPolicyToPRegFile(const base::string16& path,
const std::string& key,
const base::Value* value);

Expand Down Expand Up @@ -380,7 +382,7 @@ void RegistryTestHarness::InstallStringListPolicy(
const std::string& policy_name,
const base::ListValue* policy_value) {
RegKey key(hive_,
(string16(kTestPolicyKey) + ASCIIToUTF16("\\") +
(base::string16(kTestPolicyKey) + ASCIIToUTF16("\\") +
UTF8ToUTF16(policy_name)).c_str(),
KEY_ALL_ACCESS);
ASSERT_TRUE(key.Valid());
Expand Down Expand Up @@ -412,8 +414,8 @@ void RegistryTestHarness::Install3rdPartyPolicy(
const base::DictionaryValue* policies) {
// The first level entries are domains, and the second level entries map
// components to their policy.
const string16 kPathPrefix = string16(kTestPolicyKey) + kPathSep +
kThirdParty + kPathSep;
const base::string16 kPathPrefix =
base::string16(kTestPolicyKey) + kPathSep + kThirdParty + kPathSep;
for (base::DictionaryValue::Iterator domain(*policies);
!domain.IsAtEnd(); domain.Advance()) {
const base::DictionaryValue* components = NULL;
Expand All @@ -423,9 +425,8 @@ void RegistryTestHarness::Install3rdPartyPolicy(
}
for (base::DictionaryValue::Iterator component(*components);
!component.IsAtEnd(); component.Advance()) {
const string16 path = kPathPrefix +
UTF8ToUTF16(domain.key()) + kPathSep +
UTF8ToUTF16(component.key());
const base::string16 path = kPathPrefix +
UTF8ToUTF16(domain.key()) + kPathSep + UTF8ToUTF16(component.key());
InstallValue(component.value(), hive_, path, kMandatory);
}
}
Expand Down Expand Up @@ -513,19 +514,19 @@ void PRegTestHarness::Install3rdPartyPolicy(
const base::DictionaryValue* policies) {
// The first level entries are domains, and the second level entries map
// components to their policy.
const string16 kPathPrefix = string16(kTestPolicyKey) + kPathSep +
kThirdParty + kPathSep;
const base::string16 kPathPrefix =
base::string16(kTestPolicyKey) + kPathSep + kThirdParty + kPathSep;
for (base::DictionaryValue::Iterator domain(*policies);
!domain.IsAtEnd(); domain.Advance()) {
const base::DictionaryValue* components = NULL;
if (!domain.value().GetAsDictionary(&components)) {
ADD_FAILURE();
continue;
}
const string16 domain_path = kPathPrefix + UTF8ToUTF16(domain.key());
const base::string16 domain_path = kPathPrefix + UTF8ToUTF16(domain.key());
for (base::DictionaryValue::Iterator component(*components);
!component.IsAtEnd(); component.Advance()) {
const string16 component_path =
const base::string16 component_path =
domain_path + kPathSep + UTF8ToUTF16(component.key());
AppendPolicyToPRegFile(component_path, UTF16ToUTF8(kMandatory),
&component.value());
Expand Down Expand Up @@ -553,24 +554,24 @@ PolicyProviderTestHarness* PRegTestHarness::Create() {

// static
void PRegTestHarness::AppendChars(std::vector<uint8>* buffer,
const string16& chars) {
for (string16::const_iterator c(chars.begin()); c != chars.end(); ++c) {
const base::string16& chars) {
for (base::string16::const_iterator c(chars.begin()); c != chars.end(); ++c) {
buffer->push_back(*c & 0xff);
buffer->push_back((*c >> 8) & 0xff);
}
}

void PRegTestHarness::AppendRecordToPRegFile(const string16& path,
void PRegTestHarness::AppendRecordToPRegFile(const base::string16& path,
const std::string& key,
DWORD type,
DWORD size,
uint8* data) {
std::vector<uint8> buffer;
AppendChars(&buffer, L"[");
AppendChars(&buffer, path);
AppendChars(&buffer, string16(L"\0;", 2));
AppendChars(&buffer, base::string16(L"\0;", 2));
AppendChars(&buffer, UTF8ToUTF16(key));
AppendChars(&buffer, string16(L"\0;", 2));
AppendChars(&buffer, base::string16(L"\0;", 2));
type = base::ByteSwapToLE32(type);
uint8* type_data = reinterpret_cast<uint8*>(&type);
buffer.insert(buffer.end(), type_data, type_data + sizeof(DWORD));
Expand All @@ -589,18 +590,18 @@ void PRegTestHarness::AppendRecordToPRegFile(const string16& path,
buffer.size()));
}

void PRegTestHarness::AppendDWORDToPRegFile(const string16& path,
void PRegTestHarness::AppendDWORDToPRegFile(const base::string16& path,
const std::string& key,
DWORD value) {
value = base::ByteSwapToLE32(value);
AppendRecordToPRegFile(path, key, REG_DWORD, sizeof(DWORD),
reinterpret_cast<uint8*>(&value));
}

void PRegTestHarness::AppendStringToPRegFile(const string16& path,
void PRegTestHarness::AppendStringToPRegFile(const base::string16& path,
const std::string& key,
const std::string& value) {
string16 string16_value(UTF8ToUTF16(value));
base::string16 string16_value(UTF8ToUTF16(value));
std::vector<char16> data;
std::transform(string16_value.begin(), string16_value.end(),
std::back_inserter(data), std::ptr_fun(base::ByteSwapToLE16));
Expand All @@ -610,7 +611,7 @@ void PRegTestHarness::AppendStringToPRegFile(const string16& path,
reinterpret_cast<uint8*>(vector_as_array(&data)));
}

void PRegTestHarness::AppendPolicyToPRegFile(const string16& path,
void PRegTestHarness::AppendPolicyToPRegFile(const base::string16& path,
const std::string& key,
const base::Value* value) {
switch (value->GetType()) {
Expand Down Expand Up @@ -639,7 +640,7 @@ void PRegTestHarness::AppendPolicyToPRegFile(const string16& path,
break;
}
case base::Value::TYPE_DICTIONARY: {
string16 subpath = path + kPathSep + UTF8ToUTF16(key);
base::string16 subpath = path + kPathSep + UTF8ToUTF16(key);
const base::DictionaryValue* dict = NULL;
ASSERT_TRUE(value->GetAsDictionary(&dict));
for (base::DictionaryValue::Iterator entry(*dict); !entry.IsAtEnd();
Expand All @@ -649,7 +650,7 @@ void PRegTestHarness::AppendPolicyToPRegFile(const string16& path,
break;
}
case base::Value::TYPE_LIST: {
string16 subpath = path + kPathSep + UTF8ToUTF16(key);
base::string16 subpath = path + kPathSep + UTF8ToUTF16(key);
const base::ListValue* list = NULL;
ASSERT_TRUE(value->GetAsList(&list));
for (size_t i = 0; i < list->GetSize(); ++i) {
Expand Down Expand Up @@ -818,7 +819,7 @@ TEST_F(PolicyLoaderWinTest, Merge3rdPartyPolicies) {
" }"
"}"));

const string16 kPathSuffix =
const base::string16 kPathSuffix =
kTestPolicyKey + ASCIIToUTF16("\\3rdparty\\extensions\\merge");

const char kUserMandatory[] = "user-mandatory";
Expand Down Expand Up @@ -907,7 +908,7 @@ TEST_F(PolicyLoaderWinTest, LoadStringEncodedValues) {
encoded_policy.SetString("list", encoded_list);
encoded_policy.SetString("dict", encoded_dict);

const string16 kPathSuffix =
const base::string16 kPathSuffix =
kTestPolicyKey + ASCIIToUTF16("\\3rdparty\\extensions\\string");
EXPECT_TRUE(
InstallValue(encoded_policy, HKEY_CURRENT_USER, kPathSuffix, kMandatory));
Expand Down Expand Up @@ -935,7 +936,7 @@ TEST_F(PolicyLoaderWinTest, LoadIntegerEncodedValues) {
encoded_policy.SetInteger("int", 123);
encoded_policy.SetInteger("double", 456);

const string16 kPathSuffix =
const base::string16 kPathSuffix =
kTestPolicyKey + ASCIIToUTF16("\\3rdparty\\extensions\\int");
EXPECT_TRUE(
InstallValue(encoded_policy, HKEY_CURRENT_USER, kPathSuffix, kMandatory));
Expand Down Expand Up @@ -982,7 +983,7 @@ TEST_F(PolicyLoaderWinTest, DefaultPropertySchemaType) {
base::DictionaryValue all_policies;
all_policies.Set("policy", policy.DeepCopy());

const string16 kPathSuffix =
const base::string16 kPathSuffix =
kTestPolicyKey + ASCIIToUTF16("\\3rdparty\\extensions\\test");
EXPECT_TRUE(
InstallValue(all_policies, HKEY_CURRENT_USER, kPathSuffix, kMandatory));
Expand Down Expand Up @@ -1159,7 +1160,7 @@ TEST_F(PolicyLoaderWinTest, LBSSupport) {
" }"
"}";

const string16 kPathSuffix =
const base::string16 kPathSuffix =
kTestPolicyKey + ASCIIToUTF16("\\3rdparty\\extensions");

base::ListValue list;
Expand Down
Loading

0 comments on commit 50ea6da

Please sign in to comment.