| 34 | } |
| 35 | |
| 36 | BrowserCookie BrowserCookie::FromJson(const Json::Value& json_cookie) { |
| 37 | BrowserCookie cookie; |
| 38 | cookie.name_ = json_cookie["name"].asString(); |
| 39 | cookie.value_ = json_cookie["value"].asString(); |
| 40 | cookie.is_secure_ = json_cookie["secure"].asBool(); |
| 41 | |
| 42 | Json::Value expiry = json_cookie.get("expiry", Json::Value::null); |
| 43 | if (!expiry.isNull()) { |
| 44 | if (expiry.isNumeric()) { |
| 45 | cookie.expiration_time_ = expiry.asUInt64(); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | Json::Value domain = json_cookie.get("domain", Json::Value::null); |
| 50 | if (!domain.isNull() && domain.isString() && domain.asString() != "") { |
| 51 | cookie.domain_ = domain.asString(); |
| 52 | } |
| 53 | |
| 54 | Json::Value path = json_cookie.get("path", Json::Value::null); |
| 55 | if (!path.isNull() && path.isString() && path.asString() != "") { |
| 56 | cookie.path_ = path.asString(); |
| 57 | } |
| 58 | return cookie; |
| 59 | } |
| 60 | |
| 61 | std::string BrowserCookie::ToString() const { |
| 62 | std::string cookie_string(this->name_ + |