OLD | NEW |
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 #include "extensions/browser/api/messaging/native_message_host.h" | 5 #include "extensions/browser/api/messaging/native_message_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/message_loop/message_loop_proxy.h" | 16 #include "base/message_loop/message_loop_proxy.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/extensions/api/messaging/native_messaging_test_util.h" | 19 #include "chrome/browser/extensions/api/messaging/native_messaging_test_util.h" |
20 #include "components/policy/core/common/policy_service.h" | 20 #include "components/policy/core/common/policy_service.h" |
| 21 #include "content/public/browser/browser_thread.h" |
21 #include "extensions/common/constants.h" | 22 #include "extensions/common/constants.h" |
22 #include "extensions/common/url_pattern.h" | 23 #include "extensions/common/url_pattern.h" |
23 #include "net/url_request/url_request_context_getter.h" | 24 #include "net/url_request/url_request_context_getter.h" |
24 #include "remoting/host/chromoting_host_context.h" | 25 #include "remoting/host/chromoting_host_context.h" |
25 #include "remoting/host/it2me/it2me_native_messaging_host.h" | 26 #include "remoting/host/it2me/it2me_native_messaging_host.h" |
26 #include "ui/gfx/native_widget_types.h" | 27 #include "ui/gfx/native_widget_types.h" |
27 #include "url/gurl.h" | 28 #include "url/gurl.h" |
28 | 29 |
29 namespace extensions { | 30 namespace extensions { |
30 | 31 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 int allowed_origins_count; | 90 int allowed_origins_count; |
90 scoped_ptr<NativeMessageHost>(*create_function)(); | 91 scoped_ptr<NativeMessageHost>(*create_function)(); |
91 }; | 92 }; |
92 | 93 |
93 scoped_ptr<NativeMessageHost> CreateIt2MeHost() { | 94 scoped_ptr<NativeMessageHost> CreateIt2MeHost() { |
94 scoped_ptr<remoting::It2MeHostFactory> host_factory( | 95 scoped_ptr<remoting::It2MeHostFactory> host_factory( |
95 new remoting::It2MeHostFactory()); | 96 new remoting::It2MeHostFactory()); |
96 host_factory->set_policy_service(g_browser_process->policy_service()); | 97 host_factory->set_policy_service(g_browser_process->policy_service()); |
97 scoped_ptr<remoting::ChromotingHostContext> context = | 98 scoped_ptr<remoting::ChromotingHostContext> context = |
98 remoting::ChromotingHostContext::CreateForChromeOS( | 99 remoting::ChromotingHostContext::CreateForChromeOS( |
99 make_scoped_refptr(g_browser_process->system_request_context())); | 100 make_scoped_refptr(g_browser_process->system_request_context()), |
| 101 content::BrowserThread::GetMessageLoopProxyForThread( |
| 102 content::BrowserThread::IO), |
| 103 content::BrowserThread::GetMessageLoopProxyForThread( |
| 104 content::BrowserThread::UI), |
| 105 content::BrowserThread::GetMessageLoopProxyForThread( |
| 106 content::BrowserThread::FILE)); |
100 scoped_ptr<NativeMessageHost> host(new remoting::It2MeNativeMessagingHost( | 107 scoped_ptr<NativeMessageHost> host(new remoting::It2MeNativeMessagingHost( |
101 context.Pass(), host_factory.Pass())); | 108 context.Pass(), host_factory.Pass())); |
102 return host.Pass(); | 109 return host.Pass(); |
103 } | 110 } |
104 | 111 |
105 // If you modify the list of allowed_origins, don't forget to update | 112 // If you modify the list of allowed_origins, don't forget to update |
106 // remoting/host/it2me/com.google.chrome.remote_assistance.json.jinja2 | 113 // remoting/host/it2me/com.google.chrome.remote_assistance.json.jinja2 |
107 // to keep the two lists in sync. | 114 // to keep the two lists in sync. |
108 // TODO(kelvinp): Load the native messaging manifest as a resource file into | 115 // TODO(kelvinp): Load the native messaging manifest as a resource file into |
109 // chrome and fetch the list of allowed_origins from the manifest (see | 116 // chrome and fetch the list of allowed_origins from the manifest (see |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 164 } |
158 *error = kForbiddenError; | 165 *error = kForbiddenError; |
159 return nullptr; | 166 return nullptr; |
160 } | 167 } |
161 } | 168 } |
162 *error = kNotFoundError; | 169 *error = kNotFoundError; |
163 return nullptr; | 170 return nullptr; |
164 } | 171 } |
165 | 172 |
166 } // namespace extensions | 173 } // namespace extensions |
OLD | NEW |