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