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