Add support to update_engine_client for -app_version and -omaha_url.

These options prevent auto-detection of these parameters.
Note that this CL makes the check_for_update DBus method obsolete from
the client's point of view.

BUG=4593
TEST=unit tests, gmerged on device and tried the client with different options.

Review URL: http://codereview.chromium.org/3048008
diff --git a/update_engine_client.cc b/update_engine_client.cc
index e68a7aa..bb4beaa 100644
--- a/update_engine_client.cc
+++ b/update_engine_client.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include <string>
+
 #include <gflags/gflags.h>
 #include <glib.h>
 
@@ -18,12 +20,17 @@
 using chromeos_update_engine::kUpdateEngineServicePath;
 using chromeos_update_engine::kUpdateEngineServiceInterface;
 using chromeos_update_engine::utils::GetGErrorMessage;
+using std::string;
 
-DEFINE_bool(status, false, "Print the status to stdout.");
-DEFINE_bool(force_update, false,
-            "Force an update, even over an expensive network.");
+DEFINE_string(app_version, "",
+              "Force the current app version.");
 DEFINE_bool(check_for_update, false,
             "Initiate check for updates.");
+DEFINE_bool(force_update, false,
+            "Force an update, even over an expensive network.");
+DEFINE_string(omaha_url, "",
+              "The URL of the Omaha update server.");
+DEFINE_bool(status, false, "Print the status to stdout.");
 DEFINE_bool(watch_for_updates, false,
             "Listen for status updates and print them to the screen.");
 
@@ -134,14 +141,18 @@
   g_main_loop_unref(loop);
 }
 
-bool CheckForUpdates(bool force) {
+bool CheckForUpdates(bool force, const string& app_version,
+                     const string& omaha_url) {
   DBusGProxy* proxy;
   GError* error = NULL;
 
   CHECK(GetProxy(&proxy));
 
   gboolean rc =
-      org_chromium_UpdateEngineInterface_check_for_update(proxy, &error);
+      org_chromium_UpdateEngineInterface_attempt_update(proxy,
+                                                        app_version.c_str(),
+                                                        omaha_url.c_str(),
+                                                        &error);
   CHECK_EQ(rc, TRUE) << "Error checking for update: "
                      << GetGErrorMessage(error);
   return true;
@@ -164,12 +175,14 @@
     }
     return 0;
   }
-  if (FLAGS_force_update || FLAGS_check_for_update) {
+  if (FLAGS_force_update || FLAGS_check_for_update ||
+      !FLAGS_app_version.empty() || !FLAGS_omaha_url.empty()) {
     LOG(INFO) << "Initiating update check and install.";
     if (FLAGS_force_update) {
       LOG(INFO) << "Will not abort due to being on expensive network.";
     }
-    CHECK(CheckForUpdates(FLAGS_force_update))
+    CHECK(CheckForUpdates(FLAGS_force_update, FLAGS_app_version,
+                          FLAGS_omaha_url))
         << "Update check/initiate update failed.";
     return 0;
   }