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 "chrome/browser/extensions/api/messaging/message_service.h" | 5 #include "chrome/browser/extensions/api/messaging/message_service.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // Port1 is always even, port2 is always odd. | 53 // Port1 is always even, port2 is always odd. |
54 #define IS_OPENER_PORT_ID(port_id) (((port_id) & 1) == 0) | 54 #define IS_OPENER_PORT_ID(port_id) (((port_id) & 1) == 0) |
55 | 55 |
56 // Change even to odd and vice versa, to get the other side of a given channel. | 56 // Change even to odd and vice versa, to get the other side of a given channel. |
57 #define GET_OPPOSITE_PORT_ID(source_port_id) ((source_port_id) ^ 1) | 57 #define GET_OPPOSITE_PORT_ID(source_port_id) ((source_port_id) ^ 1) |
58 | 58 |
59 namespace extensions { | 59 namespace extensions { |
60 | 60 |
61 const char kReceivingEndDoesntExistError[] = | 61 const char kReceivingEndDoesntExistError[] = |
62 "Could not establish connection. Receiving end does not exist."; | 62 "Could not establish connection. Receiving end does not exist."; |
| 63 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) |
63 const char kMissingPermissionError[] = | 64 const char kMissingPermissionError[] = |
64 "Access to native messaging requires nativeMessaging permission."; | 65 "Access to native messaging requires nativeMessaging permission."; |
| 66 #endif |
65 | 67 |
66 struct MessageService::MessageChannel { | 68 struct MessageService::MessageChannel { |
67 scoped_ptr<MessagePort> opener; | 69 scoped_ptr<MessagePort> opener; |
68 scoped_ptr<MessagePort> receiver; | 70 scoped_ptr<MessagePort> receiver; |
69 }; | 71 }; |
70 | 72 |
71 struct MessageService::OpenChannelParams { | 73 struct MessageService::OpenChannelParams { |
72 content::RenderProcessHost* source; | 74 content::RenderProcessHost* source; |
73 base::DictionaryValue source_tab; | 75 base::DictionaryValue source_tab; |
74 scoped_ptr<MessagePort> receiver; | 76 scoped_ptr<MessagePort> receiver; |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 } | 720 } |
719 | 721 |
720 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source, | 722 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source, |
721 int port_id, | 723 int port_id, |
722 const std::string& error_message) { | 724 const std::string& error_message) { |
723 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); | 725 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); |
724 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message); | 726 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message); |
725 } | 727 } |
726 | 728 |
727 } // namespace extensions | 729 } // namespace extensions |
OLD | NEW |