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

Side by Side Diff: components/policy/core/common/cloud/cloud_policy_constants.cc

Issue 742513006: Add ManagementMode enum and GetManagementMode(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing POLICY_EXPORT Created 6 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "components/policy/core/common/cloud/cloud_policy_constants.h" 5 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h"
9 #include "components/policy/core/common/policy_switches.h" 10 #include "components/policy/core/common/policy_switches.h"
11 #include "policy/proto/device_management_backend.pb.h"
12
13 namespace em = enterprise_management;
10 14
11 namespace policy { 15 namespace policy {
12 16
13 // Constants related to the device management protocol. 17 // Constants related to the device management protocol.
14 namespace dm_protocol { 18 namespace dm_protocol {
15 19
16 // Name constants for URL query parameters. 20 // Name constants for URL query parameters.
17 const char kParamAgent[] = "agent"; 21 const char kParamAgent[] = "agent";
18 const char kParamAppType[] = "apptype"; 22 const char kParamAppType[] = "apptype";
19 const char kParamDeviceID[] = "deviceid"; 23 const char kParamDeviceID[] = "deviceid";
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 99
96 const char* GetChromeUserPolicyType() { 100 const char* GetChromeUserPolicyType() {
97 #if defined(OS_ANDROID) || defined(OS_IOS) 101 #if defined(OS_ANDROID) || defined(OS_IOS)
98 CommandLine* command_line = CommandLine::ForCurrentProcess(); 102 CommandLine* command_line = CommandLine::ForCurrentProcess();
99 if (command_line->HasSwitch(switches::kFakeCloudPolicyType)) 103 if (command_line->HasSwitch(switches::kFakeCloudPolicyType))
100 return "google/chrome/user"; 104 return "google/chrome/user";
101 #endif 105 #endif
102 return dm_protocol::kChromeUserPolicyType; 106 return dm_protocol::kChromeUserPolicyType;
103 } 107 }
104 108
109 ManagementMode GetManagementMode(const em::PolicyData& policy_data) {
110 if (policy_data.has_management_mode()) {
111 switch (policy_data.management_mode()) {
112 case em::PolicyData::LOCAL_OWNER:
113 return MANAGEMENT_MODE_LOCAL_OWNER;
114
115 case em::PolicyData::ENTERPRISE_MANAGED:
116 return MANAGEMENT_MODE_ENTERPRISE_MANAGED;
117
118 case em::PolicyData::CONSUMER_MANAGED:
119 return MANAGEMENT_MODE_CONSUMER_MANAGED;
120
121 default:
122 NOTREACHED();
123 return MANAGEMENT_MODE_LOCAL_OWNER;
124 }
125 }
126
127 return policy_data.has_request_token() ?
128 MANAGEMENT_MODE_ENTERPRISE_MANAGED : MANAGEMENT_MODE_LOCAL_OWNER;
129 }
130
105 } // namespace policy 131 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698