blob: a9a7786f3bff00ba49fb5bf3dd9cad6c10ba082e [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;
Michael Kolb14612442011-06-24 13:06:29 -070023import android.os.Message;
Mathew Inwoode1dbb952011-07-08 17:27:38 +010024import android.util.Log;
Michael Kolb14612442011-06-24 13:06:29 -070025import android.view.KeyEvent;
26import android.view.View;
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080027import org.codeaurora.swe.HttpAuthHandler;
Michael Kolb14612442011-06-24 13:06:29 -070028import android.webkit.ValueCallback;
29import android.webkit.WebChromeClient.CustomViewCallback;
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080030import org.codeaurora.swe.WebView;
Michael Kolb14612442011-06-24 13:06:29 -070031
Michael Kolb14612442011-06-24 13:06:29 -070032public class PreloadController implements WebViewController {
33
Mathew Inwoode1dbb952011-07-08 17:27:38 +010034 private static final boolean LOGD_ENABLED = false;
35 private static final String LOGTAG = "PreloadController";
36
Michael Kolb14612442011-06-24 13:06:29 -070037 private Context mContext;
38
39 public PreloadController(Context ctx) {
Ben Murdoch914c5592011-08-01 13:58:47 +010040 mContext = ctx.getApplicationContext();
Michael Kolb14612442011-06-24 13:06:29 -070041
42 }
43
44 @Override
45 public Context getContext() {
46 return mContext;
47 }
48
49 @Override
50 public Activity getActivity() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010051 if (LOGD_ENABLED) Log.d(LOGTAG, "getActivity()");
Michael Kolb14612442011-06-24 13:06:29 -070052 return null;
53 }
54
55 @Override
56 public TabControl getTabControl() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010057 if (LOGD_ENABLED) Log.d(LOGTAG, "getTabControl()");
Michael Kolb14612442011-06-24 13:06:29 -070058 return null;
59 }
60
61 @Override
62 public WebViewFactory getWebViewFactory() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010063 if (LOGD_ENABLED) Log.d(LOGTAG, "getWebViewFactory()");
Michael Kolb14612442011-06-24 13:06:29 -070064 return null;
65 }
66
67 @Override
68 public void onSetWebView(Tab tab, WebView view) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010069 if (LOGD_ENABLED) Log.d(LOGTAG, "onSetWebView()");
Michael Kolb14612442011-06-24 13:06:29 -070070 }
71
72 @Override
73 public void createSubWindow(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010074 if (LOGD_ENABLED) Log.d(LOGTAG, "createSubWindow()");
Michael Kolb14612442011-06-24 13:06:29 -070075 }
76
77 @Override
78 public void onPageStarted(Tab tab, WebView view, Bitmap favicon) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010079 if (LOGD_ENABLED) Log.d(LOGTAG, "onPageStarted()");
Narayan Kamathc8892c72011-07-20 14:36:22 +010080 if (view != null) {
81 // Clear history of all previously visited pages. When the
82 // user visits a preloaded tab, the only item in the history
83 // list should the currently viewed page.
84 view.clearHistory();
85 }
Michael Kolb14612442011-06-24 13:06:29 -070086 }
87
88 @Override
89 public void onPageFinished(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +010090 if (LOGD_ENABLED) Log.d(LOGTAG, "onPageFinished()");
Narayan Kamathc8892c72011-07-20 14:36:22 +010091 if (tab != null) {
92 final WebView view = tab.getWebView();
93 if (view != null) {
94 // Clear history of all previously visited pages. When the
95 // user visits a preloaded tab.
96 view.clearHistory();
97 }
98 }
Michael Kolb14612442011-06-24 13:06:29 -070099 }
100
101 @Override
102 public void onProgressChanged(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100103 if (LOGD_ENABLED) Log.d(LOGTAG, "onProgressChanged()");
Michael Kolb14612442011-06-24 13:06:29 -0700104 }
105
106 @Override
107 public void onReceivedTitle(Tab tab, String title) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100108 if (LOGD_ENABLED) Log.d(LOGTAG, "onReceivedTitle()");
Michael Kolb14612442011-06-24 13:06:29 -0700109 }
110
111 @Override
112 public void onFavicon(Tab tab, WebView view, Bitmap icon) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100113 if (LOGD_ENABLED) Log.d(LOGTAG, "onFavicon()");
Michael Kolb14612442011-06-24 13:06:29 -0700114 }
115
116 @Override
117 public boolean shouldOverrideUrlLoading(Tab tab, WebView view, String url) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100118 if (LOGD_ENABLED) Log.d(LOGTAG, "shouldOverrideUrlLoading()");
Michael Kolb14612442011-06-24 13:06:29 -0700119 return false;
120 }
121
122 @Override
123 public boolean shouldOverrideKeyEvent(KeyEvent event) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100124 if (LOGD_ENABLED) Log.d(LOGTAG, "shouldOverrideKeyEvent()");
Michael Kolb14612442011-06-24 13:06:29 -0700125 return false;
126 }
127
128 @Override
John Reck997b1b72012-04-19 18:08:25 -0700129 public boolean onUnhandledKeyEvent(KeyEvent event) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100130 if (LOGD_ENABLED) Log.d(LOGTAG, "onUnhandledKeyEvent()");
John Reck997b1b72012-04-19 18:08:25 -0700131 return false;
Michael Kolb14612442011-06-24 13:06:29 -0700132 }
133
134 @Override
135 public void doUpdateVisitedHistory(Tab tab, boolean isReload) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100136 if (LOGD_ENABLED) Log.d(LOGTAG, "doUpdateVisitedHistory()");
Michael Kolb14612442011-06-24 13:06:29 -0700137 }
138
139 @Override
140 public void getVisitedHistory(ValueCallback<String[]> callback) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100141 if (LOGD_ENABLED) Log.d(LOGTAG, "getVisitedHistory()");
Michael Kolb14612442011-06-24 13:06:29 -0700142 }
143
144 @Override
145 public void onReceivedHttpAuthRequest(Tab tab, WebView view,
146 HttpAuthHandler handler, String host,
147 String realm) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100148 if (LOGD_ENABLED) Log.d(LOGTAG, "onReceivedHttpAuthRequest()");
Michael Kolb14612442011-06-24 13:06:29 -0700149 }
150
151 @Override
152 public void onDownloadStart(Tab tab, String url, String useragent,
153 String contentDisposition, String mimeType,
Pankaj Garg5762b362015-11-02 07:57:06 -0800154 String referer, String auth, long contentLength) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100155 if (LOGD_ENABLED) Log.d(LOGTAG, "onDownloadStart()");
Michael Kolb14612442011-06-24 13:06:29 -0700156 }
157
158 @Override
159 public void showCustomView(Tab tab, View view, int requestedOrientation,
160 CustomViewCallback callback) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100161 if (LOGD_ENABLED) Log.d(LOGTAG, "showCustomView()");
Michael Kolb14612442011-06-24 13:06:29 -0700162 }
163
164 @Override
165 public void hideCustomView() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100166 if (LOGD_ENABLED) Log.d(LOGTAG, "hideCustomView()");
Michael Kolb14612442011-06-24 13:06:29 -0700167 }
168
169 @Override
170 public Bitmap getDefaultVideoPoster() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100171 if (LOGD_ENABLED) Log.d(LOGTAG, "getDefaultVideoPoster()");
Michael Kolb14612442011-06-24 13:06:29 -0700172 return null;
173 }
174
175 @Override
176 public View getVideoLoadingProgressView() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100177 if (LOGD_ENABLED) Log.d(LOGTAG, "getVideoLoadingProgressView()");
Michael Kolb14612442011-06-24 13:06:29 -0700178 return null;
179 }
180
181 @Override
Michael Kolb14612442011-06-24 13:06:29 -0700182 public void onUserCanceledSsl(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100183 if (LOGD_ENABLED) Log.d(LOGTAG, "onUserCanceledSsl()");
Michael Kolb14612442011-06-24 13:06:29 -0700184 }
185
186 @Override
Steve Block2466eff2011-10-03 15:33:09 +0100187 public void onUpdatedSecurityState(Tab tab) {
188 if (LOGD_ENABLED) Log.d(LOGTAG, "onUpdatedSecurityState()");
Michael Kolb14612442011-06-24 13:06:29 -0700189 }
190
191 @Override
Ben Murdoch8cad4132012-01-11 10:56:43 +0000192 public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100193 if (LOGD_ENABLED) Log.d(LOGTAG, "openFileChooser()");
Michael Kolb14612442011-06-24 13:06:29 -0700194 }
195
196 @Override
Vivek Sekharb54614f2014-05-01 19:03:37 -0700197 public void showFileChooser(ValueCallback<String[]> uploadFilePaths, String acceptTypes,
198 boolean capture) {
199 if (LOGD_ENABLED) Log.d(LOGTAG, "showFileChooser()");
200 }
201
202 @Override
Michael Kolb14612442011-06-24 13:06:29 -0700203 public void endActionMode() {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100204 if (LOGD_ENABLED) Log.d(LOGTAG, "endActionMode()");
Michael Kolb14612442011-06-24 13:06:29 -0700205 }
206
207 @Override
208 public void attachSubWindow(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100209 if (LOGD_ENABLED) Log.d(LOGTAG, "attachSubWindow()");
Michael Kolb14612442011-06-24 13:06:29 -0700210 }
211
212 @Override
213 public void dismissSubWindow(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100214 if (LOGD_ENABLED) Log.d(LOGTAG, "dismissSubWindow()");
Michael Kolb14612442011-06-24 13:06:29 -0700215 }
216
217 @Override
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100218 public Tab openTab(String url, boolean incognito, boolean setActive, boolean useCurrent) {
219 if (LOGD_ENABLED) Log.d(LOGTAG, "openTab()");
Michael Kolb14612442011-06-24 13:06:29 -0700220 return null;
221 }
222
223 @Override
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100224 public Tab openTab(String url, Tab parent, boolean setActive, boolean useCurrent) {
225 if (LOGD_ENABLED) Log.d(LOGTAG, "openTab()");
Michael Kolb14612442011-06-24 13:06:29 -0700226 return null;
227 }
228
229 @Override
230 public boolean switchToTab(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100231 if (LOGD_ENABLED) Log.d(LOGTAG, "switchToTab()");
Michael Kolb14612442011-06-24 13:06:29 -0700232 return false;
233 }
234
235 @Override
236 public void closeTab(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100237 if (LOGD_ENABLED) Log.d(LOGTAG, "closeTab()");
Michael Kolb14612442011-06-24 13:06:29 -0700238 }
239
240 @Override
241 public void setupAutoFill(Message message) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100242 if (LOGD_ENABLED) Log.d(LOGTAG, "setupAutoFill()");
Michael Kolb14612442011-06-24 13:06:29 -0700243 }
244
245 @Override
246 public void bookmarkedStatusHasChanged(Tab tab) {
Mathew Inwoode1dbb952011-07-08 17:27:38 +0100247 if (LOGD_ENABLED) Log.d(LOGTAG, "bookmarkedStatusHasChanged()");
Michael Kolb14612442011-06-24 13:06:29 -0700248 }
249
250 @Override
John Reck1cf4b792011-07-26 10:22:22 -0700251 public boolean shouldCaptureThumbnails() {
252 return false;
253 }
254
Pankaj Gargf49e0222015-09-01 12:19:13 -0700255 @Override
256 public void onThumbnailCapture(Bitmap bm) { }
Michael Kolb14612442011-06-24 13:06:29 -0700257}