OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #include "content/common/pepper_plugin_registry.h" | 5 #include "content/common/pepper_plugin_registry.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/native_library.h" | 9 #include "base/native_library.h" |
10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 | 71 |
72 plugins->push_back(plugin); | 72 plugins->push_back(plugin); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 } // namespace | 76 } // namespace |
77 | 77 |
78 webkit::WebPluginInfo PepperPluginInfo::ToWebPluginInfo() const { | 78 webkit::WebPluginInfo PepperPluginInfo::ToWebPluginInfo() const { |
79 webkit::WebPluginInfo info; | 79 webkit::WebPluginInfo info; |
80 | 80 |
81 info.name = name.empty() ? path.BaseName().LossyDisplayName() : | 81 info.type = is_out_of_process ? |
82 ASCIIToUTF16(name); | 82 webkit::WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS : |
83 webkit::WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS; | |
84 | |
85 info.name = name.empty() ? | |
86 path.BaseName().LossyDisplayName() : ASCIIToUTF16(name); | |
brettw
2011/08/16 23:28:05
Can you use UTF8ToUTF16 instead? This will assert
| |
83 info.path = path; | 87 info.path = path; |
84 info.version = ASCIIToUTF16(version); | 88 info.version = ASCIIToUTF16(version); |
85 info.desc = ASCIIToUTF16(description); | 89 info.desc = ASCIIToUTF16(description); |
86 info.mime_types = mime_types; | 90 info.mime_types = mime_types; |
87 | 91 |
88 webkit::WebPluginInfo::EnabledStates enabled_state = | 92 webkit::WebPluginInfo::EnabledStates enabled_state = |
89 webkit::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; | 93 webkit::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; |
90 | 94 |
91 if (!enabled) { | 95 if (!enabled) { |
92 enabled_state = | 96 enabled_state = |
93 webkit::WebPluginInfo::USER_DISABLED_POLICY_UNMANAGED; | 97 webkit::WebPluginInfo::USER_DISABLED_POLICY_UNMANAGED; |
94 } | 98 } |
95 | 99 |
96 info.enabled = enabled_state; | 100 info.enabled = enabled_state; |
97 return info; | 101 return info; |
98 } | 102 } |
99 | 103 |
100 PepperPluginInfo::PepperPluginInfo() | 104 PepperPluginInfo::PepperPluginInfo() |
101 : is_internal(false), | 105 : is_internal(false), |
102 is_out_of_process(false), | 106 is_out_of_process(false), |
103 enabled(true) { | 107 enabled(true) { |
104 } | 108 } |
105 | 109 |
106 PepperPluginInfo::~PepperPluginInfo() { | 110 PepperPluginInfo::~PepperPluginInfo() { |
107 } | 111 } |
108 | 112 |
113 bool MakePepperPluginInfo(const webkit::WebPluginInfo& webplugin_info, | |
114 PepperPluginInfo* pepper_info) { | |
115 | |
116 if (!webkit::IsPepperPlugin(webplugin_info)) | |
brettw
2011/08/16 23:28:05
No blank line before this
| |
117 return false; | |
118 | |
119 pepper_info->is_out_of_process = | |
120 webplugin_info.type == | |
121 webkit::WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS; | |
122 | |
123 pepper_info->enabled = webkit::IsPluginEnabled(webplugin_info); | |
124 pepper_info->path = FilePath(webplugin_info.path); | |
125 pepper_info->name = UTF16ToASCII(webplugin_info.name); | |
126 pepper_info->description = UTF16ToASCII(webplugin_info.desc); | |
127 pepper_info->version = UTF16ToASCII(webplugin_info.version); | |
128 pepper_info->mime_types = webplugin_info.mime_types; | |
129 return true; | |
130 } | |
131 | |
109 // static | 132 // static |
110 PepperPluginRegistry* PepperPluginRegistry::GetInstance() { | 133 PepperPluginRegistry* PepperPluginRegistry::GetInstance() { |
111 static PepperPluginRegistry* registry = NULL; | 134 static PepperPluginRegistry* registry = NULL; |
112 // This object leaks. It is a temporary hack to work around a crash. | 135 // This object leaks. It is a temporary hack to work around a crash. |
113 // http://code.google.com/p/chromium/issues/detail?id=63234 | 136 // http://code.google.com/p/chromium/issues/detail?id=63234 |
114 if (!registry) | 137 if (!registry) |
115 registry = new PepperPluginRegistry; | 138 registry = new PepperPluginRegistry; |
116 return registry; | 139 return registry; |
117 } | 140 } |
118 | 141 |
(...skipping 13 matching lines...) Expand all Loading... | |
132 base::NativeLibrary library = base::LoadNativeLibrary(plugins[i].path, | 155 base::NativeLibrary library = base::LoadNativeLibrary(plugins[i].path, |
133 &error); | 156 &error); |
134 LOG_IF(WARNING, !library) << "Unable to load plugin " | 157 LOG_IF(WARNING, !library) << "Unable to load plugin " |
135 << plugins[i].path.value() << " " | 158 << plugins[i].path.value() << " " |
136 << error; | 159 << error; |
137 } | 160 } |
138 } | 161 } |
139 } | 162 } |
140 | 163 |
141 const PepperPluginInfo* PepperPluginRegistry::GetInfoForPlugin( | 164 const PepperPluginInfo* PepperPluginRegistry::GetInfoForPlugin( |
142 const FilePath& path) const { | 165 const webkit::WebPluginInfo& info) { |
143 for (size_t i = 0; i < plugin_list_.size(); ++i) { | 166 for (size_t i = 0; i < plugin_list_.size(); ++i) { |
144 if (path == plugin_list_[i].path) | 167 if (info.path == plugin_list_[i].path) |
145 return &plugin_list_[i]; | 168 return &plugin_list_[i]; |
146 } | 169 } |
147 return NULL; | 170 // We did not find the plugin in our list. But wait! the plugin can also |
171 // be a latecomer, as it happens with windows flapper. This information | |
brettw
2011/08/16 23:28:05
flapper -> pepper flash.
| |
172 // is actually in |info| and we can use it to construct it and add it to | |
173 // the list. This same deal needs to be done in the browser side in | |
174 // PluginService. | |
175 PepperPluginInfo plugin; | |
176 if (!MakePepperPluginInfo(info, &plugin)) | |
177 return NULL; | |
178 | |
179 plugin_list_.push_back(plugin); | |
180 return &plugin_list_[plugin_list_.size() - 1]; | |
148 } | 181 } |
149 | 182 |
150 webkit::ppapi::PluginModule* PepperPluginRegistry::GetLiveModule( | 183 webkit::ppapi::PluginModule* PepperPluginRegistry::GetLiveModule( |
151 const FilePath& path) { | 184 const FilePath& path) { |
152 NonOwningModuleMap::iterator it = live_modules_.find(path); | 185 NonOwningModuleMap::iterator it = live_modules_.find(path); |
153 if (it == live_modules_.end()) | 186 if (it == live_modules_.end()) |
154 return NULL; | 187 return NULL; |
155 return it->second; | 188 return it->second; |
156 } | 189 } |
157 | 190 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 base::MessageLoopProxy* PepperPluginRegistry::GetIPCMessageLoop() { | 254 base::MessageLoopProxy* PepperPluginRegistry::GetIPCMessageLoop() { |
222 // This is called only in the renderer so we know we have a child process. | 255 // This is called only in the renderer so we know we have a child process. |
223 DCHECK(ChildProcess::current()) << "Must be in the renderer."; | 256 DCHECK(ChildProcess::current()) << "Must be in the renderer."; |
224 return ChildProcess::current()->io_message_loop_proxy(); | 257 return ChildProcess::current()->io_message_loop_proxy(); |
225 } | 258 } |
226 | 259 |
227 base::WaitableEvent* PepperPluginRegistry::GetShutdownEvent() { | 260 base::WaitableEvent* PepperPluginRegistry::GetShutdownEvent() { |
228 DCHECK(ChildProcess::current()) << "Must be in the renderer."; | 261 DCHECK(ChildProcess::current()) << "Must be in the renderer."; |
229 return ChildProcess::current()->GetShutDownEvent(); | 262 return ChildProcess::current()->GetShutDownEvent(); |
230 } | 263 } |
OLD | NEW |