make use of media_use_ffmpeg in BUILD.gn
[chromium-blink-merge.git] / extensions / browser / api / messaging / native_message_host.h
blobda241e06f83f9f2c8300dd484aee936394616a54
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.
5 #ifndef EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGE_HOST_H_
6 #define EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGE_HOST_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/single_thread_task_runner.h"
12 #include "ui/gfx/native_widget_types.h"
14 namespace extensions {
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 static const char kFailedToStartError[];
23 static const char kInvalidNameError[];
24 static const char kNativeHostExited[];
25 static const char kNotFoundError[];
26 static const char kForbiddenError[];
27 static const char kHostInputOuputError[];
29 // Callback interface for receiving messages from the native host.
30 class Client {
31 public:
32 virtual ~Client() {}
34 // Called on the UI thread.
35 virtual void PostMessageFromNativeHost(const std::string& message) = 0;
36 virtual void CloseChannel(const std::string& error_message) = 0;
39 // Creates the NativeMessageHost based on the |native_host_name|.
40 static scoped_ptr<NativeMessageHost> Create(
41 gfx::NativeView native_view,
42 const std::string& source_extension_id,
43 const std::string& native_host_name,
44 bool allow_user_level,
45 std::string* error);
47 virtual ~NativeMessageHost() {}
49 // Called when a message is received from MessageService (Chrome).
50 virtual void OnMessage(const std::string& message) = 0;
52 // Sets the client to start receiving messages from the native host.
53 virtual void Start(Client* client) = 0;
55 // Returns the task runner that the host runs on. The Client should only
56 // invoke OnMessage() on this task runner.
57 virtual scoped_refptr<base::SingleThreadTaskRunner> task_runner() const = 0;
60 } // namespace extensions
62 #endif // EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGE_HOST_H_