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 | * |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame^] | 28 | * @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] | 29 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 31 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | public class PluginList { |
| 33 | private ArrayList<Plugin> mPlugins; |
| 34 | |
| 35 | /** |
| 36 | * Public constructor. Initializes the list of plugins. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 37 | * |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame^] | 38 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 39 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 41 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | public PluginList() { |
| 43 | mPlugins = new ArrayList<Plugin>(); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Returns the list of plugins as a java.util.List. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 48 | * |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame^] | 49 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 50 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 52 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | public synchronized List getList() { |
| 54 | return mPlugins; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Adds a plugin to the list. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 59 | * |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame^] | 60 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 61 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 62 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 63 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 64 | public synchronized void addPlugin(Plugin plugin) { |
| 65 | if (!mPlugins.contains(plugin)) { |
| 66 | mPlugins.add(plugin); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Removes a plugin from the list. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 72 | * |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame^] | 73 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 74 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 75 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 76 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | public synchronized void removePlugin(Plugin plugin) { |
| 78 | int location = mPlugins.indexOf(plugin); |
| 79 | if (location != -1) { |
| 80 | mPlugins.remove(location); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Clears the plugin list. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 86 | * |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame^] | 87 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 88 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 90 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 91 | public synchronized void clear() { |
| 92 | mPlugins.clear(); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Dispatches the click event to the appropriate plugin. |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 97 | * |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame^] | 98 | * @deprecated This interface was intended to be used by Gears. Since Gears was |
| 99 | * deprecated, so is this class. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | */ |
Andrei Popescu | 385df69 | 2009-08-13 11:59:57 +0100 | [diff] [blame] | 101 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 102 | public synchronized void pluginClicked(Context context, int position) { |
| 103 | try { |
| 104 | Plugin plugin = mPlugins.get(position); |
| 105 | plugin.dispatchClickEvent(context); |
| 106 | } catch (IndexOutOfBoundsException e) { |
| 107 | // This can happen if the list of plugins |
| 108 | // gets changed while the pref menu is up. |
| 109 | } |
| 110 | } |
| 111 | } |