OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/policy/policy_status_info.h" | 5 #include "chrome/browser/policy/policy_status_info.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "grit/generated_resources.h" |
| 12 #include "ui/base/l10n/l10n_util.h" |
11 | 13 |
12 namespace policy { | 14 namespace policy { |
13 | 15 |
14 const char PolicyStatusInfo::kLevelDictPath[] = "level"; | 16 const char PolicyStatusInfo::kLevelDictPath[] = "level"; |
15 const char PolicyStatusInfo::kNameDictPath[] = "name"; | 17 const char PolicyStatusInfo::kNameDictPath[] = "name"; |
16 const char PolicyStatusInfo::kSetDictPath[] = "set"; | 18 const char PolicyStatusInfo::kSetDictPath[] = "set"; |
17 const char PolicyStatusInfo::kSourceTypeDictPath[] = "sourceType"; | 19 const char PolicyStatusInfo::kSourceTypeDictPath[] = "sourceType"; |
18 const char PolicyStatusInfo::kStatusDictPath[] = "status"; | 20 const char PolicyStatusInfo::kStatusDictPath[] = "status"; |
19 const char PolicyStatusInfo::kValueDictPath[] = "value"; | 21 const char PolicyStatusInfo::kValueDictPath[] = "value"; |
20 | 22 |
(...skipping 18 matching lines...) Expand all Loading... |
39 status(status), | 41 status(status), |
40 error_message(error_message) { | 42 error_message(error_message) { |
41 } | 43 } |
42 | 44 |
43 PolicyStatusInfo::~PolicyStatusInfo() { | 45 PolicyStatusInfo::~PolicyStatusInfo() { |
44 } | 46 } |
45 | 47 |
46 DictionaryValue* PolicyStatusInfo::GetDictionaryValue() const { | 48 DictionaryValue* PolicyStatusInfo::GetDictionaryValue() const { |
47 string16 level_string = GetPolicyLevelString(level); | 49 string16 level_string = GetPolicyLevelString(level); |
48 string16 source_type_string = GetSourceTypeString(source_type); | 50 string16 source_type_string = GetSourceTypeString(source_type); |
49 string16 status_message = status == ENFORCED ? ASCIIToUTF16("ok") | 51 string16 status_message = |
50 : error_message; | 52 status == ENFORCED ? l10n_util::GetStringUTF16(IDS_OK) : error_message; |
51 DictionaryValue* result = new DictionaryValue(); | 53 DictionaryValue* result = new DictionaryValue(); |
52 result->SetString(std::string(kNameDictPath), name); | 54 result->SetString(std::string(kNameDictPath), name); |
53 result->SetString(std::string(kLevelDictPath), level_string); | 55 result->SetString(std::string(kLevelDictPath), level_string); |
54 result->SetString(std::string(kSourceTypeDictPath), source_type_string); | 56 result->SetString(std::string(kSourceTypeDictPath), source_type_string); |
55 result->Set(std::string(kValueDictPath), value->DeepCopy()); | 57 result->Set(std::string(kValueDictPath), value->DeepCopy()); |
56 result->SetBoolean(std::string(kSetDictPath), level != LEVEL_UNDEFINED); | 58 result->SetBoolean(std::string(kSetDictPath), level != LEVEL_UNDEFINED); |
57 result->SetString(std::string(kStatusDictPath), status_message); | 59 result->SetString(std::string(kStatusDictPath), status_message); |
58 | 60 |
59 return result; | 61 return result; |
60 } | 62 } |
(...skipping 16 matching lines...) Expand all Loading... |
77 } | 79 } |
78 | 80 |
79 // static | 81 // static |
80 string16 PolicyStatusInfo::GetPolicyLevelString(PolicyLevel level) { | 82 string16 PolicyStatusInfo::GetPolicyLevelString(PolicyLevel level) { |
81 static const char* strings[] = { "mandatory", "recommended", "undefined" }; | 83 static const char* strings[] = { "mandatory", "recommended", "undefined" }; |
82 DCHECK(static_cast<size_t>(level) < arraysize(strings)); | 84 DCHECK(static_cast<size_t>(level) < arraysize(strings)); |
83 return ASCIIToUTF16(strings[level]); | 85 return ASCIIToUTF16(strings[level]); |
84 } | 86 } |
85 | 87 |
86 } // namespace policy | 88 } // namespace policy |
OLD | NEW |