PluginList.java revision 385df699a6d602cab501092821a79cc6ab3a390e
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.content.Context;
20import java.util.ArrayList;
21import java.util.List;
22
23/**
24 * A simple list of initialized plugins. This list gets
25 * populated when the plugins are initialized (at
26 * browser startup, at the moment).
27 *
28 * @deprecated This interface was inteded to be used by Gears. Since Gears was
29 * deprecated, so is this class.
30 */
31@Deprecated
32public class PluginList {
33    private ArrayList<Plugin> mPlugins;
34
35   /**
36    * Public constructor. Initializes the list of plugins.
37    *
38    * @deprecated
39    */
40    @Deprecated
41    public PluginList() {
42        mPlugins = new ArrayList<Plugin>();
43    }
44
45   /**
46    * Returns the list of plugins as a java.util.List.
47    *
48    * @deprecated
49    */
50    @Deprecated
51    public synchronized List getList() {
52        return mPlugins;
53    }
54
55   /**
56    * Adds a plugin to the list.
57    *
58    * @deprecated
59    */
60    @Deprecated
61    public synchronized void addPlugin(Plugin plugin) {
62        if (!mPlugins.contains(plugin)) {
63            mPlugins.add(plugin);
64        }
65    }
66
67   /**
68    * Removes a plugin from the list.
69    *
70    * @deprecated
71    */
72    @Deprecated
73    public synchronized void removePlugin(Plugin plugin) {
74        int location = mPlugins.indexOf(plugin);
75        if (location != -1) {
76            mPlugins.remove(location);
77        }
78    }
79
80   /**
81    * Clears the plugin list.
82    *
83    * @deprecated
84    */
85    @Deprecated
86    public synchronized void clear() {
87        mPlugins.clear();
88    }
89
90   /**
91    * Dispatches the click event to the appropriate plugin.
92    *
93    * @deprecated
94    */
95    @Deprecated
96    public synchronized void pluginClicked(Context context, int position) {
97        try {
98            Plugin plugin = mPlugins.get(position);
99            plugin.dispatchClickEvent(context);
100        } catch (IndexOutOfBoundsException e) {
101            // This can happen if the list of plugins
102            // gets changed while the pref menu is up.
103        }
104    }
105}
106