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/browser/automation/extension_port_container.h" | 5 #include "chrome/browser/automation/extension_port_container.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 33 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
34 | 34 |
35 if (port_id_ != -1) | 35 if (port_id_ != -1) |
36 service_->CloseChannel(port_id_); | 36 service_->CloseChannel(port_id_); |
37 } | 37 } |
38 | 38 |
39 bool ExtensionPortContainer::PostResponseToExternalPort( | 39 bool ExtensionPortContainer::PostResponseToExternalPort( |
40 const std::string& message) { | 40 const std::string& message) { |
41 return automation_->Send( | 41 return automation_->Send( |
42 new AutomationMsg_ForwardMessageToExternalHost( | 42 new AutomationMsg_ForwardMessageToExternalHost( |
43 0, tab_handle_, message, ext::kAutomationOrigin, | 43 tab_handle_, message, ext::kAutomationOrigin, |
44 ext::kAutomationPortResponseTarget)); | 44 ext::kAutomationPortResponseTarget)); |
45 } | 45 } |
46 | 46 |
47 bool ExtensionPortContainer::PostMessageToExternalPort( | 47 bool ExtensionPortContainer::PostMessageToExternalPort( |
48 const std::string& message) { | 48 const std::string& message) { |
49 return automation_->Send( | 49 return automation_->Send( |
50 new AutomationMsg_ForwardMessageToExternalHost( | 50 new AutomationMsg_ForwardMessageToExternalHost( |
51 0, tab_handle_, message, | 51 tab_handle_, message, |
52 ext::kAutomationOrigin, | 52 ext::kAutomationOrigin, |
53 ext::kAutomationPortRequestTarget)); | 53 ext::kAutomationPortRequestTarget)); |
54 } | 54 } |
55 | 55 |
56 void ExtensionPortContainer::PostMessageFromExternalPort( | 56 void ExtensionPortContainer::PostMessageFromExternalPort( |
57 const std::string &message) { | 57 const std::string &message) { |
58 service_->PostMessageFromRenderer(port_id_, message); | 58 service_->PostMessageFromRenderer(port_id_, message); |
59 } | 59 } |
60 | 60 |
61 bool ExtensionPortContainer::Connect(const std::string &extension_id, | 61 bool ExtensionPortContainer::Connect(const std::string &extension_id, |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // This will delete the port and notify the other end of the disconnect. | 250 // This will delete the port and notify the other end of the disconnect. |
251 automation->RemovePortContainer(port); | 251 automation->RemovePortContainer(port); |
252 } | 252 } |
253 } else { | 253 } else { |
254 // We don't expect other messages here. | 254 // We don't expect other messages here. |
255 NOTREACHED(); | 255 NOTREACHED(); |
256 } | 256 } |
257 | 257 |
258 return true; | 258 return true; |
259 } | 259 } |
OLD | NEW |