OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/extensions/extension_message_service.h" | 5 #include "chrome/browser/extensions/extension_message_service.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/singleton.h" | 8 #include "base/singleton.h" |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 MessagePort receiver; | 296 MessagePort receiver; |
297 receiver.debug_info = 2; | 297 receiver.debug_info = 2; |
298 if (ExtensionTabUtil::GetTabById(tab_id, source->profile(), true, | 298 if (ExtensionTabUtil::GetTabById(tab_id, source->profile(), true, |
299 NULL, NULL, &contents, NULL)) { | 299 NULL, NULL, &contents, NULL)) { |
300 receiver.sender = contents->render_view_host(); | 300 receiver.sender = contents->render_view_host(); |
301 receiver.routing_id = contents->render_view_host()->routing_id(); | 301 receiver.routing_id = contents->render_view_host()->routing_id(); |
302 receiver.debug_info = 3; | 302 receiver.debug_info = 3; |
303 } | 303 } |
304 | 304 |
305 if (contents && contents->controller().needs_reload()) { | 305 if (contents && contents->controller().needs_reload()) { |
306 // The tab isn't loaded yet (it may be phantom). Don't attempt to connect. | 306 // The tab isn't loaded yet (it needs to be restored). Don't attempt to |
307 // Treat this as a disconnect. | 307 // connect. Treat this as a disconnect. |
308 DispatchOnDisconnect(MessagePort(source, MSG_ROUTING_CONTROL), | 308 DispatchOnDisconnect(MessagePort(source, MSG_ROUTING_CONTROL), |
309 GET_OPPOSITE_PORT_ID(receiver_port_id)); | 309 GET_OPPOSITE_PORT_ID(receiver_port_id)); |
310 return; | 310 return; |
311 } | 311 } |
312 | 312 |
313 TabContents* source_contents = tab_util::GetTabContentsByID( | 313 TabContents* source_contents = tab_util::GetTabContentsByID( |
314 source_process_id, source_routing_id); | 314 source_process_id, source_routing_id); |
315 | 315 |
316 // Include info about the opener's tab (if it was a tab). | 316 // Include info about the opener's tab (if it was a tab). |
317 std::string tab_json = "null"; | 317 std::string tab_json = "null"; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 return port1_id; | 393 return port1_id; |
394 } | 394 } |
395 | 395 |
396 int ExtensionMessageService::OpenSpecialChannelToTab( | 396 int ExtensionMessageService::OpenSpecialChannelToTab( |
397 const std::string& extension_id, const std::string& channel_name, | 397 const std::string& extension_id, const std::string& channel_name, |
398 TabContents* target_tab_contents, IPC::Message::Sender* source) { | 398 TabContents* target_tab_contents, IPC::Message::Sender* source) { |
399 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 399 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
400 DCHECK(target_tab_contents); | 400 DCHECK(target_tab_contents); |
401 | 401 |
402 if (target_tab_contents->controller().needs_reload()) { | 402 if (target_tab_contents->controller().needs_reload()) { |
403 // The tab isn't loaded yet (it may be phantom). Don't attempt to connect. | 403 // The tab isn't loaded yet (it needs to be reloaded). Don't attempt to |
| 404 // connect. |
404 return -1; | 405 return -1; |
405 } | 406 } |
406 | 407 |
407 int port1_id = -1; | 408 int port1_id = -1; |
408 int port2_id = -1; | 409 int port2_id = -1; |
409 // Create a channel ID for both sides of the channel. | 410 // Create a channel ID for both sides of the channel. |
410 AllocatePortIdPair(&port1_id, &port2_id); | 411 AllocatePortIdPair(&port1_id, &port2_id); |
411 | 412 |
412 MessagePort receiver( | 413 MessagePort receiver( |
413 target_tab_contents->render_view_host(), | 414 target_tab_contents->render_view_host(), |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 | 551 |
551 if (current->second->opener.sender == sender) { | 552 if (current->second->opener.sender == sender) { |
552 CloseChannelImpl(current, GET_CHANNEL_OPENER_ID(current->first), | 553 CloseChannelImpl(current, GET_CHANNEL_OPENER_ID(current->first), |
553 notify_other_port); | 554 notify_other_port); |
554 } else if (current->second->receiver.sender == sender) { | 555 } else if (current->second->receiver.sender == sender) { |
555 CloseChannelImpl(current, GET_CHANNEL_RECEIVERS_ID(current->first), | 556 CloseChannelImpl(current, GET_CHANNEL_RECEIVERS_ID(current->first), |
556 notify_other_port); | 557 notify_other_port); |
557 } | 558 } |
558 } | 559 } |
559 } | 560 } |
OLD | NEW |