1/* 2 * Copyright (C) 2010 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 17package com.android.browser; 18 19import android.graphics.Bitmap; 20import android.net.Uri; 21import android.os.Message; 22import android.view.View; 23import android.webkit.ConsoleMessage; 24import android.webkit.GeolocationPermissions; 25import android.webkit.JsPromptResult; 26import android.webkit.JsResult; 27import android.webkit.ValueCallback; 28import android.webkit.WebChromeClient; 29import android.webkit.WebStorage; 30import android.webkit.WebView; 31 32/** 33 * 34 * WebChromeClient for browser tests. 35 * Wraps around existing client so that specific methods can be overridden if needed. 36 * 37 */ 38abstract class TestWebChromeClient extends WebChromeClient { 39 40 private WebChromeClient mWrappedClient; 41 42 protected TestWebChromeClient(WebChromeClient wrappedClient) { 43 mWrappedClient = wrappedClient; 44 } 45 46 /** {@inheritDoc} */ 47 @Override 48 public void onProgressChanged(WebView view, int newProgress) { 49 mWrappedClient.onProgressChanged(view, newProgress); 50 } 51 52 /** {@inheritDoc} */ 53 @Override 54 public void onReceivedTitle(WebView view, String title) { 55 mWrappedClient.onReceivedTitle(view, title); 56 } 57 58 /** {@inheritDoc} */ 59 @Override 60 public void onReceivedIcon(WebView view, Bitmap icon) { 61 mWrappedClient.onReceivedIcon(view, icon); 62 } 63 64 /** {@inheritDoc} */ 65 @Override 66 public void onReceivedTouchIconUrl(WebView view, String url, 67 boolean precomposed) { 68 mWrappedClient.onReceivedTouchIconUrl(view, url, precomposed); 69 } 70 71 /** {@inheritDoc} */ 72 @Override 73 public void onShowCustomView(View view, CustomViewCallback callback) { 74 mWrappedClient.onShowCustomView(view, callback); 75 } 76 77 /** {@inheritDoc} */ 78 @Override 79 public void onHideCustomView() { 80 mWrappedClient.onHideCustomView(); 81 } 82 83 /** {@inheritDoc} */ 84 @Override 85 public boolean onCreateWindow(WebView view, boolean dialog, 86 boolean userGesture, Message resultMsg) { 87 return mWrappedClient.onCreateWindow(view, dialog, userGesture, resultMsg); 88 } 89 90 /** {@inheritDoc} */ 91 @Override 92 public void onRequestFocus(WebView view) { 93 mWrappedClient.onRequestFocus(view); 94 } 95 96 /** {@inheritDoc} */ 97 @Override 98 public void onCloseWindow(WebView window) { 99 mWrappedClient.onCloseWindow(window); 100 } 101 102 /** {@inheritDoc} */ 103 @Override 104 public boolean onJsAlert(WebView view, String url, String message, 105 JsResult result) { 106 return mWrappedClient.onJsAlert(view, url, message, result); 107 } 108 109 /** {@inheritDoc} */ 110 @Override 111 public boolean onJsConfirm(WebView view, String url, String message, 112 JsResult result) { 113 return mWrappedClient.onJsConfirm(view, url, message, result); 114 } 115 116 /** {@inheritDoc} */ 117 @Override 118 public boolean onJsPrompt(WebView view, String url, String message, 119 String defaultValue, JsPromptResult result) { 120 return mWrappedClient.onJsPrompt(view, url, message, defaultValue, result); 121 } 122 123 /** {@inheritDoc} */ 124 @Override 125 public boolean onJsBeforeUnload(WebView view, String url, String message, 126 JsResult result) { 127 return mWrappedClient.onJsBeforeUnload(view, url, message, result); 128 } 129 130 /** {@inheritDoc} */ 131 @Override 132 public void onExceededDatabaseQuota(String url, String databaseIdentifier, 133 long currentQuota, long estimatedSize, long totalUsedQuota, 134 WebStorage.QuotaUpdater quotaUpdater) { 135 mWrappedClient.onExceededDatabaseQuota(url, databaseIdentifier, currentQuota, 136 estimatedSize, totalUsedQuota, quotaUpdater); 137 } 138 139 /** {@inheritDoc} */ 140 @Override 141 public void onReachedMaxAppCacheSize(long spaceNeeded, long totalUsedQuota, 142 WebStorage.QuotaUpdater quotaUpdater) { 143 mWrappedClient.onReachedMaxAppCacheSize(spaceNeeded, totalUsedQuota, quotaUpdater); 144 } 145 146 /** {@inheritDoc} */ 147 @Override 148 public void onGeolocationPermissionsShowPrompt(String origin, 149 GeolocationPermissions.Callback callback) { 150 mWrappedClient.onGeolocationPermissionsShowPrompt(origin, callback); 151 } 152 153 /** {@inheritDoc} */ 154 @Override 155 public void onGeolocationPermissionsHidePrompt() { 156 mWrappedClient.onGeolocationPermissionsHidePrompt(); 157 } 158 159 /** {@inheritDoc} */ 160 @Override 161 public boolean onJsTimeout() { 162 return mWrappedClient.onJsTimeout(); 163 } 164 165 /** {@inheritDoc} */ 166 @Override 167 @Deprecated 168 public void onConsoleMessage(String message, int lineNumber, String sourceID) { 169 mWrappedClient.onConsoleMessage(message, lineNumber, sourceID); 170 } 171 172 /** {@inheritDoc} */ 173 @Override 174 public boolean onConsoleMessage(ConsoleMessage consoleMessage) { 175 return mWrappedClient.onConsoleMessage(consoleMessage); 176 } 177 178 /** {@inheritDoc} */ 179 @Override 180 public Bitmap getDefaultVideoPoster() { 181 return mWrappedClient.getDefaultVideoPoster(); 182 } 183 184 /** {@inheritDoc} */ 185 @Override 186 public View getVideoLoadingProgressView() { 187 return mWrappedClient.getVideoLoadingProgressView(); 188 } 189 190 /** {@inheritDoc} */ 191 @Override 192 public void getVisitedHistory(ValueCallback<String[]> callback) { 193 mWrappedClient.getVisitedHistory(callback); 194 } 195 196 /** {@inheritDoc} */ 197 @Override 198 public void openFileChooser(ValueCallback<Uri> uploadFile) { 199 mWrappedClient.openFileChooser(uploadFile); 200 } 201} 202