Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(652)

Side by Side Diff: android_webview/java/src/org/chromium/android_webview/AwSettings.java

Issue 11419093: [Android WebView] Implement WebSettings.{get|set}CacheMode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged after the last changes Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 package org.chromium.android_webview; 5 package org.chromium.android_webview;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.pm.PackageManager; 8 import android.content.pm.PackageManager;
9 import android.os.Process; 9 import android.os.Process;
10 import android.webkit.WebSettings;
10 11
11 /** 12 /**
12 * Stores Android WebView specific settings that does not need to be synced to W ebKit. 13 * Stores Android WebView specific settings that does not need to be synced to W ebKit.
13 * Use {@link org.chromium.content.browser.ContentSettings} for WebKit settings. 14 * Use {@link org.chromium.content.browser.ContentSettings} for WebKit settings.
14 * 15 *
15 * Methods in this class can be called from any thread, including threads create d by 16 * Methods in this class can be called from any thread, including threads create d by
16 * the client of WebView. 17 * the client of WebView.
17 */ 18 */
18 public class AwSettings { 19 public class AwSettings {
19 // Lock to protect all settings. 20 // Lock to protect all settings.
20 private final Object mAwSettingsLock = new Object(); 21 private final Object mAwSettingsLock = new Object();
21 22
22 private final Context mContext; 23 private final Context mContext;
23 private boolean mBlockNetworkLoads; // Default depends on permission of emb edding APK. 24 private boolean mBlockNetworkLoads; // Default depends on permission of emb edding APK.
24 private boolean mAllowContentUrlAccess = true; 25 private boolean mAllowContentUrlAccess = true;
25 private boolean mAllowFileUrlAccess = true; 26 private boolean mAllowFileUrlAccess = true;
27 private int mCacheMode = WebSettings.LOAD_DEFAULT;
26 28
27 public AwSettings(Context context) { 29 public AwSettings(Context context) {
28 mContext = context; 30 mContext = context;
29 mBlockNetworkLoads = mContext.checkPermission( 31 mBlockNetworkLoads = mContext.checkPermission(
30 android.Manifest.permission.INTERNET, 32 android.Manifest.permission.INTERNET,
31 Process.myPid(), 33 Process.myPid(),
32 Process.myUid()) != PackageManager.PERMISSION_GRANTED; 34 Process.myUid()) != PackageManager.PERMISSION_GRANTED;
33 } 35 }
34 36
35 /** 37 /**
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 91 }
90 92
91 /** 93 /**
92 * See {@link android.webkit.WebSettings#getAllowContentAccess}. 94 * See {@link android.webkit.WebSettings#getAllowContentAccess}.
93 */ 95 */
94 public boolean getAllowContentAccess() { 96 public boolean getAllowContentAccess() {
95 synchronized (mAwSettingsLock) { 97 synchronized (mAwSettingsLock) {
96 return mAllowContentUrlAccess; 98 return mAllowContentUrlAccess;
97 } 99 }
98 } 100 }
101
102 /**
103 * See {@link android.webkit.WebSettings#setCacheMode}.
104 */
105 public void setCacheMode(int mode) {
106 synchronized (mAwSettingsLock) {
107 if (mCacheMode != mode) {
108 mCacheMode = mode;
109 }
110 }
111 }
112
113 /**
114 * See {@link android.webkit.WebSettings#getCacheMode}.
115 */
116 public int getCacheMode() {
117 synchronized (mAwSettingsLock) {
118 return mCacheMode;
119 }
120 }
99 } 121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698