| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/renderer/plugin_channel_host.h" | 5 #include "chrome/renderer/plugin_channel_host.h" |
| 6 | 6 |
| 7 #include "chrome/common/plugin_messages.h" | 7 #include "chrome/common/plugin_messages.h" |
| 8 #include "chrome/plugin/npobject_base.h" | 8 #include "chrome/plugin/npobject_base.h" |
| 9 | 9 |
| 10 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 bool PluginChannelHost::IsListening() { | 61 bool PluginChannelHost::IsListening() { |
| 62 return IsListeningFilter::is_listening_; | 62 return IsListeningFilter::is_listening_; |
| 63 } | 63 } |
| 64 | 64 |
| 65 // static | 65 // static |
| 66 void PluginChannelHost::SetListening(bool flag) { | 66 void PluginChannelHost::SetListening(bool flag) { |
| 67 IsListeningFilter::is_listening_ = flag; | 67 IsListeningFilter::is_listening_ = flag; |
| 68 } | 68 } |
| 69 | 69 |
| 70 PluginChannelHost* PluginChannelHost::GetPluginChannelHost( | 70 PluginChannelHost* PluginChannelHost::GetPluginChannelHost( |
| 71 const std::string& channel_name, MessageLoop* ipc_message_loop) { | 71 const IPC::ChannelHandle& channel_handle, MessageLoop* ipc_message_loop) { |
| 72 PluginChannelHost* result = | 72 PluginChannelHost* result = |
| 73 static_cast<PluginChannelHost*>(PluginChannelBase::GetChannel( | 73 static_cast<PluginChannelHost*>(PluginChannelBase::GetChannel( |
| 74 channel_name, | 74 channel_handle, |
| 75 IPC::Channel::MODE_CLIENT, | 75 IPC::Channel::MODE_CLIENT, |
| 76 ClassFactory, | 76 ClassFactory, |
| 77 ipc_message_loop, | 77 ipc_message_loop, |
| 78 true)); | 78 true)); |
| 79 return result; | 79 return result; |
| 80 } | 80 } |
| 81 | 81 |
| 82 PluginChannelHost::PluginChannelHost() : expecting_shutdown_(false) { | 82 PluginChannelHost::PluginChannelHost() : expecting_shutdown_(false) { |
| 83 } | 83 } |
| 84 | 84 |
| 85 PluginChannelHost::~PluginChannelHost() { | 85 PluginChannelHost::~PluginChannelHost() { |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool PluginChannelHost::Init(MessageLoop* ipc_message_loop, | 88 bool PluginChannelHost::Init(MessageLoop* ipc_message_loop, |
| 89 bool create_pipe_now) { | 89 bool create_pipe_now) { |
| 90 #if defined(OS_POSIX) | |
| 91 if (!IPC::ChannelSocketExists(channel_name())) { | |
| 92 // Attempting to use this IPC channel would result in a crash | |
| 93 // inside IPC code within the PluginChannelBase::Init call. The plugin | |
| 94 // channel in the plugin process is supposed to have created this channel | |
| 95 // and sent it to this process, the renderer process. If this channel | |
| 96 // closes and is removed, it cannot be reused until the plugin process | |
| 97 // recreates it. | |
| 98 LOG(ERROR) << "Refusing use of missing IPC channel " << channel_name(); | |
| 99 return false; | |
| 100 } | |
| 101 #endif | |
| 102 | |
| 103 bool ret = PluginChannelBase::Init(ipc_message_loop, create_pipe_now); | 90 bool ret = PluginChannelBase::Init(ipc_message_loop, create_pipe_now); |
| 104 is_listening_filter_ = new IsListeningFilter; | 91 is_listening_filter_ = new IsListeningFilter; |
| 105 channel_->AddFilter(is_listening_filter_); | 92 channel_->AddFilter(is_listening_filter_); |
| 106 return ret; | 93 return ret; |
| 107 } | 94 } |
| 108 | 95 |
| 109 int PluginChannelHost::GenerateRouteID() { | 96 int PluginChannelHost::GenerateRouteID() { |
| 110 int route_id = MSG_ROUTING_NONE; | 97 int route_id = MSG_ROUTING_NONE; |
| 111 Send(new PluginMsg_GenerateRouteID(&route_id)); | 98 Send(new PluginMsg_GenerateRouteID(&route_id)); |
| 112 | 99 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 void PluginChannelHost::OnChannelError() { | 133 void PluginChannelHost::OnChannelError() { |
| 147 PluginChannelBase::OnChannelError(); | 134 PluginChannelBase::OnChannelError(); |
| 148 | 135 |
| 149 for (ProxyMap::iterator iter = proxies_.begin(); | 136 for (ProxyMap::iterator iter = proxies_.begin(); |
| 150 iter != proxies_.end(); iter++) { | 137 iter != proxies_.end(); iter++) { |
| 151 iter->second->OnChannelError(); | 138 iter->second->OnChannelError(); |
| 152 } | 139 } |
| 153 | 140 |
| 154 proxies_.clear(); | 141 proxies_.clear(); |
| 155 } | 142 } |
| OLD | NEW |