athena: Re-add ui_chromeos resources in athena_resources.pak.
[chromium-blink-merge.git] / extensions / browser / extension_message_filter.h
blobc45fb03c462d80068c6f352a6ed6fa2e28ac0cc1
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 "content/public/browser/browser_message_filter.h"
15 #include "url/gurl.h"
17 struct ExtensionHostMsg_Request_Params;
19 namespace base {
20 class DictionaryValue;
23 namespace content {
24 class BrowserContext;
27 namespace extensions {
29 class InfoMap;
31 // This class filters out incoming extension-specific IPC messages from the
32 // renderer process. It is created on the UI thread. Messages may be handled on
33 // the IO thread or the UI thread.
34 class ExtensionMessageFilter : public content::BrowserMessageFilter {
35 public:
36 ExtensionMessageFilter(int render_process_id,
37 content::BrowserContext* context);
39 int render_process_id() { return render_process_id_; }
41 private:
42 friend class content::BrowserThread;
43 friend class base::DeleteHelper<ExtensionMessageFilter>;
45 virtual ~ExtensionMessageFilter();
47 // content::BrowserMessageFilter implementation.
48 virtual void OverrideThreadForMessage(
49 const IPC::Message& message,
50 content::BrowserThread::ID* thread) OVERRIDE;
51 virtual void OnDestruct() const OVERRIDE;
52 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
54 // Message handlers on the UI thread.
55 void OnExtensionAddListener(const std::string& extension_id,
56 const GURL& listener_url,
57 const std::string& event_name);
58 void OnExtensionRemoveListener(const std::string& extension_id,
59 const GURL& listener_url,
60 const std::string& event_name);
61 void OnExtensionAddLazyListener(const std::string& extension_id,
62 const std::string& event_name);
63 void OnExtensionRemoveLazyListener(const std::string& extension_id,
64 const std::string& event_name);
65 void OnExtensionAddFilteredListener(const std::string& extension_id,
66 const std::string& event_name,
67 const base::DictionaryValue& filter,
68 bool lazy);
69 void OnExtensionRemoveFilteredListener(const std::string& extension_id,
70 const std::string& event_name,
71 const base::DictionaryValue& filter,
72 bool lazy);
73 void OnExtensionShouldSuspendAck(const std::string& extension_id,
74 int sequence_id);
75 void OnExtensionSuspendAck(const std::string& extension_id);
76 void OnExtensionTransferBlobsAck(const std::vector<std::string>& blob_uuids);
78 // Message handlers on the IO thread.
79 void OnExtensionGenerateUniqueID(int* unique_id);
80 void OnExtensionResumeRequests(int route_id);
81 void OnExtensionRequestForIOThread(
82 int routing_id,
83 const ExtensionHostMsg_Request_Params& params);
85 const int render_process_id_;
87 // Should only be accessed on the UI thread.
88 content::BrowserContext* browser_context_;
90 scoped_refptr<extensions::InfoMap> extension_info_map_;
92 // Weak pointers produced by this factory are bound to the IO thread.
93 base::WeakPtrFactory<ExtensionMessageFilter> weak_ptr_factory_;
95 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageFilter);
98 } // namespace extensions
100 #endif // EXTENSIONS_BROWSER_EXTENSION_MESSAGE_FILTER_H_