Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/sdk/CookieParser.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/CookieParser.js b/third_party/WebKit/Source/devtools/front_end/sdk/CookieParser.js |
| index 118b790caf17b8b40b0319b7bd598ef44427c787..40b9ef748704b411c49f6a64aa82ac3a8f58f006 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/sdk/CookieParser.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/sdk/CookieParser.js |
| @@ -250,10 +250,11 @@ SDK.Cookie = class { |
| } |
| /** |
| - * @return {string} |
| + * TODO(allada) This should not rely on _attributes and instead store them individually. |
|
allada
2016/12/23 00:37:11
nit: We try not to add any non-jsdoc stuff in /**
|
| + * @return {!Protocol.Network.CookieSameSite} |
| */ |
| sameSite() { |
| - return this._attributes['samesite']; |
| + return /** @type {!Protocol.Network.CookieSameSite} */ (this._attributes['samesite']); |
| } |
| /** |
| @@ -307,6 +308,10 @@ SDK.Cookie = class { |
| return this._size; |
| } |
| + url() { |
| + return (this.secure() ? 'https://' : 'http://') + this.domain() + this.path(); |
| + } |
| + |
| /** |
| * @param {number} size |
| */ |
| @@ -349,8 +354,21 @@ SDK.Cookie = class { |
| * @param {function(?Protocol.Error)=} callback |
| */ |
| remove(callback) { |
| - this._target.networkAgent().deleteCookie( |
| - this.name(), (this.secure() ? 'https://' : 'http://') + this.domain() + this.path(), callback); |
| + this._target.networkAgent().deleteCookie(this.name(), this.url(), callback); |
| + } |
| + |
| + /** |
| + * @param {function(?Protocol.Error, boolean)=} callback |
| + */ |
| + save(callback) { |
| + var domain = this.domain(); |
| + if (!domain.startsWith('.')) |
| + domain = ''; |
| + var expires = undefined; |
| + if (this.expires()) |
| + expires = Math.floor(Date.parse(this.expires()) / 1000); |
| + this._target.networkAgent().setCookie(this.url(), this.name(), this.value(), domain, this.path(), this.secure(), |
| + this.httpOnly(), this.sameSite(), expires, callback); |
| } |
| }; |
| @@ -400,7 +418,7 @@ SDK.Cookies._parseProtocolCookie = function(target, protocolCookie) { |
| cookie.addAttribute('path', protocolCookie['path']); |
| cookie.addAttribute('port', protocolCookie['port']); |
| if (protocolCookie['expires']) |
| - cookie.addAttribute('expires', protocolCookie['expires']); |
| + cookie.addAttribute('expires', (new Date(protocolCookie['expires'])).toUTCString()); |
| if (protocolCookie['httpOnly']) |
| cookie.addAttribute('httpOnly'); |
| if (protocolCookie['secure']) |