OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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 EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGE_HOST_H_ | |
6 #define EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGE_HOST_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/memory/weak_ptr.h" | |
12 #include "ui/gfx/native_widget_types.h" | |
13 | |
14 class PrefService; | |
15 | |
16 namespace extensions { | |
17 | |
18 // An interface for receiving messages from MessageService (Chrome) using the | |
19 // Native Messaging API. A NativeMessageHost object hosts a native component, | |
20 // which can run in the browser-process or in a separate process (SEe | |
Sergey Ulanov
2014/09/25 01:45:22
typo: SEe
kelvinp
2014/09/26 18:12:27
Done.
| |
21 // NativeMessageProcessHost). | |
22 class NativeMessageHost { | |
23 public: | |
24 // Callback interface for receiving messages from the native component. It is | |
25 // implemented by MessageService. | |
26 class Client { | |
27 public: | |
28 virtual ~Client() {} | |
29 | |
30 // Called on the UI thread. | |
31 virtual void PostMessageFromNativeHost(int port_id, | |
32 const std::string& message) = 0; | |
33 virtual void CloseChannel(int port_id, | |
34 const std::string& error_message) = 0; | |
35 }; | |
36 | |
37 // Creates the NativeMessageHost based on the |native_host_name|. | |
38 static scoped_ptr<NativeMessageHost> Create( | |
39 gfx::NativeView native_view, | |
40 base::WeakPtr<Client> client, | |
41 const std::string& source_extension_id, | |
42 const std::string& native_host_name, | |
43 int destination_port, | |
Sergey Ulanov
2014/09/25 01:45:22
It looks wrong that the host implementation have t
kelvinp
2014/09/26 18:12:27
Done.
| |
44 bool allow_user_level); | |
45 | |
46 // Sends a message to the native component with the specified payload. | |
47 virtual void Send(const std::string& json) = 0; | |
48 | |
49 virtual ~NativeMessageHost() {} | |
Sergey Ulanov
2014/09/25 01:45:22
destructor should be declared between static metho
kelvinp
2014/09/26 18:12:27
Done.
| |
50 }; | |
51 | |
52 } // namespace extensions | |
53 | |
54 #endif // EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGE_HOST_H_ | |
OLD | NEW |