AW NS: support file scheme cookies
This adds AllowFileSchemeCookies() to the CookieManager mojo interface
to support WebView's #setAcceptFileSchemeCookies() API.
This must be a dynamic API instead of a NetworkContextParam because apps
may legitimately call the Java API after the NetworkContext has
been initialized (so long as they call it before the first use of the
underlying CookieStore). We currently accommodate this in the legacy
code path by lazily creating the CookieStore the first time it's used.
To properly support the corresponding getter API, this CL modifies
CookieMonster::SetCookieableSchemes to pass a boolean success value to a
callback (which network::CookieManager also exposes as a callback).
This adds test coverage for the getter API, including covering the
call-after-cookie-store-initialization case, where it's no longer
possible to enable file:// scheme cookies.
As we haven't yet finalized a solution for using the CookieManager prior
to content-layer initialization (http://crbug.com/933461), this CL does
not attempt to resolve synchronization issues with that case.
Design: http://go/wv-ns-cookie-apis#bookmark=id.hq3jcr72p6ai
Bug: 933458
Test: $ run_webview_instrumentation_test_apk \
Test: --enable-features=NetworkService,NetworkServiceInProcess \
Test: -f CookieManagerTest.*FileScheme*
Test: $ net_unittests --gtest_filter=SQLitePersistentCookieStoreTest.* \
Test: :CookieMonsterTest.*
Cq-Include-Trybots: luci.chromium.try:android_mojo
Change-Id: I1c7c9ef3919686df39abc7ac760fddf91e176e15
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1533486
Commit-Queue: Nate Fischer <[email protected]>
Reviewed-by: Mustafa Emre Acer <[email protected]>
Reviewed-by: Richard Coles <[email protected]>
Reviewed-by: Elly Fong-Jones <[email protected]>
Reviewed-by: Maks Orlovich <[email protected]>
Cr-Commit-Position: refs/heads/master@{#644622}
diff --git a/net/cookies/cookie_monster.h b/net/cookies/cookie_monster.h
index e6851bca..747b378 100644
--- a/net/cookies/cookie_monster.h
+++ b/net/cookies/cookie_monster.h
@@ -174,11 +174,8 @@
void FlushStore(base::OnceClosure callback) override;
void SetForceKeepSessionState() override;
CookieChangeDispatcher& GetChangeDispatcher() override;
-
- // Resets the list of cookieable schemes to the supplied schemes. Does
- // nothing if called after first use of the instance (i.e. after the
- // instance initialization process).
- void SetCookieableSchemes(const std::vector<std::string>& schemes);
+ void SetCookieableSchemes(const std::vector<std::string>& schemes,
+ SetCookieableSchemesCallback callback) override;
// Enables writing session cookies into the cookie database. If this this
// method is called, it must be called before first use of the instance