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