The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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/) |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 29 | * |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 30 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 31 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 32 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 34 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | public class Plugin { |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 36 | /* |
| 37 | * @hide |
| 38 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 39 | * deprecated, so is this class. |
| 40 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | public interface PreferencesClickHandler { |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 42 | /* |
| 43 | * @hide |
| 44 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 45 | * deprecated, so is this class. |
| 46 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 56 | /** |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 57 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 58 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 59 | * deprecated, so is this class. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 60 | */ |
| 61 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 73 | /** |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 74 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 75 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 76 | * deprecated, so is this class. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 77 | */ |
| 78 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 79 | public String toString() { |
| 80 | return mName; |
| 81 | } |
| 82 | |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 83 | /** |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 84 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 85 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 86 | * deprecated, so is this class. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 87 | */ |
| 88 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | public String getName() { |
| 90 | return mName; |
| 91 | } |
| 92 | |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 93 | /** |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 94 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 95 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 96 | * deprecated, so is this class. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 97 | */ |
| 98 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 99 | public String getPath() { |
| 100 | return mPath; |
| 101 | } |
| 102 | |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 103 | /** |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 104 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 105 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 106 | * deprecated, so is this class. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 107 | */ |
| 108 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 109 | public String getFileName() { |
| 110 | return mFileName; |
| 111 | } |
| 112 | |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 113 | /** |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 114 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 115 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 116 | * deprecated, so is this class. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 117 | */ |
| 118 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 119 | public String getDescription() { |
| 120 | return mDescription; |
| 121 | } |
| 122 | |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 123 | /** |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 124 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 125 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 126 | * deprecated, so is this class. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 127 | */ |
| 128 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 129 | public void setName(String name) { |
| 130 | mName = name; |
| 131 | } |
| 132 | |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 133 | /** |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 134 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 135 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 136 | * deprecated, so is this class. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 137 | */ |
| 138 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 139 | public void setPath(String path) { |
| 140 | mPath = path; |
| 141 | } |
| 142 | |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 143 | /** |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 144 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 145 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 146 | * deprecated, so is this class. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 147 | */ |
| 148 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 149 | public void setFileName(String fileName) { |
| 150 | mFileName = fileName; |
| 151 | } |
| 152 | |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 153 | /** |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 154 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 155 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 156 | * deprecated, so is this class. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 157 | */ |
| 158 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 159 | public void setDescription(String description) { |
| 160 | mDescription = description; |
| 161 | } |
| 162 | |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 163 | /** |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 164 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 165 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 166 | * deprecated, so is this class. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 167 | */ |
| 168 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 169 | public void setClickHandler(PreferencesClickHandler handler) { |
| 170 | mHandler = handler; |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * Invokes the click handler for this plugin. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 175 | * |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 176 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 177 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 178 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 179 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 180 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 189 | * |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 190 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 191 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 192 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 193 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 194 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 195 | private class DefaultClickHandler implements PreferencesClickHandler, |
| 196 | DialogInterface.OnClickListener { |
| 197 | private AlertDialog mDialog; |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 198 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | } |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 211 | /** |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 212 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 213 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 214 | * deprecated, so is this class. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 215 | */ |
| 216 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 217 | public void onClick(DialogInterface dialog, int which) { |
| 218 | mDialog.dismiss(); |
| 219 | mDialog = null; |
| 220 | } |
| 221 | } |
| 222 | } |