| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/plugin/webplugin_proxy.h" | 5 #include "chrome/plugin/webplugin_proxy.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #if defined(OS_WIN) | 8 #if defined(OS_WIN) |
| 9 #include "app/win_util.h" | 9 #include "app/win_util.h" |
| 10 #endif | 10 #endif |
| 11 #include "base/scoped_handle.h" | 11 #include "base/scoped_handle.h" |
| 12 #include "base/shared_memory.h" | 12 #include "base/shared_memory.h" |
| 13 #include "base/singleton.h" | 13 #include "base/singleton.h" |
| 14 #include "base/waitable_event.h" | 14 #include "base/waitable_event.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/common/child_process_logging.h" |
| 16 #include "chrome/common/plugin_messages.h" | 17 #include "chrome/common/plugin_messages.h" |
| 17 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 18 #include "chrome/plugin/npobject_proxy.h" | 19 #include "chrome/plugin/npobject_proxy.h" |
| 19 #include "chrome/plugin/npobject_util.h" | 20 #include "chrome/plugin/npobject_util.h" |
| 20 #include "chrome/plugin/plugin_channel.h" | 21 #include "chrome/plugin/plugin_channel.h" |
| 21 #include "chrome/plugin/plugin_thread.h" | 22 #include "chrome/plugin/plugin_thread.h" |
| 22 #include "chrome/plugin/webplugin_delegate_stub.h" | 23 #include "chrome/plugin/webplugin_delegate_stub.h" |
| 23 #include "skia/ext/platform_device.h" | 24 #include "skia/ext/platform_device.h" |
| 24 #include "webkit/glue/webplugin_delegate.h" | 25 #include "webkit/glue/webplugin_delegate.h" |
| 25 | 26 |
| 26 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 27 #include "base/gfx/gdi_util.h" | 28 #include "base/gfx/gdi_util.h" |
| 28 #endif | 29 #endif |
| 29 | 30 |
| 30 typedef std::map<CPBrowsingContext, WebPluginProxy*> ContextMap; | 31 typedef std::map<CPBrowsingContext, WebPluginProxy*> ContextMap; |
| 31 static ContextMap& GetContextMap() { | 32 static ContextMap& GetContextMap() { |
| 32 return *Singleton<ContextMap>::get(); | 33 return *Singleton<ContextMap>::get(); |
| 33 } | 34 } |
| 34 | 35 |
| 35 WebPluginProxy::WebPluginProxy( | 36 WebPluginProxy::WebPluginProxy( |
| 36 PluginChannel* channel, | 37 PluginChannel* channel, |
| 37 int route_id, | 38 int route_id, |
| 38 WebPluginDelegate* delegate) | 39 WebPluginDelegate* delegate, |
| 40 const GURL& page_url) |
| 39 : channel_(channel), | 41 : channel_(channel), |
| 40 route_id_(route_id), | 42 route_id_(route_id), |
| 41 cp_browsing_context_(0), | 43 cp_browsing_context_(0), |
| 42 window_npobject_(NULL), | 44 window_npobject_(NULL), |
| 43 plugin_element_(NULL), | 45 plugin_element_(NULL), |
| 44 delegate_(delegate), | 46 delegate_(delegate), |
| 45 waiting_for_paint_(false), | 47 waiting_for_paint_(false), |
| 48 page_url_(page_url), |
| 46 ALLOW_THIS_IN_INITIALIZER_LIST(runnable_method_factory_(this)) | 49 ALLOW_THIS_IN_INITIALIZER_LIST(runnable_method_factory_(this)) |
| 47 { | 50 { |
| 48 } | 51 } |
| 49 | 52 |
| 50 WebPluginProxy::~WebPluginProxy() { | 53 WebPluginProxy::~WebPluginProxy() { |
| 51 if (cp_browsing_context_) | 54 if (cp_browsing_context_) |
| 52 GetContextMap().erase(cp_browsing_context_); | 55 GetContextMap().erase(cp_browsing_context_); |
| 53 } | 56 } |
| 54 | 57 |
| 55 bool WebPluginProxy::Send(IPC::Message* msg) { | 58 bool WebPluginProxy::Send(IPC::Message* msg) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 return NPN_RetainObject(window_npobject_); | 155 return NPN_RetainObject(window_npobject_); |
| 153 | 156 |
| 154 int npobject_route_id = channel_->GenerateRouteID(); | 157 int npobject_route_id = channel_->GenerateRouteID(); |
| 155 bool success = false; | 158 bool success = false; |
| 156 intptr_t npobject_ptr; | 159 intptr_t npobject_ptr; |
| 157 Send(new PluginHostMsg_GetWindowScriptNPObject( | 160 Send(new PluginHostMsg_GetWindowScriptNPObject( |
| 158 route_id_, npobject_route_id, &success, &npobject_ptr)); | 161 route_id_, npobject_route_id, &success, &npobject_ptr)); |
| 159 if (!success) | 162 if (!success) |
| 160 return NULL; | 163 return NULL; |
| 161 | 164 |
| 162 window_npobject_ = NPObjectProxy::Create(channel_, | 165 window_npobject_ = NPObjectProxy::Create( |
| 163 npobject_route_id, | 166 channel_, npobject_route_id, npobject_ptr, modal_dialog_event_.get(), |
| 164 npobject_ptr, | 167 page_url_); |
| 165 modal_dialog_event_.get()); | |
| 166 | 168 |
| 167 return window_npobject_; | 169 return window_npobject_; |
| 168 } | 170 } |
| 169 | 171 |
| 170 NPObject* WebPluginProxy::GetPluginElement() { | 172 NPObject* WebPluginProxy::GetPluginElement() { |
| 171 if (plugin_element_) | 173 if (plugin_element_) |
| 172 return NPN_RetainObject(plugin_element_); | 174 return NPN_RetainObject(plugin_element_); |
| 173 | 175 |
| 174 int npobject_route_id = channel_->GenerateRouteID(); | 176 int npobject_route_id = channel_->GenerateRouteID(); |
| 175 bool success = false; | 177 bool success = false; |
| 176 intptr_t npobject_ptr; | 178 intptr_t npobject_ptr; |
| 177 Send(new PluginHostMsg_GetPluginElement( | 179 Send(new PluginHostMsg_GetPluginElement( |
| 178 route_id_, npobject_route_id, &success, &npobject_ptr)); | 180 route_id_, npobject_route_id, &success, &npobject_ptr)); |
| 179 if (!success) | 181 if (!success) |
| 180 return NULL; | 182 return NULL; |
| 181 | 183 |
| 182 plugin_element_ = NPObjectProxy::Create(channel_, | 184 plugin_element_ = NPObjectProxy::Create( |
| 183 npobject_route_id, | 185 channel_, npobject_route_id, npobject_ptr, modal_dialog_event_.get(), |
| 184 npobject_ptr, | 186 page_url_); |
| 185 modal_dialog_event_.get()); | |
| 186 | 187 |
| 187 return plugin_element_; | 188 return plugin_element_; |
| 188 } | 189 } |
| 189 | 190 |
| 190 void WebPluginProxy::SetCookie(const GURL& url, | 191 void WebPluginProxy::SetCookie(const GURL& url, |
| 191 const GURL& policy_url, | 192 const GURL& policy_url, |
| 192 const std::string& cookie) { | 193 const std::string& cookie) { |
| 193 Send(new PluginHostMsg_SetCookie(route_id_, url, policy_url, cookie)); | 194 Send(new PluginHostMsg_SetCookie(route_id_, url, policy_url, cookie)); |
| 194 } | 195 } |
| 195 | 196 |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 intptr_t existing_stream, | 512 intptr_t existing_stream, |
| 512 bool notify_needed, | 513 bool notify_needed, |
| 513 intptr_t notify_data) { | 514 intptr_t notify_data) { |
| 514 | 515 |
| 515 Send(new PluginHostMsg_InitiateHTTPRangeRequest(route_id_, url, | 516 Send(new PluginHostMsg_InitiateHTTPRangeRequest(route_id_, url, |
| 516 range_info, existing_stream, | 517 range_info, existing_stream, |
| 517 notify_needed, notify_data)); | 518 notify_needed, notify_data)); |
| 518 } | 519 } |
| 519 | 520 |
| 520 void WebPluginProxy::OnPaint(const gfx::Rect& damaged_rect) { | 521 void WebPluginProxy::OnPaint(const gfx::Rect& damaged_rect) { |
| 522 child_process_logging::ScopedActiveURLSetter url_setter(page_url_); |
| 523 |
| 521 Paint(damaged_rect); | 524 Paint(damaged_rect); |
| 522 Send(new PluginHostMsg_InvalidateRect(route_id_, damaged_rect)); | 525 Send(new PluginHostMsg_InvalidateRect(route_id_, damaged_rect)); |
| 523 } | 526 } |
| 524 | 527 |
| 525 bool WebPluginProxy::IsOffTheRecord() { | 528 bool WebPluginProxy::IsOffTheRecord() { |
| 526 return channel_->off_the_record(); | 529 return channel_->off_the_record(); |
| 527 } | 530 } |
| 528 | 531 |
| 529 void WebPluginProxy::ResourceClientDeleted( | 532 void WebPluginProxy::ResourceClientDeleted( |
| 530 WebPluginResourceClient* resource_client) { | 533 WebPluginResourceClient* resource_client) { |
| 531 ResourceClientMap::iterator index = resource_clients_.begin(); | 534 ResourceClientMap::iterator index = resource_clients_.begin(); |
| 532 while (index != resource_clients_.end()) { | 535 while (index != resource_clients_.end()) { |
| 533 WebPluginResourceClient* client = (*index).second; | 536 WebPluginResourceClient* client = (*index).second; |
| 534 | 537 |
| 535 if (client == resource_client) { | 538 if (client == resource_client) { |
| 536 resource_clients_.erase(index++); | 539 resource_clients_.erase(index++); |
| 537 } else { | 540 } else { |
| 538 index++; | 541 index++; |
| 539 } | 542 } |
| 540 } | 543 } |
| 541 } | 544 } |
| OLD | NEW |