Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: content/public/browser/plugin_service.h

Issue 9006036: Create an API around PluginService and use it from Chrome. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/content_browser.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_PUBLIC_BROWSER_PLUGIN_SERVICE_H_
6 #define CONTENT_PUBLIC_BROWSER_PLUGIN_SERVICE_H_
7 #pragma once
8
9 #include <string>
10 #include <vector>
11
12 #include "base/callback.h"
13 #include "base/string16.h"
14 #include "content/common/content_export.h"
15
16 class FilePath;
17 class GURL;
18 class PluginProcessHost;
19
20 namespace webkit {
21 struct WebPluginInfo;
22 namespace npapi {
23 class PluginGroup;
24 class PluginList;
25 }
26 }
27
28 namespace content {
29
30 class BrowserContext;
31 class PluginServiceFilter;
32 class ResourceContext;
33 struct PepperPluginInfo;
34
35 // This must be created on the main thread but it's only called on the IO/file
36 // thread. This is an asynchronous wrapper around the PluginList interface for
37 // querying plugin information. This must be used instead of that to avoid
38 // doing expensive disk operations on the IO/UI threads.
39 class PluginService {
40 public:
41 typedef base::Callback<void(const std::vector<webkit::WebPluginInfo>&)>
42 GetPluginsCallback;
43 typedef base::Callback<void(const std::vector<webkit::npapi::PluginGroup>&)>
44 GetPluginGroupsCallback;
45
46 // Returns the PluginService singleton.
47 CONTENT_EXPORT static PluginService* GetInstance();
48
49 // Tells all the renderer processes associated with the given browser context
50 // to throw away their cache of the plugin list, and optionally also reload
51 // all the pages with plugins. If |browser_context| is NULL, purges the cache
52 // in all renderers.
53 // NOTE: can only be called on the UI thread.
54 static void PurgePluginListCache(BrowserContext* browser_context,
55 bool reload_pages);
56
57 virtual ~PluginService() {}
58
59 // Must be called on the instance to finish initialization.
60 virtual void Init() = 0;
61
62 // Starts watching for changes in the list of installed plug-ins.
63 virtual void StartWatchingPlugins() = 0;
64
65 // Returns the plugin process host corresponding to the plugin process that
66 // has been started by this service. Returns NULL if no process has been
67 // started.
68 virtual PluginProcessHost* FindNpapiPluginProcess(
69 const FilePath& plugin_path) = 0;
70
71 // Gets the plugin in the list of plugins that matches the given url and mime
72 // type. Returns true if the data is frome a stale plugin list, false if it
73 // is up to date. This can be called from any thread.
74 virtual bool GetPluginInfoArray(
75 const GURL& url,
76 const std::string& mime_type,
77 bool allow_wildcard,
78 std::vector<webkit::WebPluginInfo>* info,
79 std::vector<std::string>* actual_mime_types) = 0;
80
81 // Gets plugin info for an individual plugin and filters the plugins using
82 // the |context| and renderer IDs. This will report whether the data is stale
83 // via |is_stale| and returns whether or not the plugin can be found.
84 virtual bool GetPluginInfo(int render_process_id,
85 int render_view_id,
86 const ResourceContext& context,
87 const GURL& url,
88 const GURL& page_url,
89 const std::string& mime_type,
90 bool allow_wildcard,
91 bool* is_stale,
92 webkit::WebPluginInfo* info,
93 std::string* actual_mime_type) = 0;
94
95 // Get plugin info by plugin path (including disabled plugins). Returns true
96 // if the plugin is found and WebPluginInfo has been filled in |info|. This
97 // will use cached data in the plugin list.
98 virtual bool GetPluginInfoByPath(const FilePath& plugin_path,
99 webkit::WebPluginInfo* info) = 0;
100
101 // Asynchronously loads plugins if necessary and then calls back to the
102 // provided function on the calling MessageLoop on completion.
103 virtual void GetPlugins(const GetPluginsCallback& callback) = 0;
104
105 // Asynchronously loads the list of plugin groups if necessary and then calls
106 // back to the provided function on the calling MessageLoop on completion.
107 virtual void GetPluginGroups(const GetPluginGroupsCallback& callback) = 0;
108
109 // Returns information about a pepper plugin if it exists, otherwise NULL.
110 // The caller does not own the pointer, and it's not guaranteed to live past
111 // the call stack.
112 virtual PepperPluginInfo* GetRegisteredPpapiPluginInfo(
113 const FilePath& plugin_path) = 0;
114
115 virtual void SetFilter(PluginServiceFilter* filter) = 0;
116 virtual PluginServiceFilter* GetFilter() = 0;
117
118 // The following functions are wrappers around webkit::npapi::PluginList.
119 // These must be used instead of those in order to ensure that we have a
120 // single global list in the component build and so that we don't
121 // accidentally load plugins in the wrong process or thread. Refer to
122 // PluginList for further documentation of these functions.
123 virtual void RefreshPlugins() = 0;
124 virtual void AddExtraPluginPath(const FilePath& path) = 0;
125 virtual void RemoveExtraPluginPath(const FilePath& path) = 0;
126 virtual void UnregisterInternalPlugin(const FilePath& path) = 0;
127 virtual void RegisterInternalPlugin(const webkit::WebPluginInfo& info) = 0;
128 virtual string16 GetPluginGroupName(const std::string& plugin_name) = 0;
129
130 // TODO(dpranke): This should be private.
131 virtual webkit::npapi::PluginList* GetPluginList() = 0;
132 };
133
134 } // namespace content
135
136 #endif // CONTENT_PUBLIC_BROWSER_PLUGIN_SERVICE_H_
OLDNEW
« no previous file with comments | « content/content_browser.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698