| 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 #include "content/renderer/npapi/webplugin_impl.h" | 5 #include "content/renderer/npapi/webplugin_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 bool is_plugin_src_load; | 225 bool is_plugin_src_load; |
| 226 int64 data_offset; | 226 int64 data_offset; |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 bool WebPluginImpl::initialize(WebPluginContainer* container) { | 229 bool WebPluginImpl::initialize(WebPluginContainer* container) { |
| 230 if (!render_view_.get()) { | 230 if (!render_view_.get()) { |
| 231 LOG(ERROR) << "No RenderView"; | 231 LOG(ERROR) << "No RenderView"; |
| 232 return false; | 232 return false; |
| 233 } | 233 } |
| 234 | 234 |
| 235 WebPluginDelegate* plugin_delegate = CreatePluginDelegate(); | 235 WebPluginDelegateProxy* plugin_delegate = new WebPluginDelegateProxy( |
| 236 if (!plugin_delegate) | 236 this, mime_type_, render_view_, render_frame_); |
| 237 return false; | |
| 238 | 237 |
| 239 // Store the plugin's unique identifier, used by the container to track its | 238 // Store the plugin's unique identifier, used by the container to track its |
| 240 // script objects. | 239 // script objects. |
| 241 npp_ = plugin_delegate->GetPluginNPP(); | 240 npp_ = plugin_delegate->GetPluginNPP(); |
| 242 | 241 |
| 243 // Set the container before Initialize because the plugin may | 242 // Set the container before Initialize because the plugin may |
| 244 // synchronously call NPN_GetValue to get its container, or make calls | 243 // synchronously call NPN_GetValue to get its container, or make calls |
| 245 // passing script objects that need to be tracked, during initialization. | 244 // passing script objects that need to be tracked, during initialization. |
| 246 SetContainer(container); | 245 SetContainer(container); |
| 247 | 246 |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 parsed.path.begin - parsed.scheme.end()); | 630 parsed.path.begin - parsed.scheme.end()); |
| 632 if (string_to_search.find("@") != std::string::npos || | 631 if (string_to_search.find("@") != std::string::npos || |
| 633 string_to_search.find(";") != std::string::npos || | 632 string_to_search.find(";") != std::string::npos || |
| 634 string_to_search.find("\\") != std::string::npos) | 633 string_to_search.find("\\") != std::string::npos) |
| 635 return false; | 634 return false; |
| 636 } | 635 } |
| 637 | 636 |
| 638 return true; | 637 return true; |
| 639 } | 638 } |
| 640 | 639 |
| 641 WebPluginDelegate* WebPluginImpl::CreatePluginDelegate() { | |
| 642 bool in_process_plugin = RenderProcess::current()->UseInProcessPlugins(); | |
| 643 if (in_process_plugin) { | |
| 644 #if defined(OS_WIN) && !defined(USE_AURA) | |
| 645 return WebPluginDelegateImpl::Create(this, file_path_, mime_type_); | |
| 646 #else | |
| 647 // In-proc plugins aren't supported on non-Windows. | |
| 648 NOTIMPLEMENTED(); | |
| 649 return NULL; | |
| 650 #endif | |
| 651 } | |
| 652 | |
| 653 return new WebPluginDelegateProxy( | |
| 654 this, mime_type_, render_view_, render_frame_); | |
| 655 } | |
| 656 | |
| 657 WebPluginImpl::RoutingStatus WebPluginImpl::RouteToFrame( | 640 WebPluginImpl::RoutingStatus WebPluginImpl::RouteToFrame( |
| 658 const char* url, | 641 const char* url, |
| 659 bool is_javascript_url, | 642 bool is_javascript_url, |
| 660 bool popups_allowed, | 643 bool popups_allowed, |
| 661 const char* method, | 644 const char* method, |
| 662 const char* target, | 645 const char* target, |
| 663 const char* buf, | 646 const char* buf, |
| 664 unsigned int len, | 647 unsigned int len, |
| 665 int notify_id, | 648 int notify_id, |
| 666 Referrer referrer_flag) { | 649 Referrer referrer_flag) { |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 return false; | 1383 return false; |
| 1401 | 1384 |
| 1402 WebPluginContainer* container_widget = container_; | 1385 WebPluginContainer* container_widget = container_; |
| 1403 | 1386 |
| 1404 // Destroy the current plugin instance. | 1387 // Destroy the current plugin instance. |
| 1405 TearDownPluginInstance(loader); | 1388 TearDownPluginInstance(loader); |
| 1406 | 1389 |
| 1407 container_ = container_widget; | 1390 container_ = container_widget; |
| 1408 webframe_ = webframe; | 1391 webframe_ = webframe; |
| 1409 | 1392 |
| 1410 WebPluginDelegate* plugin_delegate = CreatePluginDelegate(); | 1393 WebPluginDelegateProxy* plugin_delegate = new WebPluginDelegateProxy( |
| 1394 this, mime_type_, render_view_, render_frame_); |
| 1411 | 1395 |
| 1412 // Store the plugin's unique identifier, used by the container to track its | 1396 // Store the plugin's unique identifier, used by the container to track its |
| 1413 // script objects, and enable script objects (since Initialize may use them | 1397 // script objects, and enable script objects (since Initialize may use them |
| 1414 // even if it fails). | 1398 // even if it fails). |
| 1415 npp_ = plugin_delegate->GetPluginNPP(); | 1399 npp_ = plugin_delegate->GetPluginNPP(); |
| 1416 container_->allowScriptObjects(); | 1400 container_->allowScriptObjects(); |
| 1417 | 1401 |
| 1418 bool ok = plugin_delegate && plugin_delegate->Initialize( | 1402 bool ok = plugin_delegate && plugin_delegate->Initialize( |
| 1419 plugin_url_, arg_names_, arg_values_, load_manually_); | 1403 plugin_url_, arg_names_, arg_values_, load_manually_); |
| 1420 | 1404 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 case PLUGIN_SRC: | 1485 case PLUGIN_SRC: |
| 1502 webframe_->setReferrerForRequest(*request, plugin_url_); | 1486 webframe_->setReferrerForRequest(*request, plugin_url_); |
| 1503 break; | 1487 break; |
| 1504 | 1488 |
| 1505 default: | 1489 default: |
| 1506 break; | 1490 break; |
| 1507 } | 1491 } |
| 1508 } | 1492 } |
| 1509 | 1493 |
| 1510 } // namespace content | 1494 } // namespace content |
| OLD | NEW |