Home | History | Annotate | Download | only in renderer_host
      1 // Copyright (c) 2011 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_RENDERER_HOST_CHROME_RENDER_MESSAGE_FILTER_H_
      6 #define CHROME_BROWSER_RENDERER_HOST_CHROME_RENDER_MESSAGE_FILTER_H_
      7 #pragma once
      8 
      9 #include "chrome/common/content_settings.h"
     10 #include "chrome/browser/prefs/pref_member.h"
     11 #include "content/browser/browser_message_filter.h"
     12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h"
     13 
     14 class FilePath;
     15 class Profile;
     16 
     17 namespace net {
     18 class URLRequestContextGetter;
     19 }
     20 
     21 // This class filters out incoming Chrome-specific IPC messages for the renderer
     22 // process on the IPC thread.
     23 class ChromeRenderMessageFilter : public BrowserMessageFilter {
     24  public:
     25   ChromeRenderMessageFilter(int render_process_id,
     26                             Profile* profile,
     27                             net::URLRequestContextGetter* request_context);
     28 
     29   // BrowserMessageFilter methods:
     30   virtual bool OnMessageReceived(const IPC::Message& message,
     31                                  bool* message_was_ok);
     32   virtual void OnDestruct() const;
     33   virtual void OverrideThreadForMessage(const IPC::Message& message,
     34                                         BrowserThread::ID* thread);
     35 
     36  private:
     37   friend class BrowserThread;
     38   friend class DeleteTask<ChromeRenderMessageFilter>;
     39 
     40   virtual ~ChromeRenderMessageFilter();
     41 
     42   void OnLaunchNaCl(const std::wstring& url,
     43                     int channel_descriptor,
     44                     IPC::Message* reply_msg);
     45   void OnDnsPrefetch(const std::vector<std::string>& hostnames);
     46   void OnRendererHistograms(int sequence_number,
     47                             const std::vector<std::string>& histogram_info);
     48   void OnResourceTypeStats(const WebKit::WebCache::ResourceTypeStats& stats);
     49   void OnV8HeapStats(int v8_memory_allocated, int v8_memory_used);
     50   void OnOpenChannelToExtension(int routing_id,
     51                                 const std::string& source_extension_id,
     52                                 const std::string& target_extension_id,
     53                                 const std::string& channel_name, int* port_id);
     54   void OpenChannelToExtensionOnUIThread(int source_process_id,
     55                                         int source_routing_id,
     56                                         int receiver_port_id,
     57                                         const std::string& source_extension_id,
     58                                         const std::string& target_extension_id,
     59                                         const std::string& channel_name);
     60   void OnOpenChannelToTab(int routing_id, int tab_id,
     61                           const std::string& extension_id,
     62                           const std::string& channel_name, int* port_id);
     63   void OpenChannelToTabOnUIThread(int source_process_id, int source_routing_id,
     64                                   int receiver_port_id,
     65                                   int tab_id, const std::string& extension_id,
     66                                   const std::string& channel_name);
     67 
     68   void OnGetExtensionMessageBundle(const std::string& extension_id,
     69                                    IPC::Message* reply_msg);
     70   void OnGetExtensionMessageBundleOnFileThread(
     71       const FilePath& extension_path,
     72       const std::string& extension_id,
     73       const std::string& default_locale,
     74       IPC::Message* reply_msg);
     75 #if defined(USE_TCMALLOC)
     76   void OnRendererTcmalloc(base::ProcessId pid, const std::string& output);
     77 #endif
     78   void OnGetOutdatedPluginsPolicy(ContentSetting* policy);
     79 
     80   int render_process_id_;
     81 
     82   // The Profile associated with our renderer process.  This should only be
     83   // accessed on the UI thread!
     84   Profile* profile_;
     85   scoped_refptr<net::URLRequestContextGetter> request_context_;
     86 
     87   BooleanPrefMember allow_outdated_plugins_;
     88 
     89   DISALLOW_COPY_AND_ASSIGN(ChromeRenderMessageFilter);
     90 };
     91 
     92 #endif  // CHROME_BROWSER_RENDERER_HOST_CHROME_RENDER_MESSAGE_FILTER_H_
     93