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

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

Issue 10443105: Take 2 at implementing activeTab. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: many more tests Created 8 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/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"
(...skipping 22 matching lines...) Expand all
33 #include "chrome/renderer/extensions/extension_request_sender.h" 33 #include "chrome/renderer/extensions/extension_request_sender.h"
34 #include "chrome/renderer/extensions/file_browser_handler_custom_bindings.h" 34 #include "chrome/renderer/extensions/file_browser_handler_custom_bindings.h"
35 #include "chrome/renderer/extensions/file_browser_private_custom_bindings.h" 35 #include "chrome/renderer/extensions/file_browser_private_custom_bindings.h"
36 #include "chrome/renderer/extensions/i18n_custom_bindings.h" 36 #include "chrome/renderer/extensions/i18n_custom_bindings.h"
37 #include "chrome/renderer/extensions/media_gallery_custom_bindings.h" 37 #include "chrome/renderer/extensions/media_gallery_custom_bindings.h"
38 #include "chrome/renderer/extensions/miscellaneous_bindings.h" 38 #include "chrome/renderer/extensions/miscellaneous_bindings.h"
39 #include "chrome/renderer/extensions/page_actions_custom_bindings.h" 39 #include "chrome/renderer/extensions/page_actions_custom_bindings.h"
40 #include "chrome/renderer/extensions/page_capture_custom_bindings.h" 40 #include "chrome/renderer/extensions/page_capture_custom_bindings.h"
41 #include "chrome/renderer/extensions/send_request_natives.h" 41 #include "chrome/renderer/extensions/send_request_natives.h"
42 #include "chrome/renderer/extensions/set_icon_natives.h" 42 #include "chrome/renderer/extensions/set_icon_natives.h"
43 #include "chrome/renderer/extensions/tab_finder.h"
43 #include "chrome/renderer/extensions/tabs_custom_bindings.h" 44 #include "chrome/renderer/extensions/tabs_custom_bindings.h"
44 #include "chrome/renderer/extensions/tts_custom_bindings.h" 45 #include "chrome/renderer/extensions/tts_custom_bindings.h"
45 #include "chrome/renderer/extensions/user_script_slave.h" 46 #include "chrome/renderer/extensions/user_script_slave.h"
46 #include "chrome/renderer/extensions/web_request_custom_bindings.h" 47 #include "chrome/renderer/extensions/web_request_custom_bindings.h"
47 #include "chrome/renderer/extensions/webstore_bindings.h" 48 #include "chrome/renderer/extensions/webstore_bindings.h"
48 #include "chrome/renderer/module_system.h" 49 #include "chrome/renderer/module_system.h"
49 #include "chrome/renderer/native_handler.h" 50 #include "chrome/renderer/native_handler.h"
50 #include "chrome/renderer/resource_bundle_source_map.h" 51 #include "chrome/renderer/resource_bundle_source_map.h"
51 #include "content/public/renderer/render_thread.h" 52 #include "content/public/renderer/render_thread.h"
52 #include "content/public/renderer/render_view.h" 53 #include "content/public/renderer/render_view.h"
(...skipping 12 matching lines...) Expand all
65 66
66 using WebKit::WebDataSource; 67 using WebKit::WebDataSource;
67 using WebKit::WebDocument; 68 using WebKit::WebDocument;
68 using WebKit::WebFrame; 69 using WebKit::WebFrame;
69 using WebKit::WebScopedUserGesture; 70 using WebKit::WebScopedUserGesture;
70 using WebKit::WebSecurityPolicy; 71 using WebKit::WebSecurityPolicy;
71 using WebKit::WebString; 72 using WebKit::WebString;
72 using WebKit::WebVector; 73 using WebKit::WebVector;
73 using WebKit::WebView; 74 using WebKit::WebView;
74 using content::RenderThread; 75 using content::RenderThread;
76 using content::RenderView;
75 using extensions::ApiDefinitionsNatives; 77 using extensions::ApiDefinitionsNatives;
76 using extensions::AppWindowCustomBindings; 78 using extensions::AppWindowCustomBindings;
77 using extensions::ContextMenusCustomBindings; 79 using extensions::ContextMenusCustomBindings;
78 using extensions::Extension; 80 using extensions::Extension;
79 using extensions::ExperimentalAppCustomBindings; 81 using extensions::ExperimentalAppCustomBindings;
80 using extensions::ExperimentalUsbCustomBindings; 82 using extensions::ExperimentalUsbCustomBindings;
81 using extensions::ExtensionAPI; 83 using extensions::ExtensionAPI;
82 using extensions::ExtensionCustomBindings; 84 using extensions::ExtensionCustomBindings;
83 using extensions::Feature; 85 using extensions::Feature;
84 using extensions::FileBrowserHandlerCustomBindings; 86 using extensions::FileBrowserHandlerCustomBindings;
85 using extensions::FileBrowserPrivateCustomBindings; 87 using extensions::FileBrowserPrivateCustomBindings;
86 using extensions::I18NCustomBindings; 88 using extensions::I18NCustomBindings;
87 using extensions::MiscellaneousBindings; 89 using extensions::MiscellaneousBindings;
88 using extensions::MediaGalleryCustomBindings; 90 using extensions::MediaGalleryCustomBindings;
89 using extensions::PageActionsCustomBindings; 91 using extensions::PageActionsCustomBindings;
90 using extensions::PageCaptureCustomBindings; 92 using extensions::PageCaptureCustomBindings;
91 using extensions::SendRequestNatives; 93 using extensions::SendRequestNatives;
92 using extensions::SetIconNatives; 94 using extensions::SetIconNatives;
93 using extensions::TTSCustomBindings; 95 using extensions::TTSCustomBindings;
96 using extensions::TabFinder;
94 using extensions::TabsCustomBindings; 97 using extensions::TabsCustomBindings;
95 using extensions::UpdatedExtensionPermissionsInfo; 98 using extensions::UpdatedExtensionPermissionsInfo;
96 using extensions::WebRequestCustomBindings; 99 using extensions::WebRequestCustomBindings;
97 100
98 namespace { 101 namespace {
99 102
100 static const int64 kInitialExtensionIdleHandlerDelayMs = 5*1000; 103 static const int64 kInitialExtensionIdleHandlerDelayMs = 5*1000;
101 static const int64 kMaxExtensionIdleHandlerDelayMs = 5*60*1000; 104 static const int64 kMaxExtensionIdleHandlerDelayMs = 5*60*1000;
102 static const char kEventDispatchFunction[] = "Event.dispatchJSON"; 105 static const char kEventDispatchFunction[] = "Event.dispatchJSON";
103 static const char kOnUnloadEvent[] = "runtime.onBackgroundPageUnloadingSoon"; 106 static const char kOnUnloadEvent[] = "runtime.onBackgroundPageUnloadingSoon";
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 RouteFunction("DecrementKeepaliveCount", 149 RouteFunction("DecrementKeepaliveCount",
147 base::Bind(&LazyBackgroundPageNativeHandler::DecrementKeepaliveCount, 150 base::Bind(&LazyBackgroundPageNativeHandler::DecrementKeepaliveCount,
148 base::Unretained(this))); 151 base::Unretained(this)));
149 } 152 }
150 153
151 v8::Handle<v8::Value> IncrementKeepaliveCount(const v8::Arguments& args) { 154 v8::Handle<v8::Value> IncrementKeepaliveCount(const v8::Arguments& args) {
152 ChromeV8Context* context = 155 ChromeV8Context* context =
153 extension_dispatcher()->v8_context_set().GetCurrent(); 156 extension_dispatcher()->v8_context_set().GetCurrent();
154 if (!context) 157 if (!context)
155 return v8::Undefined(); 158 return v8::Undefined();
156 content::RenderView* render_view = context->GetRenderView(); 159 RenderView* render_view = context->GetRenderView();
157 if (IsContextLazyBackgroundPage(render_view, context->extension())) { 160 if (IsContextLazyBackgroundPage(render_view, context->extension())) {
158 render_view->Send(new ExtensionHostMsg_IncrementLazyKeepaliveCount( 161 render_view->Send(new ExtensionHostMsg_IncrementLazyKeepaliveCount(
159 render_view->GetRoutingID())); 162 render_view->GetRoutingID()));
160 } 163 }
161 return v8::Undefined(); 164 return v8::Undefined();
162 } 165 }
163 166
164 v8::Handle<v8::Value> DecrementKeepaliveCount(const v8::Arguments& args) { 167 v8::Handle<v8::Value> DecrementKeepaliveCount(const v8::Arguments& args) {
165 ChromeV8Context* context = 168 ChromeV8Context* context =
166 extension_dispatcher()->v8_context_set().GetCurrent(); 169 extension_dispatcher()->v8_context_set().GetCurrent();
167 if (!context) 170 if (!context)
168 return v8::Undefined(); 171 return v8::Undefined();
169 content::RenderView* render_view = context->GetRenderView(); 172 RenderView* render_view = context->GetRenderView();
170 if (IsContextLazyBackgroundPage(render_view, context->extension())) { 173 if (IsContextLazyBackgroundPage(render_view, context->extension())) {
171 render_view->Send(new ExtensionHostMsg_DecrementLazyKeepaliveCount( 174 render_view->Send(new ExtensionHostMsg_DecrementLazyKeepaliveCount(
172 render_view->GetRoutingID())); 175 render_view->GetRoutingID()));
173 } 176 }
174 return v8::Undefined(); 177 return v8::Undefined();
175 } 178 }
176 179
177 private: 180 private:
178 bool IsContextLazyBackgroundPage(content::RenderView* render_view, 181 bool IsContextLazyBackgroundPage(RenderView* render_view,
179 const Extension* extension) { 182 const Extension* extension) {
180 if (!render_view) 183 if (!render_view)
181 return false; 184 return false;
182 185
183 ExtensionHelper* helper = ExtensionHelper::Get(render_view); 186 ExtensionHelper* helper = ExtensionHelper::Get(render_view);
184 return (extension && extension->has_lazy_background_page() && 187 return (extension && extension->has_lazy_background_page() &&
185 helper->view_type() == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); 188 helper->view_type() == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE);
186 } 189 }
187 }; 190 };
188 191
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 IPC_MESSAGE_HANDLER(ExtensionMsg_DeliverMessage, OnDeliverMessage) 261 IPC_MESSAGE_HANDLER(ExtensionMsg_DeliverMessage, OnDeliverMessage)
259 IPC_MESSAGE_HANDLER(ExtensionMsg_DispatchOnDisconnect, 262 IPC_MESSAGE_HANDLER(ExtensionMsg_DispatchOnDisconnect,
260 OnDispatchOnDisconnect) 263 OnDispatchOnDisconnect)
261 IPC_MESSAGE_HANDLER(ExtensionMsg_SetFunctionNames, OnSetFunctionNames) 264 IPC_MESSAGE_HANDLER(ExtensionMsg_SetFunctionNames, OnSetFunctionNames)
262 IPC_MESSAGE_HANDLER(ExtensionMsg_Loaded, OnLoaded) 265 IPC_MESSAGE_HANDLER(ExtensionMsg_Loaded, OnLoaded)
263 IPC_MESSAGE_HANDLER(ExtensionMsg_Unloaded, OnUnloaded) 266 IPC_MESSAGE_HANDLER(ExtensionMsg_Unloaded, OnUnloaded)
264 IPC_MESSAGE_HANDLER(ExtensionMsg_SetScriptingWhitelist, 267 IPC_MESSAGE_HANDLER(ExtensionMsg_SetScriptingWhitelist,
265 OnSetScriptingWhitelist) 268 OnSetScriptingWhitelist)
266 IPC_MESSAGE_HANDLER(ExtensionMsg_ActivateExtension, OnActivateExtension) 269 IPC_MESSAGE_HANDLER(ExtensionMsg_ActivateExtension, OnActivateExtension)
267 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdatePermissions, OnUpdatePermissions) 270 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdatePermissions, OnUpdatePermissions)
271 IPC_MESSAGE_HANDLER(ExtensionMsg_SetTabSpecificPermissions,
272 OnSetTabSpecificPermissions)
273 IPC_MESSAGE_HANDLER(ExtensionMsg_ClearTabSpecificPermissions,
274 OnClearTabSpecificPermissions)
268 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateUserScripts, OnUpdateUserScripts) 275 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateUserScripts, OnUpdateUserScripts)
269 IPC_MESSAGE_HANDLER(ExtensionMsg_UsingWebRequestAPI, OnUsingWebRequestAPI) 276 IPC_MESSAGE_HANDLER(ExtensionMsg_UsingWebRequestAPI, OnUsingWebRequestAPI)
270 IPC_MESSAGE_HANDLER(ExtensionMsg_ShouldUnload, OnShouldUnload) 277 IPC_MESSAGE_HANDLER(ExtensionMsg_ShouldUnload, OnShouldUnload)
271 IPC_MESSAGE_HANDLER(ExtensionMsg_Unload, OnUnload) 278 IPC_MESSAGE_HANDLER(ExtensionMsg_Unload, OnUnload)
272 IPC_MESSAGE_UNHANDLED(handled = false) 279 IPC_MESSAGE_UNHANDLED(handled = false)
273 IPC_END_MESSAGE_MAP() 280 IPC_END_MESSAGE_MAP()
274 281
275 return handled; 282 return handled;
276 } 283 }
277 284
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 if (is_extension_process_) { 346 if (is_extension_process_) {
340 RenderThread::Get()->ScheduleIdleHandler( 347 RenderThread::Get()->ScheduleIdleHandler(
341 kInitialExtensionIdleHandlerDelayMs); 348 kInitialExtensionIdleHandlerDelayMs);
342 } 349 }
343 350
344 // Tell the browser process when an event has been dispatched with a lazy 351 // Tell the browser process when an event has been dispatched with a lazy
345 // background page active. 352 // background page active.
346 const Extension* extension = extensions_.GetByID(extension_id); 353 const Extension* extension = extensions_.GetByID(extension_id);
347 if (extension && extension->has_lazy_background_page() && 354 if (extension && extension->has_lazy_background_page() &&
348 function_name == kEventDispatchFunction) { 355 function_name == kEventDispatchFunction) {
349 content::RenderView* background_view = 356 RenderView* background_view =
350 ExtensionHelper::GetBackgroundPage(extension_id); 357 ExtensionHelper::GetBackgroundPage(extension_id);
351 if (background_view) { 358 if (background_view) {
352 background_view->Send(new ExtensionHostMsg_EventAck( 359 background_view->Send(new ExtensionHostMsg_EventAck(
353 background_view->GetRoutingID())); 360 background_view->GetRoutingID()));
354 } 361 }
355 } 362 }
356 } 363 }
357 364
358 void ExtensionDispatcher::OnDispatchOnConnect( 365 void ExtensionDispatcher::OnDispatchOnConnect(
359 int target_port_id, 366 int target_port_id,
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 // whitelist entries need to be updated when the kManagement permission 776 // whitelist entries need to be updated when the kManagement permission
770 // changes. 777 // changes.
771 if (extension->HasAPIPermission(ExtensionAPIPermission::kManagement)) { 778 if (extension->HasAPIPermission(ExtensionAPIPermission::kManagement)) {
772 WebSecurityPolicy::addOriginAccessWhitelistEntry( 779 WebSecurityPolicy::addOriginAccessWhitelistEntry(
773 extension->url(), 780 extension->url(),
774 WebString::fromUTF8(chrome::kChromeUIScheme), 781 WebString::fromUTF8(chrome::kChromeUIScheme),
775 WebString::fromUTF8(chrome::kChromeUIExtensionIconHost), 782 WebString::fromUTF8(chrome::kChromeUIExtensionIconHost),
776 false); 783 false);
777 } 784 }
778 785
779 UpdateOriginPermissions(UpdatedExtensionPermissionsInfo::ADDED, 786 AddOrRemoveOriginPermissions(
780 extension, 787 UpdatedExtensionPermissionsInfo::ADDED,
781 extension->GetActivePermissions()->explicit_hosts()); 788 extension,
789 *extension->GetActiveHostPermissionsForAllTabs());
782 } 790 }
783 791
784 void ExtensionDispatcher::UpdateOriginPermissions( 792 void ExtensionDispatcher::AddOrRemoveOriginPermissions(
785 UpdatedExtensionPermissionsInfo::Reason reason, 793 UpdatedExtensionPermissionsInfo::Reason reason,
786 const Extension* extension, 794 const Extension* extension,
787 const URLPatternSet& origins) { 795 const URLPatternSet& origins) {
788 for (URLPatternSet::const_iterator i = origins.begin(); 796 for (URLPatternSet::const_iterator i = origins.begin();
789 i != origins.end(); ++i) { 797 i != origins.end(); ++i) {
790 const char* schemes[] = { 798 const char* schemes[] = {
791 chrome::kHttpScheme, 799 chrome::kHttpScheme,
792 chrome::kHttpsScheme, 800 chrome::kHttpsScheme,
793 chrome::kFileScheme, 801 chrome::kFileScheme,
794 chrome::kChromeUIScheme, 802 chrome::kChromeUIScheme,
(...skipping 15 matching lines...) Expand all
810 void ExtensionDispatcher::OnUpdatePermissions( 818 void ExtensionDispatcher::OnUpdatePermissions(
811 int reason_id, 819 int reason_id,
812 const std::string& extension_id, 820 const std::string& extension_id,
813 const ExtensionAPIPermissionSet& apis, 821 const ExtensionAPIPermissionSet& apis,
814 const URLPatternSet& explicit_hosts, 822 const URLPatternSet& explicit_hosts,
815 const URLPatternSet& scriptable_hosts) { 823 const URLPatternSet& scriptable_hosts) {
816 const Extension* extension = extensions_.GetByID(extension_id); 824 const Extension* extension = extensions_.GetByID(extension_id);
817 if (!extension) 825 if (!extension)
818 return; 826 return;
819 827
828 // General permissions.
820 scoped_refptr<const ExtensionPermissionSet> delta = 829 scoped_refptr<const ExtensionPermissionSet> delta =
821 new ExtensionPermissionSet(apis, explicit_hosts, scriptable_hosts); 830 new ExtensionPermissionSet(apis, explicit_hosts, scriptable_hosts);
822 scoped_refptr<const ExtensionPermissionSet> old_active = 831 scoped_refptr<const ExtensionPermissionSet> old_active =
823 extension->GetActivePermissions(); 832 extension->GetActivePermissions();
824 UpdatedExtensionPermissionsInfo::Reason reason = 833 UpdatedExtensionPermissionsInfo::Reason reason =
825 static_cast<UpdatedExtensionPermissionsInfo::Reason>(reason_id); 834 static_cast<UpdatedExtensionPermissionsInfo::Reason>(reason_id);
826 835
827 const ExtensionPermissionSet* new_active = NULL; 836 const ExtensionPermissionSet* new_active = NULL;
828 if (reason == UpdatedExtensionPermissionsInfo::ADDED) { 837 switch (reason) {
829 new_active = ExtensionPermissionSet::CreateUnion(old_active, delta); 838 case UpdatedExtensionPermissionsInfo::ADDED:
830 } else { 839 new_active = ExtensionPermissionSet::CreateUnion(old_active, delta);
831 CHECK_EQ(UpdatedExtensionPermissionsInfo::REMOVED, reason); 840 break;
832 new_active = ExtensionPermissionSet::CreateDifference(old_active, delta); 841 case UpdatedExtensionPermissionsInfo::REMOVED:
Aaron Boodman 2012/06/08 05:31:30 default: NOTREACHED() or CHECK(false)
not at google - send to devlin 2012/06/12 20:40:51 clang catches missing enum branches as a compile e
842 new_active = ExtensionPermissionSet::CreateDifference(old_active, delta);
843 break;
833 } 844 }
834 845
846 URLPatternSet active_hosts_before =
847 *extension->GetActiveHostPermissionsForAllTabs();
848
835 extension->SetActivePermissions(new_active); 849 extension->SetActivePermissions(new_active);
836 UpdateOriginPermissions(reason, extension, explicit_hosts); 850
851 // Host permissions. These are different from the general permissions because
852 // they need to take into account the additional host permissions granted via
853 // the activeTab permission for various tabs.
854 URLPatternSet added_or_removed;
855 switch (reason) {
856 case UpdatedExtensionPermissionsInfo::ADDED:
857 URLPatternSet::CreateDifference(
858 *extension->GetActiveHostPermissionsForAllTabs(),
859 active_hosts_before,
860 &added_or_removed);
861 break;
862 case UpdatedExtensionPermissionsInfo::REMOVED:
863 URLPatternSet::CreateDifference(
864 active_hosts_before,
865 *extension->GetActiveHostPermissionsForAllTabs(),
866 &added_or_removed);
867 break;
868 }
869
870 AddOrRemoveOriginPermissions(reason, extension, added_or_removed);
871 }
872
873 void ExtensionDispatcher::OnSetTabSpecificPermissions(
874 int page_id,
875 int tab_id,
876 const std::string& extension_id,
877 const URLPatternSet& origin_set) {
878 // If this renderer contains the target tab then check against page_id to
Aaron Boodman 2012/06/08 05:31:30 If we were keeping this code, probably the cleaner
not at google - send to devlin 2012/06/12 20:40:51 Yeah, we discussed this, but I'll write some of it
879 // avoid race conditions. The target tab is a more sensitive target since it
880 // has the opportunity to block executeScript calls. It would be nice to also
881 // check it on other renderers, but this obviously isn't possible.
882 RenderView* view = TabFinder::Find(tab_id);
883 if (view && view->GetPageId() != page_id) {
884 LOG(WARNING) <<
885 "Wrong page ID, wanted " << page_id << " but was " << view->GetPageId();
not at google - send to devlin 2012/06/07 08:49:22 (Also removed this logging).
886 return;
887 }
888
889 const Extension* extension = extensions_.GetByID(extension_id);
890 if (!extension)
891 return;
892
893 URLPatternSet before = *extension->GetActiveHostPermissionsForAllTabs();
894
895 extension->SetTabSpecificHostPermissions(tab_id, origin_set);
896
897 // The origin permissions for XHR include the the union of host permissions
898 // for all tabs, granted via the activeTab permission.
899 URLPatternSet added;
900 URLPatternSet::CreateDifference(
901 *extension->GetActiveHostPermissionsForAllTabs(),
902 before,
903 &added);
904 AddOrRemoveOriginPermissions(UpdatedExtensionPermissionsInfo::ADDED,
905 extension,
906 added);
907 }
908
909 void ExtensionDispatcher::OnClearTabSpecificPermissions(
910 int tab_id,
911 const std::vector<std::string>& extension_ids) {
912 for (std::vector<std::string>::const_iterator it = extension_ids.begin();
913 it != extension_ids.end(); ++it) {
914 const Extension* extension = extensions_.GetByID(*it);
915 if (!extension)
916 continue;
917
918 URLPatternSet before = *extension->GetActiveHostPermissionsForAllTabs();
919
920 extension->ClearTabSpecificHostPermissions(tab_id);
921
922 // The origin permissions for XHR include the the union of host permissions
923 // for all tabs, granted via the activeTab permission.
924 URLPatternSet removed;
925 URLPatternSet::CreateDifference(
926 before,
927 *extension->GetActiveHostPermissionsForAllTabs(),
928 &removed);
929 AddOrRemoveOriginPermissions(UpdatedExtensionPermissionsInfo::REMOVED,
930 extension,
931 removed);
932 }
837 } 933 }
838 934
839 void ExtensionDispatcher::OnUpdateUserScripts( 935 void ExtensionDispatcher::OnUpdateUserScripts(
840 base::SharedMemoryHandle scripts) { 936 base::SharedMemoryHandle scripts) {
841 DCHECK(base::SharedMemory::IsHandleValid(scripts)) << "Bad scripts handle"; 937 DCHECK(base::SharedMemory::IsHandleValid(scripts)) << "Bad scripts handle";
842 user_script_slave_->UpdateScripts(scripts); 938 user_script_slave_->UpdateScripts(scripts);
843 UpdateActiveExtensions(); 939 UpdateActiveExtensions();
844 } 940 }
845 941
846 void ExtensionDispatcher::UpdateActiveExtensions() { 942 void ExtensionDispatcher::UpdateActiveExtensions() {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 // APIs, they don't get extension bindings injected. If we end up here it 1054 // APIs, they don't get extension bindings injected. If we end up here it
959 // means that a sandboxed page somehow managed to invoke an API anyway, so 1055 // means that a sandboxed page somehow managed to invoke an API anyway, so
960 // we should abort. 1056 // we should abort.
961 WebKit::WebFrame* frame = context->web_frame(); 1057 WebKit::WebFrame* frame = context->web_frame();
962 ExtensionURLInfo url_info(frame->document().securityOrigin(), 1058 ExtensionURLInfo url_info(frame->document().securityOrigin(),
963 UserScriptSlave::GetDataSourceURLForFrame(frame)); 1059 UserScriptSlave::GetDataSourceURLForFrame(frame));
964 CHECK(!extensions_.IsSandboxedPage(url_info)); 1060 CHECK(!extensions_.IsSandboxedPage(url_info));
965 1061
966 return true; 1062 return true;
967 } 1063 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698