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_PLUGIN_INFO_MESSAGE_FILTER_H_ | 5 #ifndef CHROME_BROWSER_PLUGINS_PLUGIN_INFO_MESSAGE_FILTER_H_ |
6 #define CHROME_BROWSER_PLUGINS_PLUGIN_INFO_MESSAGE_FILTER_H_ | 6 #define CHROME_BROWSER_PLUGINS_PLUGIN_INFO_MESSAGE_FILTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/prefs/pref_member.h" | 13 #include "base/prefs/pref_member.h" |
14 #include "base/sequenced_task_runner_helpers.h" | 14 #include "base/sequenced_task_runner_helpers.h" |
15 #include "chrome/browser/plugins/plugin_prefs.h" | 15 #include "chrome/browser/plugins/plugin_prefs.h" |
16 #include "chrome/common/content_settings.h" | 16 #include "chrome/common/content_settings.h" |
17 #include "content/public/browser/browser_message_filter.h" | 17 #include "content/public/browser/browser_message_filter.h" |
18 | 18 |
19 struct ChromeViewHostMsg_GetPluginInfo_Output; | 19 struct ChromeViewHostMsg_GetPluginInfo_Output; |
20 struct ChromeViewHostMsg_GetPluginInfo_Status; | 20 struct ChromeViewHostMsg_GetPluginInfo_Status; |
21 class GURL; | 21 class GURL; |
22 class HostContentSettingsMap; | 22 class HostContentSettingsMap; |
23 class PluginFinder; | 23 class PluginFinder; |
24 class PluginMetadata; | 24 class PluginMetadata; |
25 class Profile; | 25 class Profile; |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 class ResourceContext; | 28 class ResourceContext; |
| 29 class WebContents; |
29 struct WebPluginInfo; | 30 struct WebPluginInfo; |
30 } | 31 } |
31 | 32 |
32 // This class filters out incoming IPC messages requesting plug-in information. | 33 // This class filters out incoming IPC messages requesting plug-in information. |
33 class PluginInfoMessageFilter : public content::BrowserMessageFilter { | 34 class PluginInfoMessageFilter : public content::BrowserMessageFilter { |
34 public: | 35 public: |
35 struct GetPluginInfo_Params; | 36 struct GetPluginInfo_Params; |
36 | 37 |
37 // Contains all the information needed by the PluginInfoMessageFilter. | 38 // Contains all the information needed by the PluginInfoMessageFilter. |
38 class Context { | 39 class Context { |
(...skipping 18 matching lines...) Expand all Loading... |
57 void GetPluginContentSetting(const content::WebPluginInfo& plugin, | 58 void GetPluginContentSetting(const content::WebPluginInfo& plugin, |
58 const GURL& policy_url, | 59 const GURL& policy_url, |
59 const GURL& plugin_url, | 60 const GURL& plugin_url, |
60 const std::string& resource, | 61 const std::string& resource, |
61 ContentSetting* setting, | 62 ContentSetting* setting, |
62 bool* is_default, | 63 bool* is_default, |
63 bool* is_managed) const; | 64 bool* is_managed) const; |
64 void MaybeGrantAccess(const ChromeViewHostMsg_GetPluginInfo_Status& status, | 65 void MaybeGrantAccess(const ChromeViewHostMsg_GetPluginInfo_Status& status, |
65 const base::FilePath& path) const; | 66 const base::FilePath& path) const; |
66 | 67 |
| 68 int render_process_id() { return render_process_id_; } |
67 private: | 69 private: |
68 int render_process_id_; | 70 int render_process_id_; |
69 content::ResourceContext* resource_context_; | 71 content::ResourceContext* resource_context_; |
70 const HostContentSettingsMap* host_content_settings_map_; | 72 const HostContentSettingsMap* host_content_settings_map_; |
71 scoped_refptr<PluginPrefs> plugin_prefs_; | 73 scoped_refptr<PluginPrefs> plugin_prefs_; |
72 | 74 |
73 BooleanPrefMember allow_outdated_plugins_; | 75 BooleanPrefMember allow_outdated_plugins_; |
74 BooleanPrefMember always_authorize_plugins_; | 76 BooleanPrefMember always_authorize_plugins_; |
75 }; | 77 }; |
76 | 78 |
77 PluginInfoMessageFilter(int render_process_id, Profile* profile); | 79 PluginInfoMessageFilter(int render_process_id, Profile* profile); |
78 | 80 |
79 // content::BrowserMessageFilter methods: | 81 // content::BrowserMessageFilter methods: |
80 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 82 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
81 virtual void OnDestruct() const OVERRIDE; | 83 virtual void OnDestruct() const OVERRIDE; |
82 | 84 |
83 private: | 85 private: |
84 friend struct content::BrowserThread::DeleteOnThread< | 86 friend struct content::BrowserThread::DeleteOnThread< |
85 content::BrowserThread::UI>; | 87 content::BrowserThread::UI>; |
86 friend class base::DeleteHelper<PluginInfoMessageFilter>; | 88 friend class base::DeleteHelper<PluginInfoMessageFilter>; |
87 | 89 |
88 virtual ~PluginInfoMessageFilter(); | 90 virtual ~PluginInfoMessageFilter(); |
89 | 91 |
| 92 // Creates a MimeHandlerViewGuest on UI thread. |
| 93 void CreateGuestOnUI( |
| 94 Profile* profile, |
| 95 int render_process_id, |
| 96 GURL top_origin_url, |
| 97 scoped_ptr<ChromeViewHostMsg_GetPluginInfo_Output> output, |
| 98 IPC::Message* reply_msg); |
| 99 |
| 100 void GuestCreatedOnUICallback( |
| 101 scoped_ptr<ChromeViewHostMsg_GetPluginInfo_Output> output, |
| 102 IPC::Message* reply_msg, |
| 103 content::WebContents* guest_web_contents); |
| 104 |
| 105 // Callback called when we have done creating MimeHandlerViewGuest on |
| 106 // UI thread. |
| 107 // This callback is called on IO thread. |
| 108 void GuestCreatedOnIO( |
| 109 const scoped_ptr<ChromeViewHostMsg_GetPluginInfo_Output>& output, |
| 110 IPC::Message* reply_msg); |
| 111 |
90 void OnGetPluginInfo(int render_frame_id, | 112 void OnGetPluginInfo(int render_frame_id, |
91 const GURL& url, | 113 const GURL& url, |
92 const GURL& top_origin_url, | 114 const GURL& top_origin_url, |
93 const std::string& mime_type, | 115 const std::string& mime_type, |
94 IPC::Message* reply_msg); | 116 IPC::Message* reply_msg); |
95 | 117 |
96 // |params| wraps the parameters passed to |OnGetPluginInfo|, because | 118 // |params| wraps the parameters passed to |OnGetPluginInfo|, because |
97 // |base::Bind| doesn't support the required arity <http://crbug.com/98542>. | 119 // |base::Bind| doesn't support the required arity <http://crbug.com/98542>. |
98 void PluginsLoaded(const GetPluginInfo_Params& params, | 120 void PluginsLoaded(const GetPluginInfo_Params& params, |
99 IPC::Message* reply_msg, | 121 IPC::Message* reply_msg, |
100 const std::vector<content::WebPluginInfo>& plugins); | 122 const std::vector<content::WebPluginInfo>& plugins); |
101 | 123 |
102 #if defined(ENABLE_PEPPER_CDMS) | 124 #if defined(ENABLE_PEPPER_CDMS) |
103 // Returns whether any internal plugin supporting |mime_type| is registered. | 125 // Returns whether any internal plugin supporting |mime_type| is registered. |
104 // Does not determine whether the plugin can actually be instantiated | 126 // Does not determine whether the plugin can actually be instantiated |
105 // (e.g. whether it is allowed or has all its dependencies). | 127 // (e.g. whether it is allowed or has all its dependencies). |
106 // When the returned *|is_registered| is true, |additional_param_names| and | 128 // When the returned *|is_registered| is true, |additional_param_names| and |
107 // |additional_param_values| contain the name-value pairs, if any, specified | 129 // |additional_param_values| contain the name-value pairs, if any, specified |
108 // for the *first* plugin found that is registered for |mime_type|. | 130 // for the *first* plugin found that is registered for |mime_type|. |
109 void OnIsInternalPluginRegisteredForMimeType( | 131 void OnIsInternalPluginRegisteredForMimeType( |
110 const std::string& mime_type, | 132 const std::string& mime_type, |
111 bool* is_registered, | 133 bool* is_registered, |
112 std::vector<base::string16>* additional_param_names, | 134 std::vector<base::string16>* additional_param_names, |
113 std::vector<base::string16>* additional_param_values); | 135 std::vector<base::string16>* additional_param_values); |
114 #endif | 136 #endif |
115 | 137 |
116 Context context_; | 138 Context context_; |
| 139 Profile* profile_; |
117 | 140 |
118 base::WeakPtrFactory<PluginInfoMessageFilter> weak_ptr_factory_; | 141 base::WeakPtrFactory<PluginInfoMessageFilter> weak_ptr_factory_; |
119 | 142 |
120 DISALLOW_COPY_AND_ASSIGN(PluginInfoMessageFilter); | 143 DISALLOW_COPY_AND_ASSIGN(PluginInfoMessageFilter); |
121 }; | 144 }; |
122 | 145 |
123 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INFO_MESSAGE_FILTER_H_ | 146 #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INFO_MESSAGE_FILTER_H_ |
OLD | NEW |