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