OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EXTENSIONS_BROWSER_EXTENSION_MESSAGE_FILTER_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_MESSAGE_FILTER_H_ |
6 #define EXTENSIONS_BROWSER_EXTENSION_MESSAGE_FILTER_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_MESSAGE_FILTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "components/keyed_service/core/keyed_service_shutdown_notifier.h" |
14 #include "content/public/browser/browser_message_filter.h" | 15 #include "content/public/browser/browser_message_filter.h" |
15 #include "url/gurl.h" | |
16 | 16 |
17 struct ExtensionHostMsg_Request_Params; | 17 class GURL; |
18 | |
19 namespace base { | |
20 class DictionaryValue; | |
21 } | |
22 | 18 |
23 namespace content { | 19 namespace content { |
24 class BrowserContext; | 20 class BrowserContext; |
25 class WebContents; | |
26 } | 21 } |
27 | 22 |
28 namespace gfx { | 23 namespace gfx { |
29 class Size; | 24 class Size; |
30 } | 25 } |
31 | 26 |
32 namespace extensions { | 27 namespace extensions { |
33 | 28 |
34 class InfoMap; | 29 class ExtensionSystem; |
| 30 class ProcessManager; |
35 | 31 |
36 // This class filters out incoming extension-specific IPC messages from the | 32 // This class filters out incoming extension-specific IPC messages from the |
37 // renderer process. It is created on the UI thread. Messages may be handled on | 33 // renderer process. It is created and destroyed on the UI thread and handles |
38 // the IO thread or the UI thread. | 34 // messages there. |
39 class ExtensionMessageFilter : public content::BrowserMessageFilter { | 35 class ExtensionMessageFilter : public content::BrowserMessageFilter { |
40 public: | 36 public: |
41 ExtensionMessageFilter(int render_process_id, | 37 ExtensionMessageFilter(int render_process_id, |
42 content::BrowserContext* context); | 38 content::BrowserContext* context); |
43 | 39 |
44 int render_process_id() { return render_process_id_; } | 40 int render_process_id() { return render_process_id_; } |
45 | 41 |
| 42 static void EnsureShutdownNotifierFactoryBuilt(); |
| 43 |
46 private: | 44 private: |
| 45 friend class base::DeleteHelper<ExtensionMessageFilter>; |
47 friend class content::BrowserThread; | 46 friend class content::BrowserThread; |
48 friend class base::DeleteHelper<ExtensionMessageFilter>; | |
49 | 47 |
50 ~ExtensionMessageFilter() override; | 48 ~ExtensionMessageFilter() override; |
51 | 49 |
| 50 void ShutdownOnUIThread(); |
| 51 |
52 // content::BrowserMessageFilter implementation. | 52 // content::BrowserMessageFilter implementation. |
53 void OverrideThreadForMessage(const IPC::Message& message, | 53 void OverrideThreadForMessage(const IPC::Message& message, |
54 content::BrowserThread::ID* thread) override; | 54 content::BrowserThread::ID* thread) override; |
55 void OnDestruct() const override; | 55 void OnDestruct() const override; |
56 bool OnMessageReceived(const IPC::Message& message) override; | 56 bool OnMessageReceived(const IPC::Message& message) override; |
57 | 57 |
58 // Message handlers on the UI thread. | 58 // Message handlers on the UI thread. |
59 void OnExtensionAddListener(const std::string& extension_id, | 59 void OnExtensionAddListener(const std::string& extension_id, |
60 const GURL& listener_url, | 60 const GURL& listener_url, |
61 const std::string& event_name); | 61 const std::string& event_name); |
(...skipping 14 matching lines...) Expand all Loading... |
76 bool lazy); | 76 bool lazy); |
77 void OnExtensionRemoveFilteredListener(const std::string& extension_id, | 77 void OnExtensionRemoveFilteredListener(const std::string& extension_id, |
78 const std::string& event_name, | 78 const std::string& event_name, |
79 const base::DictionaryValue& filter, | 79 const base::DictionaryValue& filter, |
80 bool lazy); | 80 bool lazy); |
81 void OnExtensionShouldSuspendAck(const std::string& extension_id, | 81 void OnExtensionShouldSuspendAck(const std::string& extension_id, |
82 int sequence_id); | 82 int sequence_id); |
83 void OnExtensionSuspendAck(const std::string& extension_id); | 83 void OnExtensionSuspendAck(const std::string& extension_id); |
84 void OnExtensionTransferBlobsAck(const std::vector<std::string>& blob_uuids); | 84 void OnExtensionTransferBlobsAck(const std::vector<std::string>& blob_uuids); |
85 | 85 |
86 // Message handlers on the IO thread. | |
87 void OnExtensionGenerateUniqueID(int* unique_id); | |
88 void OnExtensionResumeRequests(int route_id); | |
89 void OnExtensionRequestForIOThread( | |
90 int routing_id, | |
91 const ExtensionHostMsg_Request_Params& params); | |
92 | |
93 const int render_process_id_; | 86 const int render_process_id_; |
94 | 87 |
95 // Should only be accessed on the UI thread. | 88 scoped_ptr<KeyedServiceShutdownNotifier::Subscription> shutdown_notifier_; |
96 content::BrowserContext* browser_context_; | |
97 | 89 |
98 scoped_refptr<extensions::InfoMap> extension_info_map_; | 90 // Owned by the browser context; should only be accessed on the UI thread. |
99 | 91 ExtensionSystem* extension_system_; |
100 // Weak pointers produced by this factory are bound to the IO thread. | 92 ProcessManager* process_manager_; |
101 base::WeakPtrFactory<ExtensionMessageFilter> weak_ptr_factory_; | |
102 | 93 |
103 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageFilter); | 94 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageFilter); |
104 }; | 95 }; |
105 | 96 |
106 } // namespace extensions | 97 } // namespace extensions |
107 | 98 |
108 #endif // EXTENSIONS_BROWSER_EXTENSION_MESSAGE_FILTER_H_ | 99 #endif // EXTENSIONS_BROWSER_EXTENSION_MESSAGE_FILTER_H_ |
OLD | NEW |