| 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" |
| 11 #include "chrome/browser/automation/automation_provider.h" | 11 #include "chrome/browser/automation/automation_provider.h" |
| 12 #include "chrome/browser/automation/extension_automation_constants.h" | 12 #include "chrome/browser/automation/extension_automation_constants.h" |
| 13 #include "chrome/browser/extensions/extension_message_service.h" | 13 #include "chrome/browser/extensions/extension_message_service.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/automation_messages.h" | 15 #include "chrome/common/automation_messages.h" |
| 16 #include "chrome/common/render_messages.h" | 16 #include "chrome/common/extensions/extension_messages.h" |
| 17 #include "content/browser/renderer_host/render_process_host.h" | 17 #include "content/browser/renderer_host/render_process_host.h" |
| 18 #include "content/browser/renderer_host/render_view_host.h" | 18 #include "content/browser/renderer_host/render_view_host.h" |
| 19 | 19 |
| 20 // TODO(siggi): Find a more structured way to read and write JSON messages. | 20 // TODO(siggi): Find a more structured way to read and write JSON messages. |
| 21 | 21 |
| 22 namespace ext = extension_automation_constants; | 22 namespace ext = extension_automation_constants; |
| 23 | 23 |
| 24 ExtensionPortContainer::ExtensionPortContainer(AutomationProvider* automation, | 24 ExtensionPortContainer::ExtensionPortContainer(AutomationProvider* automation, |
| 25 int tab_handle) : | 25 int tab_handle) : |
| 26 automation_(automation), service_(NULL), port_id_(-1), | 26 automation_(automation), service_(NULL), port_id_(-1), |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 std::string msg_json; | 88 std::string msg_json; |
| 89 base::JSONWriter::Write(msg_dict.get(), false, &msg_json); | 89 base::JSONWriter::Write(msg_dict.get(), false, &msg_json); |
| 90 | 90 |
| 91 PostResponseToExternalPort(msg_json); | 91 PostResponseToExternalPort(msg_json); |
| 92 } | 92 } |
| 93 | 93 |
| 94 bool ExtensionPortContainer::Send(IPC::Message *message) { | 94 bool ExtensionPortContainer::Send(IPC::Message *message) { |
| 95 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 95 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
| 96 | 96 |
| 97 IPC_BEGIN_MESSAGE_MAP(ExtensionPortContainer, *message) | 97 IPC_BEGIN_MESSAGE_MAP(ExtensionPortContainer, *message) |
| 98 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionMessageInvoke, | 98 IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnExtensionMessageInvoke) |
| 99 OnExtensionMessageInvoke) | |
| 100 IPC_MESSAGE_UNHANDLED_ERROR() | 99 IPC_MESSAGE_UNHANDLED_ERROR() |
| 101 IPC_END_MESSAGE_MAP() | 100 IPC_END_MESSAGE_MAP() |
| 102 | 101 |
| 103 delete message; | 102 delete message; |
| 104 return true; | 103 return true; |
| 105 } | 104 } |
| 106 | 105 |
| 107 void ExtensionPortContainer::OnExtensionMessageInvoke( | 106 void ExtensionPortContainer::OnExtensionMessageInvoke( |
| 108 const std::string& extension_id, | 107 const std::string& extension_id, |
| 109 const std::string& function_name, | 108 const std::string& function_name, |
| (...skipping 140 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. | 249 // This will delete the port and notify the other end of the disconnect. |
| 251 automation->RemovePortContainer(port); | 250 automation->RemovePortContainer(port); |
| 252 } | 251 } |
| 253 } else { | 252 } else { |
| 254 // We don't expect other messages here. | 253 // We don't expect other messages here. |
| 255 NOTREACHED(); | 254 NOTREACHED(); |
| 256 } | 255 } |
| 257 | 256 |
| 258 return true; | 257 return true; |
| 259 } | 258 } |
| OLD | NEW |