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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/cookies/CookiesFetcher.java

Issue 876973003: Implement the "first-party-only" cookie flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tiny bug. Created 5 years, 10 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 unified diff | Download patch
OLDNEW
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 android.content.Context; 7 import android.content.Context;
8 import android.os.AsyncTask; 8 import android.os.AsyncTask;
9 import android.util.Log; 9 import android.util.Log;
10 10
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 cookie.getUrl(), 166 cookie.getUrl(),
167 cookie.getName(), 167 cookie.getName(),
168 cookie.getValue(), 168 cookie.getValue(),
169 cookie.getDomain(), 169 cookie.getDomain(),
170 cookie.getPath(), 170 cookie.getPath(),
171 cookie.getCreationDate(), 171 cookie.getCreationDate(),
172 cookie.getExpirationDate(), 172 cookie.getExpirationDate(),
173 cookie.getLastAccessDate(), 173 cookie.getLastAccessDate(),
174 cookie.isSecure(), 174 cookie.isSecure(),
175 cookie.isHttpOnly(), 175 cookie.isHttpOnly(),
176 cookie.isFirstParty(),
176 cookie.getPriority() 177 cookie.getPriority()
177 ); 178 );
178 } 179 }
179 } 180 }
180 }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); 181 }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
181 } 182 }
182 183
183 /** 184 /**
184 * Ensure the incognito cookies are deleted when the incognito profile is go ne. 185 * Ensure the incognito cookies are deleted when the incognito profile is go ne.
185 * 186 *
186 * @param context Context for accessing the file system. 187 * @param context Context for accessing the file system.
187 * @return Whether or not the cookies were deleted. 188 * @return Whether or not the cookies were deleted.
188 */ 189 */
189 public static boolean deleteCookiesIfNecessary(Context context) { 190 public static boolean deleteCookiesIfNecessary(Context context) {
190 try { 191 try {
191 CookiesFetcher fetcher = new CookiesFetcher(context); 192 CookiesFetcher fetcher = new CookiesFetcher(context);
192 if (Profile.getLastUsedProfile().hasOffTheRecordProfile()) return fa lse; 193 if (Profile.getLastUsedProfile().hasOffTheRecordProfile()) return fa lse;
193 fetcher.scheduleDeleteCookiesFile(); 194 fetcher.scheduleDeleteCookiesFile();
194 } catch (RuntimeException e) { 195 } catch (RuntimeException e) {
195 e.printStackTrace(); 196 e.printStackTrace();
196 return false; 197 return false;
197 } 198 }
198 return true; 199 return true;
199 } 200 }
200 201
201 @CalledByNative 202 @CalledByNative
202 private CanonicalCookie createCookie(String url, String name, String value, String domain, 203 private CanonicalCookie createCookie(String url, String name, String value, String domain,
203 String path, long creation, long expiration, long lastAccess, boolea n secure, 204 String path, long creation, long expiration, long lastAccess, boolea n secure,
204 boolean httpOnly, int priority) { 205 boolean httpOnly, boolean firstParty, int priority) {
205 return new CanonicalCookie(url, name, value, domain, path, creation, exp iration, lastAccess, 206 return new CanonicalCookie(url, name, value, domain, path, creation, exp iration, lastAccess,
206 secure, httpOnly, priority); 207 secure, httpOnly, firstParty, priority);
207 } 208 }
208 209
209 @CalledByNative 210 @CalledByNative
210 private void onCookieFetchFinished(final CanonicalCookie[] cookies) { 211 private void onCookieFetchFinished(final CanonicalCookie[] cookies) {
211 // Cookies fetching requires operations with the profile and must be 212 // Cookies fetching requires operations with the profile and must be
212 // done in the main thread. Once that is done, do the save to disk 213 // done in the main thread. Once that is done, do the save to disk
213 // part in {@link AsyncTask} to avoid strict mode violations. 214 // part in {@link AsyncTask} to avoid strict mode violations.
214 new AsyncTask<Void, Void, Void>() { 215 new AsyncTask<Void, Void, Void>() {
215 @Override 216 @Override
216 protected Void doInBackground(Void... voids) { 217 protected Void doInBackground(Void... voids) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 private CanonicalCookie[] createCookiesArray(int size) { 289 private CanonicalCookie[] createCookiesArray(int size) {
289 return new CanonicalCookie[size]; 290 return new CanonicalCookie[size];
290 } 291 }
291 292
292 private native long nativeInit(); 293 private native long nativeInit();
293 private static native void nativeDestroy(long nativeCookiesFetcher); 294 private static native void nativeDestroy(long nativeCookiesFetcher);
294 private native void nativePersistCookies(long nativeCookiesFetcher); 295 private native void nativePersistCookies(long nativeCookiesFetcher);
295 private native void nativeRestoreCookies(long nativeCookiesFetcher, 296 private native void nativeRestoreCookies(long nativeCookiesFetcher,
296 String url, String name, String value, String domain, String path, 297 String url, String name, String value, String domain, String path,
297 long creation, long expiration, long lastAccess, boolean secure, 298 long creation, long expiration, long lastAccess, boolean secure,
298 boolean httpOnly, int priority); 299 boolean httpOnly, boolean firstParty, int priority);
299 } 300 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698