| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/chrome_mock_render_thread.h" | 5 #include "chrome/renderer/chrome_mock_render_thread.h" |
| 6 | 6 |
| 7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
| 8 #include "extensions/features/features.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 9 |
| 11 #if BUILDFLAG(ENABLE_EXTENSIONS) | |
| 12 #include "extensions/common/extension_messages.h" | |
| 13 #endif | |
| 14 | |
| 15 ChromeMockRenderThread::ChromeMockRenderThread() { | 10 ChromeMockRenderThread::ChromeMockRenderThread() { |
| 16 } | 11 } |
| 17 | 12 |
| 18 ChromeMockRenderThread::~ChromeMockRenderThread() { | 13 ChromeMockRenderThread::~ChromeMockRenderThread() { |
| 19 } | 14 } |
| 20 | 15 |
| 21 scoped_refptr<base::SingleThreadTaskRunner> | 16 scoped_refptr<base::SingleThreadTaskRunner> |
| 22 ChromeMockRenderThread::GetIOTaskRunner() { | 17 ChromeMockRenderThread::GetIOTaskRunner() { |
| 23 return io_task_runner_; | 18 return io_task_runner_; |
| 24 } | 19 } |
| 25 | 20 |
| 26 void ChromeMockRenderThread::set_io_task_runner( | 21 void ChromeMockRenderThread::set_io_task_runner( |
| 27 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { | 22 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { |
| 28 io_task_runner_ = task_runner; | 23 io_task_runner_ = task_runner; |
| 29 } | 24 } |
| 30 | |
| 31 bool ChromeMockRenderThread::OnMessageReceived(const IPC::Message& msg) { | |
| 32 if (content::MockRenderThread::OnMessageReceived(msg)) | |
| 33 return true; | |
| 34 | |
| 35 // Some messages we do special handling. | |
| 36 #if BUILDFLAG(ENABLE_EXTENSIONS) | |
| 37 bool handled = true; | |
| 38 IPC_BEGIN_MESSAGE_MAP(ChromeMockRenderThread, msg) | |
| 39 IPC_MESSAGE_HANDLER(ExtensionHostMsg_OpenChannelToExtension, | |
| 40 OnOpenChannelToExtension) | |
| 41 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 42 IPC_END_MESSAGE_MAP() | |
| 43 return handled; | |
| 44 #else | |
| 45 return false; | |
| 46 #endif | |
| 47 } | |
| 48 | |
| 49 #if BUILDFLAG(ENABLE_EXTENSIONS) | |
| 50 void ChromeMockRenderThread::OnOpenChannelToExtension( | |
| 51 int routing_id, | |
| 52 const ExtensionMsg_ExternalConnectionInfo& info, | |
| 53 const std::string& channel_name, | |
| 54 bool include_tls_channel_id, | |
| 55 int request_id) { | |
| 56 Send(new ExtensionMsg_AssignPortId(routing_id, 0, request_id)); | |
| 57 } | |
| 58 #endif | |
| OLD | NEW |