shill: Broadcast OLP and Usage URL cellular service properties.

This patch also switches the deprecated string payment url property to the new
dict OLP property.

BUG=chromium-os:25612,chromium-os:25011
TEST=unit tests

Change-Id: I67beaafef936bb4f2e36d2a2faf14c1280eb70be
Reviewed-on: https://gerrit.chromium.org/gerrit/15202
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Eric Shienbrood <ers@chromium.org>
Commit-Ready: Darin Petkov <petkov@chromium.org>
diff --git a/cellular_service.cc b/cellular_service.cc
index 100c947..ea7ea36 100644
--- a/cellular_service.cc
+++ b/cellular_service.cc
@@ -20,6 +20,57 @@
 // static
 const char CellularService::kServiceType[] = "cellular";
 
+// TODO(petkov): Add these to system_api/dbus/service_constants.h
+namespace {
+const char kKeyOLPURL[] = "url";
+const char kKeyOLPMethod[] = "method";
+const char kKeyOLPPostData[] = "postdata";
+}  // namespace {}
+
+CellularService::OLP::OLP() {
+  SetURL("");
+  SetMethod("");
+  SetPostData("");
+}
+
+CellularService::OLP::~OLP() {}
+
+void CellularService::OLP::CopyFrom(const OLP &olp) {
+  dict_ = olp.dict_;
+}
+
+bool CellularService::OLP::Equals(const OLP &olp) const {
+  return dict_ == olp.dict_;
+}
+
+const string &CellularService::OLP::GetURL() const {
+  return dict_.find(kKeyOLPURL)->second;
+}
+
+void CellularService::OLP::SetURL(const string &url) {
+  dict_[kKeyOLPURL] = url;
+}
+
+const string &CellularService::OLP::GetMethod() const {
+  return dict_.find(kKeyOLPMethod)->second;
+}
+
+void CellularService::OLP::SetMethod(const string &method) {
+  dict_[kKeyOLPMethod] = method;
+}
+
+const string &CellularService::OLP::GetPostData() const {
+  return dict_.find(kKeyOLPPostData)->second;
+}
+
+void CellularService::OLP::SetPostData(const string &post_data) {
+  dict_[kKeyOLPPostData] = post_data;
+}
+
+const Stringmap &CellularService::OLP::ToDict() const {
+  return dict_;
+}
+
 CellularService::CellularService(ControlInterface *control_interface,
                                  EventDispatcher *dispatcher,
                                  Metrics *metrics,
@@ -36,7 +87,8 @@
                                 &last_good_apn_info_);
   store->RegisterConstString(flimflam::kNetworkTechnologyProperty,
                              &network_technology_);
-  store->RegisterConstString(flimflam::kPaymentURLProperty, &payment_url_);
+  store->RegisterConstStringmap(flimflam::kPaymentPortalProperty,
+                                &olp_.ToDict());
   store->RegisterConstString(flimflam::kRoamingStateProperty, &roaming_state_);
   store->RegisterConstStringmap(flimflam::kServingOperatorProperty,
                                 &serving_operator_.ToDict());
@@ -90,6 +142,23 @@
   adaptor()->EmitStringChanged(flimflam::kActivationStateProperty, state);
 }
 
+void CellularService::SetOLP(const OLP &olp) {
+  if (olp_.Equals(olp)) {
+    return;
+  }
+  olp_.CopyFrom(olp);
+  adaptor()->EmitStringmapChanged(flimflam::kPaymentPortalProperty,
+                                  olp.ToDict());
+}
+
+void CellularService::SetUsageURL(const std::string &url) {
+  if (url == usage_url_) {
+    return;
+  }
+  usage_url_ = url;
+  adaptor()->EmitStringChanged(flimflam::kUsageURLProperty, url);
+}
+
 void CellularService::SetNetworkTechnology(const string &technology) {
   if (technology == network_technology_) {
     return;