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

Side by Side Diff: chrome/browser/android/cookies/cookies_fetcher.cc

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 #include "base/android/jni_android.h" 5 #include "base/android/jni_android.h"
6 #include "base/android/jni_string.h" 6 #include "base/android/jni_string.h"
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "chrome/browser/android/cookies/cookies_fetcher.h" 9 #include "chrome/browser/android/cookies/cookies_fetcher.h"
10 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 base::android::ConvertUTF8ToJavaString(env, i->Source()).obj(), 82 base::android::ConvertUTF8ToJavaString(env, i->Source()).obj(),
83 base::android::ConvertUTF8ToJavaString(env, i->Name()).obj(), 83 base::android::ConvertUTF8ToJavaString(env, i->Name()).obj(),
84 base::android::ConvertUTF8ToJavaString(env, i->Value()).obj(), 84 base::android::ConvertUTF8ToJavaString(env, i->Value()).obj(),
85 base::android::ConvertUTF8ToJavaString(env, i->Domain()).obj(), 85 base::android::ConvertUTF8ToJavaString(env, i->Domain()).obj(),
86 base::android::ConvertUTF8ToJavaString(env, i->Path()).obj(), 86 base::android::ConvertUTF8ToJavaString(env, i->Path()).obj(),
87 i->CreationDate().ToInternalValue(), 87 i->CreationDate().ToInternalValue(),
88 i->ExpiryDate().ToInternalValue(), 88 i->ExpiryDate().ToInternalValue(),
89 i->LastAccessDate().ToInternalValue(), 89 i->LastAccessDate().ToInternalValue(),
90 i->IsSecure(), 90 i->IsSecure(),
91 i->IsHttpOnly(), 91 i->IsHttpOnly(),
92 i->IsFirstParty(),
92 i->Priority()); 93 i->Priority());
93 env->SetObjectArrayElement(joa.obj(), index++, java_cookie.obj()); 94 env->SetObjectArrayElement(joa.obj(), index++, java_cookie.obj());
94 } 95 }
95 96
96 Java_CookiesFetcher_onCookieFetchFinished(env, jobject_.obj(), joa.obj()); 97 Java_CookiesFetcher_onCookieFetchFinished(env, jobject_.obj(), joa.obj());
97 98
98 // Give up the reference. 99 // Give up the reference.
99 jobject_.Reset(); 100 jobject_.Reset();
100 } 101 }
101 102
102 void CookiesFetcher::RestoreCookies(JNIEnv* env, 103 void CookiesFetcher::RestoreCookies(JNIEnv* env,
103 jobject obj, 104 jobject obj,
104 jstring url, 105 jstring url,
105 jstring name, 106 jstring name,
106 jstring value, 107 jstring value,
107 jstring domain, 108 jstring domain,
108 jstring path, 109 jstring path,
109 int64 creation, 110 int64 creation,
110 int64 expiration, 111 int64 expiration,
111 int64 last_access, 112 int64 last_access,
112 bool secure, 113 bool secure,
113 bool httponly, 114 bool httponly,
115 bool firstparty,
114 int priority) { 116 int priority) {
115 Profile* profile = ProfileManager::GetPrimaryUserProfile(); 117 Profile* profile = ProfileManager::GetPrimaryUserProfile();
116 if (!profile->HasOffTheRecordProfile()) { 118 if (!profile->HasOffTheRecordProfile()) {
117 return; // Don't create it. There is nothing to do. 119 return; // Don't create it. There is nothing to do.
118 } 120 }
119 profile = profile->GetOffTheRecordProfile(); 121 profile = profile->GetOffTheRecordProfile();
120 122
121 scoped_refptr<net::URLRequestContextGetter> getter( 123 scoped_refptr<net::URLRequestContextGetter> getter(
122 profile->GetRequestContext()); 124 profile->GetRequestContext());
123 125
124 net::CanonicalCookie cookie( 126 net::CanonicalCookie cookie(
125 GURL(base::android::ConvertJavaStringToUTF8(env, url)), 127 GURL(base::android::ConvertJavaStringToUTF8(env, url)),
126 base::android::ConvertJavaStringToUTF8(env, name), 128 base::android::ConvertJavaStringToUTF8(env, name),
127 base::android::ConvertJavaStringToUTF8(env, value), 129 base::android::ConvertJavaStringToUTF8(env, value),
128 base::android::ConvertJavaStringToUTF8(env, domain), 130 base::android::ConvertJavaStringToUTF8(env, domain),
129 base::android::ConvertJavaStringToUTF8(env, path), 131 base::android::ConvertJavaStringToUTF8(env, path),
130 base::Time::FromInternalValue(creation), 132 base::Time::FromInternalValue(creation),
131 base::Time::FromInternalValue(expiration), 133 base::Time::FromInternalValue(expiration),
132 base::Time::FromInternalValue(last_access), 134 base::Time::FromInternalValue(last_access),
133 secure, httponly, static_cast<net::CookiePriority>(priority)); 135 secure, httponly, firstparty, static_cast<net::CookiePriority>(priority));
134 136
135 // The rest must be done from the IO thread. 137 // The rest must be done from the IO thread.
136 content::BrowserThread::PostTask( 138 content::BrowserThread::PostTask(
137 content::BrowserThread::IO, 139 content::BrowserThread::IO,
138 FROM_HERE, 140 FROM_HERE,
139 base::Bind(&CookiesFetcher::RestoreToCookieJarInternal, 141 base::Bind(&CookiesFetcher::RestoreToCookieJarInternal,
140 base::Unretained(this), 142 base::Unretained(this),
141 getter, 143 getter,
142 cookie)); 144 cookie));
143 } 145 }
(...skipping 15 matching lines...) Expand all
159 161
160 monster->SetCookieWithDetailsAsync( 162 monster->SetCookieWithDetailsAsync(
161 GURL(cookie.Source()), 163 GURL(cookie.Source()),
162 cookie.Name(), 164 cookie.Name(),
163 cookie.Value(), 165 cookie.Value(),
164 cookie.Domain(), 166 cookie.Domain(),
165 cookie.Path(), 167 cookie.Path(),
166 cookie.ExpiryDate(), 168 cookie.ExpiryDate(),
167 cookie.IsSecure(), 169 cookie.IsSecure(),
168 cookie.IsHttpOnly(), 170 cookie.IsHttpOnly(),
171 cookie.IsFirstParty(),
169 cookie.Priority(), 172 cookie.Priority(),
170 cb 173 cb
171 ); 174 );
172 } 175 }
173 176
174 // JNI functions 177 // JNI functions
175 static jlong Init(JNIEnv* env, jobject obj) { 178 static jlong Init(JNIEnv* env, jobject obj) {
176 return reinterpret_cast<intptr_t>(new CookiesFetcher(env, obj, 0)); 179 return reinterpret_cast<intptr_t>(new CookiesFetcher(env, obj, 0));
177 } 180 }
178 181
179 // Register native methods 182 // Register native methods
180 bool RegisterCookiesFetcher(JNIEnv* env) { 183 bool RegisterCookiesFetcher(JNIEnv* env) {
181 return RegisterNativesImpl(env); 184 return RegisterNativesImpl(env);
182 } 185 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698