1 /* 2 * Copyright (C) 2007 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; 18 19 import com.android.internal.R; 20 21 import android.app.AlertDialog; 22 import android.content.Context; 23 import android.content.DialogInterface; 24 import android.webkit.WebView; 25 26 /** 27 * Represents a plugin (Java equivalent of the PluginPackageAndroid 28 * C++ class in libs/WebKitLib/WebKit/WebCore/plugins/android/) 29 * 30 * @hide 31 * @deprecated This interface was intended to be used by Gears. Since Gears was 32 * deprecated, so is this class. 33 */ 34 @Deprecated 35 public class Plugin { 36 /* 37 * @hide 38 * @deprecated This interface was intended to be used by Gears. Since Gears was 39 * deprecated, so is this class. 40 */ 41 public interface PreferencesClickHandler { 42 /* 43 * @hide 44 * @deprecated This interface was intended to be used by Gears. Since Gears was 45 * deprecated, so is this class. 46 */ 47 public void handleClickEvent(Context context); 48 } 49 50 private String mName; 51 private String mPath; 52 private String mFileName; 53 private String mDescription; 54 private PreferencesClickHandler mHandler; 55 56 /** 57 * @hide 58 * @deprecated This interface was intended to be used by Gears. Since Gears was 59 * deprecated, so is this class. 60 */ 61 @Deprecated 62 public Plugin(String name, 63 String path, 64 String fileName, 65 String description) { 66 mName = name; 67 mPath = path; 68 mFileName = fileName; 69 mDescription = description; 70 mHandler = new DefaultClickHandler(); 71 } 72 73 /** 74 * @hide 75 * @deprecated This interface was intended to be used by Gears. Since Gears was 76 * deprecated, so is this class. 77 */ 78 @Deprecated 79 public String toString() { 80 return mName; 81 } 82 83 /** 84 * @hide 85 * @deprecated This interface was intended to be used by Gears. Since Gears was 86 * deprecated, so is this class. 87 */ 88 @Deprecated 89 public String getName() { 90 return mName; 91 } 92 93 /** 94 * @hide 95 * @deprecated This interface was intended to be used by Gears. Since Gears was 96 * deprecated, so is this class. 97 */ 98 @Deprecated 99 public String getPath() { 100 return mPath; 101 } 102 103 /** 104 * @hide 105 * @deprecated This interface was intended to be used by Gears. Since Gears was 106 * deprecated, so is this class. 107 */ 108 @Deprecated 109 public String getFileName() { 110 return mFileName; 111 } 112 113 /** 114 * @hide 115 * @deprecated This interface was intended to be used by Gears. Since Gears was 116 * deprecated, so is this class. 117 */ 118 @Deprecated 119 public String getDescription() { 120 return mDescription; 121 } 122 123 /** 124 * @hide 125 * @deprecated This interface was intended to be used by Gears. Since Gears was 126 * deprecated, so is this class. 127 */ 128 @Deprecated 129 public void setName(String name) { 130 mName = name; 131 } 132 133 /** 134 * @hide 135 * @deprecated This interface was intended to be used by Gears. Since Gears was 136 * deprecated, so is this class. 137 */ 138 @Deprecated 139 public void setPath(String path) { 140 mPath = path; 141 } 142 143 /** 144 * @hide 145 * @deprecated This interface was intended to be used by Gears. Since Gears was 146 * deprecated, so is this class. 147 */ 148 @Deprecated 149 public void setFileName(String fileName) { 150 mFileName = fileName; 151 } 152 153 /** 154 * @hide 155 * @deprecated This interface was intended to be used by Gears. Since Gears was 156 * deprecated, so is this class. 157 */ 158 @Deprecated 159 public void setDescription(String description) { 160 mDescription = description; 161 } 162 163 /** 164 * @hide 165 * @deprecated This interface was intended to be used by Gears. Since Gears was 166 * deprecated, so is this class. 167 */ 168 @Deprecated 169 public void setClickHandler(PreferencesClickHandler handler) { 170 mHandler = handler; 171 } 172 173 /** 174 * Invokes the click handler for this plugin. 175 * 176 * @hide 177 * @deprecated This interface was intended to be used by Gears. Since Gears was 178 * deprecated, so is this class. 179 */ 180 @Deprecated 181 public void dispatchClickEvent(Context context) { 182 if (mHandler != null) { 183 mHandler.handleClickEvent(context); 184 } 185 } 186 187 /** 188 * Default click handler. The plugins should implement their own. 189 * 190 * @hide 191 * @deprecated This interface was intended to be used by Gears. Since Gears was 192 * deprecated, so is this class. 193 */ 194 @Deprecated 195 private class DefaultClickHandler implements PreferencesClickHandler, 196 DialogInterface.OnClickListener { 197 private AlertDialog mDialog; 198 @Deprecated 199 public void handleClickEvent(Context context) { 200 // Show a simple popup dialog containing the description 201 // string of the plugin. 202 if (mDialog == null) { 203 mDialog = new AlertDialog.Builder(context) 204 .setTitle(mName) 205 .setMessage(mDescription) 206 .setPositiveButton(R.string.ok, this) 207 .setCancelable(false) 208 .show(); 209 } 210 } 211 /** 212 * @hide 213 * @deprecated This interface was intended to be used by Gears. Since Gears was 214 * deprecated, so is this class. 215 */ 216 @Deprecated 217 public void onClick(DialogInterface dialog, int which) { 218 mDialog.dismiss(); 219 mDialog = null; 220 } 221 } 222 } 223