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

Side by Side Diff: extensions/browser/api/messaging/native_message_host.h

Issue 591463003: Remote Assistance on Chrome OS Part III - NativeMessageHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@native_messaging
Patch Set: Created 6 years, 2 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
OLDNEW
(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/single_thread_task_runner.h"
12 #include "ui/gfx/native_widget_types.h"
13
14 namespace extensions {
15
16 // An interface for receiving messages from MessageService (Chrome) using the
17 // Native Messaging API. A NativeMessageHost object hosts a native component,
18 // which can run in the browser-process or in a separate process (See
19 // NativeMessageProcessHost).
20 class NativeMessageHost {
21 public:
22 // Callback interface for receiving messages from the native host.
23 class Client {
24 public:
25 virtual ~Client() {}
26
27 // Called on the UI thread.
28 virtual void PostMessageFromNativeHost(const std::string& message) = 0;
29 virtual void CloseChannel(const std::string& error_message) = 0;
30 };
31
32 // Creates the NativeMessageHost based on the |native_host_name|.
33 static scoped_ptr<NativeMessageHost> Create(
34 gfx::NativeView native_view,
35 const std::string& source_extension_id,
36 const std::string& native_host_name,
37 bool allow_user_level);
38
39 virtual ~NativeMessageHost() {}
40
41 // Called when a message is received from MessageService (Chrome).
42 virtual void OnMessage(const std::string& message) = 0;
43
44 // Sets the client to start receiving messages from the native host.
45 virtual void Start(Client* client) = 0;
46
47 // Returns the task runner that the host runs on. The Client should only
48 // invoke OnMessage() on this task runner.
49 virtual scoped_refptr<base::SingleThreadTaskRunner> task_runner() const = 0;
50 };
51
52 } // namespace extensions
53
54 #endif // EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGE_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698