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