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

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

Issue 1773133002: SameSite: Implement 'Strict'/'Lax' attribute parsing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mmenke@ Created 4 years, 9 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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "chrome/browser/android/cookies/cookies_fetcher.h" 10 #include "chrome/browser/android/cookies/cookies_fetcher.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 i != cookies.end(); ++i) { 78 i != cookies.end(); ++i) {
79 ScopedJavaLocalRef<jobject> java_cookie = Java_CookiesFetcher_createCookie( 79 ScopedJavaLocalRef<jobject> java_cookie = Java_CookiesFetcher_createCookie(
80 env, jobject_.obj(), 80 env, jobject_.obj(),
81 base::android::ConvertUTF8ToJavaString(env, i->Source().spec()).obj(), 81 base::android::ConvertUTF8ToJavaString(env, i->Source().spec()).obj(),
82 base::android::ConvertUTF8ToJavaString(env, i->Name()).obj(), 82 base::android::ConvertUTF8ToJavaString(env, i->Name()).obj(),
83 base::android::ConvertUTF8ToJavaString(env, i->Value()).obj(), 83 base::android::ConvertUTF8ToJavaString(env, i->Value()).obj(),
84 base::android::ConvertUTF8ToJavaString(env, i->Domain()).obj(), 84 base::android::ConvertUTF8ToJavaString(env, i->Domain()).obj(),
85 base::android::ConvertUTF8ToJavaString(env, i->Path()).obj(), 85 base::android::ConvertUTF8ToJavaString(env, i->Path()).obj(),
86 i->CreationDate().ToInternalValue(), i->ExpiryDate().ToInternalValue(), 86 i->CreationDate().ToInternalValue(), i->ExpiryDate().ToInternalValue(),
87 i->LastAccessDate().ToInternalValue(), i->IsSecure(), i->IsHttpOnly(), 87 i->LastAccessDate().ToInternalValue(), i->IsSecure(), i->IsHttpOnly(),
88 i->IsSameSite(), i->Priority()); 88 static_cast<int>(i->SameSite()), i->Priority());
89 env->SetObjectArrayElement(joa.obj(), index++, java_cookie.obj()); 89 env->SetObjectArrayElement(joa.obj(), index++, java_cookie.obj());
90 } 90 }
91 91
92 Java_CookiesFetcher_onCookieFetchFinished(env, jobject_.obj(), joa.obj()); 92 Java_CookiesFetcher_onCookieFetchFinished(env, jobject_.obj(), joa.obj());
93 93
94 // Give up the reference. 94 // Give up the reference.
95 jobject_.Reset(); 95 jobject_.Reset();
96 } 96 }
97 97
98 void CookiesFetcher::RestoreCookies(JNIEnv* env, 98 void CookiesFetcher::RestoreCookies(JNIEnv* env,
99 const JavaParamRef<jobject>& obj, 99 const JavaParamRef<jobject>& obj,
100 const JavaParamRef<jstring>& url, 100 const JavaParamRef<jstring>& url,
101 const JavaParamRef<jstring>& name, 101 const JavaParamRef<jstring>& name,
102 const JavaParamRef<jstring>& value, 102 const JavaParamRef<jstring>& value,
103 const JavaParamRef<jstring>& domain, 103 const JavaParamRef<jstring>& domain,
104 const JavaParamRef<jstring>& path, 104 const JavaParamRef<jstring>& path,
105 int64_t creation, 105 int64_t creation,
106 int64_t expiration, 106 int64_t expiration,
107 int64_t last_access, 107 int64_t last_access,
108 bool secure, 108 bool secure,
109 bool httponly, 109 bool httponly,
110 bool same_site, 110 int same_site,
111 int priority) { 111 int priority) {
112 Profile* profile = ProfileManager::GetPrimaryUserProfile(); 112 Profile* profile = ProfileManager::GetPrimaryUserProfile();
113 if (!profile->HasOffTheRecordProfile()) { 113 if (!profile->HasOffTheRecordProfile()) {
114 return; // Don't create it. There is nothing to do. 114 return; // Don't create it. There is nothing to do.
115 } 115 }
116 profile = profile->GetOffTheRecordProfile(); 116 profile = profile->GetOffTheRecordProfile();
117 117
118 scoped_refptr<net::URLRequestContextGetter> getter( 118 scoped_refptr<net::URLRequestContextGetter> getter(
119 profile->GetRequestContext()); 119 profile->GetRequestContext());
120 120
121 net::CanonicalCookie cookie( 121 net::CanonicalCookie cookie(
122 GURL(base::android::ConvertJavaStringToUTF8(env, url)), 122 GURL(base::android::ConvertJavaStringToUTF8(env, url)),
123 base::android::ConvertJavaStringToUTF8(env, name), 123 base::android::ConvertJavaStringToUTF8(env, name),
124 base::android::ConvertJavaStringToUTF8(env, value), 124 base::android::ConvertJavaStringToUTF8(env, value),
125 base::android::ConvertJavaStringToUTF8(env, domain), 125 base::android::ConvertJavaStringToUTF8(env, domain),
126 base::android::ConvertJavaStringToUTF8(env, path), 126 base::android::ConvertJavaStringToUTF8(env, path),
127 base::Time::FromInternalValue(creation), 127 base::Time::FromInternalValue(creation),
128 base::Time::FromInternalValue(expiration), 128 base::Time::FromInternalValue(expiration),
129 base::Time::FromInternalValue(last_access), secure, httponly, same_site, 129 base::Time::FromInternalValue(last_access), secure, httponly,
130 static_cast<net::CookieSameSite>(same_site),
130 static_cast<net::CookiePriority>(priority)); 131 static_cast<net::CookiePriority>(priority));
131 132
132 // The rest must be done from the IO thread. 133 // The rest must be done from the IO thread.
133 content::BrowserThread::PostTask( 134 content::BrowserThread::PostTask(
134 content::BrowserThread::IO, 135 content::BrowserThread::IO,
135 FROM_HERE, 136 FROM_HERE,
136 base::Bind(&CookiesFetcher::RestoreToCookieJarInternal, 137 base::Bind(&CookiesFetcher::RestoreToCookieJarInternal,
137 base::Unretained(this), 138 base::Unretained(this),
138 getter, 139 getter,
139 cookie)); 140 cookie));
(...skipping 15 matching lines...) Expand all
155 156
156 // TODO(estark): Remove kEnableExperimentalWebPlatformFeatures check 157 // TODO(estark): Remove kEnableExperimentalWebPlatformFeatures check
157 // when we decide whether to ship cookie 158 // when we decide whether to ship cookie
158 // prefixes. https://crbug.com/541511 159 // prefixes. https://crbug.com/541511
159 bool experimental_features_enabled = 160 bool experimental_features_enabled =
160 base::CommandLine::ForCurrentProcess()->HasSwitch( 161 base::CommandLine::ForCurrentProcess()->HasSwitch(
161 switches::kEnableExperimentalWebPlatformFeatures); 162 switches::kEnableExperimentalWebPlatformFeatures);
162 store->SetCookieWithDetailsAsync( 163 store->SetCookieWithDetailsAsync(
163 cookie.Source(), cookie.Name(), cookie.Value(), cookie.Domain(), 164 cookie.Source(), cookie.Name(), cookie.Value(), cookie.Domain(),
164 cookie.Path(), base::Time(), cookie.ExpiryDate(), cookie.LastAccessDate(), 165 cookie.Path(), base::Time(), cookie.ExpiryDate(), cookie.LastAccessDate(),
165 cookie.IsSecure(), cookie.IsHttpOnly(), cookie.IsSameSite(), 166 cookie.IsSecure(), cookie.IsHttpOnly(), cookie.SameSite(),
166 experimental_features_enabled, cookie.Priority(), cb); 167 experimental_features_enabled, cookie.Priority(), cb);
167 } 168 }
168 169
169 // JNI functions 170 // JNI functions
170 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { 171 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
171 return reinterpret_cast<intptr_t>(new CookiesFetcher(env, obj, 0)); 172 return reinterpret_cast<intptr_t>(new CookiesFetcher(env, obj, 0));
172 } 173 }
173 174
174 // Register native methods 175 // Register native methods
175 bool RegisterCookiesFetcher(JNIEnv* env) { 176 bool RegisterCookiesFetcher(JNIEnv* env) {
176 return RegisterNativesImpl(env); 177 return RegisterNativesImpl(env);
177 } 178 }
OLDNEW
« no previous file with comments | « chrome/browser/android/cookies/cookies_fetcher.h ('k') | chrome/browser/browsing_data/cookies_tree_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698