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

Side by Side Diff: chrome/renderer/extensions/extension_dispatcher.cc

Issue 10649003: Move each permission classes to its own files in extensions/permissions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase on HEAD Created 8 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
« no previous file with comments | « chrome/renderer/extensions/extension_dispatcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/extensions/extension_dispatcher.h" 5 #include "chrome/renderer/extensions/extension_dispatcher.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
11 #include "chrome/common/child_process_logging.h" 11 #include "chrome/common/child_process_logging.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/chrome_version_info.h" 13 #include "chrome/common/chrome_version_info.h"
14 #include "chrome/common/extensions/api/extension_api.h" 14 #include "chrome/common/extensions/api/extension_api.h"
15 #include "chrome/common/extensions/extension.h" 15 #include "chrome/common/extensions/extension.h"
16 #include "chrome/common/extensions/extension_messages.h" 16 #include "chrome/common/extensions/extension_messages.h"
17 #include "chrome/common/extensions/extension_permission_set.h" 17 #include "chrome/common/extensions/permissions/permission_set.h"
18 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
19 #include "chrome/common/view_type.h" 19 #include "chrome/common/view_type.h"
20 #include "chrome/renderer/chrome_render_process_observer.h" 20 #include "chrome/renderer/chrome_render_process_observer.h"
21 #include "chrome/renderer/extensions/api_definitions_natives.h" 21 #include "chrome/renderer/extensions/api_definitions_natives.h"
22 #include "chrome/renderer/extensions/app_bindings.h" 22 #include "chrome/renderer/extensions/app_bindings.h"
23 #include "chrome/renderer/extensions/app_window_custom_bindings.h" 23 #include "chrome/renderer/extensions/app_window_custom_bindings.h"
24 #include "chrome/renderer/extensions/chrome_v8_context.h" 24 #include "chrome/renderer/extensions/chrome_v8_context.h"
25 #include "chrome/renderer/extensions/chrome_v8_extension.h" 25 #include "chrome/renderer/extensions/chrome_v8_extension.h"
26 #include "chrome/renderer/extensions/context_menus_custom_bindings.h" 26 #include "chrome/renderer/extensions/context_menus_custom_bindings.h"
27 #include "chrome/renderer/extensions/event_bindings.h" 27 #include "chrome/renderer/extensions/event_bindings.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 using extensions::ExtensionCustomBindings; 85 using extensions::ExtensionCustomBindings;
86 using extensions::Feature; 86 using extensions::Feature;
87 using extensions::FileBrowserHandlerCustomBindings; 87 using extensions::FileBrowserHandlerCustomBindings;
88 using extensions::FileBrowserPrivateCustomBindings; 88 using extensions::FileBrowserPrivateCustomBindings;
89 using extensions::FileSystemNatives; 89 using extensions::FileSystemNatives;
90 using extensions::I18NCustomBindings; 90 using extensions::I18NCustomBindings;
91 using extensions::MiscellaneousBindings; 91 using extensions::MiscellaneousBindings;
92 using extensions::MediaGalleryCustomBindings; 92 using extensions::MediaGalleryCustomBindings;
93 using extensions::PageActionsCustomBindings; 93 using extensions::PageActionsCustomBindings;
94 using extensions::PageCaptureCustomBindings; 94 using extensions::PageCaptureCustomBindings;
95 using extensions::PermissionSet;
95 using extensions::SendRequestNatives; 96 using extensions::SendRequestNatives;
96 using extensions::SetIconNatives; 97 using extensions::SetIconNatives;
97 using extensions::TTSCustomBindings; 98 using extensions::TTSCustomBindings;
98 using extensions::TabFinder; 99 using extensions::TabFinder;
99 using extensions::TabsCustomBindings; 100 using extensions::TabsCustomBindings;
100 using extensions::UpdatedExtensionPermissionsInfo; 101 using extensions::UpdatedExtensionPermissionsInfo;
101 using extensions::WebRequestCustomBindings; 102 using extensions::WebRequestCustomBindings;
102 103
103 namespace { 104 namespace {
104 105
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 return; 784 return;
784 785
785 if (is_webkit_initialized_) 786 if (is_webkit_initialized_)
786 InitOriginPermissions(extension); 787 InitOriginPermissions(extension);
787 } 788 }
788 789
789 void ExtensionDispatcher::InitOriginPermissions(const Extension* extension) { 790 void ExtensionDispatcher::InitOriginPermissions(const Extension* extension) {
790 // TODO(jstritar): We should try to remove this special case. Also, these 791 // TODO(jstritar): We should try to remove this special case. Also, these
791 // whitelist entries need to be updated when the kManagement permission 792 // whitelist entries need to be updated when the kManagement permission
792 // changes. 793 // changes.
793 if (extension->HasAPIPermission(ExtensionAPIPermission::kManagement)) { 794 if (extension->HasAPIPermission(APIPermission::kManagement)) {
794 WebSecurityPolicy::addOriginAccessWhitelistEntry( 795 WebSecurityPolicy::addOriginAccessWhitelistEntry(
795 extension->url(), 796 extension->url(),
796 WebString::fromUTF8(chrome::kChromeUIScheme), 797 WebString::fromUTF8(chrome::kChromeUIScheme),
797 WebString::fromUTF8(chrome::kChromeUIExtensionIconHost), 798 WebString::fromUTF8(chrome::kChromeUIExtensionIconHost),
798 false); 799 false);
799 } 800 }
800 801
801 AddOrRemoveOriginPermissions( 802 AddOrRemoveOriginPermissions(
802 UpdatedExtensionPermissionsInfo::ADDED, 803 UpdatedExtensionPermissionsInfo::ADDED,
803 extension, 804 extension,
(...skipping 22 matching lines...) Expand all
826 WebString::fromUTF8(i->host()), 827 WebString::fromUTF8(i->host()),
827 i->match_subdomains()); 828 i->match_subdomains());
828 } 829 }
829 } 830 }
830 } 831 }
831 } 832 }
832 833
833 void ExtensionDispatcher::OnUpdatePermissions( 834 void ExtensionDispatcher::OnUpdatePermissions(
834 int reason_id, 835 int reason_id,
835 const std::string& extension_id, 836 const std::string& extension_id,
836 const ExtensionAPIPermissionSet& apis, 837 const APIPermissionSet& apis,
837 const URLPatternSet& explicit_hosts, 838 const URLPatternSet& explicit_hosts,
838 const URLPatternSet& scriptable_hosts) { 839 const URLPatternSet& scriptable_hosts) {
839 const Extension* extension = extensions_.GetByID(extension_id); 840 const Extension* extension = extensions_.GetByID(extension_id);
840 if (!extension) 841 if (!extension)
841 return; 842 return;
842 843
843 scoped_refptr<const ExtensionPermissionSet> delta = 844 scoped_refptr<const PermissionSet> delta =
844 new ExtensionPermissionSet(apis, explicit_hosts, scriptable_hosts); 845 new PermissionSet(apis, explicit_hosts, scriptable_hosts);
845 scoped_refptr<const ExtensionPermissionSet> old_active = 846 scoped_refptr<const PermissionSet> old_active =
846 extension->GetActivePermissions(); 847 extension->GetActivePermissions();
847 UpdatedExtensionPermissionsInfo::Reason reason = 848 UpdatedExtensionPermissionsInfo::Reason reason =
848 static_cast<UpdatedExtensionPermissionsInfo::Reason>(reason_id); 849 static_cast<UpdatedExtensionPermissionsInfo::Reason>(reason_id);
849 850
850 const ExtensionPermissionSet* new_active = NULL; 851 const PermissionSet* new_active = NULL;
851 switch (reason) { 852 switch (reason) {
852 case UpdatedExtensionPermissionsInfo::ADDED: 853 case UpdatedExtensionPermissionsInfo::ADDED:
853 new_active = ExtensionPermissionSet::CreateUnion(old_active, delta); 854 new_active = PermissionSet::CreateUnion(old_active, delta);
854 break; 855 break;
855 case UpdatedExtensionPermissionsInfo::REMOVED: 856 case UpdatedExtensionPermissionsInfo::REMOVED:
856 new_active = ExtensionPermissionSet::CreateDifference(old_active, delta); 857 new_active = PermissionSet::CreateDifference(old_active, delta);
857 break; 858 break;
858 } 859 }
859 860
860 extension->SetActivePermissions(new_active); 861 extension->SetActivePermissions(new_active);
861 AddOrRemoveOriginPermissions(reason, extension, explicit_hosts); 862 AddOrRemoveOriginPermissions(reason, extension, explicit_hosts);
862 } 863 }
863 864
864 void ExtensionDispatcher::OnUpdateTabSpecificPermissions( 865 void ExtensionDispatcher::OnUpdateTabSpecificPermissions(
865 int page_id, 866 int page_id,
866 int tab_id, 867 int tab_id,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 // APIs, they don't get extension bindings injected. If we end up here it 1016 // APIs, they don't get extension bindings injected. If we end up here it
1016 // means that a sandboxed page somehow managed to invoke an API anyway, so 1017 // means that a sandboxed page somehow managed to invoke an API anyway, so
1017 // we should abort. 1018 // we should abort.
1018 WebKit::WebFrame* frame = context->web_frame(); 1019 WebKit::WebFrame* frame = context->web_frame();
1019 ExtensionURLInfo url_info(frame->document().securityOrigin(), 1020 ExtensionURLInfo url_info(frame->document().securityOrigin(),
1020 UserScriptSlave::GetDataSourceURLForFrame(frame)); 1021 UserScriptSlave::GetDataSourceURLForFrame(frame));
1021 CHECK(!extensions_.IsSandboxedPage(url_info)); 1022 CHECK(!extensions_.IsSandboxedPage(url_info));
1022 1023
1023 return true; 1024 return true;
1024 } 1025 }
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698