Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Side by Side Diff: chrome/browser/debugger/extension_ports_remote_service.h

Issue 174226: Extension ports devtools remote service.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // ExtensionsPorts service: wires extension message ports through the
6 // devtools remote protocol, allowing an external client program to
7 // exchange messages with Chrome extensions.
8
9 #ifndef CHROME_BROWSER_DEBUGGER_EXTENSION_PORTS_REMOTE_SERVICE_H_
10 #define CHROME_BROWSER_DEBUGGER_EXTENSION_PORTS_REMOTE_SERVICE_H_
11
12 #include <set>
13 #include <string>
14
15 #include "base/basictypes.h"
16 #include "base/ref_counted.h"
17 #include "chrome/browser/debugger/devtools_remote.h"
18 #include "chrome/browser/extensions/extension_message_service.h"
19 #include "ipc/ipc_message.h"
20
21 class DevToolsProtocolHandler;
22 class DevToolsRemoteMessage;
23 class DictionaryValue;
24 class ListValue;
25 class Value;
26
27 class ExtensionPortsRemoteService : public DevToolsRemoteListener,
28 public IPC::Message::Sender {
29 public:
30 // Specifies a tool name ("ExtensionPorts") handled by this class.
31 static const std::string kToolName;
32
33 // |delegate| (never NULL) is the protocol handler instance which
34 // dispatches messages to this service.
35 // The ownership of |delegate| is NOT transferred to this class.
36 explicit ExtensionPortsRemoteService(DevToolsProtocolHandler* delegate);
37 virtual ~ExtensionPortsRemoteService() {}
38
39 // DevToolsRemoteListener methods:
40
41 // Processes |message| from the external client (where the tool is
42 // "ExtensionPorts").
43 virtual void HandleMessage(const DevToolsRemoteMessage& message);
44
45 // Gets invoked on the external client socket connection loss.
46 // Closes open message ports.
47 virtual void OnConnectionLost();
48
49 // IPC::Message::Sender methods:
50
51 // This is the callback through which the ExtensionMessageService
52 // passes us messages from extensions as well as disconnect events.
53 virtual bool Send(IPC::Message* msg);
54
55 private:
56 // Operation result returned in the "result" field in messages sent
57 // to the external client.
58 typedef enum {
59 RESULT_OK = 0,
60 RESULT_UNKNOWN_COMMAND,
61 RESULT_NO_SERVICE,
62 RESULT_PARAMETER_ERROR,
63 RESULT_UNKNOWN_PORT,
64 RESULT_TAB_NOT_FOUND,
65 RESULT_CONNECT_FAILED, // probably extension ID not found.
66 } Result;
67
68 // Sends a JSON message with the |response| to the external client.
69 // |tool| and |destination| are used as the respective header values.
70 void SendResponse(const Value& response,
71 const std::string& tool,
72 const std::string& destination);
73
74 // Handles a message from the ExtensionMessageService.
75 void OnExtensionMessageInvoke(
76 const std::string& function_name, const ListValue& args);
77 // Handles a message sent from an extension through the
78 // ExtensionMessageService, to be passed to the external client.
79 void OnExtensionMessage(const std::string& message, int port_id);
80 // Handles a disconnect event sent from the ExtensionMessageService.
81 void OnExtensionPortDisconnected(int port_id);
82
83 // Implementation for the commands we can receive from the external client.
84 // Opens a channel to an extension.
85 void ConnectCommand(DictionaryValue* content, DictionaryValue* response);
86 // Disconnects a message port.
87 void DisconnectCommand(int port_id, DictionaryValue* response);
88 // Sends a message to an extension through an established message port.
89 void PostMessageCommand(int port_id, DictionaryValue* content,
90 DictionaryValue* response);
91
92 // The delegate is used to send responses and events back to the
93 // external client, and to resolve tab IDs.
94 DevToolsProtocolHandler* delegate_;
95
96 // Set of message port IDs we successfully opened.
97 typedef std::set<int> PortIdSet;
98 PortIdSet openPortIds_;
99
100 scoped_refptr<ExtensionMessageService> service_;
101
102 DISALLOW_COPY_AND_ASSIGN(ExtensionPortsRemoteService);
103 };
104
105 #endif // CHROME_BROWSER_DEBUGGER_EXTENSION_PORTS_REMOTE_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/debugger/debugger_wrapper.cc ('k') | chrome/browser/debugger/extension_ports_remote_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698