| 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 "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/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/extensions/api/messaging/extension_message_port.h" | 13 #include "chrome/browser/extensions/api/messaging/extension_message_port.h" |
| 14 #include "chrome/browser/extensions/api/messaging/native_message_port.h" | 14 #include "chrome/browser/extensions/api/messaging/native_message_port.h" |
| 15 #include "chrome/browser/extensions/extension_host.h" | 15 #include "chrome/browser/extensions/extension_host.h" |
| 16 #include "chrome/browser/extensions/extension_process_manager.h" | 16 #include "chrome/browser/extensions/extension_process_manager.h" |
| 17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/extensions/extension_system.h" | 18 #include "chrome/browser/extensions/extension_system.h" |
| 19 #include "chrome/browser/extensions/extension_tab_util.h" | 19 #include "chrome/browser/extensions/extension_tab_util.h" |
| 20 #include "chrome/browser/extensions/lazy_background_task_queue.h" | 20 #include "chrome/browser/extensions/lazy_background_task_queue.h" |
| 21 #include "chrome/browser/extensions/process_map.h" | 21 #include "chrome/browser/extensions/process_map.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/tab_contents/tab_util.h" | 23 #include "chrome/browser/tab_contents/tab_util.h" |
| 24 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
| 25 #include "chrome/common/extensions/background_info.h" |
| 25 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
| 26 #include "chrome/common/extensions/extension_messages.h" | 27 #include "chrome/common/extensions/extension_messages.h" |
| 27 #include "chrome/common/view_type.h" | 28 #include "chrome/common/view_type.h" |
| 28 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
| 29 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
| 30 #include "content/public/browser/render_process_host.h" | 31 #include "content/public/browser/render_process_host.h" |
| 31 #include "content/public/browser/render_view_host.h" | 32 #include "content/public/browser/render_view_host.h" |
| 32 #include "content/public/browser/site_instance.h" | 33 #include "content/public/browser/site_instance.h" |
| 33 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
| 34 | 35 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 } | 442 } |
| 442 } | 443 } |
| 443 } | 444 } |
| 444 | 445 |
| 445 bool MessageService::MaybeAddPendingOpenChannelTask( | 446 bool MessageService::MaybeAddPendingOpenChannelTask( |
| 446 Profile* profile, | 447 Profile* profile, |
| 447 OpenChannelParams* params) { | 448 OpenChannelParams* params) { |
| 448 ExtensionService* service = profile->GetExtensionService(); | 449 ExtensionService* service = profile->GetExtensionService(); |
| 449 const std::string& extension_id = params->target_extension_id; | 450 const std::string& extension_id = params->target_extension_id; |
| 450 const Extension* extension = service->extensions()->GetByID(extension_id); | 451 const Extension* extension = service->extensions()->GetByID(extension_id); |
| 451 if (extension && extension->has_lazy_background_page()) { | 452 if (extension && BackgroundInfo::HasLazyBackgroundPage(extension)) { |
| 452 // If the extension uses spanning incognito mode, make sure we're always | 453 // If the extension uses spanning incognito mode, make sure we're always |
| 453 // using the original profile since that is what the extension process | 454 // using the original profile since that is what the extension process |
| 454 // will use. | 455 // will use. |
| 455 if (!extension->incognito_split_mode()) | 456 if (!extension->incognito_split_mode()) |
| 456 profile = profile->GetOriginalProfile(); | 457 profile = profile->GetOriginalProfile(); |
| 457 | 458 |
| 458 if (lazy_background_task_queue_->ShouldEnqueueTask(profile, extension)) { | 459 if (lazy_background_task_queue_->ShouldEnqueueTask(profile, extension)) { |
| 459 pending_channels_[GET_CHANNEL_ID(params->receiver_port_id)] = | 460 pending_channels_[GET_CHANNEL_ID(params->receiver_port_id)] = |
| 460 PendingChannel(profile, extension_id); | 461 PendingChannel(profile, extension_id); |
| 461 scoped_ptr<OpenChannelParams> scoped_params(params); | 462 scoped_ptr<OpenChannelParams> scoped_params(params); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 483 return; | 484 return; |
| 484 | 485 |
| 485 params->source = source; | 486 params->source = source; |
| 486 params->receiver.reset(new ExtensionMessagePort(host->render_process_host(), | 487 params->receiver.reset(new ExtensionMessagePort(host->render_process_host(), |
| 487 MSG_ROUTING_CONTROL, | 488 MSG_ROUTING_CONTROL, |
| 488 params->target_extension_id)); | 489 params->target_extension_id)); |
| 489 OpenChannelImpl(params.Pass()); | 490 OpenChannelImpl(params.Pass()); |
| 490 } | 491 } |
| 491 | 492 |
| 492 } // namespace extensions | 493 } // namespace extensions |
| OLD | NEW |