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

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

Issue 2807033: Add support for omnibox.onInputStarted and onInputCancelled. (Closed)
Patch Set: fix Stop Created 10 years, 5 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
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/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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 const char ExtensionMessageService::kDispatchOnConnect[] = 108 const char ExtensionMessageService::kDispatchOnConnect[] =
109 "Port.dispatchOnConnect"; 109 "Port.dispatchOnConnect";
110 const char ExtensionMessageService::kDispatchOnDisconnect[] = 110 const char ExtensionMessageService::kDispatchOnDisconnect[] =
111 "Port.dispatchOnDisconnect"; 111 "Port.dispatchOnDisconnect";
112 const char ExtensionMessageService::kDispatchOnMessage[] = 112 const char ExtensionMessageService::kDispatchOnMessage[] =
113 "Port.dispatchOnMessage"; 113 "Port.dispatchOnMessage";
114 const char ExtensionMessageService::kDispatchEvent[] = 114 const char ExtensionMessageService::kDispatchEvent[] =
115 "Event.dispatchJSON"; 115 "Event.dispatchJSON";
116 116
117 // static
118 std::string ExtensionMessageService::GetPerExtensionEventName(
119 const std::string& event_name, const std::string& extension_id) {
120 // This should match the method we use in extension_process_binding.js when
121 // setting up the corresponding chrome.Event object.
122 return event_name + "/" + extension_id;
123 }
124
117 ExtensionMessageService::ExtensionMessageService(Profile* profile) 125 ExtensionMessageService::ExtensionMessageService(Profile* profile)
118 : profile_(profile), 126 : profile_(profile),
119 extension_devtools_manager_(NULL), 127 extension_devtools_manager_(NULL),
120 next_port_id_(0) { 128 next_port_id_(0) {
121 registrar_.Add(this, NotificationType::RENDERER_PROCESS_TERMINATED, 129 registrar_.Add(this, NotificationType::RENDERER_PROCESS_TERMINATED,
122 NotificationService::AllSources()); 130 NotificationService::AllSources());
123 registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSED, 131 registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSED,
124 NotificationService::AllSources()); 132 NotificationService::AllSources());
125 registrar_.Add(this, NotificationType::RENDER_VIEW_HOST_DELETED, 133 registrar_.Add(this, NotificationType::RENDER_VIEW_HOST_DELETED,
126 NotificationService::AllSources()); 134 NotificationService::AllSources());
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 HasExtensionBindings(*pid)) { 486 HasExtensionBindings(*pid)) {
479 // Don't send browser-level events to unprivileged processes. 487 // Don't send browser-level events to unprivileged processes.
480 continue; 488 continue;
481 } 489 }
482 490
483 DispatchEvent( 491 DispatchEvent(
484 renderer, event_name, event_args, has_incognito_data, event_url); 492 renderer, event_name, event_args, has_incognito_data, event_url);
485 } 493 }
486 } 494 }
487 495
496 void ExtensionMessageService::DispatchEventToExtension(
497 const std::string& extension_id,
498 const std::string& event_name, const std::string& event_args,
499 bool has_incognito_data, const GURL& event_url) {
500 DispatchEventToRenderers(GetPerExtensionEventName(event_name, extension_id),
501 event_args, has_incognito_data, event_url);
502 }
503
488 void ExtensionMessageService::Observe(NotificationType type, 504 void ExtensionMessageService::Observe(NotificationType type,
489 const NotificationSource& source, 505 const NotificationSource& source,
490 const NotificationDetails& details) { 506 const NotificationDetails& details) {
491 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); 507 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI);
492 508
493 switch (type.value) { 509 switch (type.value) {
494 case NotificationType::RENDERER_PROCESS_TERMINATED: 510 case NotificationType::RENDERER_PROCESS_TERMINATED:
495 case NotificationType::RENDERER_PROCESS_CLOSED: { 511 case NotificationType::RENDERER_PROCESS_CLOSED: {
496 RenderProcessHost* renderer = Source<RenderProcessHost>(source).ptr(); 512 RenderProcessHost* renderer = Source<RenderProcessHost>(source).ptr();
497 OnSenderClosed(renderer); 513 OnSenderClosed(renderer);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 566
551 if (current->second->opener.sender == sender) { 567 if (current->second->opener.sender == sender) {
552 CloseChannelImpl(current, GET_CHANNEL_OPENER_ID(current->first), 568 CloseChannelImpl(current, GET_CHANNEL_OPENER_ID(current->first),
553 notify_other_port); 569 notify_other_port);
554 } else if (current->second->receiver.sender == sender) { 570 } else if (current->second->receiver.sender == sender) {
555 CloseChannelImpl(current, GET_CHANNEL_RECEIVERS_ID(current->first), 571 CloseChannelImpl(current, GET_CHANNEL_RECEIVERS_ID(current->first),
556 notify_other_port); 572 notify_other_port);
557 } 573 }
558 } 574 }
559 } 575 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_message_service.h ('k') | chrome/browser/extensions/extension_omnibox_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698