Skip to content

Commit 26ed99f

Browse files
Jonathan DixonAndroid (Google) Code Review
authored andcommitted
Merge "static methods in CookieManger call via instance"
2 parents 5479e29 + be58c40 commit 26ed99f

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

core/java/android/webkit/CookieManager.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,17 @@ protected void flushCookieStore() {
166166
* @return True if {@link WebView} instances send and accept cookies for
167167
* file scheme URLs
168168
*/
169+
// Static for backward compatibility.
169170
public static boolean allowFileSchemeCookies() {
170-
// TODO: indirect this via the WebViewFactoryProvider.Statics interface. http://b/6379925
171-
return CookieManagerClassic.allowFileSchemeCookies();
171+
return getInstance().allowFileSchemeCookiesImpl();
172+
}
173+
174+
/**
175+
* Implements {@link #allowFileSchemeCookies()}
176+
* @hide Only for use by WebViewProvider implementations
177+
*/
178+
protected boolean allowFileSchemeCookiesImpl() {
179+
throw new MustOverrideException();
172180
}
173181

174182
/**
@@ -181,8 +189,16 @@ public static boolean allowFileSchemeCookies() {
181189
* Note that calls to this method will have no effect if made after a
182190
* {@link WebView} or CookieManager instance has been created.
183191
*/
192+
// Static for backward compatibility.
184193
public static void setAcceptFileSchemeCookies(boolean accept) {
185-
// TODO: indirect this via the WebViewFactoryProvider.Statics interface. http://b/6379925
186-
CookieManagerClassic.setAcceptFileSchemeCookies(accept);
194+
getInstance().setAcceptFileSchemeCookiesImpl(accept);
195+
}
196+
197+
/**
198+
* Implements {@link #setAcceptFileSchemeCookies(boolean)}
199+
* @hide Only for use by WebViewProvider implementations
200+
*/
201+
protected void setAcceptFileSchemeCookiesImpl(boolean accept) {
202+
throw new MustOverrideException();
187203
}
188204
}

core/java/android/webkit/CookieManagerClassic.java

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -159,27 +159,13 @@ protected void flushCookieStore() {
159159
nativeFlushCookieStore();
160160
}
161161

162-
/**
163-
* Gets whether the application's {@link WebView} instances send and accept
164-
* cookies for file scheme URLs.
165-
* @return True if {@link WebView} instances send and accept cookies for
166-
* file scheme URLs
167-
*/
168-
public static boolean allowFileSchemeCookies() {
162+
@Override
163+
protected boolean allowFileSchemeCookiesImpl() {
169164
return nativeAcceptFileSchemeCookies();
170165
}
171166

172-
/**
173-
* Sets whether the application's {@link WebView} instances should send and
174-
* accept cookies for file scheme URLs.
175-
* Use of cookies with file scheme URLs is potentially insecure. Do not use
176-
* this feature unless you can be sure that no unintentional sharing of
177-
* cookie data can take place.
178-
* <p>
179-
* Note that calls to this method will have no effect if made after a
180-
* {@link WebView} or CookieManager instance has been created.
181-
*/
182-
public static void setAcceptFileSchemeCookies(boolean accept) {
167+
@Override
168+
protected void setAcceptFileSchemeCookiesImpl(boolean accept) {
183169
nativeSetAcceptFileSchemeCookies(accept);
184170
}
185171

0 commit comments

Comments
 (0)