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 #include "extensions/browser/extension_message_filter.h" | 5 #include "extensions/browser/extension_message_filter.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "components/crx_file/id_util.h" | 9 #include "components/crx_file/id_util.h" |
10 #include "components/keyed_service/content/browser_context_keyed_service_shutdow
n_notifier_factory.h" | 10 #include "components/keyed_service/content/browser_context_keyed_service_shutdow
n_notifier_factory.h" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
13 #include "extensions/browser/blob_holder.h" | 13 #include "extensions/browser/blob_holder.h" |
14 #include "extensions/browser/event_router.h" | 14 #include "extensions/browser/event_router.h" |
15 #include "extensions/browser/event_router_factory.h" | 15 #include "extensions/browser/event_router_factory.h" |
16 #include "extensions/browser/extension_registry.h" | 16 #include "extensions/browser/extension_registry.h" |
17 #include "extensions/browser/process_manager.h" | 17 #include "extensions/browser/process_manager.h" |
18 #include "extensions/browser/process_manager_factory.h" | 18 #include "extensions/browser/process_manager_factory.h" |
19 #include "extensions/browser/process_map.h" | 19 #include "extensions/browser/process_map.h" |
20 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
21 #include "extensions/common/extension_api.h" | |
22 #include "extensions/common/extension_messages.h" | 21 #include "extensions/common/extension_messages.h" |
23 #include "extensions/common/manifest_handlers/background_info.h" | 22 #include "extensions/common/manifest_handlers/background_info.h" |
24 #include "ipc/ipc_message_macros.h" | 23 #include "ipc/ipc_message_macros.h" |
25 | 24 |
26 using content::BrowserThread; | 25 using content::BrowserThread; |
27 using content::RenderProcessHost; | 26 using content::RenderProcessHost; |
28 | 27 |
29 namespace extensions { | 28 namespace extensions { |
30 | 29 |
31 namespace { | 30 namespace { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 IPC_MESSAGE_HANDLER(ExtensionHostMsg_RemoveFilteredListener, | 127 IPC_MESSAGE_HANDLER(ExtensionHostMsg_RemoveFilteredListener, |
129 OnExtensionRemoveFilteredListener) | 128 OnExtensionRemoveFilteredListener) |
130 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ShouldSuspendAck, | 129 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ShouldSuspendAck, |
131 OnExtensionShouldSuspendAck) | 130 OnExtensionShouldSuspendAck) |
132 IPC_MESSAGE_HANDLER(ExtensionHostMsg_SuspendAck, | 131 IPC_MESSAGE_HANDLER(ExtensionHostMsg_SuspendAck, |
133 OnExtensionSuspendAck) | 132 OnExtensionSuspendAck) |
134 IPC_MESSAGE_HANDLER(ExtensionHostMsg_TransferBlobsAck, | 133 IPC_MESSAGE_HANDLER(ExtensionHostMsg_TransferBlobsAck, |
135 OnExtensionTransferBlobsAck) | 134 OnExtensionTransferBlobsAck) |
136 IPC_MESSAGE_HANDLER(ExtensionHostMsg_WakeEventPage, | 135 IPC_MESSAGE_HANDLER(ExtensionHostMsg_WakeEventPage, |
137 OnExtensionWakeEventPage) | 136 OnExtensionWakeEventPage) |
138 IPC_MESSAGE_HANDLER(ExtensionHostMsg_NotifyBadExtensionApiSchema, | |
139 OnExtensionNotifyBadExtensionApiSchema) | |
140 IPC_MESSAGE_UNHANDLED(handled = false) | 137 IPC_MESSAGE_UNHANDLED(handled = false) |
141 IPC_END_MESSAGE_MAP() | 138 IPC_END_MESSAGE_MAP() |
142 return handled; | 139 return handled; |
143 } | 140 } |
144 | 141 |
145 void ExtensionMessageFilter::OnExtensionAddListener( | 142 void ExtensionMessageFilter::OnExtensionAddListener( |
146 const std::string& extension_id, | 143 const std::string& extension_id, |
147 const GURL& listener_url, | 144 const GURL& listener_url, |
148 const std::string& event_name) { | 145 const std::string& event_name) { |
149 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 146 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 | 311 |
315 // The extension has no background page, so there is nothing to wake. | 312 // The extension has no background page, so there is nothing to wake. |
316 SendWakeEventPageResponse(request_id, false); | 313 SendWakeEventPageResponse(request_id, false); |
317 } | 314 } |
318 | 315 |
319 void ExtensionMessageFilter::SendWakeEventPageResponse(int request_id, | 316 void ExtensionMessageFilter::SendWakeEventPageResponse(int request_id, |
320 bool success) { | 317 bool success) { |
321 Send(new ExtensionMsg_WakeEventPageResponse(request_id, success)); | 318 Send(new ExtensionMsg_WakeEventPageResponse(request_id, success)); |
322 } | 319 } |
323 | 320 |
324 void ExtensionMessageFilter::OnExtensionNotifyBadExtensionApiSchema( | |
325 const std::string& full_name) { | |
326 ExtensionAPI* extension_api = ExtensionAPI::GetSharedInstance(); | |
327 | |
328 // Try to resolve the full name; if we can't then the renderer sent a | |
329 // bogus name. | |
330 std::string api_name = | |
331 extension_api->GetAPINameFromFullName(full_name, nullptr); | |
332 if (api_name.empty()) { | |
333 ShutdownForBadMessage(); | |
334 return; | |
335 } | |
336 | |
337 // Since the renderer indicated that the schema for |api_name| was | |
338 // bad, we expect getting the schema to fail, and crash the browser. | |
339 CHECK(extension_api->GetSchema(api_name)); | |
340 | |
341 // If we reach here then the schema looked valid, indicating that | |
342 // the renderer must be at fault, so kill it. | |
343 ShutdownForBadMessage(); | |
344 } | |
345 | |
346 } // namespace extensions | 321 } // namespace extensions |
OLD | NEW |