Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / renderer_host / chrome_extension_message_filter.h
index 57cd927..781afea 100644 (file)
@@ -9,6 +9,8 @@
 
 #include "base/sequenced_task_runner_helpers.h"
 #include "content/public/browser/browser_message_filter.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
 
 class GURL;
 class Profile;
@@ -22,11 +24,13 @@ class FilePath;
 
 namespace extensions {
 class InfoMap;
+struct Message;
 }
 
 // This class filters out incoming Chrome-specific IPC messages from the
 // extension process on the IPC thread.
-class ChromeExtensionMessageFilter : public content::BrowserMessageFilter {
+class ChromeExtensionMessageFilter : public content::BrowserMessageFilter,
+                                     public content::NotificationObserver {
  public:
   ChromeExtensionMessageFilter(int render_process_id, Profile* profile);
 
@@ -35,6 +39,7 @@ class ChromeExtensionMessageFilter : public content::BrowserMessageFilter {
   virtual void OverrideThreadForMessage(
       const IPC::Message& message,
       content::BrowserThread::ID* thread) OVERRIDE;
+  virtual void OnDestruct() const OVERRIDE;
 
  private:
   friend class content::BrowserThread;
@@ -76,6 +81,7 @@ class ChromeExtensionMessageFilter : public content::BrowserMessageFilter {
                                   int receiver_port_id,
                                   int tab_id, const std::string& extension_id,
                                   const std::string& channel_name);
+  void OnPostMessage(int port_id, const extensions::Message& message);
   void OnGetExtMessageBundle(const std::string& extension_id,
                              IPC::Message* reply_msg);
   void OnGetExtMessageBundleOnBlockingPool(
@@ -97,14 +103,23 @@ class ChromeExtensionMessageFilter : public content::BrowserMessageFilter {
       const std::string& extension_id,
       const ExtensionHostMsg_APIActionOrEvent_Params& params);
 
+  // content::NotificationObserver implementation.
+  virtual void Observe(int type,
+                       const content::NotificationSource& source,
+                       const content::NotificationDetails& details) OVERRIDE;
+
   const int render_process_id_;
 
   // The Profile associated with our renderer process.  This should only be
-  // accessed on the UI thread!
+  // accessed on the UI thread! Furthermore since this class is refcounted it
+  // may outlive |profile_|, so make sure to NULL check if in doubt; async
+  // calls and the like.
   Profile* profile_;
 
   scoped_refptr<extensions::InfoMap> extension_info_map_;
 
+  content::NotificationRegistrar notification_registrar_;
+
   DISALLOW_COPY_AND_ASSIGN(ChromeExtensionMessageFilter);
 };