Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_NACL_HOST_NACL_HOST_MESSAGE_FILTER_H_ |
| 6 | #define CHROME_BROWSER_NACL_HOST_NACL_HOST_MESSAGE_FILTER_H_ |
| 7 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 8 | #include "base/files/file_path.h" |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 9 | #include "base/memory/weak_ptr.h" |
| 10 | #include "content/public/browser/browser_message_filter.h" |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 11 | #include "ipc/ipc_platform_file.h" |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 12 | |
| 13 | class ExtensionInfoMap; |
| 14 | class GURL; |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 15 | |
| 16 | namespace nacl { |
| 17 | struct NaClLaunchParams; |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 18 | struct PnaclCacheInfo; |
Ben Murdoch | 2385ea3 | 2013-08-06 11:01:04 +0100 | [diff] [blame] | 19 | struct PnaclInstallProgress; |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | namespace net { |
| 23 | class HostResolver; |
| 24 | class URLRequestContextGetter; |
| 25 | } |
| 26 | |
| 27 | // This class filters out incoming Chrome-specific IPC messages for the renderer |
| 28 | // process on the IPC thread. |
| 29 | class NaClHostMessageFilter : public content::BrowserMessageFilter { |
| 30 | public: |
| 31 | NaClHostMessageFilter(int render_process_id, |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 32 | bool is_off_the_record, |
| 33 | const base::FilePath& profile_directory, |
| 34 | ExtensionInfoMap* extension_info_map, |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 35 | net::URLRequestContextGetter* request_context); |
| 36 | |
| 37 | // content::BrowserMessageFilter methods: |
| 38 | virtual bool OnMessageReceived(const IPC::Message& message, |
| 39 | bool* message_was_ok) OVERRIDE; |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 40 | virtual void OnChannelClosing() OVERRIDE; |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 41 | |
| 42 | int render_process_id() { return render_process_id_; } |
| 43 | bool off_the_record() { return off_the_record_; } |
| 44 | net::HostResolver* GetHostResolver(); |
| 45 | |
| 46 | private: |
| 47 | friend class content::BrowserThread; |
| 48 | friend class base::DeleteHelper<NaClHostMessageFilter>; |
| 49 | |
| 50 | virtual ~NaClHostMessageFilter(); |
| 51 | |
| 52 | #if !defined(DISABLE_NACL) |
| 53 | void OnLaunchNaCl(const nacl::NaClLaunchParams& launch_params, |
| 54 | IPC::Message* reply_msg); |
Ben Murdoch | 2385ea3 | 2013-08-06 11:01:04 +0100 | [diff] [blame] | 55 | void OnEnsurePnaclInstalled(int instance); |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 56 | void OnGetReadonlyPnaclFd(const std::string& filename, |
| 57 | IPC::Message* reply_msg); |
| 58 | void OnNaClCreateTemporaryFile(IPC::Message* reply_msg); |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 59 | void OnGetNexeFd(int render_view_id, |
| 60 | int pp_instance, |
| 61 | const nacl::PnaclCacheInfo& cache_info); |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 62 | void OnTranslationFinished(int instance, bool success); |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 63 | void OnNaClErrorStatus(int render_view_id, int error_id); |
| 64 | void OnOpenNaClExecutable(int render_view_id, |
| 65 | const GURL& file_url, |
| 66 | IPC::Message* reply_msg); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 67 | |
Ben Murdoch | 2385ea3 | 2013-08-06 11:01:04 +0100 | [diff] [blame] | 68 | void ReplyEnsurePnaclInstalled(int instance, bool success); |
| 69 | void SendProgressEnsurePnaclInstalled( |
| 70 | int instance, |
| 71 | const nacl::PnaclInstallProgress& progress); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 72 | void SyncReturnTemporaryFile(IPC::Message* reply_msg, |
| 73 | IPC::PlatformFileForTransit fd); |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 74 | void AsyncReturnTemporaryFile(int pp_instance, |
| 75 | IPC::PlatformFileForTransit fd, |
| 76 | bool is_hit); |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 77 | #endif |
| 78 | int render_process_id_; |
| 79 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 80 | // off_the_record_ is copied from the profile partly so that it can be |
| 81 | // read on the IO thread. |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 82 | bool off_the_record_; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 83 | base::FilePath profile_directory_; |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 84 | scoped_refptr<net::URLRequestContextGetter> request_context_; |
| 85 | scoped_refptr<ExtensionInfoMap> extension_info_map_; |
| 86 | |
| 87 | base::WeakPtrFactory<NaClHostMessageFilter> weak_ptr_factory_; |
| 88 | |
| 89 | DISALLOW_COPY_AND_ASSIGN(NaClHostMessageFilter); |
| 90 | }; |
| 91 | |
| 92 | #endif // CHROME_BROWSER_NACL_HOST_NACL_HOST_MESSAGE_FILTER_H_ |