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 #ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 struct MessageChannel; | 68 struct MessageChannel; |
69 | 69 |
70 // One side of the communication handled by extensions::MessageService. | 70 // One side of the communication handled by extensions::MessageService. |
71 class MessagePort { | 71 class MessagePort { |
72 public: | 72 public: |
73 virtual ~MessagePort() {} | 73 virtual ~MessagePort() {} |
74 // Notify the port that the channel has been opened. | 74 // Notify the port that the channel has been opened. |
75 virtual void DispatchOnConnect(int dest_port_id, | 75 virtual void DispatchOnConnect(int dest_port_id, |
76 const std::string& channel_name, | 76 const std::string& channel_name, |
77 const base::DictionaryValue& source_tab, | 77 const base::DictionaryValue& source_tab, |
| 78 int source_frame_id, |
78 const std::string& source_extension_id, | 79 const std::string& source_extension_id, |
79 const std::string& target_extension_id, | 80 const std::string& target_extension_id, |
80 const GURL& source_url, | 81 const GURL& source_url, |
81 const std::string& tls_channel_id) {} | 82 const std::string& tls_channel_id) {} |
82 | 83 |
83 // Notify the port that the channel has been closed. If |error_message| is | 84 // Notify the port that the channel has been closed. If |error_message| is |
84 // non-empty, it indicates an error occurred while opening the connection. | 85 // non-empty, it indicates an error occurred while opening the connection. |
85 virtual void DispatchOnDisconnect(int source_port_id, | 86 virtual void DispatchOnDisconnect(int source_port_id, |
86 const std::string& error_message) {} | 87 const std::string& error_message) {} |
87 | 88 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 static BrowserContextKeyedAPIFactory<MessageService>* GetFactoryInstance(); | 126 static BrowserContextKeyedAPIFactory<MessageService>* GetFactoryInstance(); |
126 | 127 |
127 // Convenience method to get the MessageService for a browser context. | 128 // Convenience method to get the MessageService for a browser context. |
128 static MessageService* Get(content::BrowserContext* context); | 129 static MessageService* Get(content::BrowserContext* context); |
129 | 130 |
130 // Given an extension's ID, opens a channel between the given renderer "port" | 131 // Given an extension's ID, opens a channel between the given renderer "port" |
131 // and every listening context owned by that extension. |channel_name| is | 132 // and every listening context owned by that extension. |channel_name| is |
132 // an optional identifier for use by extension developers. | 133 // an optional identifier for use by extension developers. |
133 void OpenChannelToExtension( | 134 void OpenChannelToExtension( |
134 int source_process_id, int source_routing_id, int receiver_port_id, | 135 int source_process_id, int source_routing_id, int receiver_port_id, |
| 136 int source_frame_id, |
135 const std::string& source_extension_id, | 137 const std::string& source_extension_id, |
136 const std::string& target_extension_id, | 138 const std::string& target_extension_id, |
137 const GURL& source_url, | 139 const GURL& source_url, |
138 const std::string& channel_name, | 140 const std::string& channel_name, |
139 bool include_tls_channel_id); | 141 bool include_tls_channel_id); |
140 | 142 |
141 // Same as above, but opens a channel to the tab with the given ID. Messages | 143 // Same as above, but opens a channel to the tab with the given ID. Messages |
142 // are restricted to that tab, so if there are multiple tabs in that process, | 144 // are restricted to that tab, so if there are multiple tabs in that process, |
143 // only the targeted tab will receive messages. | 145 // only the targeted tab will receive messages. |
144 void OpenChannelToTab( | 146 void OpenChannelToTab( |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 LazyBackgroundTaskQueue* lazy_background_task_queue_; | 273 LazyBackgroundTaskQueue* lazy_background_task_queue_; |
272 | 274 |
273 base::WeakPtrFactory<MessageService> weak_factory_; | 275 base::WeakPtrFactory<MessageService> weak_factory_; |
274 | 276 |
275 DISALLOW_COPY_AND_ASSIGN(MessageService); | 277 DISALLOW_COPY_AND_ASSIGN(MessageService); |
276 }; | 278 }; |
277 | 279 |
278 } // namespace extensions | 280 } // namespace extensions |
279 | 281 |
280 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 282 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ |
OLD | NEW |