| 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> | 
| 11 | 11 | 
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" | 
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" | 
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" | 
| 15 #include "chrome/browser/extensions/api/messaging/native_message_process_host.h" | 15 #include "chrome/browser/extensions/api/messaging/native_message_process_host.h" | 
| 16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" | 
| 17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" | 
| 18 | 18 | 
|  | 19 class GURL; | 
| 19 class Profile; | 20 class Profile; | 
| 20 | 21 | 
|  | 22 namespace base { | 
|  | 23 class DictionaryValue; | 
|  | 24 } | 
|  | 25 | 
| 21 namespace content { | 26 namespace content { | 
| 22 class RenderProcessHost; | 27 class RenderProcessHost; | 
| 23 class WebContents; | 28 class WebContents; | 
| 24 } | 29 } | 
| 25 | 30 | 
| 26 namespace extensions { | 31 namespace extensions { | 
| 27 class ExtensionHost; | 32 class ExtensionHost; | 
| 28 class LazyBackgroundTaskQueue; | 33 class LazyBackgroundTaskQueue; | 
| 29 | 34 | 
| 30 // This class manages message and event passing between renderer processes. | 35 // This class manages message and event passing between renderer processes. | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 56   // example). | 61   // example). | 
| 57   struct MessageChannel; | 62   struct MessageChannel; | 
| 58 | 63 | 
| 59   // One side of the communication handled by extensions::MessageService. | 64   // One side of the communication handled by extensions::MessageService. | 
| 60   class MessagePort { | 65   class MessagePort { | 
| 61    public: | 66    public: | 
| 62     virtual ~MessagePort() {} | 67     virtual ~MessagePort() {} | 
| 63     // Notify the port that the channel has been opened. | 68     // Notify the port that the channel has been opened. | 
| 64     virtual void DispatchOnConnect(int dest_port_id, | 69     virtual void DispatchOnConnect(int dest_port_id, | 
| 65                                    const std::string& channel_name, | 70                                    const std::string& channel_name, | 
| 66                                    const std::string& tab_json, | 71                                    const base::DictionaryValue& source_tab, | 
| 67                                    const std::string& source_extension_id, | 72                                    const std::string& source_extension_id, | 
| 68                                    const std::string& target_extension_id) {} | 73                                    const std::string& target_extension_id, | 
|  | 74                                    const GURL& source_url) {} | 
| 69 | 75 | 
| 70     // Notify the port that the channel has been closed. If |error_message| is | 76     // Notify the port that the channel has been closed. If |error_message| is | 
| 71     // non-empty, it indicates an error occurred while opening the connection. | 77     // non-empty, it indicates an error occurred while opening the connection. | 
| 72     virtual void DispatchOnDisconnect(int source_port_id, | 78     virtual void DispatchOnDisconnect(int source_port_id, | 
| 73                                       const std::string& error_message) {} | 79                                       const std::string& error_message) {} | 
| 74 | 80 | 
| 75     // Dispatch a message to this end of the communication. | 81     // Dispatch a message to this end of the communication. | 
| 76     virtual void DispatchOnMessage(const std::string& message, | 82     virtual void DispatchOnMessage(const std::string& message, | 
| 77                                    int target_port_id) = 0; | 83                                    int target_port_id) = 0; | 
| 78 | 84 | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 98   explicit MessageService(LazyBackgroundTaskQueue* queue); | 104   explicit MessageService(LazyBackgroundTaskQueue* queue); | 
| 99   virtual ~MessageService(); | 105   virtual ~MessageService(); | 
| 100 | 106 | 
| 101   // Given an extension's ID, opens a channel between the given renderer "port" | 107   // Given an extension's ID, opens a channel between the given renderer "port" | 
| 102   // and every listening context owned by that extension. |channel_name| is | 108   // and every listening context owned by that extension. |channel_name| is | 
| 103   // an optional identifier for use by extension developers. | 109   // an optional identifier for use by extension developers. | 
| 104   void OpenChannelToExtension( | 110   void OpenChannelToExtension( | 
| 105       int source_process_id, int source_routing_id, int receiver_port_id, | 111       int source_process_id, int source_routing_id, int receiver_port_id, | 
| 106       const std::string& source_extension_id, | 112       const std::string& source_extension_id, | 
| 107       const std::string& target_extension_id, | 113       const std::string& target_extension_id, | 
|  | 114       const GURL& source_url, | 
| 108       const std::string& channel_name); | 115       const std::string& channel_name); | 
| 109 | 116 | 
| 110   // Same as above, but opens a channel to the tab with the given ID.  Messages | 117   // Same as above, but opens a channel to the tab with the given ID.  Messages | 
| 111   // are restricted to that tab, so if there are multiple tabs in that process, | 118   // are restricted to that tab, so if there are multiple tabs in that process, | 
| 112   // only the targeted tab will receive messages. | 119   // only the targeted tab will receive messages. | 
| 113   void OpenChannelToTab( | 120   void OpenChannelToTab( | 
| 114       int source_process_id, int source_routing_id, int receiver_port_id, | 121       int source_process_id, int source_routing_id, int receiver_port_id, | 
| 115       int tab_id, const std::string& extension_id, | 122       int tab_id, const std::string& extension_id, | 
| 116       const std::string& channel_name); | 123       const std::string& channel_name); | 
| 117 | 124 | 
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 201   LazyBackgroundTaskQueue* lazy_background_task_queue_; | 208   LazyBackgroundTaskQueue* lazy_background_task_queue_; | 
| 202 | 209 | 
| 203   base::WeakPtrFactory<MessageService> weak_factory_; | 210   base::WeakPtrFactory<MessageService> weak_factory_; | 
| 204 | 211 | 
| 205   DISALLOW_COPY_AND_ASSIGN(MessageService); | 212   DISALLOW_COPY_AND_ASSIGN(MessageService); | 
| 206 }; | 213 }; | 
| 207 | 214 | 
| 208 }  // namespace extensions | 215 }  // namespace extensions | 
| 209 | 216 | 
| 210 #endif  // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 217 #endif  // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 
| OLD | NEW | 
|---|