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

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

Issue 7785032: Revert 98987 - Pass user_affiliation request parameter on user cloud policy requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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
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/device_management_backend_impl.h" 5 #include "chrome/browser/policy/device_management_backend_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #if defined(OS_POSIX) && !defined(OS_MACOSX) 10 #if defined(OS_POSIX) && !defined(OS_MACOSX)
(...skipping 16 matching lines...) Expand all
27 namespace policy { 27 namespace policy {
28 28
29 // Name constants for URL query parameters. 29 // Name constants for URL query parameters.
30 const char DeviceManagementBackendImpl::kParamAgent[] = "agent"; 30 const char DeviceManagementBackendImpl::kParamAgent[] = "agent";
31 const char DeviceManagementBackendImpl::kParamAppType[] = "apptype"; 31 const char DeviceManagementBackendImpl::kParamAppType[] = "apptype";
32 const char DeviceManagementBackendImpl::kParamDeviceID[] = "deviceid"; 32 const char DeviceManagementBackendImpl::kParamDeviceID[] = "deviceid";
33 const char DeviceManagementBackendImpl::kParamDeviceType[] = "devicetype"; 33 const char DeviceManagementBackendImpl::kParamDeviceType[] = "devicetype";
34 const char DeviceManagementBackendImpl::kParamOAuthToken[] = "oauth_token"; 34 const char DeviceManagementBackendImpl::kParamOAuthToken[] = "oauth_token";
35 const char DeviceManagementBackendImpl::kParamPlatform[] = "platform"; 35 const char DeviceManagementBackendImpl::kParamPlatform[] = "platform";
36 const char DeviceManagementBackendImpl::kParamRequest[] = "request"; 36 const char DeviceManagementBackendImpl::kParamRequest[] = "request";
37 const char DeviceManagementBackendImpl::kParamUserAffiliation[] =
38 "user_affiliation";
39 37
40 // String constants for the device and app type we report to the server. 38 // String constants for the device and app type we report to the server.
41 const char DeviceManagementBackendImpl::kValueAppType[] = "Chrome"; 39 const char DeviceManagementBackendImpl::kValueAppType[] = "Chrome";
42 const char DeviceManagementBackendImpl::kValueDeviceType[] = "2"; 40 const char DeviceManagementBackendImpl::kValueDeviceType[] = "2";
43 const char DeviceManagementBackendImpl::kValueRequestPolicy[] = "policy"; 41 const char DeviceManagementBackendImpl::kValueRequestPolicy[] = "policy";
44 const char DeviceManagementBackendImpl::kValueRequestRegister[] = "register"; 42 const char DeviceManagementBackendImpl::kValueRequestRegister[] = "register";
45 const char DeviceManagementBackendImpl::kValueRequestUnregister[] = 43 const char DeviceManagementBackendImpl::kValueRequestUnregister[] =
46 "unregister"; 44 "unregister";
47 const char DeviceManagementBackendImpl::kValueUserAffiliationManaged[] =
48 "managed";
49 const char DeviceManagementBackendImpl::kValueUserAffiliationNone[] = "none";
50 45
51 namespace { 46 namespace {
52 47
53 const char kValueAgent[] = "%s %s(%s)"; 48 const char kValueAgent[] = "%s %s(%s)";
54 const char kValuePlatform[] = "%s|%s|%s"; 49 const char kValuePlatform[] = "%s|%s|%s";
55 50
56 const char kPostContentType[] = "application/protobuf"; 51 const char kPostContentType[] = "application/protobuf";
57 52
58 const char kServiceTokenAuthHeader[] = "Authorization: GoogleLogin auth="; 53 const char kServiceTokenAuthHeader[] = "Authorization: GoogleLogin auth=";
59 const char kDMTokenAuthHeader[] = "Authorization: GoogleDMToken token="; 54 const char kDMTokenAuthHeader[] = "Authorization: GoogleDMToken token=";
60 55
61 // HTTP Error Codes of the DM Server with their concrete meinings in the context 56 // HTTP Error Codes of the DM Server with their concrete meinings in the context
62 // of the DM Server communication. 57 // of the DM Server communication.
63 const int kSuccess = 200; 58 const int kSuccess = 200;
64 const int kInvalidArgument = 400; 59 const int kInvalidArgument = 400;
65 const int kInvalidAuthCookieOrDMToken = 401; 60 const int kInvalidAuthCookieOrDMToken = 401;
66 const int kDeviceManagementNotAllowed = 403; 61 const int kDeviceManagementNotAllowed = 403;
67 const int kInvalidURL = 404; // This error is not coming from the GFE. 62 const int kInvalidURL = 404; // This error is not coming from the GFE.
68 const int kDeviceNotFound = 410; 63 const int kDeviceNotFound = 410;
69 const int kPendingApproval = 412; 64 const int kPendingApproval = 412;
70 const int kInternalServerError = 500; 65 const int kInternalServerError = 500;
71 const int kServiceUnavailable = 503; 66 const int kServiceUnavailable = 503;
72 const int kPolicyNotFound = 902; // This error is not sent as HTTP status code. 67 const int kPolicyNotFound = 902; // This error is not sent as HTTP status code.
73 68
74 // TODO(pastarmovj): Legacy error codes are here for comaptibility only. They 69 // TODO(pastarmovj): Legacy error codes are here for comaptibility only. They
75 // should be removed once the DM Server has been updated. 70 // should be removed once the DM Server has been updated.
76 const int kPendingApprovalLegacy = 491; 71 const int kPendingApprovalLegacy = 491;
77 const int kDeviceNotFoundLegacy = 901; 72 const int kDeviceNotFoundLegacy = 901;
78 73
74
79 #if defined(OS_CHROMEOS) 75 #if defined(OS_CHROMEOS)
80 // Machine info keys. 76 // Machine info keys.
81 const char kMachineInfoHWClass[] = "hardware_class"; 77 const char kMachineInfoHWClass[] = "hardware_class";
82 const char kMachineInfoBoard[] = "CHROMEOS_RELEASE_BOARD"; 78 const char kMachineInfoBoard[] = "CHROMEOS_RELEASE_BOARD";
83 #endif 79 #endif
84 80
85 } // namespace 81 } // namespace
86 82
87 // Helper class for URL query parameter encoding/decoding. 83 // Helper class for URL query parameter encoding/decoding.
88 class URLQueryParameters { 84 class URLQueryParameters {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 DISALLOW_COPY_AND_ASSIGN(DeviceManagementUnregisterJob); 377 DISALLOW_COPY_AND_ASSIGN(DeviceManagementUnregisterJob);
382 }; 378 };
383 379
384 // Handles policy request jobs. 380 // Handles policy request jobs.
385 class DeviceManagementPolicyJob : public DeviceManagementJobBase { 381 class DeviceManagementPolicyJob : public DeviceManagementJobBase {
386 public: 382 public:
387 DeviceManagementPolicyJob( 383 DeviceManagementPolicyJob(
388 DeviceManagementBackendImpl* backend_impl, 384 DeviceManagementBackendImpl* backend_impl,
389 const std::string& device_management_token, 385 const std::string& device_management_token,
390 const std::string& device_id, 386 const std::string& device_id,
391 const std::string& user_affiliation,
392 const em::DevicePolicyRequest& request, 387 const em::DevicePolicyRequest& request,
393 DeviceManagementBackend::DevicePolicyResponseDelegate* delegate) 388 DeviceManagementBackend::DevicePolicyResponseDelegate* delegate)
394 : DeviceManagementJobBase( 389 : DeviceManagementJobBase(
395 backend_impl, 390 backend_impl,
396 DeviceManagementBackendImpl::kValueRequestPolicy, 391 DeviceManagementBackendImpl::kValueRequestPolicy,
397 device_id), 392 device_id),
398 delegate_(delegate) { 393 delegate_(delegate) {
399 SetDeviceManagementToken(device_management_token); 394 SetDeviceManagementToken(device_management_token);
400 SetQueryParam(DeviceManagementBackendImpl::kParamUserAffiliation,
401 user_affiliation);
402 em::DeviceManagementRequest request_wrapper; 395 em::DeviceManagementRequest request_wrapper;
403 request_wrapper.mutable_policy_request()->CopyFrom(request); 396 request_wrapper.mutable_policy_request()->CopyFrom(request);
404 SetPayload(request_wrapper); 397 SetPayload(request_wrapper);
405 } 398 }
406 virtual ~DeviceManagementPolicyJob() {} 399 virtual ~DeviceManagementPolicyJob() {}
407 400
408 private: 401 private:
409 // DeviceManagementJobBase overrides. 402 // DeviceManagementJobBase overrides.
410 virtual void OnError(DeviceManagementBackend::ErrorCode error) { 403 virtual void OnError(DeviceManagementBackend::ErrorCode error) {
411 MetricPolicy sample; 404 MetricPolicy sample;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 const std::string& device_id, 531 const std::string& device_id,
539 const em::DeviceUnregisterRequest& request, 532 const em::DeviceUnregisterRequest& request,
540 DeviceUnregisterResponseDelegate* delegate) { 533 DeviceUnregisterResponseDelegate* delegate) {
541 AddJob(new DeviceManagementUnregisterJob(this, device_management_token, 534 AddJob(new DeviceManagementUnregisterJob(this, device_management_token,
542 device_id, request, delegate)); 535 device_id, request, delegate));
543 } 536 }
544 537
545 void DeviceManagementBackendImpl::ProcessPolicyRequest( 538 void DeviceManagementBackendImpl::ProcessPolicyRequest(
546 const std::string& device_management_token, 539 const std::string& device_management_token,
547 const std::string& device_id, 540 const std::string& device_id,
548 CloudPolicyDataStore::UserAffiliation affiliation,
549 const em::DevicePolicyRequest& request, 541 const em::DevicePolicyRequest& request,
550 DevicePolicyResponseDelegate* delegate) { 542 DevicePolicyResponseDelegate* delegate) {
551 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchRequested, 543 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchRequested,
552 kMetricPolicySize); 544 kMetricPolicySize);
553 AddJob(new DeviceManagementPolicyJob(this, device_management_token, device_id, 545 AddJob(new DeviceManagementPolicyJob(this, device_management_token, device_id,
554 UserAffiliationToString(affiliation),
555 request, delegate)); 546 request, delegate));
556 } 547 }
557 548
558 // static
559 const char* DeviceManagementBackendImpl::UserAffiliationToString(
560 CloudPolicyDataStore::UserAffiliation affiliation) {
561 switch (affiliation) {
562 case CloudPolicyDataStore::USER_AFFILIATION_MANAGED:
563 return kValueUserAffiliationManaged;
564 case CloudPolicyDataStore::USER_AFFILIATION_NONE:
565 return kValueUserAffiliationNone;
566 }
567 NOTREACHED();
568 return kValueUserAffiliationNone;
569 }
570
571 } // namespace policy 549 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_management_backend_impl.h ('k') | chrome/browser/policy/device_management_service_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698