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

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

Issue 314113010: Remove deprecated permissions functions from Extension (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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"
(...skipping 23 matching lines...) Expand all
34 #include "extensions/browser/extension_util.h" 34 #include "extensions/browser/extension_util.h"
35 #include "extensions/browser/extensions_browser_client.h" 35 #include "extensions/browser/extensions_browser_client.h"
36 #include "extensions/browser/lazy_background_task_queue.h" 36 #include "extensions/browser/lazy_background_task_queue.h"
37 #include "extensions/browser/process_manager.h" 37 #include "extensions/browser/process_manager.h"
38 #include "extensions/common/extension.h" 38 #include "extensions/common/extension.h"
39 #include "extensions/common/extension_messages.h" 39 #include "extensions/common/extension_messages.h"
40 #include "extensions/common/manifest_constants.h" 40 #include "extensions/common/manifest_constants.h"
41 #include "extensions/common/manifest_handlers/background_info.h" 41 #include "extensions/common/manifest_handlers/background_info.h"
42 #include "extensions/common/manifest_handlers/externally_connectable.h" 42 #include "extensions/common/manifest_handlers/externally_connectable.h"
43 #include "extensions/common/manifest_handlers/incognito_info.h" 43 #include "extensions/common/manifest_handlers/incognito_info.h"
44 #include "extensions/common/permissions/permissions_data.h"
44 #include "net/base/completion_callback.h" 45 #include "net/base/completion_callback.h"
45 #include "url/gurl.h" 46 #include "url/gurl.h"
46 47
47 using content::BrowserContext; 48 using content::BrowserContext;
48 using content::SiteInstance; 49 using content::SiteInstance;
49 using content::WebContents; 50 using content::WebContents;
50 51
51 // Since we have 2 ports for every channel, we just index channels by half the 52 // Since we have 2 ports for every channel, we just index channels by half the
52 // port ID. 53 // port ID.
53 #define GET_CHANNEL_ID(port_id) ((port_id) / 2) 54 #define GET_CHANNEL_ID(port_id) ((port_id) / 2)
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 return; 362 return;
362 363
363 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) 364 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
364 Profile* profile = Profile::FromBrowserContext(source->GetBrowserContext()); 365 Profile* profile = Profile::FromBrowserContext(source->GetBrowserContext());
365 ExtensionService* extension_service = 366 ExtensionService* extension_service =
366 ExtensionSystem::Get(profile)->extension_service(); 367 ExtensionSystem::Get(profile)->extension_service();
367 bool has_permission = false; 368 bool has_permission = false;
368 if (extension_service) { 369 if (extension_service) {
369 const Extension* extension = 370 const Extension* extension =
370 extension_service->GetExtensionById(source_extension_id, false); 371 extension_service->GetExtensionById(source_extension_id, false);
371 has_permission = extension && extension->HasAPIPermission( 372 has_permission = extension &&
372 APIPermission::kNativeMessaging); 373 extension->permissions_data()->HasAPIPermission(
374 APIPermission::kNativeMessaging);
373 } 375 }
374 376
375 if (!has_permission) { 377 if (!has_permission) {
376 DispatchOnDisconnect(source, receiver_port_id, kMissingPermissionError); 378 DispatchOnDisconnect(source, receiver_port_id, kMissingPermissionError);
377 return; 379 return;
378 } 380 }
379 381
380 PrefService* pref_service = profile->GetPrefs(); 382 PrefService* pref_service = profile->GetPrefs();
381 383
382 // Verify that the host is not blocked by policies. 384 // Verify that the host is not blocked by policies.
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 } 766 }
765 767
766 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source, 768 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source,
767 int port_id, 769 int port_id,
768 const std::string& error_message) { 770 const std::string& error_message) {
769 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); 771 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, "");
770 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message); 772 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message);
771 } 773 }
772 774
773 } // namespace extensions 775 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698