summaryrefslogtreecommitdiffstats
path: root/extensions/browser/extension_message_filter.h
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-02 06:01:53 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-02 06:01:53 +0000
commitafed5113d24a8950c348dd3fed9a2f66caeeb0a2 (patch)
treea840cf0e9a940066d0cffbf9771d4427a562d91a /extensions/browser/extension_message_filter.h
parent21aa42a0f242394b05c1855abfacc94935d8df5c (diff)
downloadchromium_src-afed5113d24a8950c348dd3fed9a2f66caeeb0a2.zip
chromium_src-afed5113d24a8950c348dd3fed9a2f66caeeb0a2.tar.gz
chromium_src-afed5113d24a8950c348dd3fed9a2f66caeeb0a2.tar.bz2
Move extensions IPC filtering to extensions::ExtensionMessageFilter
This moves a bunch of message filtering out of ChromeRenderMessageFilter and into the extensions module. This allows other clients of src/extensions (e.g. app_shell) to handle these IPCs. With this change app_shell can register handlers for events like chrome.runtime.onStartup() and do something useful with them. BUG=335632,339637 TEST=existing browser_tests (Extension*) Review URL: https://codereview.chromium.org/138283004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248386 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/browser/extension_message_filter.h')
-rw-r--r--extensions/browser/extension_message_filter.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/extensions/browser/extension_message_filter.h b/extensions/browser/extension_message_filter.h
new file mode 100644
index 0000000..8518bf9e
--- /dev/null
+++ b/extensions/browser/extension_message_filter.h
@@ -0,0 +1,77 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EXTENSIONS_BROWSER_EXTENSION_RENDER_MESSAGE_FILTER_H_
+#define EXTENSIONS_BROWSER_EXTENSION_RENDER_MESSAGE_FILTER_H_
+
+#include <string>
+
+#include "base/compiler_specific.h"
+#include "base/macros.h"
+#include "content/public/browser/browser_message_filter.h"
+
+namespace base {
+class DictionaryValue;
+}
+
+namespace content {
+class BrowserContext;
+}
+
+namespace extensions {
+
+// This class filters out incoming extension-specific IPC messages from the
+// renderer process. It is created on the UI thread. Messages may be handled on
+// the IO thread or the UI thread.
+class ExtensionMessageFilter : public content::BrowserMessageFilter {
+ public:
+ ExtensionMessageFilter(int render_process_id,
+ content::BrowserContext* context);
+
+ private:
+ virtual ~ExtensionMessageFilter();
+
+ // content::BrowserMessageFilter implementation.
+ virtual void OverrideThreadForMessage(
+ const IPC::Message& message,
+ content::BrowserThread::ID* thread) OVERRIDE;
+ virtual bool OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok) OVERRIDE;
+
+ // Message handlers on the UI thread.
+ void OnExtensionAddListener(const std::string& extension_id,
+ const std::string& event_name);
+ void OnExtensionRemoveListener(const std::string& extension_id,
+ const std::string& event_name);
+ void OnExtensionAddLazyListener(const std::string& extension_id,
+ const std::string& event_name);
+ void OnExtensionRemoveLazyListener(const std::string& extension_id,
+ const std::string& event_name);
+ void OnExtensionAddFilteredListener(const std::string& extension_id,
+ const std::string& event_name,
+ const base::DictionaryValue& filter,
+ bool lazy);
+ void OnExtensionRemoveFilteredListener(const std::string& extension_id,
+ const std::string& event_name,
+ const base::DictionaryValue& filter,
+ bool lazy);
+ void OnExtensionShouldSuspendAck(const std::string& extension_id,
+ int sequence_id);
+ void OnExtensionSuspendAck(const std::string& extension_id);
+
+ // Message handlers on the IO thread.
+ void OnExtensionGenerateUniqueID(int* unique_id);
+ void OnExtensionResumeRequests(int route_id);
+
+ const int render_process_id_;
+
+ // Should only be accessed on the UI thread.
+ content::BrowserContext* browser_context_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionMessageFilter);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_EXTENSION_RENDER_MESSAGE_FILTER_H_