| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 package org.chromium.chrome.browser.cookies; | 5 package org.chromium.chrome.browser.cookies; |
| 6 | 6 |
| 7 import java.io.DataInputStream; | 7 import java.io.DataInputStream; |
| 8 import java.io.DataOutputStream; | 8 import java.io.DataOutputStream; |
| 9 import java.io.IOException; | 9 import java.io.IOException; |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * Java representation of net/cookies/canonical_cookie.h. | 12 * Java representation of net/cookies/canonical_cookie.h. |
| 13 */ | 13 */ |
| 14 class CanonicalCookie { | 14 class CanonicalCookie { |
| 15 private final String mUrl; | 15 private final String mUrl; |
| 16 private final String mName; | 16 private final String mName; |
| 17 private final String mValue; | 17 private final String mValue; |
| 18 private final String mDomain; | 18 private final String mDomain; |
| 19 private final String mPath; | 19 private final String mPath; |
| 20 private final long mCreation; | 20 private final long mCreation; |
| 21 private final long mExpiration; | 21 private final long mExpiration; |
| 22 private final long mLastAccess; | 22 private final long mLastAccess; |
| 23 private final boolean mSecure; | 23 private final boolean mSecure; |
| 24 private final boolean mHttpOnly; | 24 private final boolean mHttpOnly; |
| 25 private final boolean mFirstPartyOnly; | 25 private final boolean mSameSite; |
| 26 private final int mPriority; | 26 private final int mPriority; |
| 27 | 27 |
| 28 /** Constructs a CanonicalCookie */ | 28 /** Constructs a CanonicalCookie */ |
| 29 CanonicalCookie(String url, String name, String value, String domain, String
path, | 29 CanonicalCookie(String url, String name, String value, String domain, String
path, |
| 30 long creation, long expiration, long lastAccess, boolean secure, boo
lean httpOnly, | 30 long creation, long expiration, long lastAccess, boolean secure, boo
lean httpOnly, |
| 31 boolean firstPartyOnly, int priority) { | 31 boolean sameSite, int priority) { |
| 32 mUrl = url; | 32 mUrl = url; |
| 33 mName = name; | 33 mName = name; |
| 34 mValue = value; | 34 mValue = value; |
| 35 mDomain = domain; | 35 mDomain = domain; |
| 36 mPath = path; | 36 mPath = path; |
| 37 mCreation = creation; | 37 mCreation = creation; |
| 38 mExpiration = expiration; | 38 mExpiration = expiration; |
| 39 mLastAccess = lastAccess; | 39 mLastAccess = lastAccess; |
| 40 mSecure = secure; | 40 mSecure = secure; |
| 41 mHttpOnly = httpOnly; | 41 mHttpOnly = httpOnly; |
| 42 mFirstPartyOnly = firstPartyOnly; | 42 mSameSite = sameSite; |
| 43 mPriority = priority; | 43 mPriority = priority; |
| 44 } | 44 } |
| 45 | 45 |
| 46 /** @return Priority of the cookie. */ | 46 /** @return Priority of the cookie. */ |
| 47 int getPriority() { | 47 int getPriority() { |
| 48 return mPriority; | 48 return mPriority; |
| 49 } | 49 } |
| 50 | 50 |
| 51 /** @return True if the cookie is HTTP only. */ | 51 /** @return True if the cookie is HTTP only. */ |
| 52 boolean isHttpOnly() { | 52 boolean isHttpOnly() { |
| 53 return mHttpOnly; | 53 return mHttpOnly; |
| 54 } | 54 } |
| 55 | 55 |
| 56 /** @return True if the cookie is First-Party only. */ | 56 /** @return True if the cookie is Same-Site. */ |
| 57 boolean isFirstPartyOnly() { | 57 boolean isSameSite() { |
| 58 return mFirstPartyOnly; | 58 return mSameSite; |
| 59 } | 59 } |
| 60 | 60 |
| 61 /** @return True if the cookie is secure. */ | 61 /** @return True if the cookie is secure. */ |
| 62 boolean isSecure() { | 62 boolean isSecure() { |
| 63 return mSecure; | 63 return mSecure; |
| 64 } | 64 } |
| 65 | 65 |
| 66 /** @return Last accessed time. */ | 66 /** @return Last accessed time. */ |
| 67 long getLastAccessDate() { | 67 long getLastAccessDate() { |
| 68 return mLastAccess; | 68 return mLastAccess; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 out.writeUTF(mUrl); | 113 out.writeUTF(mUrl); |
| 114 out.writeUTF(mName); | 114 out.writeUTF(mName); |
| 115 out.writeUTF(mValue); | 115 out.writeUTF(mValue); |
| 116 out.writeUTF(mDomain); | 116 out.writeUTF(mDomain); |
| 117 out.writeUTF(mPath); | 117 out.writeUTF(mPath); |
| 118 out.writeLong(mCreation); | 118 out.writeLong(mCreation); |
| 119 out.writeLong(mExpiration); | 119 out.writeLong(mExpiration); |
| 120 out.writeLong(mLastAccess); | 120 out.writeLong(mLastAccess); |
| 121 out.writeBoolean(mSecure); | 121 out.writeBoolean(mSecure); |
| 122 out.writeBoolean(mHttpOnly); | 122 out.writeBoolean(mHttpOnly); |
| 123 out.writeBoolean(mFirstPartyOnly); | 123 out.writeBoolean(mSameSite); |
| 124 out.writeInt(mPriority); | 124 out.writeInt(mPriority); |
| 125 } | 125 } |
| 126 | 126 |
| 127 /** | 127 /** |
| 128 * Constructs a cookie by deserializing a single entry from the | 128 * Constructs a cookie by deserializing a single entry from the |
| 129 * input stream. | 129 * input stream. |
| 130 * | 130 * |
| 131 * @param in Stream to read a cookie entry from. | 131 * @param in Stream to read a cookie entry from. |
| 132 */ | 132 */ |
| 133 static CanonicalCookie createFromStream(DataInputStream in) | 133 static CanonicalCookie createFromStream(DataInputStream in) |
| 134 throws IOException { | 134 throws IOException { |
| 135 return new CanonicalCookie(in.readUTF(), in.readUTF(), in.readUTF(), in.
readUTF(), | 135 return new CanonicalCookie(in.readUTF(), in.readUTF(), in.readUTF(), in.
readUTF(), |
| 136 in.readUTF(), in.readLong(), in.readLong(), in.readLong(), in.re
adBoolean(), | 136 in.readUTF(), in.readLong(), in.readLong(), in.readLong(), in.re
adBoolean(), |
| 137 in.readBoolean(), in.readBoolean(), in.readInt()); | 137 in.readBoolean(), in.readBoolean(), in.readInt()); |
| 138 } | 138 } |
| 139 } | 139 } |
| OLD | NEW |