nacl_host_message_filter.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. #ifndef COMPONENTS_NACL_BROWSER_NACL_HOST_MESSAGE_FILTER_H_
  5. #define COMPONENTS_NACL_BROWSER_NACL_HOST_MESSAGE_FILTER_H_
  6. #include <vector>
  7. #include "base/files/file.h"
  8. #include "base/files/file_path.h"
  9. #include "base/memory/weak_ptr.h"
  10. #include "components/nacl/browser/nacl_browser_delegate.h"
  11. #include "content/public/browser/browser_message_filter.h"
  12. #include "ppapi/shared_impl/ppapi_permissions.h"
  13. class GURL;
  14. namespace nacl {
  15. struct NaClLaunchParams;
  16. struct NaClResourcePrefetchResult;
  17. struct PnaclCacheInfo;
  18. }
  19. namespace nacl {
  20. // This class filters out incoming Chrome-specific IPC messages for the renderer
  21. // process on the IPC thread.
  22. class NaClHostMessageFilter : public content::BrowserMessageFilter {
  23. public:
  24. NaClHostMessageFilter(int render_process_id,
  25. bool is_off_the_record,
  26. const base::FilePath& profile_directory);
  27. NaClHostMessageFilter(const NaClHostMessageFilter&) = delete;
  28. NaClHostMessageFilter& operator=(const NaClHostMessageFilter&) = delete;
  29. // content::BrowserMessageFilter methods:
  30. bool OnMessageReceived(const IPC::Message& message) override;
  31. void OnChannelClosing() override;
  32. void OverrideThreadForMessage(const IPC::Message& message,
  33. content::BrowserThread::ID* thread) override;
  34. int render_process_id() { return render_process_id_; }
  35. bool off_the_record() { return off_the_record_; }
  36. const base::FilePath& profile_directory() const { return profile_directory_; }
  37. private:
  38. friend class content::BrowserThread;
  39. friend class base::DeleteHelper<NaClHostMessageFilter>;
  40. ~NaClHostMessageFilter() override;
  41. void OnLaunchNaCl(const NaClLaunchParams& launch_params,
  42. IPC::Message* reply_msg);
  43. void BatchOpenResourceFiles(
  44. const nacl::NaClLaunchParams& launch_params,
  45. IPC::Message* reply_msg,
  46. ppapi::PpapiPermissions permissions,
  47. NaClBrowserDelegate::MapUrlToLocalFilePathCallback map_url_callback);
  48. void LaunchNaClContinuation(
  49. const nacl::NaClLaunchParams& launch_params,
  50. IPC::Message* reply_msg,
  51. NaClBrowserDelegate::MapUrlToLocalFilePathCallback map_url_callback);
  52. void LaunchNaClContinuationOnUIThread(
  53. const nacl::NaClLaunchParams& launch_params,
  54. IPC::Message* reply_msg,
  55. const std::vector<NaClResourcePrefetchResult>& prefetched_resource_files,
  56. ppapi::PpapiPermissions permissions,
  57. NaClBrowserDelegate::MapUrlToLocalFilePathCallback map_url_callback);
  58. void OnGetReadonlyPnaclFd(const std::string& filename,
  59. bool is_executable,
  60. IPC::Message* reply_msg);
  61. void OnNaClCreateTemporaryFile(IPC::Message* reply_msg);
  62. void OnNaClGetNumProcessors(int* num_processors);
  63. void OnGetNexeFd(int pp_instance, const PnaclCacheInfo& cache_info);
  64. void OnTranslationFinished(int instance, bool success);
  65. void OnMissingArchError(int render_view_id);
  66. void OnOpenNaClExecutable(int render_frame_id,
  67. const GURL& file_url,
  68. IPC::Message* reply_msg);
  69. void SyncReturnTemporaryFile(IPC::Message* reply_msg,
  70. base::File file);
  71. void AsyncReturnTemporaryFile(int pp_instance,
  72. const base::File& file,
  73. bool is_hit);
  74. void OnNaClDebugEnabledForURL(const GURL& nmf_url, bool* should_debug);
  75. int render_process_id_;
  76. // off_the_record_ is copied from the profile partly so that it can be
  77. // read on the IO thread.
  78. bool off_the_record_;
  79. base::FilePath profile_directory_;
  80. base::WeakPtrFactory<NaClHostMessageFilter> weak_ptr_factory_{this};
  81. };
  82. } // namespace nacl
  83. #endif // COMPONENTS_NACL_BROWSER_NACL_HOST_MESSAGE_FILTER_H_