| 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 // Implementation of the ExtensionPortsRemoteService. | 5 // Implementation of the ExtensionPortsRemoteService. |
| 6 | 6 |
| 7 // Inspired significantly from debugger_remote_service | 7 // Inspired significantly from debugger_remote_service |
| 8 // and ../automation/extension_port_container. | 8 // and ../automation/extension_port_container. |
| 9 | 9 |
| 10 #include "chrome/browser/debugger/extension_ports_remote_service.h" | 10 #include "chrome/browser/debugger/extension_ports_remote_service.h" |
| 11 | 11 |
| 12 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/debugger/devtools_manager.h" | 18 #include "chrome/browser/debugger/devtools_manager.h" |
| 19 #include "chrome/browser/debugger/devtools_protocol_handler.h" | 19 #include "chrome/browser/debugger/devtools_protocol_handler.h" |
| 20 #include "chrome/browser/debugger/devtools_remote_message.h" | 20 #include "chrome/browser/debugger/devtools_remote_message.h" |
| 21 #include "chrome/browser/debugger/inspectable_tab_proxy.h" | 21 #include "chrome/browser/debugger/inspectable_tab_proxy.h" |
| 22 #include "chrome/browser/profile.h" | 22 #include "chrome/browser/profile.h" |
| 23 #include "chrome/browser/profile_manager.h" | 23 #include "chrome/browser/profile_manager.h" |
| 24 #include "chrome/browser/tab_contents/tab_contents.h" | 24 #include "chrome/browser/tab_contents/tab_contents.h" |
| 25 #include "chrome/common/devtools_messages.h" | 25 #include "chrome/common/devtools_messages.h" |
| 26 #include "chrome/common/notification_service.h" | 26 #include "chrome/common/notification_service.h" |
| 27 #include "chrome/common/render_messages.h" | 27 #include "chrome/common/render_messages.h" |
| 28 #include "chrome/common/render_messages_params.h" |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 // Protocol is as follows: | 32 // Protocol is as follows: |
| 32 // | 33 // |
| 33 // From external client: | 34 // From external client: |
| 34 // {"command": "connect", | 35 // {"command": "connect", |
| 35 // "data": { | 36 // "data": { |
| 36 // "extensionId": "<extension_id string>", | 37 // "extensionId": "<extension_id string>", |
| 37 // "channelName": "<port name string>", (optional) | 38 // "channelName": "<port name string>", (optional) |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 LOG(INFO) << "unknown port: " << port_id; | 382 LOG(INFO) << "unknown port: " << port_id; |
| 382 response->SetInteger(kResultKey, RESULT_UNKNOWN_PORT); | 383 response->SetInteger(kResultKey, RESULT_UNKNOWN_PORT); |
| 383 return; | 384 return; |
| 384 } | 385 } |
| 385 // Post the message through the ExtensionMessageService. | 386 // Post the message through the ExtensionMessageService. |
| 386 DCHECK(service_); | 387 DCHECK(service_); |
| 387 service_->PostMessageFromRenderer(port_id, message); | 388 service_->PostMessageFromRenderer(port_id, message); |
| 388 // Confirm to the external client that we sent its message. | 389 // Confirm to the external client that we sent its message. |
| 389 response->SetInteger(kResultKey, RESULT_OK); | 390 response->SetInteger(kResultKey, RESULT_OK); |
| 390 } | 391 } |
| OLD | NEW |