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

Side by Side Diff: chrome/browser/extensions/extension_message_service.cc

Issue 4694008: Make pink's TabContentsWrapper change compile on Windows.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
OLDNEW
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/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.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"
11 #include "chrome/browser/child_process_security_policy.h" 11 #include "chrome/browser/child_process_security_policy.h"
12 #include "chrome/browser/extensions/extension_process_manager.h" 12 #include "chrome/browser/extensions/extension_process_manager.h"
13 #include "chrome/browser/extensions/extension_tabs_module.h" 13 #include "chrome/browser/extensions/extension_tabs_module.h"
14 #include "chrome/browser/profile.h" 14 #include "chrome/browser/profile.h"
15 #include "chrome/browser/renderer_host/render_process_host.h" 15 #include "chrome/browser/renderer_host/render_process_host.h"
16 #include "chrome/browser/renderer_host/render_view_host.h" 16 #include "chrome/browser/renderer_host/render_view_host.h"
17 #include "chrome/browser/tab_contents/tab_contents.h" 17 #include "chrome/browser/tab_contents/tab_contents.h"
18 #include "chrome/browser/tab_contents/tab_util.h" 18 #include "chrome/browser/tab_contents/tab_util.h"
19 #include "chrome/browser/tab_contents_wrapper.h"
19 #include "chrome/common/extensions/extension.h" 20 #include "chrome/common/extensions/extension.h"
20 #include "chrome/common/notification_service.h" 21 #include "chrome/common/notification_service.h"
21 #include "chrome/common/render_messages.h" 22 #include "chrome/common/render_messages.h"
22 23
23 // Since we have 2 ports for every channel, we just index channels by half the 24 // Since we have 2 ports for every channel, we just index channels by half the
24 // port ID. 25 // port ID.
25 #define GET_CHANNEL_ID(port_id) ((port_id) / 2) 26 #define GET_CHANNEL_ID(port_id) ((port_id) / 2)
26 #define GET_CHANNEL_OPENER_ID(channel_id) ((channel_id) * 2) 27 #define GET_CHANNEL_OPENER_ID(channel_id) ((channel_id) * 2)
27 #define GET_CHANNEL_RECEIVERS_ID(channel_id) ((channel_id) * 2 + 1) 28 #define GET_CHANNEL_RECEIVERS_ID(channel_id) ((channel_id) * 2 + 1)
28 29
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 167 }
167 168
168 void ExtensionMessageService::OpenChannelToTab( 169 void ExtensionMessageService::OpenChannelToTab(
169 int source_process_id, int source_routing_id, int receiver_port_id, 170 int source_process_id, int source_routing_id, int receiver_port_id,
170 int tab_id, const std::string& extension_id, 171 int tab_id, const std::string& extension_id,
171 const std::string& channel_name) { 172 const std::string& channel_name) {
172 RenderProcessHost* source = RenderProcessHost::FromID(source_process_id); 173 RenderProcessHost* source = RenderProcessHost::FromID(source_process_id);
173 if (!source) 174 if (!source)
174 return; 175 return;
175 176
176 TabContents* contents = NULL; 177 TabContentsWrapper* contents = NULL;
177 MessagePort receiver; 178 MessagePort receiver;
178 if (ExtensionTabUtil::GetTabById(tab_id, source->profile(), true, 179 if (ExtensionTabUtil::GetTabById(tab_id, source->profile(), true,
179 NULL, NULL, &contents, NULL)) { 180 NULL, NULL, &contents, NULL)) {
180 receiver.sender = contents->render_view_host(); 181 receiver.sender = contents->render_view_host();
181 receiver.routing_id = contents->render_view_host()->routing_id(); 182 receiver.routing_id = contents->render_view_host()->routing_id();
182 } 183 }
183 184
184 if (contents && contents->controller().needs_reload()) { 185 if (contents && contents->controller().needs_reload()) {
185 // The tab isn't loaded yet. Don't attempt to connect. Treat this as a 186 // The tab isn't loaded yet. Don't attempt to connect. Treat this as a
186 // disconnect. 187 // disconnect.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 356
356 if (current->second->opener.sender == sender) { 357 if (current->second->opener.sender == sender) {
357 CloseChannelImpl(current, GET_CHANNEL_OPENER_ID(current->first), 358 CloseChannelImpl(current, GET_CHANNEL_OPENER_ID(current->first),
358 notify_other_port); 359 notify_other_port);
359 } else if (current->second->receiver.sender == sender) { 360 } else if (current->second->receiver.sender == sender) {
360 CloseChannelImpl(current, GET_CHANNEL_RECEIVERS_ID(current->first), 361 CloseChannelImpl(current, GET_CHANNEL_RECEIVERS_ID(current->first),
361 notify_other_port); 362 notify_other_port);
362 } 363 }
363 } 364 }
364 } 365 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698