| 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/plugin_channel.h" | 5 #include "content/plugin/plugin_channel.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 return false; | 229 return false; |
| 230 | 230 |
| 231 channel_->AddFilter(filter_.get()); | 231 channel_->AddFilter(filter_.get()); |
| 232 return true; | 232 return true; |
| 233 } | 233 } |
| 234 | 234 |
| 235 PluginChannel::PluginChannel() | 235 PluginChannel::PluginChannel() |
| 236 : renderer_id_(-1), | 236 : renderer_id_(-1), |
| 237 in_send_(0), | 237 in_send_(0), |
| 238 incognito_(false), | 238 incognito_(false), |
| 239 filter_(new MessageFilter()), | 239 filter_(new MessageFilter()) { |
| 240 npp_(new struct _NPP) { | |
| 241 set_send_unblocking_only_during_unblock_dispatch(); | 240 set_send_unblocking_only_during_unblock_dispatch(); |
| 242 const base::CommandLine* command_line = | 241 const base::CommandLine* command_line = |
| 243 base::CommandLine::ForCurrentProcess(); | 242 base::CommandLine::ForCurrentProcess(); |
| 244 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); | 243 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); |
| 245 | |
| 246 // Register |npp_| as the default owner for any object we receive via IPC. | |
| 247 SetDefaultNPObjectOwner(npp_.get()); | |
| 248 } | 244 } |
| 249 | 245 |
| 250 bool PluginChannel::OnControlMessageReceived(const IPC::Message& msg) { | 246 bool PluginChannel::OnControlMessageReceived(const IPC::Message& msg) { |
| 251 bool handled = true; | 247 bool handled = true; |
| 252 IPC_BEGIN_MESSAGE_MAP(PluginChannel, msg) | 248 IPC_BEGIN_MESSAGE_MAP(PluginChannel, msg) |
| 253 IPC_MESSAGE_HANDLER(PluginMsg_CreateInstance, OnCreateInstance) | 249 IPC_MESSAGE_HANDLER(PluginMsg_CreateInstance, OnCreateInstance) |
| 254 IPC_MESSAGE_HANDLER_DELAY_REPLY(PluginMsg_DestroyInstance, | 250 IPC_MESSAGE_HANDLER_DELAY_REPLY(PluginMsg_DestroyInstance, |
| 255 OnDestroyInstance) | 251 OnDestroyInstance) |
| 256 IPC_MESSAGE_HANDLER(PluginMsg_GenerateRouteID, OnGenerateRouteID) | 252 IPC_MESSAGE_HANDLER(PluginMsg_GenerateRouteID, OnGenerateRouteID) |
| 257 IPC_MESSAGE_HANDLER(PluginProcessMsg_ClearSiteData, OnClearSiteData) | 253 IPC_MESSAGE_HANDLER(PluginProcessMsg_ClearSiteData, OnClearSiteData) |
| 258 IPC_MESSAGE_UNHANDLED(handled = false) | 254 IPC_MESSAGE_UNHANDLED(handled = false) |
| 259 IPC_END_MESSAGE_MAP() | 255 IPC_END_MESSAGE_MAP() |
| 260 DCHECK(handled); | 256 DCHECK(handled); |
| 261 return handled; | 257 return handled; |
| 262 } | 258 } |
| 263 | 259 |
| 264 void PluginChannel::OnCreateInstance(const std::string& mime_type, | 260 void PluginChannel::OnCreateInstance(const std::string& mime_type, |
| 265 int* instance_id) { | 261 int* instance_id) { |
| 266 *instance_id = GenerateRouteID(); | 262 *instance_id = GenerateRouteID(); |
| 267 scoped_refptr<WebPluginDelegateStub> stub(new WebPluginDelegateStub( | 263 scoped_refptr<WebPluginDelegateStub> stub(new WebPluginDelegateStub( |
| 268 mime_type, *instance_id, this)); | 264 mime_type, *instance_id, this)); |
| 269 AddRoute(*instance_id, stub.get(), NULL); | 265 AddRoute(*instance_id, stub.get()); |
| 270 plugin_stubs_.push_back(stub); | 266 plugin_stubs_.push_back(stub); |
| 271 } | 267 } |
| 272 | 268 |
| 273 void PluginChannel::OnDestroyInstance(int instance_id, | 269 void PluginChannel::OnDestroyInstance(int instance_id, |
| 274 IPC::Message* reply_msg) { | 270 IPC::Message* reply_msg) { |
| 275 for (size_t i = 0; i < plugin_stubs_.size(); ++i) { | 271 for (size_t i = 0; i < plugin_stubs_.size(); ++i) { |
| 276 if (plugin_stubs_[i]->instance_id() == instance_id) { | 272 if (plugin_stubs_[i]->instance_id() == instance_id) { |
| 277 scoped_refptr<MessageFilter> filter(filter_); | 273 scoped_refptr<MessageFilter> filter(filter_); |
| 278 int render_view_id = | 274 int render_view_id = |
| 279 plugin_stubs_[i]->webplugin()->host_render_view_routing_id(); | 275 plugin_stubs_[i]->webplugin()->host_render_view_routing_id(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 : base::StringPrintf("\"%s\"", site_str); | 318 : base::StringPrintf("\"%s\"", site_str); |
| 323 VLOG(1) << "NPP_ClearSiteData(" << site_name << ", " << flags << ", " | 319 VLOG(1) << "NPP_ClearSiteData(" << site_name << ", " << flags << ", " |
| 324 << max_age << ") returned " << err; | 320 << max_age << ") returned " << err; |
| 325 success = (err == NPERR_NO_ERROR); | 321 success = (err == NPERR_NO_ERROR); |
| 326 } | 322 } |
| 327 } | 323 } |
| 328 Send(new PluginProcessHostMsg_ClearSiteDataResult(success)); | 324 Send(new PluginProcessHostMsg_ClearSiteDataResult(success)); |
| 329 } | 325 } |
| 330 | 326 |
| 331 } // namespace content | 327 } // namespace content |
| OLD | NEW |