Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(651)

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/CookieParser.js

Issue 2567873002: DevTools: Add ability to add and edit cookies (Closed)
Patch Set: Rebase. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/resources/ResourcesPanel.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3a0f35825a7d35474ede246905575c73f4ff55e7..e9b03b9f12a576629bc992573fa7bea99d7064d4 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}
+ * @return {!Protocol.Network.CookieSameSite}
*/
sameSite() {
- return this._attributes['samesite'];
+ // TODO(allada) This should not rely on _attributes and instead store them individually.
+ return /** @type {!Protocol.Network.CookieSameSite} */ (this._attributes['samesite']);
}
/**
@@ -287,7 +288,7 @@ SDK.Cookie = class {
}
/**
- * @return {string}
+ * @return {number}
*/
expires() {
return this._attributes['expires'];
@@ -308,6 +309,13 @@ SDK.Cookie = class {
}
/**
+ * @return {string}
+ */
+ url() {
+ return (this.secure() ? 'https://' : 'http://') + this.domain() + this.path();
+ }
+
+ /**
* @param {number} size
*/
setSize(size) {
@@ -349,8 +357,29 @@ 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(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, mycallback);
+
+ /**
+ * @param {?Protocol.Error} error
+ * @param {boolean} success
+ */
+ function mycallback(error, success) {
+ callback(error ? false : success);
+ }
}
};
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/resources/ResourcesPanel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698