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