blob: b564318795274972ccb7160eabef0262a538fa41 [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
Bijan Amirzada41242f22014-03-21 12:12:18 -070017package com.android.browser;
Michael Kolb14612442011-06-24 13:06:29 -070018
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;
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080028import org.codeaurora.swe.HttpAuthHandler;
29import org.codeaurora.swe.SslErrorHandler;
Michael Kolb14612442011-06-24 13:06:29 -070030import android.webkit.ValueCallback;
31import android.webkit.WebChromeClient.CustomViewCallback;
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080032import org.codeaurora.swe.WebView;
Michael Kolb14612442011-06-24 13:06:29 -070033
Michael Kolb14612442011-06-24 13:06:29 -070034public class PreloadController implements WebViewController {
35
Mathew Inwoode1dbb952011-07-08 17:27:38 +010036 private static final boolean LOGD_ENABLED = false;
37 private static final String LOGTAG = "PreloadController";
38
Michael Kolb14612442011-06-24 13:06:29 -070039 private Context mContext;
40
41 public PreloadController(Context ctx) {
Ben Murdoch914c5592011-08-01 13:58:47 +010042 mContext = ctx.getApplicationContext();
Michael Kolb14612442011-06-24 13:06:29 -070043
44 }
45
46 @Override
47 public Context getContext() {
48 return mContext;
49 }
50
51 @Override
52 public Activity getActivity() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010053 if (LOGD_ENABLED) Log.d(LOGTAG, "getActivity()");
Michael Kolb14612442011-06-24 13:06:29 -070054 return null;
55 }
56
57 @Override
58 public TabControl getTabControl() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010059 if (LOGD_ENABLED) Log.d(LOGTAG, "getTabControl()");
Michael Kolb14612442011-06-24 13:06:29 -070060 return null;
61 }
62
63 @Override
64 public WebViewFactory getWebViewFactory() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010065 if (LOGD_ENABLED) Log.d(LOGTAG, "getWebViewFactory()");
Michael Kolb14612442011-06-24 13:06:29 -070066 return null;
67 }
68
69 @Override
70 public void onSetWebView(Tab tab, WebView view) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010071 if (LOGD_ENABLED) Log.d(LOGTAG, "onSetWebView()");
Michael Kolb14612442011-06-24 13:06:29 -070072 }
73
74 @Override
75 public void createSubWindow(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010076 if (LOGD_ENABLED) Log.d(LOGTAG, "createSubWindow()");
Michael Kolb14612442011-06-24 13:06:29 -070077 }
78
79 @Override
80 public void onPageStarted(Tab tab, WebView view, Bitmap favicon) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010081 if (LOGD_ENABLED) Log.d(LOGTAG, "onPageStarted()");
Narayan Kamathc8892c72011-07-20 14:36:22 +010082 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 }
Michael Kolb14612442011-06-24 13:06:29 -070088 }
89
90 @Override
91 public void onPageFinished(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010092 if (LOGD_ENABLED) Log.d(LOGTAG, "onPageFinished()");
Narayan Kamathc8892c72011-07-20 14:36:22 +010093 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 }
Michael Kolb14612442011-06-24 13:06:29 -0700101 }
102
103 @Override
104 public void onProgressChanged(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100105 if (LOGD_ENABLED) Log.d(LOGTAG, "onProgressChanged()");
Michael Kolb14612442011-06-24 13:06:29 -0700106 }
107
108 @Override
109 public void onReceivedTitle(Tab tab, String title) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100110 if (LOGD_ENABLED) Log.d(LOGTAG, "onReceivedTitle()");
Michael Kolb14612442011-06-24 13:06:29 -0700111 }
112
113 @Override
114 public void onFavicon(Tab tab, WebView view, Bitmap icon) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100115 if (LOGD_ENABLED) Log.d(LOGTAG, "onFavicon()");
Michael Kolb14612442011-06-24 13:06:29 -0700116 }
117
118 @Override
119 public boolean shouldOverrideUrlLoading(Tab tab, WebView view, String url) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100120 if (LOGD_ENABLED) Log.d(LOGTAG, "shouldOverrideUrlLoading()");
Michael Kolb14612442011-06-24 13:06:29 -0700121 return false;
122 }
123
124 @Override
125 public boolean shouldOverrideKeyEvent(KeyEvent event) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100126 if (LOGD_ENABLED) Log.d(LOGTAG, "shouldOverrideKeyEvent()");
Michael Kolb14612442011-06-24 13:06:29 -0700127 return false;
128 }
129
130 @Override
John Reck997b1b72012-04-19 18:08:25 -0700131 public boolean onUnhandledKeyEvent(KeyEvent event) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100132 if (LOGD_ENABLED) Log.d(LOGTAG, "onUnhandledKeyEvent()");
John Reck997b1b72012-04-19 18:08:25 -0700133 return false;
Michael Kolb14612442011-06-24 13:06:29 -0700134 }
135
136 @Override
137 public void doUpdateVisitedHistory(Tab tab, boolean isReload) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100138 if (LOGD_ENABLED) Log.d(LOGTAG, "doUpdateVisitedHistory()");
Michael Kolb14612442011-06-24 13:06:29 -0700139 }
140
141 @Override
142 public void getVisitedHistory(ValueCallback<String[]> callback) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100143 if (LOGD_ENABLED) Log.d(LOGTAG, "getVisitedHistory()");
Michael Kolb14612442011-06-24 13:06:29 -0700144 }
145
146 @Override
147 public void onReceivedHttpAuthRequest(Tab tab, WebView view,
148 HttpAuthHandler handler, String host,
149 String realm) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100150 if (LOGD_ENABLED) Log.d(LOGTAG, "onReceivedHttpAuthRequest()");
Michael Kolb14612442011-06-24 13:06:29 -0700151 }
152
153 @Override
154 public void onDownloadStart(Tab tab, String url, String useragent,
155 String contentDisposition, String mimeType,
Selim Gurun0b3d66f2012-08-29 13:08:13 -0700156 String referer, long contentLength) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100157 if (LOGD_ENABLED) Log.d(LOGTAG, "onDownloadStart()");
Michael Kolb14612442011-06-24 13:06:29 -0700158 }
159
160 @Override
161 public void showCustomView(Tab tab, View view, int requestedOrientation,
162 CustomViewCallback callback) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100163 if (LOGD_ENABLED) Log.d(LOGTAG, "showCustomView()");
Michael Kolb14612442011-06-24 13:06:29 -0700164 }
165
166 @Override
167 public void hideCustomView() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100168 if (LOGD_ENABLED) Log.d(LOGTAG, "hideCustomView()");
Michael Kolb14612442011-06-24 13:06:29 -0700169 }
170
171 @Override
172 public Bitmap getDefaultVideoPoster() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100173 if (LOGD_ENABLED) Log.d(LOGTAG, "getDefaultVideoPoster()");
Michael Kolb14612442011-06-24 13:06:29 -0700174 return null;
175 }
176
177 @Override
178 public View getVideoLoadingProgressView() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100179 if (LOGD_ENABLED) Log.d(LOGTAG, "getVideoLoadingProgressView()");
Michael Kolb14612442011-06-24 13:06:29 -0700180 return null;
181 }
182
183 @Override
184 public void showSslCertificateOnError(WebView view,
185 SslErrorHandler handler, SslError error) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100186 if (LOGD_ENABLED) Log.d(LOGTAG, "showSslCertificateOnError()");
Michael Kolb14612442011-06-24 13:06:29 -0700187 }
188
189 @Override
190 public void onUserCanceledSsl(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100191 if (LOGD_ENABLED) Log.d(LOGTAG, "onUserCanceledSsl()");
Michael Kolb14612442011-06-24 13:06:29 -0700192 }
193
194 @Override
Michael Kolb14612442011-06-24 13:06:29 -0700195 public boolean shouldShowErrorConsole() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100196 if (LOGD_ENABLED) Log.d(LOGTAG, "shouldShowErrorConsole()");
Michael Kolb14612442011-06-24 13:06:29 -0700197 return false;
198 }
199
200 @Override
Steve Block2466eff2011-10-03 15:33:09 +0100201 public void onUpdatedSecurityState(Tab tab) {
202 if (LOGD_ENABLED) Log.d(LOGTAG, "onUpdatedSecurityState()");
Michael Kolb14612442011-06-24 13:06:29 -0700203 }
204
205 @Override
Ben Murdoch8cad4132012-01-11 10:56:43 +0000206 public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100207 if (LOGD_ENABLED) Log.d(LOGTAG, "openFileChooser()");
Michael Kolb14612442011-06-24 13:06:29 -0700208 }
209
210 @Override
211 public void endActionMode() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100212 if (LOGD_ENABLED) Log.d(LOGTAG, "endActionMode()");
Michael Kolb14612442011-06-24 13:06:29 -0700213 }
214
215 @Override
216 public void attachSubWindow(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100217 if (LOGD_ENABLED) Log.d(LOGTAG, "attachSubWindow()");
Michael Kolb14612442011-06-24 13:06:29 -0700218 }
219
220 @Override
221 public void dismissSubWindow(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100222 if (LOGD_ENABLED) Log.d(LOGTAG, "dismissSubWindow()");
Michael Kolb14612442011-06-24 13:06:29 -0700223 }
224
225 @Override
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100226 public Tab openTab(String url, boolean incognito, boolean setActive, boolean useCurrent) {
227 if (LOGD_ENABLED) Log.d(LOGTAG, "openTab()");
Michael Kolb14612442011-06-24 13:06:29 -0700228 return null;
229 }
230
231 @Override
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100232 public Tab openTab(String url, Tab parent, boolean setActive, boolean useCurrent) {
233 if (LOGD_ENABLED) Log.d(LOGTAG, "openTab()");
Michael Kolb14612442011-06-24 13:06:29 -0700234 return null;
235 }
236
237 @Override
238 public boolean switchToTab(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100239 if (LOGD_ENABLED) Log.d(LOGTAG, "switchToTab()");
Michael Kolb14612442011-06-24 13:06:29 -0700240 return false;
241 }
242
243 @Override
244 public void closeTab(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100245 if (LOGD_ENABLED) Log.d(LOGTAG, "closeTab()");
Michael Kolb14612442011-06-24 13:06:29 -0700246 }
247
248 @Override
249 public void setupAutoFill(Message message) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100250 if (LOGD_ENABLED) Log.d(LOGTAG, "setupAutoFill()");
Michael Kolb14612442011-06-24 13:06:29 -0700251 }
252
253 @Override
254 public void bookmarkedStatusHasChanged(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100255 if (LOGD_ENABLED) Log.d(LOGTAG, "bookmarkedStatusHasChanged()");
Michael Kolb14612442011-06-24 13:06:29 -0700256 }
257
258 @Override
259 public void showAutoLogin(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100260 if (LOGD_ENABLED) Log.d(LOGTAG, "showAutoLogin()");
Michael Kolb14612442011-06-24 13:06:29 -0700261 }
262
263 @Override
264 public void hideAutoLogin(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100265 if (LOGD_ENABLED) Log.d(LOGTAG, "hideAutoLogin()");
Michael Kolb14612442011-06-24 13:06:29 -0700266 }
267
John Reck1cf4b792011-07-26 10:22:22 -0700268 @Override
269 public boolean shouldCaptureThumbnails() {
270 return false;
271 }
272
Michael Kolb14612442011-06-24 13:06:29 -0700273}