AU: add an interactive flag to Omaha requests

Such a flag can be used to distinguish between user-initiated
(interactive) checks and those that are due to background scheduling. In
the former case, we may want to suppress the probabilistic throttling
that's commonly used with latest releases. This CL piggybacks the new
functionality on top of an existing dataflow used for distinguishing
between interactive / scheduled checks, only it pushes it further so it
is evident in the Omaha request as well.

Comes with a unit test for ensuring that the Omaha flag is set as
expected.

BUG=chromium-os:26594
TEST=Dbus initiated checks correctly tainted

Change-Id: Ia2b3ff5ce3a866c64e453557028b8cbd92c1a258
Reviewed-on: https://gerrit.chromium.org/gerrit/41081
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index 69d5895..276f189 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -50,6 +50,7 @@
     "unittest",
     "OEM MODEL 09235 7471",
     false,  // delta okay
+    false,  // interactive
     "http://url",
     false, // update_disabled
     ""); // target_version_prefix);
@@ -820,6 +821,7 @@
                             "unittest_track&lt;",
                             "<OEM MODEL>",
                             false,  // delta okay
+                            false,  // interactive
                             "http://url",
                             false,   // update_disabled
                             "");  // target_version_prefix
@@ -1031,6 +1033,7 @@
                               "unittest_track",
                               "OEM MODEL REV 1234",
                               delta_okay,
+                              false,  // interactive
                               "http://url",
                               false, // update_disabled
                               "");   // target_version_prefix
@@ -1050,6 +1053,42 @@
   }
 }
 
+TEST(OmahaRequestActionTest, FormatInteractiveOutputTest) {
+  for (int i = 0; i < 2; i++) {
+    bool interactive = i == 1;
+    const char* interactive_str = interactive ? "true" : "false";
+    vector<char> post_data;
+    OmahaRequestParams params(OmahaRequestParams::kOsPlatform,
+                              OmahaRequestParams::kOsVersion,
+                              "service_pack",
+                              "x86-generic",
+                              OmahaRequestParams::kAppId,
+                              "0.1.0.0",
+                              "en-US",
+                              "unittest_track",
+                              "OEM MODEL REV 1234",
+                              true,  // delta_okay
+                              interactive,
+                              "http://url",
+                              false, // update_disabled
+                              "");   // target_version_prefix
+    ASSERT_FALSE(TestUpdateCheck(NULL,  // prefs
+                                 params,
+                                 "invalid xml>",
+                                 -1,
+                                 false,  // ping_only
+                                 kActionCodeOmahaRequestXMLParseError,
+                                 NULL,
+                                 &post_data));
+    // convert post_data to string
+    string post_str(&post_data[0], post_data.size());
+    EXPECT_NE(post_str.find(StringPrintf(" userinitiated=\"%s\"",
+                                         interactive_str)),
+              string::npos)
+        << "i = " << i;
+  }
+}
+
 TEST(OmahaRequestActionTest, OmahaEventTest) {
   OmahaEvent default_event;
   EXPECT_EQ(OmahaEvent::kTypeUnknown, default_event.type);