Finish refactoring of DomCodeToUsLayoutKeyboardCode().
[chromium-blink-merge.git] / extensions / browser / extension_message_filter.h
blobe0c0e0c76d3924d4732a4df1621d341e101f5561
1 // Copyright 2014 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.
5 #ifndef EXTENSIONS_BROWSER_EXTENSION_MESSAGE_FILTER_H_
6 #define EXTENSIONS_BROWSER_EXTENSION_MESSAGE_FILTER_H_
8 #include <string>
9 #include <vector>
11 #include "base/compiler_specific.h"
12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h"
14 #include "components/keyed_service/core/keyed_service_shutdown_notifier.h"
15 #include "content/public/browser/browser_message_filter.h"
17 class GURL;
19 namespace content {
20 class BrowserContext;
23 namespace gfx {
24 class Size;
27 namespace extensions {
29 class EventRouter;
30 class ProcessManager;
32 // This class filters out incoming extension-specific IPC messages from the
33 // renderer process. It is created and destroyed on the UI thread and handles
34 // messages there.
35 class ExtensionMessageFilter : public content::BrowserMessageFilter {
36 public:
37 ExtensionMessageFilter(int render_process_id,
38 content::BrowserContext* context);
40 int render_process_id() { return render_process_id_; }
42 static void EnsureShutdownNotifierFactoryBuilt();
44 private:
45 friend class base::DeleteHelper<ExtensionMessageFilter>;
46 friend class content::BrowserThread;
48 ~ExtensionMessageFilter() override;
50 void ShutdownOnUIThread();
52 // content::BrowserMessageFilter implementation.
53 void OverrideThreadForMessage(const IPC::Message& message,
54 content::BrowserThread::ID* thread) override;
55 void OnDestruct() const override;
56 bool OnMessageReceived(const IPC::Message& message) override;
58 // Message handlers on the UI thread.
59 void OnExtensionAddListener(const std::string& extension_id,
60 const GURL& listener_url,
61 const std::string& event_name);
62 void OnExtensionRemoveListener(const std::string& extension_id,
63 const GURL& listener_url,
64 const std::string& event_name);
65 void OnExtensionAddLazyListener(const std::string& extension_id,
66 const std::string& event_name);
67 void OnExtensionRemoveLazyListener(const std::string& extension_id,
68 const std::string& event_name);
69 void OnExtensionAddFilteredListener(const std::string& extension_id,
70 const std::string& event_name,
71 const base::DictionaryValue& filter,
72 bool lazy);
73 void OnExtensionRemoveFilteredListener(const std::string& extension_id,
74 const std::string& event_name,
75 const base::DictionaryValue& filter,
76 bool lazy);
77 void OnExtensionShouldSuspendAck(const std::string& extension_id,
78 int sequence_id);
79 void OnExtensionSuspendAck(const std::string& extension_id);
80 void OnExtensionTransferBlobsAck(const std::vector<std::string>& blob_uuids);
82 const int render_process_id_;
84 scoped_ptr<KeyedServiceShutdownNotifier::Subscription> shutdown_notifier_;
86 // Owned by the browser context; should only be accessed on the UI thread.
87 EventRouter* event_router_;
88 ProcessManager* process_manager_;
90 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageFilter);
93 } // namespace extensions
95 #endif // EXTENSIONS_BROWSER_EXTENSION_MESSAGE_FILTER_H_