summaryrefslogtreecommitdiffstats
path: root/chrome/browser/policy/device_management_backend_impl.h
diff options
context:
space:
mode:
authormnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-03 14:40:44 +0000
committermnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-03 14:40:44 +0000
commitbb58e6e839255777617a32a77ccb85a9a06ce041 (patch)
treeed462618eb7238b8b65b6897a96c709c1ad5ae2d /chrome/browser/policy/device_management_backend_impl.h
parent2976306404950c06c6ce91374e977fd1ce85809d (diff)
downloadchromium_src-bb58e6e839255777617a32a77ccb85a9a06ce041.zip
chromium_src-bb58e6e839255777617a32a77ccb85a9a06ce041.tar.gz
chromium_src-bb58e6e839255777617a32a77ccb85a9a06ce041.tar.bz2
Implement device management backend.
This adds a device management backend implementation running over HTTP. BUG=None TEST=unit tests in device_management_backend_impl_unittest.cc Review URL: http://codereview.chromium.org/4098004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64912 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/policy/device_management_backend_impl.h')
-rw-r--r--chrome/browser/policy/device_management_backend_impl.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/chrome/browser/policy/device_management_backend_impl.h b/chrome/browser/policy/device_management_backend_impl.h
new file mode 100644
index 0000000..648ca55
--- /dev/null
+++ b/chrome/browser/policy/device_management_backend_impl.h
@@ -0,0 +1,84 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_BACKEND_IMPL_H_
+#define CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_BACKEND_IMPL_H_
+#pragma once
+
+#include <map>
+#include <string>
+
+#include "chrome/browser/policy/device_management_backend.h"
+#include "chrome/common/net/url_fetcher.h"
+#include "googleurl/src/gurl.h"
+
+class URLRequestContextGetter;
+
+namespace policy {
+
+class ResponseHandler;
+class URLQueryParameters;
+
+// Device management backend implementation. This implementation makes HTTP
+// requests to the policy server through the net layer.
+class DeviceManagementBackendImpl : public DeviceManagementBackend,
+ public URLFetcher::Delegate {
+ public:
+ explicit DeviceManagementBackendImpl(const std::string& server_url);
+ virtual ~DeviceManagementBackendImpl();
+
+ // GoogleAppsPolicyService overrides:
+ virtual void ProcessRegisterRequest(
+ const std::string& auth_token,
+ const std::string& device_id,
+ const em::DeviceRegisterRequest& request,
+ DeviceRegisterResponseDelegate* response_delegate);
+ virtual void ProcessUnregisterRequest(
+ const std::string& device_management_token,
+ const em::DeviceUnregisterRequest& request,
+ DeviceUnregisterResponseDelegate* response_delegate);
+ virtual void ProcessPolicyRequest(
+ const std::string& device_management_token,
+ const em::DevicePolicyRequest& request,
+ DevicePolicyResponseDelegate* response_delegate);
+
+ // Get the agent string (used for HTTP user agent and as agent passed to the
+ // server).
+ static std::string GetAgentString();
+
+ private:
+ typedef std::map<const URLFetcher*, ResponseHandler*> ResponseHandlerMap;
+
+ // URLFetcher::Delegate override.
+ virtual void OnURLFetchComplete(const URLFetcher* source,
+ const GURL& url,
+ const URLRequestStatus& status,
+ int response_code,
+ const ResponseCookies& cookies,
+ const std::string& data);
+
+ // Create a URLFetcher for a given request message and response handler.
+ void CreateFetcher(const em::DeviceManagementRequest& request,
+ ResponseHandler* handler,
+ const std::string& query_params,
+ const std::string& extra_headers);
+
+ // Fill in the common query parameters.
+ void PutCommonQueryParameters(URLQueryParameters* params);
+
+ // Server at which to contact the service.
+ const std::string server_url_;
+
+ // The request context we use.
+ scoped_refptr<URLRequestContextGetter> request_context_getter_;
+
+ // Keeps track of all in-flight requests an their response handlers.
+ ResponseHandlerMap response_handlers_;
+
+ DISALLOW_COPY_AND_ASSIGN(DeviceManagementBackendImpl);
+};
+
+} // namespace policy
+
+#endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_BACKEND_IMPL_H_