Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: extensions/browser/extension_message_filter.cc

Issue 280393003: Blobs: Catching browser-process created Blobs in extension code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « extensions/browser/extension_message_filter.h ('k') | extensions/common/extension_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/public/browser/browser_thread.h" 7 #include "content/public/browser/browser_thread.h"
8 #include "content/public/browser/render_process_host.h" 8 #include "content/public/browser/render_process_host.h"
9 #include "content/public/browser/resource_dispatcher_host.h" 9 #include "content/public/browser/resource_dispatcher_host.h"
10 #include "extensions/browser/blob_holder.h"
10 #include "extensions/browser/event_router.h" 11 #include "extensions/browser/event_router.h"
11 #include "extensions/browser/extension_function_dispatcher.h" 12 #include "extensions/browser/extension_function_dispatcher.h"
12 #include "extensions/browser/extension_system.h" 13 #include "extensions/browser/extension_system.h"
13 #include "extensions/browser/info_map.h" 14 #include "extensions/browser/info_map.h"
14 #include "extensions/browser/process_manager.h" 15 #include "extensions/browser/process_manager.h"
15 #include "extensions/common/extension_messages.h" 16 #include "extensions/common/extension_messages.h"
16 #include "ipc/ipc_message_macros.h" 17 #include "ipc/ipc_message_macros.h"
17 18
18 using content::BrowserThread; 19 using content::BrowserThread;
19 using content::RenderProcessHost; 20 using content::RenderProcessHost;
(...skipping 17 matching lines...) Expand all
37 BrowserThread::ID* thread) { 38 BrowserThread::ID* thread) {
38 switch (message.type()) { 39 switch (message.type()) {
39 case ExtensionHostMsg_AddListener::ID: 40 case ExtensionHostMsg_AddListener::ID:
40 case ExtensionHostMsg_RemoveListener::ID: 41 case ExtensionHostMsg_RemoveListener::ID:
41 case ExtensionHostMsg_AddLazyListener::ID: 42 case ExtensionHostMsg_AddLazyListener::ID:
42 case ExtensionHostMsg_RemoveLazyListener::ID: 43 case ExtensionHostMsg_RemoveLazyListener::ID:
43 case ExtensionHostMsg_AddFilteredListener::ID: 44 case ExtensionHostMsg_AddFilteredListener::ID:
44 case ExtensionHostMsg_RemoveFilteredListener::ID: 45 case ExtensionHostMsg_RemoveFilteredListener::ID:
45 case ExtensionHostMsg_ShouldSuspendAck::ID: 46 case ExtensionHostMsg_ShouldSuspendAck::ID:
46 case ExtensionHostMsg_SuspendAck::ID: 47 case ExtensionHostMsg_SuspendAck::ID:
48 case ExtensionHostMsg_TransferBlobsAck::ID:
47 *thread = BrowserThread::UI; 49 *thread = BrowserThread::UI;
48 break; 50 break;
49 default: 51 default:
50 break; 52 break;
51 } 53 }
52 } 54 }
53 55
54 bool ExtensionMessageFilter::OnMessageReceived(const IPC::Message& message) { 56 bool ExtensionMessageFilter::OnMessageReceived(const IPC::Message& message) {
55 bool handled = true; 57 bool handled = true;
56 IPC_BEGIN_MESSAGE_MAP(ExtensionMessageFilter, message) 58 IPC_BEGIN_MESSAGE_MAP(ExtensionMessageFilter, message)
57 IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddListener, 59 IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddListener,
58 OnExtensionAddListener) 60 OnExtensionAddListener)
59 IPC_MESSAGE_HANDLER(ExtensionHostMsg_RemoveListener, 61 IPC_MESSAGE_HANDLER(ExtensionHostMsg_RemoveListener,
60 OnExtensionRemoveListener) 62 OnExtensionRemoveListener)
61 IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddLazyListener, 63 IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddLazyListener,
62 OnExtensionAddLazyListener) 64 OnExtensionAddLazyListener)
63 IPC_MESSAGE_HANDLER(ExtensionHostMsg_RemoveLazyListener, 65 IPC_MESSAGE_HANDLER(ExtensionHostMsg_RemoveLazyListener,
64 OnExtensionRemoveLazyListener) 66 OnExtensionRemoveLazyListener)
65 IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddFilteredListener, 67 IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddFilteredListener,
66 OnExtensionAddFilteredListener) 68 OnExtensionAddFilteredListener)
67 IPC_MESSAGE_HANDLER(ExtensionHostMsg_RemoveFilteredListener, 69 IPC_MESSAGE_HANDLER(ExtensionHostMsg_RemoveFilteredListener,
68 OnExtensionRemoveFilteredListener) 70 OnExtensionRemoveFilteredListener)
69 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ShouldSuspendAck, 71 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ShouldSuspendAck,
70 OnExtensionShouldSuspendAck) 72 OnExtensionShouldSuspendAck)
71 IPC_MESSAGE_HANDLER(ExtensionHostMsg_SuspendAck, 73 IPC_MESSAGE_HANDLER(ExtensionHostMsg_SuspendAck,
72 OnExtensionSuspendAck) 74 OnExtensionSuspendAck)
75 IPC_MESSAGE_HANDLER(ExtensionHostMsg_TransferBlobsAck,
76 OnExtensionTransferBlobsAck)
73 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GenerateUniqueID, 77 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GenerateUniqueID,
74 OnExtensionGenerateUniqueID) 78 OnExtensionGenerateUniqueID)
75 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ResumeRequests, 79 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ResumeRequests,
76 OnExtensionResumeRequests); 80 OnExtensionResumeRequests);
77 IPC_MESSAGE_HANDLER(ExtensionHostMsg_RequestForIOThread, 81 IPC_MESSAGE_HANDLER(ExtensionHostMsg_RequestForIOThread,
78 OnExtensionRequestForIOThread) 82 OnExtensionRequestForIOThread)
79 IPC_MESSAGE_UNHANDLED(handled = false) 83 IPC_MESSAGE_UNHANDLED(handled = false)
80 IPC_END_MESSAGE_MAP() 84 IPC_END_MESSAGE_MAP()
81 return handled; 85 return handled;
82 } 86 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 164 }
161 165
162 void ExtensionMessageFilter::OnExtensionSuspendAck( 166 void ExtensionMessageFilter::OnExtensionSuspendAck(
163 const std::string& extension_id) { 167 const std::string& extension_id) {
164 ProcessManager* process_manager = 168 ProcessManager* process_manager =
165 ExtensionSystem::Get(browser_context_)->process_manager(); 169 ExtensionSystem::Get(browser_context_)->process_manager();
166 if (process_manager) 170 if (process_manager)
167 process_manager->OnSuspendAck(extension_id); 171 process_manager->OnSuspendAck(extension_id);
168 } 172 }
169 173
174 void ExtensionMessageFilter::OnExtensionTransferBlobsAck(
175 const std::vector<std::string>& blob_uuids) {
176 RenderProcessHost* process = RenderProcessHost::FromID(render_process_id_);
177 if (!process)
178 return;
179 BlobHolder::FromRenderProcessHost(process)->DropBlobs(blob_uuids);
180 }
181
170 void ExtensionMessageFilter::OnExtensionGenerateUniqueID(int* unique_id) { 182 void ExtensionMessageFilter::OnExtensionGenerateUniqueID(int* unique_id) {
171 static int next_unique_id = 0; 183 static int next_unique_id = 0;
172 *unique_id = ++next_unique_id; 184 *unique_id = ++next_unique_id;
173 } 185 }
174 186
175 void ExtensionMessageFilter::OnExtensionResumeRequests(int route_id) { 187 void ExtensionMessageFilter::OnExtensionResumeRequests(int route_id) {
176 content::ResourceDispatcherHost::Get()->ResumeBlockedRequestsForRoute( 188 content::ResourceDispatcherHost::Get()->ResumeBlockedRequestsForRoute(
177 render_process_id_, route_id); 189 render_process_id_, route_id);
178 } 190 }
179 191
180 void ExtensionMessageFilter::OnExtensionRequestForIOThread( 192 void ExtensionMessageFilter::OnExtensionRequestForIOThread(
181 int routing_id, 193 int routing_id,
182 const ExtensionHostMsg_Request_Params& params) { 194 const ExtensionHostMsg_Request_Params& params) {
183 DCHECK_CURRENTLY_ON(BrowserThread::IO); 195 DCHECK_CURRENTLY_ON(BrowserThread::IO);
184 ExtensionFunctionDispatcher::DispatchOnIOThread( 196 ExtensionFunctionDispatcher::DispatchOnIOThread(
185 extension_info_map_.get(), 197 extension_info_map_.get(),
186 browser_context_, 198 browser_context_,
187 render_process_id_, 199 render_process_id_,
188 weak_ptr_factory_.GetWeakPtr(), 200 weak_ptr_factory_.GetWeakPtr(),
189 routing_id, 201 routing_id,
190 params); 202 params);
191 } 203 }
192 204
193 } // namespace extensions 205 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/extension_message_filter.h ('k') | extensions/common/extension_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698