| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_PLUGINS_CHROME_PLUGIN_SERVICE_FILTER_H_ | 5 #ifndef CHROME_BROWSER_PLUGINS_CHROME_PLUGIN_SERVICE_FILTER_H_ |
| 6 #define CHROME_BROWSER_PLUGINS_CHROME_PLUGIN_SERVICE_FILTER_H_ | 6 #define CHROME_BROWSER_PLUGINS_CHROME_PLUGIN_SERVICE_FILTER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "chrome/browser/plugins/plugin_prefs.h" | 17 #include "chrome/browser/plugins/plugin_prefs.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "content/public/browser/plugin_service_filter.h" | 20 #include "content/public/browser/plugin_service_filter.h" |
| 21 #include "content/public/common/webplugininfo.h" | 21 #include "content/public/common/webplugininfo.h" |
| 22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 23 #include "url/origin.h" |
| 23 | 24 |
| 24 class Profile; | 25 class Profile; |
| 25 | 26 |
| 26 namespace content { | 27 namespace content { |
| 27 class WebContents; | 28 class WebContents; |
| 28 } | 29 } |
| 29 | 30 |
| 30 // This class must be created (by calling the |GetInstance| method) on the UI | 31 // This class must be created (by calling the |GetInstance| method) on the UI |
| 31 // thread, but is safe to use on any thread after that. | 32 // thread, but is safe to use on any thread after that. |
| 32 class ChromePluginServiceFilter : public content::PluginServiceFilter, | 33 class ChromePluginServiceFilter : public content::PluginServiceFilter, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 57 | 58 |
| 58 // Authorizes all plugins for a given WebContents. If |load_blocked| is true, | 59 // Authorizes all plugins for a given WebContents. If |load_blocked| is true, |
| 59 // then the renderer is told to load the plugin with given |identifier| (or | 60 // then the renderer is told to load the plugin with given |identifier| (or |
| 60 // pllugins if |identifier| is empty). | 61 // pllugins if |identifier| is empty). |
| 61 // This method can only be called on the UI thread. | 62 // This method can only be called on the UI thread. |
| 62 void AuthorizeAllPlugins(content::WebContents* web_contents, | 63 void AuthorizeAllPlugins(content::WebContents* web_contents, |
| 63 bool load_blocked, | 64 bool load_blocked, |
| 64 const std::string& identifier); | 65 const std::string& identifier); |
| 65 | 66 |
| 66 // PluginServiceFilter implementation. | 67 // PluginServiceFilter implementation. |
| 67 // If |plugin_content_url| is not available, the same GURL passed as | 68 // If |plugin_content_url| is not available, pass the same URL used to |
| 68 // |top_level_url| should be passed. These GURLs may be empty. | 69 // generate |main_frame_origin|. These parameters may be empty. |
| 69 bool IsPluginAvailable(int render_process_id, | 70 bool IsPluginAvailable(int render_process_id, |
| 70 int render_frame_id, | 71 int render_frame_id, |
| 71 const void* context, | 72 const void* context, |
| 72 const GURL& plugin_content_url, | 73 const GURL& plugin_content_url, |
| 73 const GURL& top_level_url, | 74 const url::Origin& main_frame_origin, |
| 74 content::WebPluginInfo* plugin) override; | 75 content::WebPluginInfo* plugin) override; |
| 75 | 76 |
| 76 // CanLoadPlugin always grants permission to the browser | 77 // CanLoadPlugin always grants permission to the browser |
| 77 // (render_process_id == 0) | 78 // (render_process_id == 0) |
| 78 bool CanLoadPlugin(int render_process_id, | 79 bool CanLoadPlugin(int render_process_id, |
| 79 const base::FilePath& path) override; | 80 const base::FilePath& path) override; |
| 80 | 81 |
| 81 private: | 82 private: |
| 82 friend struct base::DefaultSingletonTraits<ChromePluginServiceFilter>; | 83 friend struct base::DefaultSingletonTraits<ChromePluginServiceFilter>; |
| 83 struct ContextInfo; | 84 struct ContextInfo; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 114 content::NotificationRegistrar registrar_; | 115 content::NotificationRegistrar registrar_; |
| 115 | 116 |
| 116 base::Lock lock_; // Guards access to member variables. | 117 base::Lock lock_; // Guards access to member variables. |
| 117 | 118 |
| 118 std::map<const void*, std::unique_ptr<ContextInfo>> resource_context_map_; | 119 std::map<const void*, std::unique_ptr<ContextInfo>> resource_context_map_; |
| 119 | 120 |
| 120 std::map<int, ProcessDetails> plugin_details_; | 121 std::map<int, ProcessDetails> plugin_details_; |
| 121 }; | 122 }; |
| 122 | 123 |
| 123 #endif // CHROME_BROWSER_PLUGINS_CHROME_PLUGIN_SERVICE_FILTER_H_ | 124 #endif // CHROME_BROWSER_PLUGINS_CHROME_PLUGIN_SERVICE_FILTER_H_ |
| OLD | NEW |