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

Side by Side Diff: remoting/host/setup/native_messaging_host.h

Issue 49113003: It2Me native messaging: GYP and source refactoring (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing Windows build break Created 7 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright 2013 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 #ifndef REMOTING_HOST_SETUP_NATIVE_MESSAGING_HOST_H_
6 #define REMOTING_HOST_SETUP_NATIVE_MESSAGING_HOST_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/thread_checker.h"
12 #include "remoting/host/setup/daemon_controller.h"
13 #include "remoting/host/setup/native_messaging_channel.h"
14 #include "remoting/host/setup/oauth_client.h"
15
16 namespace base {
17 class DictionaryValue;
18 class ListValue;
19 } // namespace base
20
21 namespace gaia {
22 class GaiaOAuthClient;
23 } // namespace gaia
24
25 namespace remoting {
26
27 namespace protocol {
28 class PairingRegistry;
29 } // namespace protocol
30
31 // Implementation of the native messaging host process.
32 class NativeMessagingHost : public NativeMessagingChannel::Delegate {
33 public:
34 typedef NativeMessagingChannel::SendResponseCallback SendResponseCallback;
35
36 NativeMessagingHost(
37 scoped_refptr<DaemonController> daemon_controller,
38 scoped_refptr<protocol::PairingRegistry> pairing_registry,
39 scoped_ptr<OAuthClient> oauth_client);
40 virtual ~NativeMessagingHost();
41
42 // NativeMessagingChannel::Delegate interface.
43 virtual void ProcessMessage(scoped_ptr<base::DictionaryValue> message,
44 const SendResponseCallback& done) OVERRIDE;
45
46 private:
47 // These "Process.." methods handle specific request types. The |response|
48 // dictionary is pre-filled by ProcessMessage() with the parts of the
49 // response already known ("id" and "type" fields).
50 bool ProcessHello(
51 const base::DictionaryValue& message,
52 scoped_ptr<base::DictionaryValue> response,
53 const SendResponseCallback& done);
54 bool ProcessClearPairedClients(
55 const base::DictionaryValue& message,
56 scoped_ptr<base::DictionaryValue> response,
57 const SendResponseCallback& done);
58 bool ProcessDeletePairedClient(
59 const base::DictionaryValue& message,
60 scoped_ptr<base::DictionaryValue> response,
61 const SendResponseCallback& done);
62 bool ProcessGetHostName(
63 const base::DictionaryValue& message,
64 scoped_ptr<base::DictionaryValue> response,
65 const SendResponseCallback& done);
66 bool ProcessGetPinHash(
67 const base::DictionaryValue& message,
68 scoped_ptr<base::DictionaryValue> response,
69 const SendResponseCallback& done);
70 bool ProcessGenerateKeyPair(
71 const base::DictionaryValue& message,
72 scoped_ptr<base::DictionaryValue> response,
73 const SendResponseCallback& done);
74 bool ProcessUpdateDaemonConfig(
75 const base::DictionaryValue& message,
76 scoped_ptr<base::DictionaryValue> response,
77 const SendResponseCallback& done);
78 bool ProcessGetDaemonConfig(
79 const base::DictionaryValue& message,
80 scoped_ptr<base::DictionaryValue> response,
81 const SendResponseCallback& done);
82 bool ProcessGetPairedClients(
83 const base::DictionaryValue& message,
84 scoped_ptr<base::DictionaryValue> response,
85 const SendResponseCallback& done);
86 bool ProcessGetUsageStatsConsent(
87 const base::DictionaryValue& message,
88 scoped_ptr<base::DictionaryValue> response,
89 const SendResponseCallback& done);
90 bool ProcessStartDaemon(
91 const base::DictionaryValue& message,
92 scoped_ptr<base::DictionaryValue> response,
93 const SendResponseCallback& done);
94 bool ProcessStopDaemon(
95 const base::DictionaryValue& message,
96 scoped_ptr<base::DictionaryValue> response,
97 const SendResponseCallback& done);
98 bool ProcessGetDaemonState(
99 const base::DictionaryValue& message,
100 scoped_ptr<base::DictionaryValue> response,
101 const SendResponseCallback& done);
102 bool ProcessGetHostClientId(
103 const base::DictionaryValue& message,
104 scoped_ptr<base::DictionaryValue> response,
105 const SendResponseCallback& done);
106 bool ProcessGetCredentialsFromAuthCode(
107 const base::DictionaryValue& message,
108 scoped_ptr<base::DictionaryValue> response,
109 const SendResponseCallback& done);
110
111 // These Send... methods get called on the DaemonController's internal thread,
112 // or on the calling thread if called by the PairingRegistry.
113 // These methods fill in the |response| dictionary from the other parameters,
114 // and pass it to SendResponse().
115 void SendConfigResponse(const SendResponseCallback& done,
116 scoped_ptr<base::DictionaryValue> response,
117 scoped_ptr<base::DictionaryValue> config);
118 void SendPairedClientsResponse(const SendResponseCallback& done,
119 scoped_ptr<base::DictionaryValue> response,
120 scoped_ptr<base::ListValue> pairings);
121 void SendUsageStatsConsentResponse(
122 const SendResponseCallback& done,
123 scoped_ptr<base::DictionaryValue> response,
124 const DaemonController::UsageStatsConsent& consent);
125 void SendAsyncResult(const SendResponseCallback& done,
126 scoped_ptr<base::DictionaryValue> response,
127 DaemonController::AsyncResult result);
128 void SendBooleanResult(const SendResponseCallback& done,
129 scoped_ptr<base::DictionaryValue> response,
130 bool result);
131 void SendCredentialsResponse(const SendResponseCallback& done,
132 scoped_ptr<base::DictionaryValue> response,
133 const std::string& user_email,
134 const std::string& refresh_token);
135
136 scoped_refptr<DaemonController> daemon_controller_;
137
138 // Used to load and update the paired clients for this host.
139 scoped_refptr<protocol::PairingRegistry> pairing_registry_;
140
141 // Used to exchange the service account authorization code for credentials.
142 scoped_ptr<OAuthClient> oauth_client_;
143
144 base::ThreadChecker thread_checker_;
145
146 base::WeakPtr<NativeMessagingHost> weak_ptr_;
147 base::WeakPtrFactory<NativeMessagingHost> weak_factory_;
148
149 DISALLOW_COPY_AND_ASSIGN(NativeMessagingHost);
150 };
151
152 // Creates a NativeMessagingHost instance, attaches it to stdin/stdout and runs
153 // the message loop until NativeMessagingHost signals shutdown.
154 int NativeMessagingHostMain();
155
156 } // namespace remoting
157
158 #endif // REMOTING_HOST_SETUP_NATIVE_MESSAGING_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698