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