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 import java.util.List; 35 36 public class PreloadController implements WebViewController { 37 38 private static final boolean LOGD_ENABLED = false; 39 private static final String LOGTAG = "PreloadController"; 40 41 private Context mContext; 42 43 public PreloadController(Context ctx) { 44 mContext = ctx.getApplicationContext(); 45 46 } 47 48 @Override 49 public Context getContext() { 50 return mContext; 51 } 52 53 @Override 54 public Activity getActivity() { 55 if (LOGD_ENABLED) Log.d(LOGTAG, "getActivity()"); 56 return null; 57 } 58 59 @Override 60 public TabControl getTabControl() { 61 if (LOGD_ENABLED) Log.d(LOGTAG, "getTabControl()"); 62 return null; 63 } 64 65 @Override 66 public WebViewFactory getWebViewFactory() { 67 if (LOGD_ENABLED) Log.d(LOGTAG, "getWebViewFactory()"); 68 return null; 69 } 70 71 @Override 72 public void onSetWebView(Tab tab, WebView view) { 73 if (LOGD_ENABLED) Log.d(LOGTAG, "onSetWebView()"); 74 } 75 76 @Override 77 public void createSubWindow(Tab tab) { 78 if (LOGD_ENABLED) Log.d(LOGTAG, "createSubWindow()"); 79 } 80 81 @Override 82 public void onPageStarted(Tab tab, WebView view, Bitmap favicon) { 83 if (LOGD_ENABLED) Log.d(LOGTAG, "onPageStarted()"); 84 if (view != null) { 85 // Clear history of all previously visited pages. When the 86 // user visits a preloaded tab, the only item in the history 87 // list should the currently viewed page. 88 view.clearHistory(); 89 } 90 } 91 92 @Override 93 public void onPageFinished(Tab tab) { 94 if (LOGD_ENABLED) Log.d(LOGTAG, "onPageFinished()"); 95 if (tab != null) { 96 final WebView view = tab.getWebView(); 97 if (view != null) { 98 // Clear history of all previously visited pages. When the 99 // user visits a preloaded tab. 100 view.clearHistory(); 101 } 102 } 103 } 104 105 @Override 106 public void onProgressChanged(Tab tab) { 107 if (LOGD_ENABLED) Log.d(LOGTAG, "onProgressChanged()"); 108 } 109 110 @Override 111 public void onReceivedTitle(Tab tab, String title) { 112 if (LOGD_ENABLED) Log.d(LOGTAG, "onReceivedTitle()"); 113 } 114 115 @Override 116 public void onFavicon(Tab tab, WebView view, Bitmap icon) { 117 if (LOGD_ENABLED) Log.d(LOGTAG, "onFavicon()"); 118 } 119 120 @Override 121 public boolean shouldOverrideUrlLoading(Tab tab, WebView view, String url) { 122 if (LOGD_ENABLED) Log.d(LOGTAG, "shouldOverrideUrlLoading()"); 123 return false; 124 } 125 126 @Override 127 public boolean shouldOverrideKeyEvent(KeyEvent event) { 128 if (LOGD_ENABLED) Log.d(LOGTAG, "shouldOverrideKeyEvent()"); 129 return false; 130 } 131 132 @Override 133 public void onUnhandledKeyEvent(KeyEvent event) { 134 if (LOGD_ENABLED) Log.d(LOGTAG, "onUnhandledKeyEvent()"); 135 } 136 137 @Override 138 public void doUpdateVisitedHistory(Tab tab, boolean isReload) { 139 if (LOGD_ENABLED) Log.d(LOGTAG, "doUpdateVisitedHistory()"); 140 } 141 142 @Override 143 public void getVisitedHistory(ValueCallback<String[]> callback) { 144 if (LOGD_ENABLED) Log.d(LOGTAG, "getVisitedHistory()"); 145 } 146 147 @Override 148 public void onReceivedHttpAuthRequest(Tab tab, WebView view, 149 HttpAuthHandler handler, String host, 150 String realm) { 151 if (LOGD_ENABLED) Log.d(LOGTAG, "onReceivedHttpAuthRequest()"); 152 } 153 154 @Override 155 public void onDownloadStart(Tab tab, String url, String useragent, 156 String contentDisposition, String mimeType, 157 long contentLength) { 158 if (LOGD_ENABLED) Log.d(LOGTAG, "onDownloadStart()"); 159 } 160 161 @Override 162 public void showCustomView(Tab tab, View view, int requestedOrientation, 163 CustomViewCallback callback) { 164 if (LOGD_ENABLED) Log.d(LOGTAG, "showCustomView()"); 165 } 166 167 @Override 168 public void hideCustomView() { 169 if (LOGD_ENABLED) Log.d(LOGTAG, "hideCustomView()"); 170 } 171 172 @Override 173 public Bitmap getDefaultVideoPoster() { 174 if (LOGD_ENABLED) Log.d(LOGTAG, "getDefaultVideoPoster()"); 175 return null; 176 } 177 178 @Override 179 public View getVideoLoadingProgressView() { 180 if (LOGD_ENABLED) Log.d(LOGTAG, "getVideoLoadingProgressView()"); 181 return null; 182 } 183 184 @Override 185 public void showSslCertificateOnError(WebView view, 186 SslErrorHandler handler, SslError error) { 187 if (LOGD_ENABLED) Log.d(LOGTAG, "showSslCertificateOnError()"); 188 } 189 190 @Override 191 public void onUserCanceledSsl(Tab tab) { 192 if (LOGD_ENABLED) Log.d(LOGTAG, "onUserCanceledSsl()"); 193 } 194 195 @Override 196 public void activateVoiceSearchMode(String title, List<String> results) { 197 if (LOGD_ENABLED) Log.d(LOGTAG, "activateVoiceSearchMode()"); 198 } 199 200 @Override 201 public void revertVoiceSearchMode(Tab tab) { 202 if (LOGD_ENABLED) Log.d(LOGTAG, "revertVoiceSearchMode()"); 203 } 204 205 @Override 206 public boolean shouldShowErrorConsole() { 207 if (LOGD_ENABLED) Log.d(LOGTAG, "shouldShowErrorConsole()"); 208 return false; 209 } 210 211 @Override 212 public void onUpdatedSecurityState(Tab tab) { 213 if (LOGD_ENABLED) Log.d(LOGTAG, "onUpdatedSecurityState()"); 214 } 215 216 @Override 217 public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) { 218 if (LOGD_ENABLED) Log.d(LOGTAG, "openFileChooser()"); 219 } 220 221 @Override 222 public void endActionMode() { 223 if (LOGD_ENABLED) Log.d(LOGTAG, "endActionMode()"); 224 } 225 226 @Override 227 public void attachSubWindow(Tab tab) { 228 if (LOGD_ENABLED) Log.d(LOGTAG, "attachSubWindow()"); 229 } 230 231 @Override 232 public void dismissSubWindow(Tab tab) { 233 if (LOGD_ENABLED) Log.d(LOGTAG, "dismissSubWindow()"); 234 } 235 236 @Override 237 public Tab openTab(String url, boolean incognito, boolean setActive, boolean useCurrent) { 238 if (LOGD_ENABLED) Log.d(LOGTAG, "openTab()"); 239 return null; 240 } 241 242 @Override 243 public Tab openTab(String url, Tab parent, boolean setActive, boolean useCurrent) { 244 if (LOGD_ENABLED) Log.d(LOGTAG, "openTab()"); 245 return null; 246 } 247 248 @Override 249 public boolean switchToTab(Tab tab) { 250 if (LOGD_ENABLED) Log.d(LOGTAG, "switchToTab()"); 251 return false; 252 } 253 254 @Override 255 public void closeTab(Tab tab) { 256 if (LOGD_ENABLED) Log.d(LOGTAG, "closeTab()"); 257 } 258 259 @Override 260 public void setupAutoFill(Message message) { 261 if (LOGD_ENABLED) Log.d(LOGTAG, "setupAutoFill()"); 262 } 263 264 @Override 265 public void bookmarkedStatusHasChanged(Tab tab) { 266 if (LOGD_ENABLED) Log.d(LOGTAG, "bookmarkedStatusHasChanged()"); 267 } 268 269 @Override 270 public void showAutoLogin(Tab tab) { 271 if (LOGD_ENABLED) Log.d(LOGTAG, "showAutoLogin()"); 272 } 273 274 @Override 275 public void hideAutoLogin(Tab tab) { 276 if (LOGD_ENABLED) Log.d(LOGTAG, "hideAutoLogin()"); 277 } 278 279 @Override 280 public boolean shouldCaptureThumbnails() { 281 return false; 282 } 283 284 } 285