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

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

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGE_HOST_H_ 5 #ifndef EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGE_HOST_H_
6 #define EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGE_HOST_H_ 6 #define EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGE_HOST_H_
7 7
8 #include <memory>
8 #include <string> 9 #include <string>
9 10
10 #include "base/memory/scoped_ptr.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "ui/gfx/native_widget_types.h" 12 #include "ui/gfx/native_widget_types.h"
13 13
14 namespace extensions { 14 namespace extensions {
15 15
16 // An interface for receiving messages from MessageService (Chrome) using the 16 // An interface for receiving messages from MessageService (Chrome) using the
17 // Native Messaging API. A NativeMessageHost object hosts a native component, 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 18 // which can run in the browser-process or in a separate process (See
19 // NativeMessageProcessHost). 19 // NativeMessageProcessHost).
20 class NativeMessageHost { 20 class NativeMessageHost {
21 public: 21 public:
22 static const char kFailedToStartError[]; 22 static const char kFailedToStartError[];
23 static const char kInvalidNameError[]; 23 static const char kInvalidNameError[];
24 static const char kNativeHostExited[]; 24 static const char kNativeHostExited[];
25 static const char kNotFoundError[]; 25 static const char kNotFoundError[];
26 static const char kForbiddenError[]; 26 static const char kForbiddenError[];
27 static const char kHostInputOuputError[]; 27 static const char kHostInputOuputError[];
28 28
29 // Callback interface for receiving messages from the native host. 29 // Callback interface for receiving messages from the native host.
30 class Client { 30 class Client {
31 public: 31 public:
32 virtual ~Client() {} 32 virtual ~Client() {}
33 33
34 // Called on the UI thread. 34 // Called on the UI thread.
35 virtual void PostMessageFromNativeHost(const std::string& message) = 0; 35 virtual void PostMessageFromNativeHost(const std::string& message) = 0;
36 virtual void CloseChannel(const std::string& error_message) = 0; 36 virtual void CloseChannel(const std::string& error_message) = 0;
37 }; 37 };
38 38
39 // Creates the NativeMessageHost based on the |native_host_name|. 39 // Creates the NativeMessageHost based on the |native_host_name|.
40 static scoped_ptr<NativeMessageHost> Create( 40 static std::unique_ptr<NativeMessageHost> Create(
41 gfx::NativeView native_view, 41 gfx::NativeView native_view,
42 const std::string& source_extension_id, 42 const std::string& source_extension_id,
43 const std::string& native_host_name, 43 const std::string& native_host_name,
44 bool allow_user_level, 44 bool allow_user_level,
45 std::string* error); 45 std::string* error);
46 46
47 virtual ~NativeMessageHost() {} 47 virtual ~NativeMessageHost() {}
48 48
49 // Called when a message is received from MessageService (Chrome). 49 // Called when a message is received from MessageService (Chrome).
50 virtual void OnMessage(const std::string& message) = 0; 50 virtual void OnMessage(const std::string& message) = 0;
51 51
52 // Sets the client to start receiving messages from the native host. 52 // Sets the client to start receiving messages from the native host.
53 virtual void Start(Client* client) = 0; 53 virtual void Start(Client* client) = 0;
54 54
55 // Returns the task runner that the host runs on. The Client should only 55 // Returns the task runner that the host runs on. The Client should only
56 // invoke OnMessage() on this task runner. 56 // invoke OnMessage() on this task runner.
57 virtual scoped_refptr<base::SingleThreadTaskRunner> task_runner() const = 0; 57 virtual scoped_refptr<base::SingleThreadTaskRunner> task_runner() const = 0;
58 }; 58 };
59 59
60 } // namespace extensions 60 } // namespace extensions
61 61
62 #endif // EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGE_HOST_H_ 62 #endif // EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGE_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698