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

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: Add NativeMessagePort::Core 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/memory/weak_ptr.h"
12 #include "base/single_thread_task_runner.h"
13 #include "ui/gfx/native_widget_types.h"
14
15 namespace extensions {
16
17 // An interface for receiving messages from MessageService (Chrome) using the
18 // Native Messaging API. A NativeMessageHost object hosts a native component,
19 // which can run in the browser-process or in a separate process (See
20 // NativeMessageProcessHost).
21 class NativeMessageHost {
22 public:
23 // Callback interface for receiving messages from the native component.
Sergey Ulanov 2014/10/01 23:23:59 s/the native component/the host/
kelvinp 2014/10/02 03:12:17 Done.
24 class Client {
25 public:
26 virtual ~Client() {}
27
28 // Called on the UI thread.
29 virtual void PostMessageFromNativeHost(const std::string& message) = 0;
30 virtual void CloseChannel(const std::string& error_message) = 0;
31 };
32
33 // Creates the NativeMessageHost based on the |native_host_name|.
34 static scoped_ptr<NativeMessageHost> Create(
35 gfx::NativeView native_view,
36 const std::string& source_extension_id,
37 const std::string& native_host_name,
38 bool allow_user_level);
39
40 virtual ~NativeMessageHost() {}
41
42 // Called when a message is received from MessageService (Chrome).
43 virtual void OnMessage(const std::string& message) = 0;
44
45 // Sets the client to receive messages from the native component.
46 virtual void set_client(Client* client) = 0;
47
48 // Returns the task runner that the host runs on. The Client should only
49 // invoke OnMessage() on this task runner.
50 virtual scoped_refptr<base::SingleThreadTaskRunner> task_runner() const = 0;
51 };
52
53 } // namespace extensions
54
55 #endif // EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGE_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698