Index: chrome/browser/chrome_plugin_service_helper.h |
diff --git a/chrome/browser/chrome_plugin_service_helper.h b/chrome/browser/chrome_plugin_service_helper.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3b4378ca0bee58bb759828183d6f61838bb8b834 |
--- /dev/null |
+++ b/chrome/browser/chrome_plugin_service_helper.h |
@@ -0,0 +1,84 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_CHROME_PLUGIN_SERVICE_HELPER_H_ |
+#define CHROME_BROWSER_CHROME_PLUGIN_SERVICE_HELPER_H_ |
+#pragma once |
+ |
+#include <vector> |
+ |
+#include "base/hash_tables.h" |
+#include "base/file_path.h" |
+#include "base/memory/singleton.h" |
+#include "base/synchronization/lock.h" |
+#include "content/browser/plugin_service.h" |
+#include "content/common/notification_observer.h" |
+#include "content/common/notification_registrar.h" |
+#include "googleurl/src/gurl.h" |
+#include "webkit/plugins/npapi/webplugininfo.h" |
+ |
+// This class must be created (by calling the |GetInstance| method) on the UI |
+// thread, but is safe to use on any thread after that. |
+class ChromePluginServiceHelper : public NotificationObserver { |
jam
2011/08/01 03:25:44
we can make this also implement the filter interfa
|
+ public: |
+ struct OverriddenPlugin { |
jam
2011/08/01 03:25:44
while you're cleaning this up, what do you think o
Bernhard Bauer
2011/08/01 16:06:12
Sounds good. Done.
|
+ int render_process_id; |
+ int render_view_id; |
+ GURL url; |
+ webkit::npapi::WebPluginInfo plugin; |
+ }; |
+ |
+ static ChromePluginServiceHelper* GetInstance(); |
+ |
+ // Overrides the plugin lookup mechanism for a given tab and object URL to use |
+ // a specifc plugin. |
+ void OverridePluginForTab(const OverriddenPlugin& plugin); |
+ |
+ // Finds the overridden plugin for a given tab and object URL and returns a |
+ // copy, or NULL if no overridden plugin was found. |
+ // Caller takes ownership. |
+ webkit::npapi::WebPluginInfo* FindOverriddenPluginForTab( |
+ int render_process_id, |
+ int render_view_id, |
+ const GURL& url); |
+ |
+ // Restricts the given plugin to the the scheme and host of the given url. |
+ // Call with an empty url to reset this. |
+ void RestrictPluginToUrl(const FilePath& plugin_path, const GURL& url); |
+ |
+ // Returns the URL a given plugin is restricted to, or an empty URL if it can |
+ // be used on all URLs. |
+ GURL FindRestrictedURLForPlugin(const FilePath& plugin_path); |
+ |
+ // Creates a new plugin filter. Caller takes ownership. |
+ // This method should only be called from the IO thread. |
+ PluginService::Filter* CreatePluginFilter( |
+ int render_process_id, |
+ int render_view_id, |
+ const content::ResourceContext& resource_context, |
+ const GURL& url, |
+ const GURL& policy_url); |
+ |
+ private: |
+ friend struct DefaultSingletonTraits<ChromePluginServiceHelper>; |
+ |
+ ChromePluginServiceHelper(); |
+ virtual ~ChromePluginServiceHelper(); |
+ |
+ // NotificationObserver implementation: |
+ virtual void Observe(int type, |
+ const NotificationSource& source, |
+ const NotificationDetails& details); |
+ |
+ NotificationRegistrar registrar_; |
+ |
+ base::Lock lock_; // Guards access to member variables. |
+ // Map of plugin paths to the origin they are restricted to. |
+ typedef base::hash_map<FilePath, GURL> RestrictedPluginMap; |
+ RestrictedPluginMap restricted_plugins_; |
+ |
+ std::vector<OverriddenPlugin> overridden_plugins_; |
+}; |
+ |
+#endif // CHROME_BROWSER_CHROME_PLUGIN_SERVICE_HELPER_H_ |