update_engine: Add rollback_allowed policy in Omaha requests

Send rollback_allowed="true" parameter to Omaha if rollback is
allowed through enterprise policy.

This parameter indicates to Omaha that the returned image might
be a rollback image, if the targetversionprefix parameter is set
and it is an earlier version than the one which is currently on
the device.

Also, this CL changes update_engine behavior to only send
targetversionprefix to Omaha if it's not empty.

BUG=chromium:814830
TEST='cros_run_unit_tests --board=cyan --packages update_engine'

Change-Id: Iaa5503e217631311fb9ba3a5237ccbfedf04afe9
Reviewed-on: https://chromium-review.googlesource.com/932123
Commit-Ready: Marton Hunyady <hunyadym@chromium.org>
Tested-by: Marton Hunyady <hunyadym@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
diff --git a/omaha_request_params.h b/omaha_request_params.h
index a57370d..62cbdab 100644
--- a/omaha_request_params.h
+++ b/omaha_request_params.h
@@ -49,6 +49,7 @@
         os_version_(kOsVersion),
         delta_okay_(true),
         interactive_(false),
+        rollback_allowed_(false),
         wall_clock_based_wait_enabled_(false),
         update_check_count_wait_enabled_(false),
         min_update_checks_needed_(kDefaultMinUpdateChecks),
@@ -123,6 +124,12 @@
     return target_version_prefix_;
   }
 
+  inline void set_rollback_allowed(bool rollback_allowed) {
+    rollback_allowed_ = rollback_allowed;
+  }
+
+  inline bool rollback_allowed() const { return rollback_allowed_; }
+
   inline void set_wall_clock_based_wait_enabled(bool enabled) {
     wall_clock_based_wait_enabled_ = enabled;
   }
@@ -301,6 +308,9 @@
   // to be pinned to. It's empty otherwise.
   std::string target_version_prefix_;
 
+  // Whether the client is accepting rollback images too.
+  bool rollback_allowed_;
+
   // True if scattering is enabled, in which case waiting_period_ specifies the
   // amount of absolute time that we've to wait for before sending a request to
   // Omaha.