OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/api/messaging/message_service.h" | 5 #include "chrome/browser/extensions/api/messaging/message_service.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <limits> | 8 #include <limits> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 std::unique_ptr<OpenChannelParams> params(new OpenChannelParams( | 320 std::unique_ptr<OpenChannelParams> params(new OpenChannelParams( |
321 source_process_id, source_routing_id, std::move(source_tab), | 321 source_process_id, source_routing_id, std::move(source_tab), |
322 source_frame_id, nullptr, receiver_port_id, source_extension_id, | 322 source_frame_id, nullptr, receiver_port_id, source_extension_id, |
323 target_extension_id, source_url, channel_name, include_tls_channel_id, | 323 target_extension_id, source_url, channel_name, include_tls_channel_id, |
324 include_guest_process_info)); | 324 include_guest_process_info)); |
325 | 325 |
326 pending_incognito_channels_[params->receiver_port_id.GetChannelId()] = | 326 pending_incognito_channels_[params->receiver_port_id.GetChannelId()] = |
327 PendingMessagesQueue(); | 327 PendingMessagesQueue(); |
328 if (context->IsOffTheRecord() && | 328 if (context->IsOffTheRecord() && |
329 !util::IsIncognitoEnabled(target_extension_id, context)) { | 329 !util::IsIncognitoEnabled(target_extension_id, context)) { |
330 // The extension is not enabled in incognito mode. However it is loaded in | |
331 // the associated incognito renderer process. This can only happen when the | |
332 // extension can't be enabled in incognito mode. This can include platform | |
333 // apps, component extensions and extensions which are not allowed in the | |
334 // incognito mode. | |
335 DCHECK(!util::CanBeIncognitoEnabled(target_extension)); | |
karandeepb
2017/03/23 02:54:03
At least in this case, CanBeIncognitoEnabled seems
Devlin
2017/03/23 22:08:36
Is this check correct? What about the case of a w
Devlin
2017/03/23 22:08:36
I'm not sure I love SupportsIncognitoToggle, since
karandeepb
2017/04/04 03:44:15
It isn't. I had misunderstood what was happening.
karandeepb
2017/04/04 03:44:15
The current naming SGTM then.
| |
336 | |
330 // Give the user a chance to accept an incognito connection from the web if | 337 // Give the user a chance to accept an incognito connection from the web if |
331 // they haven't already, with the conditions: | 338 // they haven't already. But don't do this for split mode incognito. We |
332 // - Only for spanning-mode incognito. We don't want the complication of | 339 // don't want the complication of spinning up an additional process here |
333 // spinning up an additional process here which might need to do some | 340 // which might need to do some setup that we're not expecting. |
334 // setup that we're not expecting. | 341 if (!is_web_connection || IncognitoInfo::IsSplitMode(target_extension)) { |
335 // - Only for extensions that can't normally be enabled in incognito, since | |
336 // that surface (e.g. chrome://extensions) should be the only one for | |
337 // enabling in incognito. In practice this means platform apps only. | |
338 if (!is_web_connection || IncognitoInfo::IsSplitMode(target_extension) || | |
339 util::CanBeIncognitoEnabled(target_extension)) { | |
340 OnOpenChannelAllowed(std::move(params), false); | 342 OnOpenChannelAllowed(std::move(params), false); |
341 return; | 343 return; |
342 } | 344 } |
343 | 345 |
344 // If the target extension isn't even listening for connect/message events, | 346 // If the target extension isn't even listening for connect/message events, |
345 // there is no need to go any further and the connection should be | 347 // there is no need to go any further and the connection should be |
346 // rejected without showing a prompt. See http://crbug.com/442497 | 348 // rejected without showing a prompt. See http://crbug.com/442497 |
347 EventRouter* event_router = EventRouter::Get(context); | 349 EventRouter* event_router = EventRouter::Get(context); |
348 const char* const events[] = {"runtime.onConnectExternal", | 350 const char* const events[] = {"runtime.onConnectExternal", |
349 "runtime.onMessageExternal", | 351 "runtime.onMessageExternal", |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
987 MessageChannelMap::iterator channel_iter = channels_.find(channel_id); | 989 MessageChannelMap::iterator channel_iter = channels_.find(channel_id); |
988 if (channel_iter != channels_.end()) { | 990 if (channel_iter != channels_.end()) { |
989 for (const PendingMessage& message : queue) { | 991 for (const PendingMessage& message : queue) { |
990 DispatchMessage(message.first, channel_iter->second.get(), | 992 DispatchMessage(message.first, channel_iter->second.get(), |
991 message.second); | 993 message.second); |
992 } | 994 } |
993 } | 995 } |
994 } | 996 } |
995 | 997 |
996 } // namespace extensions | 998 } // namespace extensions |
OLD | NEW |