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

Side by Side Diff: chrome/browser/extensions/api/messaging/message_service.cc

Issue 148153008: Protocol handler dialogs should only be enabled by browser or page actions [Not committed] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 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
OLDNEW
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 "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/extensions/api/messaging/extension_message_port.h" 16 #include "chrome/browser/extensions/api/messaging/extension_message_port.h"
17 #include "chrome/browser/extensions/api/messaging/incognito_connectability.h" 17 #include "chrome/browser/extensions/api/messaging/incognito_connectability.h"
18 #include "chrome/browser/extensions/api/messaging/native_message_port.h" 18 #include "chrome/browser/extensions/api/messaging/native_message_port.h"
19 #include "chrome/browser/extensions/extension_host.h" 19 #include "chrome/browser/extensions/extension_host.h"
20 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/extensions/extension_tab_util.h" 21 #include "chrome/browser/extensions/extension_tab_util.h"
22 #include "chrome/browser/extensions/extension_util.h" 22 #include "chrome/browser/extensions/extension_util.h"
23 #include "chrome/browser/external_protocol/external_protocol_handler.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/tab_contents/tab_util.h" 25 #include "chrome/browser/tab_contents/tab_util.h"
25 #include "chrome/common/extensions/extension_messages.h" 26 #include "chrome/common/extensions/extension_messages.h"
26 #include "chrome/common/extensions/manifest_handlers/externally_connectable.h" 27 #include "chrome/common/extensions/manifest_handlers/externally_connectable.h"
27 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
28 #include "content/public/browser/render_process_host.h" 29 #include "content/public/browser/render_process_host.h"
29 #include "content/public/browser/render_view_host.h" 30 #include "content/public/browser/render_view_host.h"
30 #include "content/public/browser/render_widget_host.h" 31 #include "content/public/browser/render_widget_host.h"
31 #include "content/public/browser/render_widget_host_view.h" 32 #include "content/public/browser/render_widget_host_view.h"
32 #include "content/public/browser/site_instance.h" 33 #include "content/public/browser/site_instance.h"
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 } 646 }
646 647
647 void MessageService::DispatchMessage(int source_port_id, 648 void MessageService::DispatchMessage(int source_port_id,
648 MessageChannel* channel, 649 MessageChannel* channel,
649 const Message& message) { 650 const Message& message) {
650 // Figure out which port the ID corresponds to. 651 // Figure out which port the ID corresponds to.
651 int dest_port_id = GET_OPPOSITE_PORT_ID(source_port_id); 652 int dest_port_id = GET_OPPOSITE_PORT_ID(source_port_id);
652 MessagePort* port = IS_OPENER_PORT_ID(dest_port_id) ? 653 MessagePort* port = IS_OPENER_PORT_ID(dest_port_id) ?
653 channel->opener.get() : channel->receiver.get(); 654 channel->opener.get() : channel->receiver.get();
654 655
656 if (message.user_gesture)
657 ExternalProtocolHandler::PermitLaunchUrl();
655 port->DispatchOnMessage(message, dest_port_id); 658 port->DispatchOnMessage(message, dest_port_id);
656 } 659 }
657 660
658 bool MessageService::MaybeAddPendingLazyBackgroundPageOpenChannelTask( 661 bool MessageService::MaybeAddPendingLazyBackgroundPageOpenChannelTask(
659 Profile* profile, 662 Profile* profile,
660 const Extension* extension, 663 const Extension* extension,
661 OpenChannelParams* params) { 664 OpenChannelParams* params) {
662 if (!BackgroundInfo::HasLazyBackgroundPage(extension)) 665 if (!BackgroundInfo::HasLazyBackgroundPage(extension))
663 return false; 666 return false;
664 667
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 } 759 }
757 760
758 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source, 761 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source,
759 int port_id, 762 int port_id,
760 const std::string& error_message) { 763 const std::string& error_message) {
761 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); 764 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, "");
762 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message); 765 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message);
763 } 766 }
764 767
765 } // namespace extensions 768 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698