| 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/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/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" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 static void DispatchOnMessage(const ExtensionMessageService::MessagePort& port, | 119 static void DispatchOnMessage(const ExtensionMessageService::MessagePort& port, |
| 120 const std::string& message, int target_port_id) { | 120 const std::string& message, int target_port_id) { |
| 121 port.process->Send(new ExtensionMsg_DeliverMessage( | 121 port.process->Send(new ExtensionMsg_DeliverMessage( |
| 122 port.routing_id, target_port_id, message)); | 122 port.routing_id, target_port_id, message)); |
| 123 } | 123 } |
| 124 | 124 |
| 125 static content::RenderProcessHost* GetExtensionProcess( | 125 static content::RenderProcessHost* GetExtensionProcess( |
| 126 Profile* profile, const std::string& extension_id) { | 126 Profile* profile, const std::string& extension_id) { |
| 127 SiteInstance* site_instance = | 127 SiteInstance* site_instance = |
| 128 profile->GetExtensionProcessManager()->GetSiteInstanceForURL( | 128 profile->GetExtensionProcessManager()->GetSiteInstanceForURL( |
| 129 Extension::GetBaseURLFromExtensionId(extension_id)); | 129 extensions::Extension::GetBaseURLFromExtensionId(extension_id)); |
| 130 | 130 |
| 131 if (!site_instance->HasProcess()) | 131 if (!site_instance->HasProcess()) |
| 132 return NULL; | 132 return NULL; |
| 133 | 133 |
| 134 return site_instance->GetProcess(); | 134 return site_instance->GetProcess(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 static void IncrementLazyKeepaliveCount( | 137 static void IncrementLazyKeepaliveCount( |
| 138 ExtensionMessageService::MessagePort* port) { | 138 ExtensionMessageService::MessagePort* port) { |
| 139 Profile* profile = | 139 Profile* profile = |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 false, notify_other_port); | 423 false, notify_other_port); |
| 424 } | 424 } |
| 425 } | 425 } |
| 426 } | 426 } |
| 427 | 427 |
| 428 bool ExtensionMessageService::MaybeAddPendingOpenChannelTask( | 428 bool ExtensionMessageService::MaybeAddPendingOpenChannelTask( |
| 429 Profile* profile, | 429 Profile* profile, |
| 430 const OpenChannelParams& params) { | 430 const OpenChannelParams& params) { |
| 431 ExtensionService* service = profile->GetExtensionService(); | 431 ExtensionService* service = profile->GetExtensionService(); |
| 432 const std::string& extension_id = params.target_extension_id; | 432 const std::string& extension_id = params.target_extension_id; |
| 433 const Extension* extension = service->extensions()->GetByID(extension_id); | 433 const extensions::Extension* extension = service->extensions()->GetByID( |
| 434 extension_id); |
| 434 if (extension && extension->has_lazy_background_page()) { | 435 if (extension && extension->has_lazy_background_page()) { |
| 435 // If the extension uses spanning incognito mode, make sure we're always | 436 // If the extension uses spanning incognito mode, make sure we're always |
| 436 // using the original profile since that is what the extension process | 437 // using the original profile since that is what the extension process |
| 437 // will use. | 438 // will use. |
| 438 if (!extension->incognito_split_mode()) | 439 if (!extension->incognito_split_mode()) |
| 439 profile = profile->GetOriginalProfile(); | 440 profile = profile->GetOriginalProfile(); |
| 440 | 441 |
| 441 if (lazy_background_task_queue_->ShouldEnqueueTask(profile, extension)) { | 442 if (lazy_background_task_queue_->ShouldEnqueueTask(profile, extension)) { |
| 442 lazy_background_task_queue_->AddPendingTask(profile, extension_id, | 443 lazy_background_task_queue_->AddPendingTask(profile, extension_id, |
| 443 base::Bind(&ExtensionMessageService::PendingOpenChannel, | 444 base::Bind(&ExtensionMessageService::PendingOpenChannel, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 462 OpenChannelParams params = params_in; | 463 OpenChannelParams params = params_in; |
| 463 params.source = content::RenderProcessHost::FromID(source_process_id); | 464 params.source = content::RenderProcessHost::FromID(source_process_id); |
| 464 if (!params.source) | 465 if (!params.source) |
| 465 return; | 466 return; |
| 466 | 467 |
| 467 params.receiver = MessagePort(host->render_process_host(), | 468 params.receiver = MessagePort(host->render_process_host(), |
| 468 MSG_ROUTING_CONTROL, | 469 MSG_ROUTING_CONTROL, |
| 469 params.target_extension_id); | 470 params.target_extension_id); |
| 470 OpenChannelImpl(params); | 471 OpenChannelImpl(params); |
| 471 } | 472 } |
| OLD | NEW |