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
17package android.webkit;
18
19import android.app.AlertDialog;
20import android.content.Context;
21import android.content.DialogInterface;
22
23import com.android.internal.R;
24
25/**
26 * Represents a plugin (Java equivalent of the PluginPackageAndroid
27 * C++ class in libs/WebKitLib/WebKit/WebCore/plugins/android/)
28 *
29 * @hide
30 * @deprecated This interface was intended to be used by Gears. Since Gears was
31 * deprecated, so is this class.
32 */
33@Deprecated
34public class Plugin {
35    /**
36     * @hide
37     * @deprecated This interface was intended to be used by Gears. Since Gears was
38     * deprecated, so is this class.
39     */
40    public interface PreferencesClickHandler {
41        /**
42         * @hide
43         * @deprecated This interface was intended to be used by Gears. Since Gears was
44         * deprecated, so is this class.
45         */
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
55    /**
56     * @hide
57     * @deprecated This interface was intended to be used by Gears. Since Gears was
58     * deprecated, so is this class.
59     */
60    @Deprecated
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
72    /**
73     * @hide
74     * @deprecated This interface was intended to be used by Gears. Since Gears was
75     * deprecated, so is this class.
76     */
77    @Deprecated
78    public String toString() {
79        return mName;
80    }
81
82    /**
83     * @hide
84     * @deprecated This interface was intended to be used by Gears. Since Gears was
85     * deprecated, so is this class.
86     */
87    @Deprecated
88    public String getName() {
89        return mName;
90    }
91
92    /**
93     * @hide
94     * @deprecated This interface was intended to be used by Gears. Since Gears was
95     * deprecated, so is this class.
96     */
97    @Deprecated
98    public String getPath() {
99        return mPath;
100    }
101
102    /**
103     * @hide
104     * @deprecated This interface was intended to be used by Gears. Since Gears was
105     * deprecated, so is this class.
106     */
107    @Deprecated
108    public String getFileName() {
109        return mFileName;
110    }
111
112    /**
113     * @hide
114     * @deprecated This interface was intended to be used by Gears. Since Gears was
115     * deprecated, so is this class.
116     */
117    @Deprecated
118    public String getDescription() {
119        return mDescription;
120    }
121
122    /**
123     * @hide
124     * @deprecated This interface was intended to be used by Gears. Since Gears was
125     * deprecated, so is this class.
126     */
127    @Deprecated
128    public void setName(String name) {
129        mName = name;
130    }
131
132    /**
133     * @hide
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 setPath(String path) {
139        mPath = path;
140    }
141
142    /**
143     * @hide
144     * @deprecated This interface was intended to be used by Gears. Since Gears was
145     * deprecated, so is this class.
146     */
147    @Deprecated
148    public void setFileName(String fileName) {
149        mFileName = fileName;
150    }
151
152    /**
153     * @hide
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 setDescription(String description) {
159        mDescription = description;
160    }
161
162    /**
163     * @hide
164     * @deprecated This interface was intended to be used by Gears. Since Gears was
165     * deprecated, so is this class.
166     */
167    @Deprecated
168    public void setClickHandler(PreferencesClickHandler handler) {
169        mHandler = handler;
170    }
171
172   /**
173    * Invokes the click handler for this plugin.
174    *
175    * @hide
176    * @deprecated This interface was intended to be used by Gears. Since Gears was
177    * deprecated, so is this class.
178    */
179    @Deprecated
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.
188    *
189    * @hide
190    * @deprecated This interface was intended to be used by Gears. Since Gears was
191    * deprecated, so is this class.
192    */
193    @Deprecated
194    private class DefaultClickHandler implements PreferencesClickHandler,
195                                                 DialogInterface.OnClickListener {
196        private AlertDialog mDialog;
197        @Deprecated
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        }
210        /**
211         * @hide
212         * @deprecated This interface was intended to be used by Gears. Since Gears was
213         * deprecated, so is this class.
214         */
215        @Deprecated
216        public void onClick(DialogInterface dialog, int which) {
217            mDialog.dismiss();
218            mDialog = null;
219        }
220    }
221}
222