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

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

Issue 25366003: Moved some functions off ExtensionService into a new file extension_util. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Windows compile Created 7 years, 2 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/native_message_port.h" 17 #include "chrome/browser/extensions/api/messaging/native_message_port.h"
18 #include "chrome/browser/extensions/extension_host.h" 18 #include "chrome/browser/extensions/extension_host.h"
19 #include "chrome/browser/extensions/extension_process_manager.h" 19 #include "chrome/browser/extensions/extension_process_manager.h"
20 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/extensions/extension_system.h" 21 #include "chrome/browser/extensions/extension_system.h"
22 #include "chrome/browser/extensions/extension_tab_util.h" 22 #include "chrome/browser/extensions/extension_tab_util.h"
23 #include "chrome/browser/extensions/extension_util.h"
23 #include "chrome/browser/extensions/lazy_background_task_queue.h" 24 #include "chrome/browser/extensions/lazy_background_task_queue.h"
24 #include "chrome/browser/extensions/process_map.h" 25 #include "chrome/browser/extensions/process_map.h"
25 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/tab_contents/tab_util.h" 27 #include "chrome/browser/tab_contents/tab_util.h"
27 #include "chrome/common/extensions/background_info.h" 28 #include "chrome/common/extensions/background_info.h"
28 #include "chrome/common/extensions/extension.h" 29 #include "chrome/common/extensions/extension.h"
29 #include "chrome/common/extensions/extension_messages.h" 30 #include "chrome/common/extensions/extension_messages.h"
30 #include "chrome/common/extensions/features/simple_feature.h" 31 #include "chrome/common/extensions/features/simple_feature.h"
31 #include "chrome/common/extensions/incognito_handler.h" 32 #include "chrome/common/extensions/incognito_handler.h"
32 #include "chrome/common/extensions/manifest_handlers/externally_connectable.h" 33 #include "chrome/common/extensions/manifest_handlers/externally_connectable.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 if (!target_extension) { 200 if (!target_extension) {
200 DispatchOnDisconnect( 201 DispatchOnDisconnect(
201 source, receiver_port_id, kReceivingEndDoesntExistError); 202 source, receiver_port_id, kReceivingEndDoesntExistError);
202 return; 203 return;
203 } 204 }
204 205
205 ExtensionService* extension_service = 206 ExtensionService* extension_service =
206 ExtensionSystem::Get(profile)->extension_service(); 207 ExtensionSystem::Get(profile)->extension_service();
207 208
208 if (profile->IsOffTheRecord() && 209 if (profile->IsOffTheRecord() &&
209 !extension_service->IsIncognitoEnabled(target_extension_id)) { 210 !extension_util::IsIncognitoEnabled(target_extension_id,
211 extension_service)) {
210 // Allow the security token apps (normal, dev) to be connectable from 212 // Allow the security token apps (normal, dev) to be connectable from
211 // incognito profiles. See http://crbug.com/295845. 213 // incognito profiles. See http://crbug.com/295845.
212 std::set<std::string> incognito_whitelist; 214 std::set<std::string> incognito_whitelist;
213 incognito_whitelist.insert("E4FCC42F7C7776C0985996DAED74F630C4F0A785"); 215 incognito_whitelist.insert("E4FCC42F7C7776C0985996DAED74F630C4F0A785");
214 incognito_whitelist.insert("D3D12919F7F00FE553E8A573AAA7147C51DD65C9"); 216 incognito_whitelist.insert("D3D12919F7F00FE553E8A573AAA7147C51DD65C9");
215 if (!extensions::SimpleFeature::IsIdInWhitelist(target_extension_id, 217 if (!extensions::SimpleFeature::IsIdInWhitelist(target_extension_id,
216 incognito_whitelist)) { 218 incognito_whitelist)) {
217 DispatchOnDisconnect( 219 DispatchOnDisconnect(
218 source, receiver_port_id, kReceivingEndDoesntExistError); 220 source, receiver_port_id, kReceivingEndDoesntExistError);
219 return; 221 return;
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 } 612 }
611 613
612 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source, 614 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source,
613 int port_id, 615 int port_id,
614 const std::string& error_message) { 616 const std::string& error_message) {
615 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); 617 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, "");
616 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message); 618 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message);
617 } 619 }
618 620
619 } // namespace extensions 621 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698