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

Side by Side Diff: chrome/browser/policy/policy_status_info.cc

Issue 7585036: First CL for the about:policy page. This only implements the policy section of the page. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed a change in policy.html Created 9 years, 4 months 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/policy/policy_status_info.h"
6
7 #include <algorithm>
8
9 #include "base/utf_string_conversions.h"
10
11 namespace policy {
12
13 // PolicyStatusInfo
14 PolicyStatusInfo::PolicyStatusInfo() {
15 }
16
17 PolicyStatusInfo::PolicyStatusInfo(const PolicyStatusInfo& rhs)
18 : name(rhs.name),
19 source_type(rhs.source_type),
20 level(rhs.level),
21 status(rhs.status),
22 error_message(rhs.error_message) {
23 if (rhs.value.get())
24 value.reset(rhs.value->DeepCopy());
25 else
26 value.reset(NULL);
27 }
28
29 PolicyStatusInfo::PolicyStatusInfo(
30 string16 name,
31 PolicySourceType source_type,
32 PolicyLevel level,
33 Value* value,
34 PolicyStatus status,
35 string16 error_message)
36 : name(name),
37 source_type(source_type),
38 level(level),
39 value(value),
40 status(status),
41 error_message(error_message) {
42 }
43
44 PolicyStatusInfo::~PolicyStatusInfo() {
45 }
46
47 PolicyStatusInfo& PolicyStatusInfo::operator=(const PolicyStatusInfo& rhs) {
48 name = rhs.name;
49 source_type = rhs.source_type;
50 level = rhs.level;
51 status = rhs.status;
52 error_message = rhs.error_message;
53 if (rhs.value.get())
54 value.reset(rhs.value->DeepCopy());
Mattias Nissler (ping if slow) 2011/08/24 11:57:09 AFAICS, you have operator= and the copy constructo
simo 2011/08/25 10:06:36 Yeah, that works. On 2011/08/24 11:57:09, Mattias
55 else
56 value.reset(NULL);
57 return *this;
58 }
59
60 DictionaryValue* PolicyStatusInfo::GetDictionaryValue() const {
61 string16 level_string = GetPolicyLevelString(level);
62 string16 source_type_string = GetSourceTypeString(source_type);
63 string16 status_message = status == ENFORCED ? ASCIIToUTF16("ok")
64 : error_message;
65 DictionaryValue* result = new DictionaryValue();
66 result->SetString("name", name);
Mattias Nissler (ping if slow) 2011/08/24 11:57:09 Declare static class members for these string cons
simo 2011/08/25 10:06:36 Done.
67 result->SetString("level", level_string);
68 result->SetString("sourceType", source_type_string);
69 result->Set("value", value->DeepCopy());
70 result->SetBoolean("set", level != LEVEL_UNDEFINED);
71 result->SetString("status", status_message);
72
73 return result;
74 }
75
76 bool PolicyStatusInfo::Equals(const PolicyStatusInfo* other_info) const {
77 return name == other_info->name &&
78 source_type == other_info->source_type &&
79 level == other_info->level &&
80 value->Equals(other_info->value.get()) &&
81 status == other_info->status &&
82 error_message == other_info->error_message;
83 }
84
85 // static
86 string16 PolicyStatusInfo::GetSourceTypeString(PolicySourceType source_type) {
87 static string16 strings[] = { ASCIIToUTF16("user"),
88 ASCIIToUTF16("device"),
89 ASCIIToUTF16("undefined") };
Mattias Nissler (ping if slow) 2011/08/24 11:57:09 Can you put a DCHECK that makes sure the numeric v
simo 2011/08/25 10:06:36 Done.
90 return strings[source_type];
91 }
92
93 // static
94 string16 PolicyStatusInfo::GetPolicyLevelString(PolicyLevel level) {
95 static string16 strings[] = { ASCIIToUTF16("mandatory"),
96 ASCIIToUTF16("recommended"),
97 ASCIIToUTF16("undefined") };
Mattias Nissler (ping if slow) 2011/08/24 11:57:09 same here.
simo 2011/08/25 10:06:36 Done.
98 return strings[level];
99 }
100
101 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698