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 #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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 jint priority) { | 150 jint priority) { |
151 Profile* profile = ProfileManager::GetPrimaryUserProfile(); | 151 Profile* profile = ProfileManager::GetPrimaryUserProfile(); |
152 if (!profile->HasOffTheRecordProfile()) { | 152 if (!profile->HasOffTheRecordProfile()) { |
153 return; // Don't create it. There is nothing to do. | 153 return; // Don't create it. There is nothing to do. |
154 } | 154 } |
155 profile = profile->GetOffTheRecordProfile(); | 155 profile = profile->GetOffTheRecordProfile(); |
156 | 156 |
157 scoped_refptr<net::URLRequestContextGetter> getter( | 157 scoped_refptr<net::URLRequestContextGetter> getter( |
158 profile->GetRequestContext()); | 158 profile->GetRequestContext()); |
159 | 159 |
160 net::CanonicalCookie cookie( | 160 net::CanonicalCookie cookie(*net::CanonicalCookie::Create( |
161 GURL(), base::android::ConvertJavaStringToUTF8(env, name), | 161 base::android::ConvertJavaStringToUTF8(env, name), |
162 base::android::ConvertJavaStringToUTF8(env, value), | 162 base::android::ConvertJavaStringToUTF8(env, value), |
163 base::android::ConvertJavaStringToUTF8(env, domain), | 163 base::android::ConvertJavaStringToUTF8(env, domain), |
164 base::android::ConvertJavaStringToUTF8(env, path), | 164 base::android::ConvertJavaStringToUTF8(env, path), |
165 base::Time::FromInternalValue(creation), | 165 base::Time::FromInternalValue(creation), |
166 base::Time::FromInternalValue(expiration), | 166 base::Time::FromInternalValue(expiration), |
167 base::Time::FromInternalValue(last_access), secure, httponly, | 167 base::Time::FromInternalValue(last_access), |
| 168 secure, httponly, |
168 static_cast<net::CookieSameSite>(same_site), | 169 static_cast<net::CookieSameSite>(same_site), |
169 static_cast<net::CookiePriority>(priority)); | 170 static_cast<net::CookiePriority>(priority))); |
170 | 171 |
171 // The rest must be done from the IO thread. | 172 // The rest must be done from the IO thread. |
172 content::BrowserThread::PostTask( | 173 content::BrowserThread::PostTask( |
173 content::BrowserThread::IO, FROM_HERE, | 174 content::BrowserThread::IO, FROM_HERE, |
174 base::Bind(&RestoreToCookieJarInternal, base::RetainedRef(getter), | 175 base::Bind(&RestoreToCookieJarInternal, base::RetainedRef(getter), |
175 cookie)); | 176 cookie)); |
176 } | 177 } |
177 | 178 |
178 // JNI functions | 179 // JNI functions |
179 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 180 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
180 return reinterpret_cast<intptr_t>(new CookiesFetcher(env, obj, 0)); | 181 return reinterpret_cast<intptr_t>(new CookiesFetcher(env, obj, 0)); |
181 } | 182 } |
182 | 183 |
183 // Register native methods | 184 // Register native methods |
184 bool RegisterCookiesFetcher(JNIEnv* env) { | 185 bool RegisterCookiesFetcher(JNIEnv* env) { |
185 return RegisterNativesImpl(env); | 186 return RegisterNativesImpl(env); |
186 } | 187 } |
OLD | NEW |