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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/process/process_handle.h" | 9 #include "base/process/process_handle.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 return true; | 236 return true; |
237 } | 237 } |
238 | 238 |
239 PluginChannel::PluginChannel() | 239 PluginChannel::PluginChannel() |
240 : renderer_id_(-1), | 240 : renderer_id_(-1), |
241 in_send_(0), | 241 in_send_(0), |
242 incognito_(false), | 242 incognito_(false), |
243 filter_(new MessageFilter()), | 243 filter_(new MessageFilter()), |
244 npp_(new struct _NPP) { | 244 npp_(new struct _NPP) { |
245 set_send_unblocking_only_during_unblock_dispatch(); | 245 set_send_unblocking_only_during_unblock_dispatch(); |
246 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 246 const base::CommandLine* command_line = |
| 247 base::CommandLine::ForCurrentProcess(); |
247 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); | 248 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); |
248 | 249 |
249 // Register |npp_| as the default owner for any object we receive via IPC, | 250 // Register |npp_| as the default owner for any object we receive via IPC, |
250 // and register it with WebBindings as a valid owner. | 251 // and register it with WebBindings as a valid owner. |
251 SetDefaultNPObjectOwner(npp_.get()); | 252 SetDefaultNPObjectOwner(npp_.get()); |
252 WebBindings::registerObjectOwner(npp_.get()); | 253 WebBindings::registerObjectOwner(npp_.get()); |
253 } | 254 } |
254 | 255 |
255 bool PluginChannel::OnControlMessageReceived(const IPC::Message& msg) { | 256 bool PluginChannel::OnControlMessageReceived(const IPC::Message& msg) { |
256 bool handled = true; | 257 bool handled = true; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 } | 309 } |
309 | 310 |
310 void PluginChannel::OnGenerateRouteID(int* route_id) { | 311 void PluginChannel::OnGenerateRouteID(int* route_id) { |
311 *route_id = GenerateRouteID(); | 312 *route_id = GenerateRouteID(); |
312 } | 313 } |
313 | 314 |
314 void PluginChannel::OnClearSiteData(const std::string& site, | 315 void PluginChannel::OnClearSiteData(const std::string& site, |
315 uint64 flags, | 316 uint64 flags, |
316 uint64 max_age) { | 317 uint64 max_age) { |
317 bool success = false; | 318 bool success = false; |
318 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 319 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
319 base::FilePath path = command_line->GetSwitchValuePath(switches::kPluginPath); | 320 base::FilePath path = command_line->GetSwitchValuePath(switches::kPluginPath); |
320 scoped_refptr<PluginLib> plugin_lib(PluginLib::CreatePluginLib(path)); | 321 scoped_refptr<PluginLib> plugin_lib(PluginLib::CreatePluginLib(path)); |
321 if (plugin_lib.get()) { | 322 if (plugin_lib.get()) { |
322 NPError err = plugin_lib->NP_Initialize(); | 323 NPError err = plugin_lib->NP_Initialize(); |
323 if (err == NPERR_NO_ERROR) { | 324 if (err == NPERR_NO_ERROR) { |
324 const char* site_str = site.empty() ? NULL : site.c_str(); | 325 const char* site_str = site.empty() ? NULL : site.c_str(); |
325 err = plugin_lib->NP_ClearSiteData(site_str, flags, max_age); | 326 err = plugin_lib->NP_ClearSiteData(site_str, flags, max_age); |
326 std::string site_name = | 327 std::string site_name = |
327 site.empty() ? "NULL" | 328 site.empty() ? "NULL" |
328 : base::StringPrintf("\"%s\"", site_str); | 329 : base::StringPrintf("\"%s\"", site_str); |
329 VLOG(1) << "NPP_ClearSiteData(" << site_name << ", " << flags << ", " | 330 VLOG(1) << "NPP_ClearSiteData(" << site_name << ", " << flags << ", " |
330 << max_age << ") returned " << err; | 331 << max_age << ") returned " << err; |
331 success = (err == NPERR_NO_ERROR); | 332 success = (err == NPERR_NO_ERROR); |
332 } | 333 } |
333 } | 334 } |
334 Send(new PluginProcessHostMsg_ClearSiteDataResult(success)); | 335 Send(new PluginProcessHostMsg_ClearSiteDataResult(success)); |
335 } | 336 } |
336 | 337 |
337 void PluginChannel::OnDidAbortLoading(int render_view_id) { | 338 void PluginChannel::OnDidAbortLoading(int render_view_id) { |
338 for (size_t i = 0; i < plugin_stubs_.size(); ++i) { | 339 for (size_t i = 0; i < plugin_stubs_.size(); ++i) { |
339 if (plugin_stubs_[i]->webplugin()->host_render_view_routing_id() == | 340 if (plugin_stubs_[i]->webplugin()->host_render_view_routing_id() == |
340 render_view_id) { | 341 render_view_id) { |
341 plugin_stubs_[i]->delegate()->instance()->CloseStreams(); | 342 plugin_stubs_[i]->delegate()->instance()->CloseStreams(); |
342 } | 343 } |
343 } | 344 } |
344 } | 345 } |
345 | 346 |
346 } // namespace content | 347 } // namespace content |
OLD | NEW |