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" | |
9 #include "base/time/time.h" | 8 #include "base/time/time.h" |
10 #include "chrome/browser/android/cookies/cookies_fetcher.h" | 9 #include "chrome/browser/android/cookies/cookies_fetcher.h" |
11 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
12 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/common/content_switches.h" | |
14 #include "jni/CookiesFetcher_jni.h" | 12 #include "jni/CookiesFetcher_jni.h" |
15 #include "net/cookies/cookie_monster.h" | 13 #include "net/cookies/cookie_monster.h" |
16 #include "net/cookies/cookie_store.h" | 14 #include "net/cookies/cookie_store.h" |
17 #include "net/url_request/url_request_context.h" | 15 #include "net/url_request/url_request_context.h" |
18 | 16 |
19 CookiesFetcher::CookiesFetcher(JNIEnv* env, jobject obj, Profile* profile) { | 17 CookiesFetcher::CookiesFetcher(JNIEnv* env, jobject obj, Profile* profile) { |
20 } | 18 } |
21 | 19 |
22 CookiesFetcher::~CookiesFetcher() { | 20 CookiesFetcher::~CookiesFetcher() { |
23 } | 21 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 net::CookieStore* store = getter->GetURLRequestContext()->cookie_store(); | 147 net::CookieStore* store = getter->GetURLRequestContext()->cookie_store(); |
150 | 148 |
151 // Nullable sometimes according to docs. | 149 // Nullable sometimes according to docs. |
152 if (!store) { | 150 if (!store) { |
153 return; | 151 return; |
154 } | 152 } |
155 | 153 |
156 net::CookieMonster* monster = store->GetCookieMonster(); | 154 net::CookieMonster* monster = store->GetCookieMonster(); |
157 base::Callback<void(bool success)> cb; | 155 base::Callback<void(bool success)> cb; |
158 | 156 |
159 // TODO(estark): Remove kEnableExperimentalWebPlatformFeatures check | |
160 // when we decide whether to ship cookie | |
161 // prefixes. https://crbug.com/541511 | |
162 monster->SetCookieWithDetailsAsync( | 157 monster->SetCookieWithDetailsAsync( |
163 cookie.Source(), cookie.Name(), cookie.Value(), cookie.Domain(), | 158 cookie.Source(), cookie.Name(), cookie.Value(), cookie.Domain(), |
164 cookie.Path(), cookie.ExpiryDate(), cookie.IsSecure(), | 159 cookie.Path(), cookie.ExpiryDate(), cookie.IsSecure(), |
165 cookie.IsHttpOnly(), cookie.IsFirstPartyOnly(), | 160 cookie.IsHttpOnly(), cookie.IsFirstPartyOnly(), cookie.Priority(), cb); |
166 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
167 switches::kEnableExperimentalWebPlatformFeatures), | |
168 cookie.Priority(), cb); | |
169 } | 161 } |
170 | 162 |
171 // JNI functions | 163 // JNI functions |
172 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 164 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
173 return reinterpret_cast<intptr_t>(new CookiesFetcher(env, obj, 0)); | 165 return reinterpret_cast<intptr_t>(new CookiesFetcher(env, obj, 0)); |
174 } | 166 } |
175 | 167 |
176 // Register native methods | 168 // Register native methods |
177 bool RegisterCookiesFetcher(JNIEnv* env) { | 169 bool RegisterCookiesFetcher(JNIEnv* env) { |
178 return RegisterNativesImpl(env); | 170 return RegisterNativesImpl(env); |
179 } | 171 } |
OLD | NEW |