blob: 529820ba429149e7a88e54c1d99a24cf7ed2ee97 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
17package android.webkit;
18
19import com.android.internal.R;
20
21import android.app.AlertDialog;
22import android.content.Context;
23import android.content.DialogInterface;
24import 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 Popescu385df692009-08-13 11:59:57 +010029 *
Kristian Monsenf0d97312011-01-12 19:15:35 +000030 * @hide
Dianne Hackborn4a51c202009-08-21 15:14:02 -070031 * @deprecated This interface was intended to be used by Gears. Since Gears was
Andrei Popescu385df692009-08-13 11:59:57 +010032 * deprecated, so is this class.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033 */
Andrei Popescu385df692009-08-13 11:59:57 +010034@Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035public class Plugin {
Kristian Monsenf0d97312011-01-12 19:15:35 +000036 /*
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 Project9066cfe2009-03-03 19:31:44 -080041 public interface PreferencesClickHandler {
Kristian Monsenf0d97312011-01-12 19:15:35 +000042 /*
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 Project9066cfe2009-03-03 19:31:44 -080047 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 Popescu385df692009-08-13 11:59:57 +010056 /**
Kristian Monsenf0d97312011-01-12 19:15:35 +000057 * @hide
Dianne Hackborn4a51c202009-08-21 15:14:02 -070058 * @deprecated This interface was intended to be used by Gears. Since Gears was
59 * deprecated, so is this class.
Andrei Popescu385df692009-08-13 11:59:57 +010060 */
61 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080062 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 Popescu385df692009-08-13 11:59:57 +010073 /**
Kristian Monsenf0d97312011-01-12 19:15:35 +000074 * @hide
Dianne Hackborn4a51c202009-08-21 15:14:02 -070075 * @deprecated This interface was intended to be used by Gears. Since Gears was
76 * deprecated, so is this class.
Andrei Popescu385df692009-08-13 11:59:57 +010077 */
78 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080079 public String toString() {
80 return mName;
81 }
82
Andrei Popescu385df692009-08-13 11:59:57 +010083 /**
Kristian Monsenf0d97312011-01-12 19:15:35 +000084 * @hide
Dianne Hackborn4a51c202009-08-21 15:14:02 -070085 * @deprecated This interface was intended to be used by Gears. Since Gears was
86 * deprecated, so is this class.
Andrei Popescu385df692009-08-13 11:59:57 +010087 */
88 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080089 public String getName() {
90 return mName;
91 }
92
Andrei Popescu385df692009-08-13 11:59:57 +010093 /**
Kristian Monsenf0d97312011-01-12 19:15:35 +000094 * @hide
Dianne Hackborn4a51c202009-08-21 15:14:02 -070095 * @deprecated This interface was intended to be used by Gears. Since Gears was
96 * deprecated, so is this class.
Andrei Popescu385df692009-08-13 11:59:57 +010097 */
98 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080099 public String getPath() {
100 return mPath;
101 }
102
Andrei Popescu385df692009-08-13 11:59:57 +0100103 /**
Kristian Monsenf0d97312011-01-12 19:15:35 +0000104 * @hide
Dianne Hackborn4a51c202009-08-21 15:14:02 -0700105 * @deprecated This interface was intended to be used by Gears. Since Gears was
106 * deprecated, so is this class.
Andrei Popescu385df692009-08-13 11:59:57 +0100107 */
108 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800109 public String getFileName() {
110 return mFileName;
111 }
112
Andrei Popescu385df692009-08-13 11:59:57 +0100113 /**
Kristian Monsenf0d97312011-01-12 19:15:35 +0000114 * @hide
Dianne Hackborn4a51c202009-08-21 15:14:02 -0700115 * @deprecated This interface was intended to be used by Gears. Since Gears was
116 * deprecated, so is this class.
Andrei Popescu385df692009-08-13 11:59:57 +0100117 */
118 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800119 public String getDescription() {
120 return mDescription;
121 }
122
Andrei Popescu385df692009-08-13 11:59:57 +0100123 /**
Kristian Monsenf0d97312011-01-12 19:15:35 +0000124 * @hide
Dianne Hackborn4a51c202009-08-21 15:14:02 -0700125 * @deprecated This interface was intended to be used by Gears. Since Gears was
126 * deprecated, so is this class.
Andrei Popescu385df692009-08-13 11:59:57 +0100127 */
128 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800129 public void setName(String name) {
130 mName = name;
131 }
132
Andrei Popescu385df692009-08-13 11:59:57 +0100133 /**
Kristian Monsenf0d97312011-01-12 19:15:35 +0000134 * @hide
Dianne Hackborn4a51c202009-08-21 15:14:02 -0700135 * @deprecated This interface was intended to be used by Gears. Since Gears was
136 * deprecated, so is this class.
Andrei Popescu385df692009-08-13 11:59:57 +0100137 */
138 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800139 public void setPath(String path) {
140 mPath = path;
141 }
142
Andrei Popescu385df692009-08-13 11:59:57 +0100143 /**
Kristian Monsenf0d97312011-01-12 19:15:35 +0000144 * @hide
Dianne Hackborn4a51c202009-08-21 15:14:02 -0700145 * @deprecated This interface was intended to be used by Gears. Since Gears was
146 * deprecated, so is this class.
Andrei Popescu385df692009-08-13 11:59:57 +0100147 */
148 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800149 public void setFileName(String fileName) {
150 mFileName = fileName;
151 }
152
Andrei Popescu385df692009-08-13 11:59:57 +0100153 /**
Kristian Monsenf0d97312011-01-12 19:15:35 +0000154 * @hide
Dianne Hackborn4a51c202009-08-21 15:14:02 -0700155 * @deprecated This interface was intended to be used by Gears. Since Gears was
156 * deprecated, so is this class.
Andrei Popescu385df692009-08-13 11:59:57 +0100157 */
158 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800159 public void setDescription(String description) {
160 mDescription = description;
161 }
162
Andrei Popescu385df692009-08-13 11:59:57 +0100163 /**
Kristian Monsenf0d97312011-01-12 19:15:35 +0000164 * @hide
Dianne Hackborn4a51c202009-08-21 15:14:02 -0700165 * @deprecated This interface was intended to be used by Gears. Since Gears was
166 * deprecated, so is this class.
Andrei Popescu385df692009-08-13 11:59:57 +0100167 */
168 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800169 public void setClickHandler(PreferencesClickHandler handler) {
170 mHandler = handler;
171 }
172
173 /**
174 * Invokes the click handler for this plugin.
Andrei Popescu385df692009-08-13 11:59:57 +0100175 *
Kristian Monsenf0d97312011-01-12 19:15:35 +0000176 * @hide
Dianne Hackborn4a51c202009-08-21 15:14:02 -0700177 * @deprecated This interface was intended to be used by Gears. Since Gears was
178 * deprecated, so is this class.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800179 */
Andrei Popescu385df692009-08-13 11:59:57 +0100180 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800181 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 Popescu385df692009-08-13 11:59:57 +0100189 *
Kristian Monsenf0d97312011-01-12 19:15:35 +0000190 * @hide
Dianne Hackborn4a51c202009-08-21 15:14:02 -0700191 * @deprecated This interface was intended to be used by Gears. Since Gears was
192 * deprecated, so is this class.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800193 */
Andrei Popescu385df692009-08-13 11:59:57 +0100194 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800195 private class DefaultClickHandler implements PreferencesClickHandler,
196 DialogInterface.OnClickListener {
197 private AlertDialog mDialog;
Andrei Popescu385df692009-08-13 11:59:57 +0100198 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800199 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 Popescu385df692009-08-13 11:59:57 +0100211 /**
Kristian Monsenf0d97312011-01-12 19:15:35 +0000212 * @hide
Dianne Hackborn4a51c202009-08-21 15:14:02 -0700213 * @deprecated This interface was intended to be used by Gears. Since Gears was
214 * deprecated, so is this class.
Andrei Popescu385df692009-08-13 11:59:57 +0100215 */
216 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800217 public void onClick(DialogInterface dialog, int which) {
218 mDialog.dismiss();
219 mDialog = null;
220 }
221 }
222}