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 | |
| 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). |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 27 | * |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 28 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 29 | * @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] | 30 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 32 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | public class PluginList { |
| 34 | private ArrayList<Plugin> mPlugins; |
| 35 | |
| 36 | /** |
| 37 | * Public constructor. Initializes the list of plugins. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 38 | * |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 39 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 40 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 41 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 43 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | public PluginList() { |
| 45 | mPlugins = new ArrayList<Plugin>(); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Returns the list of plugins as a java.util.List. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 50 | * |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 51 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 52 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 53 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 55 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | public synchronized List getList() { |
| 57 | return mPlugins; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Adds a plugin to the list. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 62 | * |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 63 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 64 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 65 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 66 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 67 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 76 | * |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 77 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 78 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 79 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 81 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 91 | * |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 92 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 93 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 94 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 95 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 96 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 97 | public synchronized void clear() { |
| 98 | mPlugins.clear(); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Dispatches the click event to the appropriate plugin. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 103 | * |
Kristian Monsen | f0d9731 | 2011-01-12 19:15:35 +0000 | [diff] [blame] | 104 | * @hide |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 105 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 106 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 107 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 108 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | } |