OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "base/gfx/rect.h" | 5 #include "base/gfx/rect.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "net/base/escape.h" | 9 #include "net/base/escape.h" |
10 #include "skia/ext/platform_canvas.h" | 10 #include "skia/ext/platform_canvas.h" |
11 #if defined(OS_WIN) | |
12 #include "webkit/activex_shim/activex_shared.h" | |
13 #endif | |
14 #include "webkit/api/public/WebConsoleMessage.h" | 11 #include "webkit/api/public/WebConsoleMessage.h" |
15 #include "webkit/api/public/WebCString.h" | 12 #include "webkit/api/public/WebCString.h" |
16 #include "webkit/api/public/WebCursorInfo.h" | 13 #include "webkit/api/public/WebCursorInfo.h" |
17 #include "webkit/api/public/WebData.h" | 14 #include "webkit/api/public/WebData.h" |
18 #include "webkit/api/public/WebFrame.h" | 15 #include "webkit/api/public/WebFrame.h" |
19 #include "webkit/api/public/WebHTTPBody.h" | 16 #include "webkit/api/public/WebHTTPBody.h" |
20 #include "webkit/api/public/WebHTTPHeaderVisitor.h" | 17 #include "webkit/api/public/WebHTTPHeaderVisitor.h" |
21 #include "webkit/api/public/WebInputEvent.h" | 18 #include "webkit/api/public/WebInputEvent.h" |
22 #include "webkit/api/public/WebKit.h" | 19 #include "webkit/api/public/WebKit.h" |
23 #include "webkit/api/public/WebKitClient.h" | 20 #include "webkit/api/public/WebKitClient.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 195 } |
199 | 196 |
200 } // namespace | 197 } // namespace |
201 | 198 |
202 // WebKit::WebPlugin ---------------------------------------------------------- | 199 // WebKit::WebPlugin ---------------------------------------------------------- |
203 | 200 |
204 bool WebPluginImpl::initialize(WebPluginContainer* container) { | 201 bool WebPluginImpl::initialize(WebPluginContainer* container) { |
205 if (!page_delegate_) | 202 if (!page_delegate_) |
206 return false; | 203 return false; |
207 | 204 |
208 // Get the classid and version from attributes of the object. | |
209 std::string combined_clsid; | |
210 #if defined(OS_WIN) | |
211 std::string clsid, version; | |
212 if (activex_shim::IsMimeTypeActiveX(mime_type_)) { | |
213 for (size_t i = 0; i < arg_names_.size(); i++) { | |
214 const char* param_name = arg_names_[i].c_str(); | |
215 const char* param_value = arg_values_[i].c_str(); | |
216 if (base::strcasecmp(param_name, "classid") == 0) { | |
217 activex_shim::GetClsidFromClassidAttribute(param_value, &clsid); | |
218 } else if (base::strcasecmp(param_name, "codebase") == 0) { | |
219 version = activex_shim::GetVersionFromCodebaseAttribute(param_value); | |
220 } | |
221 } | |
222 | |
223 // Attempt to map this clsid to a known NPAPI mime type if possible, failing | |
224 // which we attempt to load the activex shim for the clsid. | |
225 if (!activex_shim::GetMimeTypeForClsid(clsid, &mime_type_)) { | |
226 // We need to pass the combined clsid + version to PluginsList, so that it | |
227 // would detect if the requested version is installed. If not, it needs | |
228 // to use the default plugin to update the control. | |
229 if (!version.empty()) | |
230 combined_clsid = clsid + "#" + version; | |
231 else | |
232 combined_clsid = clsid; | |
233 } | |
234 } | |
235 #endif | |
236 | |
237 std::string actual_mime_type; | 205 std::string actual_mime_type; |
238 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( | 206 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( |
239 plugin_url_, mime_type_, combined_clsid, &actual_mime_type); | 207 plugin_url_, mime_type_, &actual_mime_type); |
240 if (!plugin_delegate) | 208 if (!plugin_delegate) |
241 return NULL; | 209 return NULL; |
242 | 210 |
243 bool ok = plugin_delegate->Initialize( | 211 bool ok = plugin_delegate->Initialize( |
244 plugin_url_, arg_names_, arg_values_, this, load_manually_); | 212 plugin_url_, arg_names_, arg_values_, this, load_manually_); |
245 if (!ok) { | 213 if (!ok) { |
246 plugin_delegate->PluginDestroyed(); | 214 plugin_delegate->PluginDestroyed(); |
247 return false; | 215 return false; |
248 } | 216 } |
249 | 217 |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 WebPluginContainer* container_widget = container_; | 985 WebPluginContainer* container_widget = container_; |
1018 | 986 |
1019 // Destroy the current plugin instance. | 987 // Destroy the current plugin instance. |
1020 TearDownPluginInstance(loader); | 988 TearDownPluginInstance(loader); |
1021 | 989 |
1022 container_ = container_widget; | 990 container_ = container_widget; |
1023 webframe_ = webframe; | 991 webframe_ = webframe; |
1024 | 992 |
1025 std::string actual_mime_type; | 993 std::string actual_mime_type; |
1026 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( | 994 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( |
1027 plugin_url_, mime_type_, std::string(), &actual_mime_type); | 995 plugin_url_, mime_type_, &actual_mime_type); |
1028 | 996 |
1029 bool ok = plugin_delegate->Initialize( | 997 bool ok = plugin_delegate->Initialize( |
1030 plugin_url_, arg_names_, arg_values_, this, load_manually_); | 998 plugin_url_, arg_names_, arg_values_, this, load_manually_); |
1031 | 999 |
1032 if (!ok) { | 1000 if (!ok) { |
1033 container_ = NULL; | 1001 container_ = NULL; |
1034 // TODO(iyengar) Should we delete the current plugin instance here? | 1002 // TODO(iyengar) Should we delete the current plugin instance here? |
1035 return false; | 1003 return false; |
1036 } | 1004 } |
1037 | 1005 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 client_index = clients_.erase(client_index); | 1049 client_index = clients_.erase(client_index); |
1082 } | 1050 } |
1083 | 1051 |
1084 // This needs to be called now and not in the destructor since the | 1052 // This needs to be called now and not in the destructor since the |
1085 // webframe_ might not be valid anymore. | 1053 // webframe_ might not be valid anymore. |
1086 webframe_ = NULL; | 1054 webframe_ = NULL; |
1087 method_factory_.RevokeAll(); | 1055 method_factory_.RevokeAll(); |
1088 } | 1056 } |
1089 | 1057 |
1090 } // namespace webkit_glue | 1058 } // namespace webkit_glue |
OLD | NEW |