Implement the update engine portion for new enterprise policies.

Enterprises need the ability to stop the auto updates and pin clients
to a given target version. This CL adds support for these features in
the update_engine.

BUG=27307: Implement StopAutoUpdate based on enterprise policy
TEST=Added new unit tests, manually tested all cases on ZGB.
CQ-DEPEND=I523c3f67e0cb07fd24744dc0a30382ff2fe2128a
Change-Id: Id576401afc6d2c93f0e9ece7c6c0ddcf4b1bc00d
Reviewed-on: https://gerrit.chromium.org/gerrit/17867
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index bbcc00b..c97a9a7 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -100,7 +100,14 @@
   if (event == NULL) {
     body = GetPingBody(ping_active_days, ping_roll_call_days);
     if (!ping_only) {
-      body += "        <o:updatecheck></o:updatecheck>\n";
+      body += StringPrintf(
+          "        <o:updatecheck"
+          " updatedisabled=\"%s\""
+          " targetversionprefix=\"%s\""
+          "></o:updatecheck>\n",
+          params.update_disabled ? "true" : "false",
+          XmlEncode(params.target_version_prefix).c_str());
+
       // If this is the first update check after a reboot following a previous
       // update, generate an event containing the previous version number. If
       // the previous version preference file doesn't exist the event is still
@@ -233,6 +240,7 @@
                                     ping_active_days_,
                                     ping_roll_call_days_,
                                     prefs_));
+
   http_fetcher_->SetPostData(request_post.data(), request_post.size(),
                              kHttpContentTypeTextXml);
   LOG(INFO) << "Posting an Omaha request to " << params_.update_url;
@@ -451,6 +459,12 @@
     return;
   }
 
+  if (params_.update_disabled) {
+    LOG(ERROR) << "Ignoring Omaha updates as updates are disabled by policy.";
+    completer.set_code(kActionCodeOmahaUpdateIgnoredPerPolicy);
+    return;
+  }
+
   // In best-effort fashion, fetch the rest of the expected attributes
   // from the updatecheck node, then return the object
   output_object.update_exists = true;