update_engine: UM: More permissive use of P2P.

The logic we had in ChromeOSPolicy so far was not as permissive as the
original in P2PManagerImpl::IsP2PEnabled(). Specifically, we want to
allow P2P even if a device policy does not have this value set, but
otherwise indicates that the device is enterprise-enrolled.

This also renames the owner variable name so it is consistent with the
rest of the variable names (no get_ prefix).

BUG=chromium:384087
TEST=Unit tests.

Change-Id: I184ebaebc168352510ea3ed0277ea74167edf666
Reviewed-on: https://chromium-review.googlesource.com/221476
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/update_manager/chromeos_policy.cc b/update_manager/chromeos_policy.cc
index a3d6495..291a147 100644
--- a/update_manager/chromeos_policy.cc
+++ b/update_manager/chromeos_policy.cc
@@ -360,13 +360,22 @@
       }
     }
 
-    // Determine whether use of P2P is allowed by policy.
+    // Determine whether use of P2P is allowed by policy. Even if P2P is not
+    // explicitly allowed, we allow it if the device is enterprise enrolled
+    // (that is, missing or empty owner string).
     const bool* policy_au_p2p_enabled_p = ec->GetValue(
         dp_provider->var_au_p2p_enabled());
-    result->p2p_allowed = policy_au_p2p_enabled_p && *policy_au_p2p_enabled_p;
+    if (policy_au_p2p_enabled_p) {
+      result->p2p_allowed = *policy_au_p2p_enabled_p;
+    } else {
+      const string* policy_owner_p = ec->GetValue(dp_provider->var_owner());
+      if (!policy_owner_p || policy_owner_p->empty())
+        result->p2p_allowed = true;
+    }
   }
 
-  // Enable P2P, if so mandated by the updater configuration.
+  // Enable P2P, if so mandated by the updater configuration. This is additive
+  // to whether or not P2P is allowed per device policy (see above).
   if (!result->p2p_allowed) {
     const bool* updater_p2p_enabled_p = ec->GetValue(
         state->updater_provider()->var_p2p_enabled());