blob: 66b89f4860d606f20aa1495bf728baf4c96ce997 [file] [log] [blame]
Michael Kolb14612442011-06-24 13:06:29 -07001/*
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
17package com.android.browser;
18
19import android.app.Activity;
20import android.content.Context;
21import android.graphics.Bitmap;
22import android.net.Uri;
23import android.net.http.SslError;
24import android.os.Message;
Mathew Inwoode1dbb952011-07-08 17:27:38 +010025import android.util.Log;
Michael Kolb14612442011-06-24 13:06:29 -070026import android.view.KeyEvent;
27import android.view.View;
28import android.webkit.HttpAuthHandler;
29import android.webkit.SslErrorHandler;
30import android.webkit.ValueCallback;
31import android.webkit.WebChromeClient.CustomViewCallback;
32import android.webkit.WebView;
33
34import java.util.List;
35
36public class PreloadController implements WebViewController {
37
Mathew Inwoode1dbb952011-07-08 17:27:38 +010038 private static final boolean LOGD_ENABLED = false;
39 private static final String LOGTAG = "PreloadController";
40
Michael Kolb14612442011-06-24 13:06:29 -070041 private Context mContext;
42
43 public PreloadController(Context ctx) {
Ben Murdoch914c5592011-08-01 13:58:47 +010044 mContext = ctx.getApplicationContext();
Michael Kolb14612442011-06-24 13:06:29 -070045
46 }
47
48 @Override
49 public Context getContext() {
50 return mContext;
51 }
52
53 @Override
54 public Activity getActivity() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010055 if (LOGD_ENABLED) Log.d(LOGTAG, "getActivity()");
Michael Kolb14612442011-06-24 13:06:29 -070056 return null;
57 }
58
59 @Override
60 public TabControl getTabControl() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010061 if (LOGD_ENABLED) Log.d(LOGTAG, "getTabControl()");
Michael Kolb14612442011-06-24 13:06:29 -070062 return null;
63 }
64
65 @Override
66 public WebViewFactory getWebViewFactory() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010067 if (LOGD_ENABLED) Log.d(LOGTAG, "getWebViewFactory()");
Michael Kolb14612442011-06-24 13:06:29 -070068 return null;
69 }
70
71 @Override
72 public void onSetWebView(Tab tab, WebView view) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010073 if (LOGD_ENABLED) Log.d(LOGTAG, "onSetWebView()");
Michael Kolb14612442011-06-24 13:06:29 -070074 }
75
76 @Override
77 public void createSubWindow(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010078 if (LOGD_ENABLED) Log.d(LOGTAG, "createSubWindow()");
Michael Kolb14612442011-06-24 13:06:29 -070079 }
80
81 @Override
82 public void onPageStarted(Tab tab, WebView view, Bitmap favicon) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010083 if (LOGD_ENABLED) Log.d(LOGTAG, "onPageStarted()");
Narayan Kamathc8892c72011-07-20 14:36:22 +010084 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 }
Michael Kolb14612442011-06-24 13:06:29 -070090 }
91
92 @Override
93 public void onPageFinished(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010094 if (LOGD_ENABLED) Log.d(LOGTAG, "onPageFinished()");
Narayan Kamathc8892c72011-07-20 14:36:22 +010095 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 }
Michael Kolb14612442011-06-24 13:06:29 -0700103 }
104
105 @Override
106 public void onProgressChanged(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100107 if (LOGD_ENABLED) Log.d(LOGTAG, "onProgressChanged()");
Michael Kolb14612442011-06-24 13:06:29 -0700108 }
109
110 @Override
111 public void onReceivedTitle(Tab tab, String title) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100112 if (LOGD_ENABLED) Log.d(LOGTAG, "onReceivedTitle()");
Michael Kolb14612442011-06-24 13:06:29 -0700113 }
114
115 @Override
116 public void onFavicon(Tab tab, WebView view, Bitmap icon) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100117 if (LOGD_ENABLED) Log.d(LOGTAG, "onFavicon()");
Michael Kolb14612442011-06-24 13:06:29 -0700118 }
119
120 @Override
121 public boolean shouldOverrideUrlLoading(Tab tab, WebView view, String url) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100122 if (LOGD_ENABLED) Log.d(LOGTAG, "shouldOverrideUrlLoading()");
Michael Kolb14612442011-06-24 13:06:29 -0700123 return false;
124 }
125
126 @Override
127 public boolean shouldOverrideKeyEvent(KeyEvent event) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100128 if (LOGD_ENABLED) Log.d(LOGTAG, "shouldOverrideKeyEvent()");
Michael Kolb14612442011-06-24 13:06:29 -0700129 return false;
130 }
131
132 @Override
John Reck997b1b72012-04-19 18:08:25 -0700133 public boolean onUnhandledKeyEvent(KeyEvent event) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100134 if (LOGD_ENABLED) Log.d(LOGTAG, "onUnhandledKeyEvent()");
John Reck997b1b72012-04-19 18:08:25 -0700135 return false;
Michael Kolb14612442011-06-24 13:06:29 -0700136 }
137
138 @Override
139 public void doUpdateVisitedHistory(Tab tab, boolean isReload) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100140 if (LOGD_ENABLED) Log.d(LOGTAG, "doUpdateVisitedHistory()");
Michael Kolb14612442011-06-24 13:06:29 -0700141 }
142
143 @Override
144 public void getVisitedHistory(ValueCallback<String[]> callback) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100145 if (LOGD_ENABLED) Log.d(LOGTAG, "getVisitedHistory()");
Michael Kolb14612442011-06-24 13:06:29 -0700146 }
147
148 @Override
149 public void onReceivedHttpAuthRequest(Tab tab, WebView view,
150 HttpAuthHandler handler, String host,
151 String realm) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100152 if (LOGD_ENABLED) Log.d(LOGTAG, "onReceivedHttpAuthRequest()");
Michael Kolb14612442011-06-24 13:06:29 -0700153 }
154
155 @Override
156 public void onDownloadStart(Tab tab, String url, String useragent,
157 String contentDisposition, String mimeType,
158 long contentLength) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100159 if (LOGD_ENABLED) Log.d(LOGTAG, "onDownloadStart()");
Michael Kolb14612442011-06-24 13:06:29 -0700160 }
161
162 @Override
163 public void showCustomView(Tab tab, View view, int requestedOrientation,
164 CustomViewCallback callback) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100165 if (LOGD_ENABLED) Log.d(LOGTAG, "showCustomView()");
Michael Kolb14612442011-06-24 13:06:29 -0700166 }
167
168 @Override
169 public void hideCustomView() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100170 if (LOGD_ENABLED) Log.d(LOGTAG, "hideCustomView()");
Michael Kolb14612442011-06-24 13:06:29 -0700171 }
172
173 @Override
174 public Bitmap getDefaultVideoPoster() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100175 if (LOGD_ENABLED) Log.d(LOGTAG, "getDefaultVideoPoster()");
Michael Kolb14612442011-06-24 13:06:29 -0700176 return null;
177 }
178
179 @Override
180 public View getVideoLoadingProgressView() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100181 if (LOGD_ENABLED) Log.d(LOGTAG, "getVideoLoadingProgressView()");
Michael Kolb14612442011-06-24 13:06:29 -0700182 return null;
183 }
184
185 @Override
186 public void showSslCertificateOnError(WebView view,
187 SslErrorHandler handler, SslError error) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100188 if (LOGD_ENABLED) Log.d(LOGTAG, "showSslCertificateOnError()");
Michael Kolb14612442011-06-24 13:06:29 -0700189 }
190
191 @Override
192 public void onUserCanceledSsl(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100193 if (LOGD_ENABLED) Log.d(LOGTAG, "onUserCanceledSsl()");
Michael Kolb14612442011-06-24 13:06:29 -0700194 }
195
196 @Override
197 public void activateVoiceSearchMode(String title, List<String> results) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100198 if (LOGD_ENABLED) Log.d(LOGTAG, "activateVoiceSearchMode()");
Michael Kolb14612442011-06-24 13:06:29 -0700199 }
200
201 @Override
202 public void revertVoiceSearchMode(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100203 if (LOGD_ENABLED) Log.d(LOGTAG, "revertVoiceSearchMode()");
Michael Kolb14612442011-06-24 13:06:29 -0700204 }
205
206 @Override
207 public boolean shouldShowErrorConsole() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100208 if (LOGD_ENABLED) Log.d(LOGTAG, "shouldShowErrorConsole()");
Michael Kolb14612442011-06-24 13:06:29 -0700209 return false;
210 }
211
212 @Override
Steve Block2466eff2011-10-03 15:33:09 +0100213 public void onUpdatedSecurityState(Tab tab) {
214 if (LOGD_ENABLED) Log.d(LOGTAG, "onUpdatedSecurityState()");
Michael Kolb14612442011-06-24 13:06:29 -0700215 }
216
217 @Override
Ben Murdoch8cad4132012-01-11 10:56:43 +0000218 public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100219 if (LOGD_ENABLED) Log.d(LOGTAG, "openFileChooser()");
Michael Kolb14612442011-06-24 13:06:29 -0700220 }
221
222 @Override
223 public void endActionMode() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100224 if (LOGD_ENABLED) Log.d(LOGTAG, "endActionMode()");
Michael Kolb14612442011-06-24 13:06:29 -0700225 }
226
227 @Override
228 public void attachSubWindow(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100229 if (LOGD_ENABLED) Log.d(LOGTAG, "attachSubWindow()");
Michael Kolb14612442011-06-24 13:06:29 -0700230 }
231
232 @Override
233 public void dismissSubWindow(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100234 if (LOGD_ENABLED) Log.d(LOGTAG, "dismissSubWindow()");
Michael Kolb14612442011-06-24 13:06:29 -0700235 }
236
237 @Override
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100238 public Tab openTab(String url, boolean incognito, boolean setActive, boolean useCurrent) {
239 if (LOGD_ENABLED) Log.d(LOGTAG, "openTab()");
Michael Kolb14612442011-06-24 13:06:29 -0700240 return null;
241 }
242
243 @Override
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100244 public Tab openTab(String url, Tab parent, boolean setActive, boolean useCurrent) {
245 if (LOGD_ENABLED) Log.d(LOGTAG, "openTab()");
Michael Kolb14612442011-06-24 13:06:29 -0700246 return null;
247 }
248
249 @Override
250 public boolean switchToTab(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100251 if (LOGD_ENABLED) Log.d(LOGTAG, "switchToTab()");
Michael Kolb14612442011-06-24 13:06:29 -0700252 return false;
253 }
254
255 @Override
256 public void closeTab(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100257 if (LOGD_ENABLED) Log.d(LOGTAG, "closeTab()");
Michael Kolb14612442011-06-24 13:06:29 -0700258 }
259
260 @Override
261 public void setupAutoFill(Message message) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100262 if (LOGD_ENABLED) Log.d(LOGTAG, "setupAutoFill()");
Michael Kolb14612442011-06-24 13:06:29 -0700263 }
264
265 @Override
266 public void bookmarkedStatusHasChanged(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100267 if (LOGD_ENABLED) Log.d(LOGTAG, "bookmarkedStatusHasChanged()");
Michael Kolb14612442011-06-24 13:06:29 -0700268 }
269
270 @Override
271 public void showAutoLogin(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100272 if (LOGD_ENABLED) Log.d(LOGTAG, "showAutoLogin()");
Michael Kolb14612442011-06-24 13:06:29 -0700273 }
274
275 @Override
276 public void hideAutoLogin(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100277 if (LOGD_ENABLED) Log.d(LOGTAG, "hideAutoLogin()");
Michael Kolb14612442011-06-24 13:06:29 -0700278 }
279
John Reck1cf4b792011-07-26 10:22:22 -0700280 @Override
281 public boolean shouldCaptureThumbnails() {
282 return false;
283 }
284
Michael Kolb14612442011-06-24 13:06:29 -0700285}