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

Side by Side Diff: extensions/renderer/extension_frame_helper.cc

Issue 1966283002: Remove port lifetime management from renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use MakeUnique instead of WrapUnique Created 4 years, 6 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
« no previous file with comments | « extensions/renderer/extension_frame_helper.h ('k') | extensions/renderer/messaging_bindings.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/renderer/extension_frame_helper.h" 5 #include "extensions/renderer/extension_frame_helper.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "content/public/renderer/render_frame.h" 8 #include "content/public/renderer/render_frame.h"
9 #include "extensions/common/api/messaging/message.h" 9 #include "extensions/common/api/messaging/message.h"
10 #include "extensions/common/constants.h" 10 #include "extensions/common/constants.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 void ExtensionFrameHelper::WillReleaseScriptContext( 182 void ExtensionFrameHelper::WillReleaseScriptContext(
183 v8::Local<v8::Context> context, 183 v8::Local<v8::Context> context,
184 int world_id) { 184 int world_id) {
185 extension_dispatcher_->WillReleaseScriptContext( 185 extension_dispatcher_->WillReleaseScriptContext(
186 render_frame()->GetWebFrame(), context, world_id); 186 render_frame()->GetWebFrame(), context, world_id);
187 } 187 }
188 188
189 bool ExtensionFrameHelper::OnMessageReceived(const IPC::Message& message) { 189 bool ExtensionFrameHelper::OnMessageReceived(const IPC::Message& message) {
190 bool handled = true; 190 bool handled = true;
191 IPC_BEGIN_MESSAGE_MAP(ExtensionFrameHelper, message) 191 IPC_BEGIN_MESSAGE_MAP(ExtensionFrameHelper, message)
192 IPC_MESSAGE_HANDLER(ExtensionMsg_ValidateMessagePort,
193 OnExtensionValidateMessagePort)
192 IPC_MESSAGE_HANDLER(ExtensionMsg_DispatchOnConnect, 194 IPC_MESSAGE_HANDLER(ExtensionMsg_DispatchOnConnect,
193 OnExtensionDispatchOnConnect) 195 OnExtensionDispatchOnConnect)
194 IPC_MESSAGE_HANDLER(ExtensionMsg_DeliverMessage, OnExtensionDeliverMessage) 196 IPC_MESSAGE_HANDLER(ExtensionMsg_DeliverMessage, OnExtensionDeliverMessage)
195 IPC_MESSAGE_HANDLER(ExtensionMsg_DispatchOnDisconnect, 197 IPC_MESSAGE_HANDLER(ExtensionMsg_DispatchOnDisconnect,
196 OnExtensionDispatchOnDisconnect) 198 OnExtensionDispatchOnDisconnect)
197 IPC_MESSAGE_HANDLER(ExtensionMsg_SetTabId, OnExtensionSetTabId) 199 IPC_MESSAGE_HANDLER(ExtensionMsg_SetTabId, OnExtensionSetTabId)
198 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateBrowserWindowId, 200 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateBrowserWindowId,
199 OnUpdateBrowserWindowId) 201 OnUpdateBrowserWindowId)
200 IPC_MESSAGE_HANDLER(ExtensionMsg_NotifyRenderViewType, 202 IPC_MESSAGE_HANDLER(ExtensionMsg_NotifyRenderViewType,
201 OnNotifyRendererViewType) 203 OnNotifyRendererViewType)
202 IPC_MESSAGE_HANDLER(ExtensionMsg_Response, OnExtensionResponse) 204 IPC_MESSAGE_HANDLER(ExtensionMsg_Response, OnExtensionResponse)
203 IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnExtensionMessageInvoke) 205 IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnExtensionMessageInvoke)
204 IPC_MESSAGE_UNHANDLED(handled = false) 206 IPC_MESSAGE_UNHANDLED(handled = false)
205 IPC_END_MESSAGE_MAP() 207 IPC_END_MESSAGE_MAP()
206 return handled; 208 return handled;
207 } 209 }
208 210
211 void ExtensionFrameHelper::OnExtensionValidateMessagePort(int port_id) {
212 MessagingBindings::ValidateMessagePort(
213 extension_dispatcher_->script_context_set(), port_id, render_frame());
214 }
215
209 void ExtensionFrameHelper::OnExtensionDispatchOnConnect( 216 void ExtensionFrameHelper::OnExtensionDispatchOnConnect(
210 int target_port_id, 217 int target_port_id,
211 const std::string& channel_name, 218 const std::string& channel_name,
212 const ExtensionMsg_TabConnectionInfo& source, 219 const ExtensionMsg_TabConnectionInfo& source,
213 const ExtensionMsg_ExternalConnectionInfo& info, 220 const ExtensionMsg_ExternalConnectionInfo& info,
214 const std::string& tls_channel_id) { 221 const std::string& tls_channel_id) {
215 MessagingBindings::DispatchOnConnect( 222 MessagingBindings::DispatchOnConnect(
216 extension_dispatcher_->script_context_set(), 223 extension_dispatcher_->script_context_set(),
217 target_port_id, 224 target_port_id,
218 channel_name, 225 channel_name,
219 source, 226 source,
220 info, 227 info,
221 tls_channel_id, 228 tls_channel_id,
222 render_frame()); 229 render_frame());
223 } 230 }
224 231
225 void ExtensionFrameHelper::OnExtensionDeliverMessage(int target_id, 232 void ExtensionFrameHelper::OnExtensionDeliverMessage(int target_id,
233 int source_tab_id,
226 const Message& message) { 234 const Message& message) {
227 MessagingBindings::DeliverMessage( 235 MessagingBindings::DeliverMessage(
228 extension_dispatcher_->script_context_set(), target_id, message, 236 extension_dispatcher_->script_context_set(), target_id, message,
229 render_frame()); 237 render_frame());
230 } 238 }
231 239
232 void ExtensionFrameHelper::OnExtensionDispatchOnDisconnect( 240 void ExtensionFrameHelper::OnExtensionDispatchOnDisconnect(
233 int port_id, 241 int port_id,
234 const std::string& error_message) { 242 const std::string& error_message) {
235 MessagingBindings::DispatchOnDisconnect( 243 MessagingBindings::DispatchOnDisconnect(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 const std::string& module_name, 276 const std::string& module_name,
269 const std::string& function_name, 277 const std::string& function_name,
270 const base::ListValue& args, 278 const base::ListValue& args,
271 bool user_gesture) { 279 bool user_gesture) {
272 extension_dispatcher_->InvokeModuleSystemMethod(render_frame(), extension_id, 280 extension_dispatcher_->InvokeModuleSystemMethod(render_frame(), extension_id,
273 module_name, function_name, 281 module_name, function_name,
274 args, user_gesture); 282 args, user_gesture);
275 } 283 }
276 284
277 } // namespace extensions 285 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/extension_frame_helper.h ('k') | extensions/renderer/messaging_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698