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.app.Activity; 20import android.content.Context; 21import android.graphics.Bitmap; 22import android.net.Uri; 23import android.net.http.SslError; 24import android.os.Message; 25import android.view.KeyEvent; 26import android.view.View; 27import android.webkit.HttpAuthHandler; 28import android.webkit.SslErrorHandler; 29import android.webkit.ValueCallback; 30import android.webkit.WebChromeClient; 31import android.webkit.WebView; 32 33import java.util.List; 34 35/** 36 * WebView aspect of the controller 37 */ 38public interface WebViewController { 39 40 Context getContext(); 41 42 Activity getActivity(); 43 44 TabControl getTabControl(); 45 46 WebViewFactory getWebViewFactory(); 47 48 void onSetWebView(Tab tab, WebView view); 49 50 void createSubWindow(Tab tab); 51 52 void onPageStarted(Tab tab, WebView view, Bitmap favicon); 53 54 void onPageFinished(Tab tab); 55 56 void onProgressChanged(Tab tab); 57 58 void onReceivedTitle(Tab tab, final String title); 59 60 void onFavicon(Tab tab, WebView view, Bitmap icon); 61 62 boolean shouldOverrideUrlLoading(Tab tab, WebView view, String url); 63 64 boolean shouldOverrideKeyEvent(KeyEvent event); 65 66 boolean onUnhandledKeyEvent(KeyEvent event); 67 68 void doUpdateVisitedHistory(Tab tab, boolean isReload); 69 70 void getVisitedHistory(final ValueCallback<String[]> callback); 71 72 void onReceivedHttpAuthRequest(Tab tab, WebView view, final HttpAuthHandler handler, 73 final String host, final String realm); 74 75 void onDownloadStart(Tab tab, String url, String useragent, String contentDisposition, 76 String mimeType, String referer, long contentLength); 77 78 void showCustomView(Tab tab, View view, int requestedOrientation, 79 WebChromeClient.CustomViewCallback callback); 80 81 void hideCustomView(); 82 83 Bitmap getDefaultVideoPoster(); 84 85 View getVideoLoadingProgressView(); 86 87 void showSslCertificateOnError(WebView view, SslErrorHandler handler, 88 SslError error); 89 90 void onUserCanceledSsl(Tab tab); 91 92 boolean shouldShowErrorConsole(); 93 94 void onUpdatedSecurityState(Tab tab); 95 96 void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture); 97 98 void endActionMode(); 99 100 void attachSubWindow(Tab tab); 101 102 void dismissSubWindow(Tab tab); 103 104 Tab openTab(String url, boolean incognito, boolean setActive, 105 boolean useCurrent); 106 107 Tab openTab(String url, Tab parent, boolean setActive, 108 boolean useCurrent); 109 110 boolean switchToTab(Tab tab); 111 112 void closeTab(Tab tab); 113 114 void bookmarkedStatusHasChanged(Tab tab); 115 116 void showAutoLogin(Tab tab); 117 118 void hideAutoLogin(Tab tab); 119 120 boolean shouldCaptureThumbnails(); 121} 122