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_EXTENSIONS_EXTENSION_MESSAGE_HANDLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_HANDLER_H_ 7 #pragma once 8 9 #include "content/browser/renderer_host/render_view_host_observer.h" 10 11 class Profile; 12 struct ExtensionHostMsg_DomMessage_Params; 13 14 // Filters and dispatches extension-related IPC messages that arrive from 15 // renderer/extension processes. This object is created for renderers and also 16 // ExtensionHost/BackgroundContents. Contrast this with ExtensionTabHelper, 17 // which is only created for TabContents. 18 class ExtensionMessageHandler : public RenderViewHostObserver { 19 public: 20 // |sender| is guaranteed to outlive this object. 21 explicit ExtensionMessageHandler(RenderViewHost* render_view_host); 22 virtual ~ExtensionMessageHandler(); 23 24 // RenderViewHostObserver overrides. 25 virtual bool OnMessageReceived(const IPC::Message& message); 26 27 private: 28 // Message handlers. 29 void OnPostMessage(int port_id, const std::string& message); 30 void OnRequest(const ExtensionHostMsg_DomMessage_Params& params); 31 32 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageHandler); 33 }; 34 35 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_HANDLER_H_ 36