update_engine: Remove legacy logic and tests.

This removes logic that was used for tracking whether updates were
disabled by device policy, and unit tests that checked for the presence
of such logic. This logic is now part of the Update Manager's
UpdateCheckAllowed policy request. It is safe to remove the old check
because it'll always conclude that the update request can be sent, given
that the said policy has concluded the same.

BUG=None
TEST=Unit tests.

Change-Id: Ibbb3728f7239f608a6317bc5a8b76cac7f54bc5f
Reviewed-on: https://chromium-review.googlesource.com/220876
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index cb436a3..e4b8a7b 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -104,11 +104,6 @@
   if (event == nullptr) {
     app_body = GetPingXml(ping_active_days, ping_roll_call_days);
     if (!ping_only) {
-      // not passing update_disabled to Omaha because we want to
-      // get the update and report with UpdateDeferred result so that
-      // borgmon charts show up updates that are deferred. This is also
-      // the expected behavior when we move to Omaha v3.0 protocol, so it'll
-      // be consistent.
       app_body += base::StringPrintf(
           "        <updatecheck targetversionprefix=\"%s\""
           "></updatecheck>\n",
@@ -1287,11 +1282,6 @@
 
 bool OmahaRequestAction::ShouldIgnoreUpdate(
     const OmahaResponse& response) const {
-  if (params_->update_disabled()) {
-    LOG(INFO) << "Ignoring Omaha updates as updates are disabled by policy.";
-    return true;
-  }
-
   // Note: policy decision to not update to a version we rolled back from.
   string rollback_version =
       system_state_->payload_state()->GetRollbackVersion();
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index 572721d..0248c22 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -62,7 +62,6 @@
     false,   // delta okay
     false,   // interactive
     "http://url",
-    false,   // update_disabled
     "",      // target_version_prefix
     false,   // use_p2p_for_downloading
     false);  // use_p2p_for_sharing
@@ -417,37 +416,6 @@
   EXPECT_EQ("20101020", response.deadline);
 }
 
-TEST(OmahaRequestActionTest, ValidUpdateBlockedByPolicyTest) {
-  OmahaResponse response;
-  OmahaRequestParams params = kDefaultTestParams;
-  params.set_update_disabled(true);
-  ASSERT_FALSE(
-      TestUpdateCheck(nullptr,  // prefs
-                      nullptr,  // payload_state
-                      nullptr,  // p2p_manager
-                      nullptr,  // connection_manager
-                      &params,
-                      GetUpdateResponse(OmahaRequestParams::kAppId,
-                                        "1.2.3.4",  // version
-                                        "http://more/info",
-                                        "true",  // prompt
-                                        "http://code/base/",  // dl url
-                                        "file.signed",  // file name
-                                        "HASH1234=",  // checksum
-                                        "false",  // needs admin
-                                        "123",  // size
-                                        ""),  // deadline
-                      -1,
-                      false,  // ping_only
-                      ErrorCode::kOmahaUpdateIgnoredPerPolicy,
-                      metrics::CheckResult::kUpdateAvailable,
-                      metrics::CheckReaction::kIgnored,
-                      metrics::DownloadErrorCode::kUnset,
-                      &response,
-                      nullptr));
-  EXPECT_FALSE(response.update_exists);
-}
-
 TEST(OmahaRequestActionTest, ValidUpdateBlockedByConnection) {
   OmahaResponse response;
   // Set up a connection manager that doesn't allow a valid update over
@@ -524,28 +492,6 @@
   EXPECT_FALSE(response.update_exists);
 }
 
-TEST(OmahaRequestActionTest, NoUpdatesSentWhenBlockedByPolicyTest) {
-  OmahaResponse response;
-  OmahaRequestParams params = kDefaultTestParams;
-  params.set_update_disabled(true);
-  ASSERT_TRUE(
-      TestUpdateCheck(nullptr,  // prefs
-                      nullptr,  // payload_state
-                      nullptr,  // p2p_manager
-                      nullptr,  // connection_manager
-                      &params,
-                      GetNoUpdateResponse(OmahaRequestParams::kAppId),
-                      -1,
-                      false,  // ping_only
-                      ErrorCode::kSuccess,
-                      metrics::CheckResult::kNoUpdateAvailable,
-                      metrics::CheckReaction::kUnset,
-                      metrics::DownloadErrorCode::kUnset,
-                      &response,
-                      nullptr));
-  EXPECT_FALSE(response.update_exists);
-}
-
 TEST(OmahaRequestActionTest, WallClockBasedWaitAloneCausesScattering) {
   OmahaResponse response;
   OmahaRequestParams params = kDefaultTestParams;
@@ -1205,7 +1151,6 @@
                             false,   // delta okay
                             false,   // interactive
                             "http://url",
-                            false,   // update_disabled
                             "",      // target_version_prefix
                             false,   // use_p2p_for_downloading
                             false);  // use_p2p_for_sharing
@@ -1335,42 +1280,6 @@
 }
 
 
-TEST(OmahaRequestActionTest, FormatUpdateDisabledOutputTest) {
-  vector<char> post_data;
-  NiceMock<PrefsMock> prefs;
-  EXPECT_CALL(prefs, GetString(kPrefsPreviousVersion, _))
-      .WillOnce(DoAll(SetArgumentPointee<1>(string("")), Return(true)));
-  EXPECT_CALL(prefs, SetString(kPrefsPreviousVersion, _)).Times(1);
-  OmahaRequestParams params = kDefaultTestParams;
-  params.set_update_disabled(true);
-  ASSERT_FALSE(TestUpdateCheck(&prefs,
-                               nullptr,  // payload_state
-                               nullptr,  // p2p_manager
-                               nullptr,  // connection_manager
-                               &params,
-                               "invalid xml>",
-                               -1,
-                               false,  // ping_only
-                               ErrorCode::kOmahaRequestXMLParseError,
-                               metrics::CheckResult::kParsingError,
-                               metrics::CheckReaction::kUnset,
-                               metrics::DownloadErrorCode::kUnset,
-                               nullptr,  // response
-                               &post_data));
-  // convert post_data to string
-  string post_str(&post_data[0], post_data.size());
-  EXPECT_NE(post_str.find(
-      "        <ping active=\"1\" a=\"-1\" r=\"-1\"></ping>\n"
-      "        <updatecheck targetversionprefix=\"\"></updatecheck>\n"),
-      string::npos);
-  EXPECT_NE(post_str.find("hardware_class=\"OEM MODEL 09235 7471\""),
-            string::npos);
-  EXPECT_NE(post_str.find("fw_version=\"ChromeOSFirmware.1.0\""),
-            string::npos);
-  EXPECT_NE(post_str.find("ec_version=\"0X0A1\""),
-            string::npos);
-}
-
 TEST(OmahaRequestActionTest, FormatSuccessEventOutputTest) {
   vector<char> post_data;
   TestEvent(kDefaultTestParams,
@@ -1455,7 +1364,6 @@
                               delta_okay,
                               false,  // interactive
                               "http://url",
-                              false,  // update_disabled
                               "",     // target_version_prefix
                               false,  // use_p2p_for_downloading
                               false);  // use_p2p_for_sharing
@@ -1503,7 +1411,6 @@
                               true,   // delta_okay
                               interactive,
                               "http://url",
-                              false,  // update_disabled
                               "",     // target_version_prefix
                               false,  // use_p2p_for_downloading
                               false);  // use_p2p_for_sharing
diff --git a/omaha_request_params.h b/omaha_request_params.h
index 4d249b3..7e2486a 100644
--- a/omaha_request_params.h
+++ b/omaha_request_params.h
@@ -39,7 +39,6 @@
         canary_app_id_(kAppId),
         delta_okay_(true),
         interactive_(false),
-        update_disabled_(false),
         wall_clock_based_wait_enabled_(false),
         update_check_count_wait_enabled_(false),
         min_update_checks_needed_(kDefaultMinUpdateChecks),
@@ -67,7 +66,6 @@
                      bool in_delta_okay,
                      bool in_interactive,
                      const std::string& in_update_url,
-                     bool in_update_disabled,
                      const std::string& in_target_version_prefix,
                      bool in_use_p2p_for_downloading,
                      bool in_use_p2p_for_sharing)
@@ -88,7 +86,6 @@
         delta_okay_(in_delta_okay),
         interactive_(in_interactive),
         update_url_(in_update_url),
-        update_disabled_(in_update_disabled),
         target_version_prefix_(in_target_version_prefix),
         wall_clock_based_wait_enabled_(false),
         update_check_count_wait_enabled_(false),
@@ -132,11 +129,6 @@
   inline void set_update_url(const std::string& url) { update_url_ = url; }
   inline std::string update_url() const { return update_url_; }
 
-  inline void set_update_disabled(bool disabled) {
-    update_disabled_ = disabled;
-  }
-  inline bool update_disabled() const { return update_disabled_; }
-
   inline void set_target_version_prefix(const std::string& prefix) {
     target_version_prefix_ = prefix;
   }
@@ -356,9 +348,6 @@
   // The URL to send the Omaha request to.
   std::string update_url_;
 
-  // True if we've been told to block updates per enterprise policy.
-  bool update_disabled_;
-
   // Prefix of the target OS version that the enterprise wants this device
   // to be pinned to. It's empty otherwise.
   std::string target_version_prefix_;
diff --git a/update_attempter.cc b/update_attempter.cc
index bc18945..9a91d51 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -409,9 +409,7 @@
     omaha_request_params_->UpdateDownloadChannel();
   }
 
-  LOG(INFO) << "update_disabled = "
-            << utils::ToString(omaha_request_params_->update_disabled())
-            << ", target_version_prefix = "
+  LOG(INFO) << "target_version_prefix = "
             << omaha_request_params_->target_version_prefix()
             << ", scatter_factor_in_seconds = "
             << utils::FormatSecs(scatter_factor_.InSeconds());