| 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/plugin/webplugin_proxy.h" | 5 #include "content/plugin/webplugin_proxy.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/memory/scoped_handle.h" | 11 #include "base/memory/scoped_handle.h" |
| 12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "content/child/npapi/npobject_proxy.h" | 14 #include "content/child/npapi/npobject_proxy.h" |
| 15 #include "content/child/npapi/npobject_util.h" | 15 #include "content/child/npapi/npobject_util.h" |
| 16 #include "content/child/npapi/webplugin_delegate_impl.h" | 16 #include "content/child/npapi/webplugin_delegate_impl.h" |
| 17 #include "content/child/npapi/webplugin_resource_client.h" |
| 17 #include "content/child/plugin_messages.h" | 18 #include "content/child/plugin_messages.h" |
| 18 #include "content/plugin/plugin_channel.h" | 19 #include "content/plugin/plugin_channel.h" |
| 19 #include "content/plugin/plugin_thread.h" | 20 #include "content/plugin/plugin_thread.h" |
| 21 #include "content/plugin/plugin_url_fetcher.h" |
| 20 #include "content/public/common/content_client.h" | 22 #include "content/public/common/content_client.h" |
| 21 #include "content/public/common/url_constants.h" | 23 #include "content/public/common/url_constants.h" |
| 22 #include "skia/ext/platform_canvas.h" | 24 #include "skia/ext/platform_canvas.h" |
| 23 #include "skia/ext/platform_device.h" | 25 #include "skia/ext/platform_device.h" |
| 24 #include "third_party/WebKit/public/web/WebBindings.h" | 26 #include "third_party/WebKit/public/web/WebBindings.h" |
| 25 #include "ui/gfx/blit.h" | 27 #include "ui/gfx/blit.h" |
| 26 #include "ui/gfx/canvas.h" | 28 #include "ui/gfx/canvas.h" |
| 27 | 29 |
| 28 #if defined(OS_MACOSX) | 30 #if defined(OS_MACOSX) |
| 29 #include "base/mac/mac_util.h" | 31 #include "base/mac/mac_util.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 BrokerDuplicateHandle(pump_messages_event, channel_->peer_pid(), | 141 BrokerDuplicateHandle(pump_messages_event, channel_->peer_pid(), |
| 140 &pump_messages_event_for_renderer, | 142 &pump_messages_event_for_renderer, |
| 141 SYNCHRONIZE | EVENT_MODIFY_STATE, 0); | 143 SYNCHRONIZE | EVENT_MODIFY_STATE, 0); |
| 142 DCHECK(pump_messages_event_for_renderer); | 144 DCHECK(pump_messages_event_for_renderer); |
| 143 Send(new PluginHostMsg_SetWindowlessData( | 145 Send(new PluginHostMsg_SetWindowlessData( |
| 144 route_id_, pump_messages_event_for_renderer, dummy_activation_window)); | 146 route_id_, pump_messages_event_for_renderer, dummy_activation_window)); |
| 145 } | 147 } |
| 146 #endif | 148 #endif |
| 147 | 149 |
| 148 void WebPluginProxy::CancelResource(unsigned long id) { | 150 void WebPluginProxy::CancelResource(unsigned long id) { |
| 149 Send(new PluginHostMsg_CancelResource(route_id_, id)); | 151 if (resource_clients_.count(id)) { |
| 150 resource_clients_.erase(id); | 152 Send(new PluginHostMsg_CancelResource(route_id_, id)); |
| 153 |
| 154 resource_clients_.erase(id); |
| 155 } else if (plugin_url_fetchers_.count(id)) { |
| 156 plugin_url_fetchers_[id]->Cancel(); |
| 157 } else { |
| 158 NOTREACHED(); |
| 159 } |
| 151 } | 160 } |
| 152 | 161 |
| 153 void WebPluginProxy::Invalidate() { | 162 void WebPluginProxy::Invalidate() { |
| 154 gfx::Rect rect(0, 0, | 163 gfx::Rect rect(0, 0, |
| 155 delegate_->GetRect().width(), | 164 delegate_->GetRect().width(), |
| 156 delegate_->GetRect().height()); | 165 delegate_->GetRect().height()); |
| 157 InvalidateRect(rect); | 166 InvalidateRect(rect); |
| 158 } | 167 } |
| 159 | 168 |
| 160 void WebPluginProxy::InvalidateRect(const gfx::Rect& rect) { | 169 void WebPluginProxy::InvalidateRect(const gfx::Rect& rect) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 if (!damaged_rect_.IsEmpty()) | 308 if (!damaged_rect_.IsEmpty()) |
| 300 InvalidateRect(damaged_rect_); | 309 InvalidateRect(damaged_rect_); |
| 301 } | 310 } |
| 302 | 311 |
| 303 void WebPluginProxy::OnResourceCreated(int resource_id, | 312 void WebPluginProxy::OnResourceCreated(int resource_id, |
| 304 WebPluginResourceClient* client) { | 313 WebPluginResourceClient* client) { |
| 305 DCHECK(resource_clients_.find(resource_id) == resource_clients_.end()); | 314 DCHECK(resource_clients_.find(resource_id) == resource_clients_.end()); |
| 306 resource_clients_[resource_id] = client; | 315 resource_clients_[resource_id] = client; |
| 307 } | 316 } |
| 308 | 317 |
| 318 void WebPluginProxy::FetchURL(const PluginMsg_FetchURL_Params& params) { |
| 319 // TODO(jam): once we switch over to resource loading always happening in this |
| 320 // code path, remove WebPluginResourceClient abstraction. |
| 321 WebPluginResourceClient* resource_client = delegate_->CreateResourceClient( |
| 322 params.resource_id, params.url, params.notify_id); |
| 323 |
| 324 DCHECK(plugin_url_fetchers_.find(params.resource_id) == |
| 325 plugin_url_fetchers_.end()); |
| 326 plugin_url_fetchers_[params.resource_id] = new PluginURLFetcher( |
| 327 resource_client, this, params.url, params.first_party_for_cookies, |
| 328 params.method, params.post_data, params.referrer, params.notify_redirect, |
| 329 params.is_plugin_src_load, channel_->renderer_id(), params.resource_id); |
| 330 } |
| 331 |
| 309 void WebPluginProxy::HandleURLRequest(const char* url, | 332 void WebPluginProxy::HandleURLRequest(const char* url, |
| 310 const char* method, | 333 const char* method, |
| 311 const char* target, | 334 const char* target, |
| 312 const char* buf, | 335 const char* buf, |
| 313 unsigned int len, | 336 unsigned int len, |
| 314 int notify_id, | 337 int notify_id, |
| 315 bool popups_allowed, | 338 bool popups_allowed, |
| 316 bool notify_redirects) { | 339 bool notify_redirects) { |
| 317 if (!target && (0 == base::strcasecmp(method, "GET"))) { | 340 if (!target && (0 == base::strcasecmp(method, "GET"))) { |
| 318 // Please refer to https://bugzilla.mozilla.org/show_bug.cgi?id=366082 | 341 // Please refer to https://bugzilla.mozilla.org/show_bug.cgi?id=366082 |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 Paint(damaged_rect); | 692 Paint(damaged_rect); |
| 670 Send(new PluginHostMsg_InvalidateRect(route_id_, damaged_rect)); | 693 Send(new PluginHostMsg_InvalidateRect(route_id_, damaged_rect)); |
| 671 } | 694 } |
| 672 | 695 |
| 673 bool WebPluginProxy::IsOffTheRecord() { | 696 bool WebPluginProxy::IsOffTheRecord() { |
| 674 return channel_->incognito(); | 697 return channel_->incognito(); |
| 675 } | 698 } |
| 676 | 699 |
| 677 void WebPluginProxy::ResourceClientDeleted( | 700 void WebPluginProxy::ResourceClientDeleted( |
| 678 WebPluginResourceClient* resource_client) { | 701 WebPluginResourceClient* resource_client) { |
| 702 // resource_client->ResourceId() is 0 at this point, so can't use it as an |
| 703 // index into the map. |
| 679 ResourceClientMap::iterator index = resource_clients_.begin(); | 704 ResourceClientMap::iterator index = resource_clients_.begin(); |
| 680 while (index != resource_clients_.end()) { | 705 while (index != resource_clients_.end()) { |
| 681 WebPluginResourceClient* client = (*index).second; | 706 WebPluginResourceClient* client = (*index).second; |
| 682 | |
| 683 if (client == resource_client) { | 707 if (client == resource_client) { |
| 684 resource_clients_.erase(index++); | 708 resource_clients_.erase(index); |
| 709 return; |
| 685 } else { | 710 } else { |
| 686 index++; | 711 index++; |
| 687 } | 712 } |
| 688 } | 713 } |
| 714 |
| 715 PluginURLFetcherMap::iterator index2 = plugin_url_fetchers_.begin(); |
| 716 while (index2 != plugin_url_fetchers_.end()) { |
| 717 PluginURLFetcher* fetcher = (*index2).second; |
| 718 if (fetcher->client() == resource_client) { |
| 719 plugin_url_fetchers_.erase(index2); |
| 720 return; |
| 721 } else { |
| 722 index2++; |
| 723 } |
| 724 } |
| 689 } | 725 } |
| 690 | 726 |
| 691 void WebPluginProxy::URLRedirectResponse(bool allow, int resource_id) { | 727 void WebPluginProxy::URLRedirectResponse(bool allow, int resource_id) { |
| 692 Send(new PluginHostMsg_URLRedirectResponse(route_id_, allow, resource_id)); | 728 if (resource_clients_.count(resource_id)) { |
| 729 Send(new PluginHostMsg_URLRedirectResponse(route_id_, allow, resource_id)); |
| 730 } else if (plugin_url_fetchers_.count(resource_id)) { |
| 731 plugin_url_fetchers_[resource_id]->URLRedirectResponse(allow); |
| 732 } else { |
| 733 NOTREACHED(); |
| 734 } |
| 693 } | 735 } |
| 694 | 736 |
| 695 #if defined(OS_WIN) && !defined(USE_AURA) | 737 #if defined(OS_WIN) && !defined(USE_AURA) |
| 696 void WebPluginProxy::UpdateIMEStatus() { | 738 void WebPluginProxy::UpdateIMEStatus() { |
| 697 // Retrieve the IME status from a plug-in and send it to a renderer process | 739 // Retrieve the IME status from a plug-in and send it to a renderer process |
| 698 // when the plug-in has updated it. | 740 // when the plug-in has updated it. |
| 699 int input_type; | 741 int input_type; |
| 700 gfx::Rect caret_rect; | 742 gfx::Rect caret_rect; |
| 701 if (!delegate_->GetIMEStatus(&input_type, &caret_rect)) | 743 if (!delegate_->GetIMEStatus(&input_type, &caret_rect)) |
| 702 return; | 744 return; |
| 703 | 745 |
| 704 Send(new PluginHostMsg_NotifyIMEStatus(route_id_, input_type, caret_rect)); | 746 Send(new PluginHostMsg_NotifyIMEStatus(route_id_, input_type, caret_rect)); |
| 705 } | 747 } |
| 706 #endif | 748 #endif |
| 707 | 749 |
| 708 } // namespace content | 750 } // namespace content |
| OLD | NEW |