1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.browser; 18 19 import android.app.Activity; 20 import android.content.Context; 21 import android.graphics.Bitmap; 22 import android.net.Uri; 23 import android.net.http.SslError; 24 import android.os.Message; 25 import android.util.Log; 26 import android.view.KeyEvent; 27 import android.view.View; 28 import android.webkit.HttpAuthHandler; 29 import android.webkit.SslErrorHandler; 30 import android.webkit.ValueCallback; 31 import android.webkit.WebChromeClient.CustomViewCallback; 32 import android.webkit.WebView; 33 34 public class PreloadController implements WebViewController { 35 36 private static final boolean LOGD_ENABLED = false; 37 private static final String LOGTAG = "PreloadController"; 38 39 private Context mContext; 40 41 public PreloadController(Context ctx) { 42 mContext = ctx.getApplicationContext(); 43 44 } 45 46 @Override 47 public Context getContext() { 48 return mContext; 49 } 50 51 @Override 52 public Activity getActivity() { 53 if (LOGD_ENABLED) Log.d(LOGTAG, "getActivity()"); 54 return null; 55 } 56 57 @Override 58 public TabControl getTabControl() { 59 if (LOGD_ENABLED) Log.d(LOGTAG, "getTabControl()"); 60 return null; 61 } 62 63 @Override 64 public WebViewFactory getWebViewFactory() { 65 if (LOGD_ENABLED) Log.d(LOGTAG, "getWebViewFactory()"); 66 return null; 67 } 68 69 @Override 70 public void onSetWebView(Tab tab, WebView view) { 71 if (LOGD_ENABLED) Log.d(LOGTAG, "onSetWebView()"); 72 } 73 74 @Override 75 public void createSubWindow(Tab tab) { 76 if (LOGD_ENABLED) Log.d(LOGTAG, "createSubWindow()"); 77 } 78 79 @Override 80 public void onPageStarted(Tab tab, WebView view, Bitmap favicon) { 81 if (LOGD_ENABLED) Log.d(LOGTAG, "onPageStarted()"); 82 if (view != null) { 83 // Clear history of all previously visited pages. When the 84 // user visits a preloaded tab, the only item in the history 85 // list should the currently viewed page. 86 view.clearHistory(); 87 } 88 } 89 90 @Override 91 public void onPageFinished(Tab tab) { 92 if (LOGD_ENABLED) Log.d(LOGTAG, "onPageFinished()"); 93 if (tab != null) { 94 final WebView view = tab.getWebView(); 95 if (view != null) { 96 // Clear history of all previously visited pages. When the 97 // user visits a preloaded tab. 98 view.clearHistory(); 99 } 100 } 101 } 102 103 @Override 104 public void onProgressChanged(Tab tab) { 105 if (LOGD_ENABLED) Log.d(LOGTAG, "onProgressChanged()"); 106 } 107 108 @Override 109 public void onReceivedTitle(Tab tab, String title) { 110 if (LOGD_ENABLED) Log.d(LOGTAG, "onReceivedTitle()"); 111 } 112 113 @Override 114 public void onFavicon(Tab tab, WebView view, Bitmap icon) { 115 if (LOGD_ENABLED) Log.d(LOGTAG, "onFavicon()"); 116 } 117 118 @Override 119 public boolean shouldOverrideUrlLoading(Tab tab, WebView view, String url) { 120 if (LOGD_ENABLED) Log.d(LOGTAG, "shouldOverrideUrlLoading()"); 121 return false; 122 } 123 124 @Override 125 public boolean shouldOverrideKeyEvent(KeyEvent event) { 126 if (LOGD_ENABLED) Log.d(LOGTAG, "shouldOverrideKeyEvent()"); 127 return false; 128 } 129 130 @Override 131 public boolean onUnhandledKeyEvent(KeyEvent event) { 132 if (LOGD_ENABLED) Log.d(LOGTAG, "onUnhandledKeyEvent()"); 133 return false; 134 } 135 136 @Override 137 public void doUpdateVisitedHistory(Tab tab, boolean isReload) { 138 if (LOGD_ENABLED) Log.d(LOGTAG, "doUpdateVisitedHistory()"); 139 } 140 141 @Override 142 public void getVisitedHistory(ValueCallback<String[]> callback) { 143 if (LOGD_ENABLED) Log.d(LOGTAG, "getVisitedHistory()"); 144 } 145 146 @Override 147 public void onReceivedHttpAuthRequest(Tab tab, WebView view, 148 HttpAuthHandler handler, String host, 149 String realm) { 150 if (LOGD_ENABLED) Log.d(LOGTAG, "onReceivedHttpAuthRequest()"); 151 } 152 153 @Override 154 public void onDownloadStart(Tab tab, String url, String useragent, 155 String contentDisposition, String mimeType, 156 String referer, long contentLength) { 157 if (LOGD_ENABLED) Log.d(LOGTAG, "onDownloadStart()"); 158 } 159 160 @Override 161 public void showCustomView(Tab tab, View view, int requestedOrientation, 162 CustomViewCallback callback) { 163 if (LOGD_ENABLED) Log.d(LOGTAG, "showCustomView()"); 164 } 165 166 @Override 167 public void hideCustomView() { 168 if (LOGD_ENABLED) Log.d(LOGTAG, "hideCustomView()"); 169 } 170 171 @Override 172 public Bitmap getDefaultVideoPoster() { 173 if (LOGD_ENABLED) Log.d(LOGTAG, "getDefaultVideoPoster()"); 174 return null; 175 } 176 177 @Override 178 public View getVideoLoadingProgressView() { 179 if (LOGD_ENABLED) Log.d(LOGTAG, "getVideoLoadingProgressView()"); 180 return null; 181 } 182 183 @Override 184 public void showSslCertificateOnError(WebView view, 185 SslErrorHandler handler, SslError error) { 186 if (LOGD_ENABLED) Log.d(LOGTAG, "showSslCertificateOnError()"); 187 } 188 189 @Override 190 public void onUserCanceledSsl(Tab tab) { 191 if (LOGD_ENABLED) Log.d(LOGTAG, "onUserCanceledSsl()"); 192 } 193 194 @Override 195 public boolean shouldShowErrorConsole() { 196 if (LOGD_ENABLED) Log.d(LOGTAG, "shouldShowErrorConsole()"); 197 return false; 198 } 199 200 @Override 201 public void onUpdatedSecurityState(Tab tab) { 202 if (LOGD_ENABLED) Log.d(LOGTAG, "onUpdatedSecurityState()"); 203 } 204 205 @Override 206 public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) { 207 if (LOGD_ENABLED) Log.d(LOGTAG, "openFileChooser()"); 208 } 209 210 @Override 211 public void endActionMode() { 212 if (LOGD_ENABLED) Log.d(LOGTAG, "endActionMode()"); 213 } 214 215 @Override 216 public void attachSubWindow(Tab tab) { 217 if (LOGD_ENABLED) Log.d(LOGTAG, "attachSubWindow()"); 218 } 219 220 @Override 221 public void dismissSubWindow(Tab tab) { 222 if (LOGD_ENABLED) Log.d(LOGTAG, "dismissSubWindow()"); 223 } 224 225 @Override 226 public Tab openTab(String url, boolean incognito, boolean setActive, boolean useCurrent) { 227 if (LOGD_ENABLED) Log.d(LOGTAG, "openTab()"); 228 return null; 229 } 230 231 @Override 232 public Tab openTab(String url, Tab parent, boolean setActive, boolean useCurrent) { 233 if (LOGD_ENABLED) Log.d(LOGTAG, "openTab()"); 234 return null; 235 } 236 237 @Override 238 public boolean switchToTab(Tab tab) { 239 if (LOGD_ENABLED) Log.d(LOGTAG, "switchToTab()"); 240 return false; 241 } 242 243 @Override 244 public void closeTab(Tab tab) { 245 if (LOGD_ENABLED) Log.d(LOGTAG, "closeTab()"); 246 } 247 248 @Override 249 public void setupAutoFill(Message message) { 250 if (LOGD_ENABLED) Log.d(LOGTAG, "setupAutoFill()"); 251 } 252 253 @Override 254 public void bookmarkedStatusHasChanged(Tab tab) { 255 if (LOGD_ENABLED) Log.d(LOGTAG, "bookmarkedStatusHasChanged()"); 256 } 257 258 @Override 259 public void showAutoLogin(Tab tab) { 260 if (LOGD_ENABLED) Log.d(LOGTAG, "showAutoLogin()"); 261 } 262 263 @Override 264 public void hideAutoLogin(Tab tab) { 265 if (LOGD_ENABLED) Log.d(LOGTAG, "hideAutoLogin()"); 266 } 267 268 @Override 269 public boolean shouldCaptureThumbnails() { 270 return false; 271 } 272 273 } 274