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/thread_task_runner_handle.h" |
17 #include "base/values.h" | 18 #include "base/values.h" |
18 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/extensions/api/messaging/native_messaging_test_util.h" | 20 #include "chrome/browser/extensions/api/messaging/native_messaging_test_util.h" |
20 #include "components/policy/core/common/policy_service.h" | 21 #include "components/policy/core/common/policy_service.h" |
21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
22 #include "extensions/common/constants.h" | 23 #include "extensions/common/constants.h" |
23 #include "extensions/common/url_pattern.h" | 24 #include "extensions/common/url_pattern.h" |
24 #include "net/url_request/url_request_context_getter.h" | 25 #include "net/url_request/url_request_context_getter.h" |
25 #include "remoting/host/chromoting_host_context.h" | 26 #include "remoting/host/chromoting_host_context.h" |
26 #include "remoting/host/it2me/it2me_native_messaging_host.h" | 27 #include "remoting/host/it2me/it2me_native_messaging_host.h" |
(...skipping 30 matching lines...) Expand all Loading... |
57 if (request_string.find("stopHostTest") != std::string::npos) { | 58 if (request_string.find("stopHostTest") != std::string::npos) { |
58 client_->CloseChannel(kNativeHostExited); | 59 client_->CloseChannel(kNativeHostExited); |
59 } else if (request_string.find("bigMessageTest") != std::string::npos) { | 60 } else if (request_string.find("bigMessageTest") != std::string::npos) { |
60 client_->CloseChannel(kHostInputOuputError); | 61 client_->CloseChannel(kHostInputOuputError); |
61 } else { | 62 } else { |
62 ProcessEcho(*request); | 63 ProcessEcho(*request); |
63 } | 64 } |
64 }; | 65 }; |
65 | 66 |
66 scoped_refptr<base::SingleThreadTaskRunner> task_runner() const override { | 67 scoped_refptr<base::SingleThreadTaskRunner> task_runner() const override { |
67 return base::MessageLoopProxy::current(); | 68 return base::ThreadTaskRunnerHandle::Get(); |
68 }; | 69 }; |
69 | 70 |
70 private: | 71 private: |
71 void ProcessEcho(const base::DictionaryValue& request) { | 72 void ProcessEcho(const base::DictionaryValue& request) { |
72 scoped_ptr<base::DictionaryValue> response(new base::DictionaryValue()); | 73 scoped_ptr<base::DictionaryValue> response(new base::DictionaryValue()); |
73 response->SetInteger("id", ++message_number_); | 74 response->SetInteger("id", ++message_number_); |
74 response->Set("echo", request.DeepCopy()); | 75 response->Set("echo", request.DeepCopy()); |
75 response->SetString("caller_url", kEchoHostOrigins[0]); | 76 response->SetString("caller_url", kEchoHostOrigins[0]); |
76 std::string response_string; | 77 std::string response_string; |
77 base::JSONWriter::Write(response.get(), &response_string); | 78 base::JSONWriter::Write(response.get(), &response_string); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 } | 165 } |
165 *error = kForbiddenError; | 166 *error = kForbiddenError; |
166 return nullptr; | 167 return nullptr; |
167 } | 168 } |
168 } | 169 } |
169 *error = kNotFoundError; | 170 *error = kNotFoundError; |
170 return nullptr; | 171 return nullptr; |
171 } | 172 } |
172 | 173 |
173 } // namespace extensions | 174 } // namespace extensions |
OLD | NEW |