OLD | NEW |
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 import android.webkit.WebSettings; |
11 | 11 |
12 /** | 12 /** |
13 * 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. |
14 * Use {@link org.chromium.content.browser.ContentSettings} for WebKit settings. | 14 * Use {@link org.chromium.content.browser.ContentSettings} for WebKit settings. |
15 * | 15 * |
16 * 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 |
17 * the client of WebView. | 17 * the client of WebView. |
18 */ | 18 */ |
19 public class AwSettings { | 19 public class AwSettings { |
20 // Lock to protect all settings. | 20 // Lock to protect all settings. |
21 private final Object mAwSettingsLock = new Object(); | 21 private final Object mAwSettingsLock = new Object(); |
22 | 22 |
23 private final Context mContext; | 23 private final Context mContext; |
24 private boolean mBlockNetworkLoads; // Default depends on permission of emb
edding APK. | 24 private boolean mBlockNetworkLoads; // Default depends on permission of emb
edding APK. |
25 private boolean mAllowContentUrlAccess = true; | 25 private boolean mAllowContentUrlAccess = true; |
26 private boolean mAllowFileUrlAccess = true; | 26 private boolean mAllowFileUrlAccess = true; |
27 private int mCacheMode = WebSettings.LOAD_DEFAULT; | 27 private int mCacheMode = WebSettings.LOAD_DEFAULT; |
28 private boolean mShouldFocusFirstNode = true; | 28 private boolean mShouldFocusFirstNode = true; |
| 29 private boolean mGeolocationEnabled = true; |
29 | 30 |
30 public AwSettings(Context context) { | 31 public AwSettings(Context context) { |
31 mContext = context; | 32 mContext = context; |
32 mBlockNetworkLoads = mContext.checkPermission( | 33 mBlockNetworkLoads = mContext.checkPermission( |
33 android.Manifest.permission.INTERNET, | 34 android.Manifest.permission.INTERNET, |
34 Process.myPid(), | 35 Process.myPid(), |
35 Process.myUid()) != PackageManager.PERMISSION_GRANTED; | 36 Process.myUid()) != PackageManager.PERMISSION_GRANTED; |
36 } | 37 } |
37 | 38 |
38 /** | 39 /** |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 131 } |
131 | 132 |
132 /** | 133 /** |
133 * See {@link android.webkit.WebSettings#setNeedInitialFocus}. | 134 * See {@link android.webkit.WebSettings#setNeedInitialFocus}. |
134 */ | 135 */ |
135 public boolean shouldFocusFirstNode() { | 136 public boolean shouldFocusFirstNode() { |
136 synchronized(mAwSettingsLock) { | 137 synchronized(mAwSettingsLock) { |
137 return mShouldFocusFirstNode; | 138 return mShouldFocusFirstNode; |
138 } | 139 } |
139 } | 140 } |
| 141 |
| 142 /** |
| 143 * See {@link android.webkit.WebSettings#setGeolocationEnabled}. |
| 144 */ |
| 145 public void setGeolocationEnabled(boolean flag) { |
| 146 synchronized (mAwSettingsLock) { |
| 147 if (mGeolocationEnabled != flag) { |
| 148 mGeolocationEnabled = flag; |
| 149 } |
| 150 } |
| 151 } |
| 152 |
| 153 /** |
| 154 * @return Returns if geolocation is currently enabled. |
| 155 */ |
| 156 boolean getGeolocationEnabled() { |
| 157 synchronized (mAwSettingsLock) { |
| 158 return mGeolocationEnabled; |
| 159 } |
| 160 } |
140 } | 161 } |
OLD | NEW |