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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
18 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/extensions/api/messaging/arc_support_host.h" |
21 #include "chrome/browser/extensions/api/messaging/native_messaging_test_util.h" | 22 #include "chrome/browser/extensions/api/messaging/native_messaging_test_util.h" |
22 #include "components/policy/core/common/policy_service.h" | 23 #include "components/policy/core/common/policy_service.h" |
23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
24 #include "extensions/common/constants.h" | 25 #include "extensions/common/constants.h" |
25 #include "extensions/common/url_pattern.h" | 26 #include "extensions/common/url_pattern.h" |
26 #include "net/url_request/url_request_context_getter.h" | 27 #include "net/url_request/url_request_context_getter.h" |
27 #include "remoting/host/chromoting_host_context.h" | 28 #include "remoting/host/chromoting_host_context.h" |
28 #include "remoting/host/it2me/it2me_native_messaging_host.h" | 29 #include "remoting/host/it2me/it2me_native_messaging_host.h" |
29 #include "ui/gfx/native_widget_types.h" | 30 #include "ui/gfx/native_widget_types.h" |
30 #include "url/gurl.h" | 31 #include "url/gurl.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 129 |
129 static const BuiltInHost kBuiltInHost[] = { | 130 static const BuiltInHost kBuiltInHost[] = { |
130 {"com.google.chrome.test.echo", // ScopedTestNativeMessagingHost::kHostName | 131 {"com.google.chrome.test.echo", // ScopedTestNativeMessagingHost::kHostName |
131 kEchoHostOrigins, | 132 kEchoHostOrigins, |
132 arraysize(kEchoHostOrigins), | 133 arraysize(kEchoHostOrigins), |
133 &EchoHost::Create}, | 134 &EchoHost::Create}, |
134 {"com.google.chrome.remote_assistance", | 135 {"com.google.chrome.remote_assistance", |
135 kRemotingIt2MeOrigins, | 136 kRemotingIt2MeOrigins, |
136 arraysize(kRemotingIt2MeOrigins), | 137 arraysize(kRemotingIt2MeOrigins), |
137 &CreateIt2MeHost}, | 138 &CreateIt2MeHost}, |
| 139 {ArcSupportHost::kHostName, |
| 140 ArcSupportHost::kHostOrigin, |
| 141 1, |
| 142 &ArcSupportHost::Create}, |
138 }; | 143 }; |
139 | 144 |
140 bool MatchesSecurityOrigin(const BuiltInHost& host, | 145 bool MatchesSecurityOrigin(const BuiltInHost& host, |
141 const std::string& extension_id) { | 146 const std::string& extension_id) { |
142 GURL origin(std::string(kExtensionScheme) + "://" + extension_id); | 147 GURL origin(std::string(kExtensionScheme) + "://" + extension_id); |
143 for (int i = 0; i < host.allowed_origins_count; i++) { | 148 for (int i = 0; i < host.allowed_origins_count; i++) { |
144 URLPattern allowed_origin(URLPattern::SCHEME_ALL, host.allowed_origins[i]); | 149 URLPattern allowed_origin(URLPattern::SCHEME_ALL, host.allowed_origins[i]); |
145 if (allowed_origin.MatchesSecurityOrigin(origin)) { | 150 if (allowed_origin.MatchesSecurityOrigin(origin)) { |
146 return true; | 151 return true; |
147 } | 152 } |
(...skipping 18 matching lines...) Expand all Loading... |
166 } | 171 } |
167 *error = kForbiddenError; | 172 *error = kForbiddenError; |
168 return nullptr; | 173 return nullptr; |
169 } | 174 } |
170 } | 175 } |
171 *error = kNotFoundError; | 176 *error = kNotFoundError; |
172 return nullptr; | 177 return nullptr; |
173 } | 178 } |
174 | 179 |
175 } // namespace extensions | 180 } // namespace extensions |
OLD | NEW |