OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/test/webdriver/cookie.h" | 5 #include "chrome/test/webdriver/cookie.h" |
6 | 6 |
7 #include <time.h> | 7 #include <time.h> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 if (!dict.GetBoolean("secure", &secure_)) { | 66 if (!dict.GetBoolean("secure", &secure_)) { |
67 secure_ = false; | 67 secure_ = false; |
68 } | 68 } |
69 | 69 |
70 if (dict.HasKey("expiry")) { | 70 if (dict.HasKey("expiry")) { |
71 // The expiration time need only be a number with seconds since UTC epcoh; | 71 // The expiration time need only be a number with seconds since UTC epcoh; |
72 // it could be either a floating point or integer number. | 72 // it could be either a floating point or integer number. |
73 double expiry; | 73 double expiry; |
74 if (!dict.GetDouble("expiry", &expiry)) { | 74 if (!dict.GetDouble("expiry", &expiry)) { |
75 int tmp; | 75 return; // Expiry is not a number, so the cookie is invalid. |
76 if (!dict.GetInteger("expiry", &tmp)) | |
77 return; // Expiry is not a number, so the cookie is invalid. | |
78 expiry = static_cast<double>(tmp); | |
79 } | 76 } |
80 | 77 |
81 expiration_ = base::Time::FromDoubleT(expiry); | 78 expiration_ = base::Time::FromDoubleT(expiry); |
82 } | 79 } |
83 | 80 |
84 valid_ = true; | 81 valid_ = true; |
85 } | 82 } |
86 | 83 |
87 Cookie::~Cookie() {} | 84 Cookie::~Cookie() {} |
88 | 85 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 cookie += " secure;"; | 154 cookie += " secure;"; |
158 } | 155 } |
159 if (http_) { | 156 if (http_) { |
160 cookie += " http_only;"; | 157 cookie += " http_only;"; |
161 } | 158 } |
162 | 159 |
163 return cookie; | 160 return cookie; |
164 } | 161 } |
165 | 162 |
166 } // namespace webdriver | 163 } // namespace webdriver |
OLD | NEW |