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/renderer/extensions/dispatcher.h" | 5 #include "chrome/renderer/extensions/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/debug/alias.h" | 9 #include "base/debug/alias.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
693 const std::string& v8_extension_name, | 693 const std::string& v8_extension_name, |
694 int extension_group, | 694 int extension_group, |
695 int world_id) { | 695 int world_id) { |
696 g_hack_extension_group = extension_group; | 696 g_hack_extension_group = extension_group; |
697 return true; | 697 return true; |
698 } | 698 } |
699 | 699 |
700 v8::Handle<v8::Object> Dispatcher::GetOrCreateObject( | 700 v8::Handle<v8::Object> Dispatcher::GetOrCreateObject( |
701 v8::Handle<v8::Object> object, | 701 v8::Handle<v8::Object> object, |
702 const std::string& field) { | 702 const std::string& field) { |
703 v8::HandleScope handle_scope; | 703 v8::HandleScope handle_scope; |
not at google - send to devlin
2013/06/05 19:03:44
we shuold remove the handle scope here, misleading
cduvall
2013/06/05 23:27:59
Done.
| |
704 v8::Handle<v8::String> key = v8::String::New(field.c_str()); | 704 v8::Handle<v8::String> key = v8::String::New(field.c_str()); |
705 // If the object has a callback property, it is assumed it is an unavailable | 705 // If the object has a callback property, it is assumed it is an unavailable |
706 // API, so it is safe to delete. This is checked before GetOrCreateObject is | 706 // API, so it is safe to delete. This is checked before GetOrCreateObject is |
707 // called. | 707 // called. |
708 if (object->HasRealNamedCallbackProperty(key)) { | 708 if (object->HasRealNamedCallbackProperty(key)) { |
709 object->Delete(key); | 709 object->Delete(key); |
710 } else if (object->HasRealNamedProperty(key)) { | 710 } else if (object->HasRealNamedProperty(key)) { |
711 v8::Handle<v8::Value> value = object->Get(key); | 711 v8::Handle<v8::Value> value = object->Get(key); |
712 CHECK(value->IsObject()); | 712 CHECK(value->IsObject()); |
713 return handle_scope.Close(v8::Handle<v8::Object>::Cast(value)); | 713 return handle_scope.Close(v8::Handle<v8::Object>::Cast(value)); |
714 } | 714 } |
715 | 715 |
716 v8::Handle<v8::Object> new_object = v8::Object::New(); | 716 v8::Handle<v8::Object> new_object = v8::Object::New(); |
717 object->Set(key, new_object); | 717 object->Set(key, new_object); |
718 return handle_scope.Close(new_object); | 718 return handle_scope.Close(new_object); |
719 } | 719 } |
720 | 720 |
721 void Dispatcher::RegisterSchemaGeneratedBindings( | 721 void Dispatcher::AddOrRemoveBindings(ChromeV8Context* context) { |
722 ModuleSystem* module_system, | 722 v8::HandleScope handle_scope; |
723 ChromeV8Context* context) { | 723 v8::Context::Scope(context->v8_context()); |
not at google - send to devlin
2013/06/05 19:03:44
nit: new line after the scope declarations make it
cduvall
2013/06/05 23:27:59
Done.
cduvall
2013/06/06 00:01:41
Strangely, if I take out the v8::Context::Scope, a
cduvall
2013/06/06 00:33:42
Wow, looks like I'm a dummy. This line should be:
| |
724 std::set<std::string> apis = | 724 std::set<std::string> apis = |
725 ExtensionAPI::GetSharedInstance()->GetAllAPINames(); | 725 ExtensionAPI::GetSharedInstance()->GetAllAPINames(); |
726 for (std::set<std::string>::iterator it = apis.begin(); | 726 for (std::set<std::string>::iterator it = apis.begin(); |
727 it != apis.end(); ++it) { | 727 it != apis.end(); ++it) { |
728 const std::string& api_name = *it; | 728 const std::string& api_name = *it; |
729 if (!context->IsAnyFeatureAvailableToContext(api_name)) | 729 if (!context->IsAnyFeatureAvailableToContext(api_name)) { |
730 DeregisterBinding(api_name, context); | |
730 continue; | 731 continue; |
732 } | |
731 | 733 |
732 Feature* feature = | 734 Feature* feature = |
733 BaseFeatureProvider::GetByName("api")->GetFeature(api_name); | 735 BaseFeatureProvider::GetByName("api")->GetFeature(api_name); |
734 if (feature && feature->IsInternal()) | 736 if (feature && feature->IsInternal()) |
735 continue; | 737 continue; |
736 | 738 |
737 std::vector<std::string> split; | 739 RegisterBinding(api_name, context); |
738 base::SplitString(api_name, '.', &split); | |
739 | |
740 v8::Handle<v8::Object> bind_object = | |
741 GetOrCreateChrome(context->v8_context()); | |
742 | |
743 // Check if this API has an ancestor. If the API's ancestor is available and | |
744 // the API is not available, don't install the bindings for this API. If | |
745 // the API is available and its ancestor is not, delete the ancestor and | |
746 // install the bindings for the API. This is to prevent loading the ancestor | |
747 // API schema if it will not be needed. | |
748 // | |
749 // For example: | |
750 // If app is available and app.window is not, just install app. | |
751 // If app.window is available and app is not, delete app and install | |
752 // app.window on a new object so app does not have to be loaded. | |
753 std::string ancestor_name; | |
754 bool only_ancestor_available = false; | |
755 for (size_t i = 0; i < split.size() - 1; ++i) { | |
756 ancestor_name += (i ? ".": "") + split[i]; | |
757 if (!ancestor_name.empty() && | |
758 context->GetAvailability(ancestor_name).is_available() && | |
759 !context->GetAvailability(api_name).is_available()) { | |
760 only_ancestor_available = true; | |
761 break; | |
762 } | |
763 bind_object = GetOrCreateObject(bind_object, split[i]); | |
764 } | |
765 if (only_ancestor_available) | |
766 continue; | |
767 | |
768 if (lazy_bindings_map_.find(api_name) != lazy_bindings_map_.end()) { | |
769 InstallBindings(module_system, context->v8_context(), api_name); | |
770 } else if (!source_map_.Contains(api_name)) { | |
771 module_system->RegisterNativeHandler( | |
772 api_name, | |
773 scoped_ptr<NativeHandler>(new BindingGeneratingNativeHandler( | |
774 module_system, | |
775 api_name, | |
776 "binding"))); | |
777 module_system->SetNativeLazyField(bind_object, | |
778 split.back(), | |
779 api_name, | |
780 "binding"); | |
781 } else { | |
782 module_system->SetLazyField(bind_object, | |
783 split.back(), | |
784 api_name, | |
785 "binding"); | |
786 } | |
787 } | 740 } |
788 } | 741 } |
789 | 742 |
743 void Dispatcher::DeregisterBinding(const std::string& api_name, | |
744 ChromeV8Context* context) { | |
745 v8::HandleScope handle_scope; | |
not at google - send to devlin
2013/06/05 19:03:44
handle scope shouldn't be necessary here, callers
cduvall
2013/06/05 23:27:59
Done.
| |
746 std::string bind_name; | |
747 v8::Handle<v8::Object> bind_object = | |
748 GetOrCreateBindObjectIfAvailable(api_name, &bind_name, context); | |
749 v8::Handle<v8::String> v8_bind_name = v8::String::New(bind_name.c_str()); | |
750 if (bind_object->HasRealNamedProperty(v8_bind_name)) | |
751 bind_object->Delete(v8_bind_name); | |
752 } | |
753 | |
754 v8::Handle<v8::Object> Dispatcher::GetOrCreateBindObjectIfAvailable( | |
755 const std::string& api_name, | |
756 std::string* bind_name, | |
757 ChromeV8Context* context) { | |
758 v8::HandleScope handle_scope; | |
not at google - send to devlin
2013/06/05 19:03:44
handle scope shouldn't be necessary here, callers
cduvall
2013/06/05 23:27:59
Done.
| |
759 std::vector<std::string> split; | |
760 base::SplitString(api_name, '.', &split); | |
761 | |
762 v8::Handle<v8::Object> bind_object; | |
763 | |
764 // Check if this API has an ancestor. If the API's ancestor is available and | |
765 // the API is not available, don't install the bindings for this API. If | |
766 // the API is available and its ancestor is not, delete the ancestor and | |
767 // install the bindings for the API. This is to prevent loading the ancestor | |
768 // API schema if it will not be needed. | |
769 // | |
770 // For example: | |
771 // If app is available and app.window is not, just install app. | |
772 // If app.window is available and app is not, delete app and install | |
773 // app.window on a new object so app does not have to be loaded. | |
774 std::string ancestor_name; | |
775 bool only_ancestor_available = false; | |
776 for (size_t i = 0; i < split.size() - 1; ++i) { | |
777 ancestor_name += (i ? ".": "") + split[i]; | |
778 if (!ancestor_name.empty() && | |
779 context->GetAvailability(ancestor_name).is_available() && | |
780 !context->GetAvailability(api_name).is_available()) { | |
781 only_ancestor_available = true; | |
782 break; | |
783 } | |
784 if (bind_object.IsEmpty()) | |
785 bind_object = GetOrCreateChrome(context->v8_context()); | |
786 bind_object = GetOrCreateObject(bind_object, split[i]); | |
787 } | |
788 if (only_ancestor_available) | |
789 return handle_scope.Close(v8::Handle<v8::Object>()); | |
790 if (bind_name) | |
791 *bind_name = split.back(); | |
792 | |
793 return handle_scope.Close(bind_object.IsEmpty() ? | |
794 GetOrCreateChrome(context->v8_context()) : bind_object); | |
795 } | |
796 | |
797 void Dispatcher::RegisterBinding(const std::string& api_name, | |
798 ChromeV8Context* context) { | |
799 std::string bind_name; | |
800 v8::Handle<v8::Object> bind_object = | |
801 GetOrCreateBindObjectIfAvailable(api_name, &bind_name, context); | |
802 if (bind_object.IsEmpty()) | |
803 return; | |
804 | |
805 ModuleSystem* module_system = context->module_system(); | |
806 CHECK(module_system); | |
not at google - send to devlin
2013/06/05 19:03:44
myeh, no point CHECKing here. maybe a DCHECK if yo
cduvall
2013/06/05 23:27:59
Done.
| |
807 if (lazy_bindings_map_.find(api_name) != lazy_bindings_map_.end()) { | |
808 InstallBindings(module_system, context->v8_context(), api_name); | |
809 } else if (!source_map_.Contains(api_name)) { | |
810 module_system->RegisterNativeHandler( | |
811 api_name, | |
812 scoped_ptr<NativeHandler>(new BindingGeneratingNativeHandler( | |
813 module_system, | |
814 api_name, | |
815 "binding"))); | |
816 module_system->SetNativeLazyField(bind_object, | |
817 bind_name, | |
818 api_name, | |
819 "binding"); | |
820 } else { | |
821 module_system->SetLazyField(bind_object, | |
822 bind_name, | |
823 api_name, | |
824 "binding"); | |
825 } | |
826 } | |
827 | |
790 void Dispatcher::RegisterNativeHandlers(ModuleSystem* module_system, | 828 void Dispatcher::RegisterNativeHandlers(ModuleSystem* module_system, |
791 ChromeV8Context* context) { | 829 ChromeV8Context* context) { |
792 module_system->RegisterNativeHandler("event_bindings", | 830 module_system->RegisterNativeHandler("event_bindings", |
793 scoped_ptr<NativeHandler>(EventBindings::Create(this, context))); | 831 scoped_ptr<NativeHandler>(EventBindings::Create(this, context))); |
794 module_system->RegisterNativeHandler("miscellaneous_bindings", | 832 module_system->RegisterNativeHandler("miscellaneous_bindings", |
795 scoped_ptr<NativeHandler>(MiscellaneousBindings::Get(this, context))); | 833 scoped_ptr<NativeHandler>(MiscellaneousBindings::Get(this, context))); |
796 module_system->RegisterNativeHandler("apiDefinitions", | 834 module_system->RegisterNativeHandler("apiDefinitions", |
797 scoped_ptr<NativeHandler>(new ApiDefinitionsNatives(this, context))); | 835 scoped_ptr<NativeHandler>(new ApiDefinitionsNatives(this, context))); |
798 module_system->RegisterNativeHandler("sendRequest", | 836 module_system->RegisterNativeHandler("sendRequest", |
799 scoped_ptr<NativeHandler>( | 837 scoped_ptr<NativeHandler>( |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1012 | 1050 |
1013 Feature::Context context_type = | 1051 Feature::Context context_type = |
1014 ClassifyJavaScriptContext(extension_id, extension_group, url_info); | 1052 ClassifyJavaScriptContext(extension_id, extension_group, url_info); |
1015 | 1053 |
1016 ChromeV8Context* context = | 1054 ChromeV8Context* context = |
1017 new ChromeV8Context(v8_context, frame, extension, context_type); | 1055 new ChromeV8Context(v8_context, frame, extension, context_type); |
1018 v8_context_set_.Add(context); | 1056 v8_context_set_.Add(context); |
1019 | 1057 |
1020 scoped_ptr<ModuleSystem> module_system(new ModuleSystem(context, | 1058 scoped_ptr<ModuleSystem> module_system(new ModuleSystem(context, |
1021 &source_map_)); | 1059 &source_map_)); |
1060 context->set_module_system(module_system.Pass()); | |
not at google - send to devlin
2013/06/05 19:03:44
to prevent callers from using the module system ac
cduvall
2013/06/05 23:27:59
Done.
| |
1061 | |
1022 // Enable natives in startup. | 1062 // Enable natives in startup. |
1023 ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system.get()); | 1063 ModuleSystem::NativesEnabledScope natives_enabled_scope( |
1064 context->module_system()); | |
1024 | 1065 |
1025 RegisterNativeHandlers(module_system.get(), context); | 1066 RegisterNativeHandlers(context->module_system(), context); |
1026 | 1067 |
1027 module_system->RegisterNativeHandler("chrome", | 1068 context->module_system()->RegisterNativeHandler("chrome", |
1028 scoped_ptr<NativeHandler>(new ChromeNativeHandler(context))); | 1069 scoped_ptr<NativeHandler>(new ChromeNativeHandler(context))); |
1029 module_system->RegisterNativeHandler("chrome_hidden", | 1070 context->module_system()->RegisterNativeHandler("chrome_hidden", |
1030 scoped_ptr<NativeHandler>(new ChromeHiddenNativeHandler(context))); | 1071 scoped_ptr<NativeHandler>(new ChromeHiddenNativeHandler(context))); |
1031 module_system->RegisterNativeHandler("print", | 1072 context->module_system()->RegisterNativeHandler("print", |
1032 scoped_ptr<NativeHandler>(new PrintNativeHandler(context))); | 1073 scoped_ptr<NativeHandler>(new PrintNativeHandler(context))); |
1033 module_system->RegisterNativeHandler("lazy_background_page", | 1074 context->module_system()->RegisterNativeHandler("lazy_background_page", |
1034 scoped_ptr<NativeHandler>( | 1075 scoped_ptr<NativeHandler>( |
1035 new LazyBackgroundPageNativeHandler(this, context))); | 1076 new LazyBackgroundPageNativeHandler(this, context))); |
1036 module_system->RegisterNativeHandler("logging", | 1077 context->module_system()->RegisterNativeHandler("logging", |
1037 scoped_ptr<NativeHandler>(new LoggingNativeHandler(context))); | 1078 scoped_ptr<NativeHandler>(new LoggingNativeHandler(context))); |
1038 module_system->RegisterNativeHandler("schema_registry", | 1079 context->module_system()->RegisterNativeHandler("schema_registry", |
1039 scoped_ptr<NativeHandler>( | 1080 scoped_ptr<NativeHandler>( |
1040 new SchemaRegistryNativeHandler(v8_schema_registry(), context))); | 1081 new SchemaRegistryNativeHandler(v8_schema_registry(), context))); |
1041 module_system->RegisterNativeHandler("v8_context", | 1082 context->module_system()->RegisterNativeHandler("v8_context", |
1042 scoped_ptr<NativeHandler>(new V8ContextNativeHandler(context, this))); | 1083 scoped_ptr<NativeHandler>(new V8ContextNativeHandler(context, this))); |
1043 module_system->RegisterNativeHandler("test_features", | 1084 context->module_system()->RegisterNativeHandler("test_features", |
1044 scoped_ptr<NativeHandler>(new TestFeaturesNativeHandler(context))); | 1085 scoped_ptr<NativeHandler>(new TestFeaturesNativeHandler(context))); |
1045 | 1086 |
1046 int manifest_version = extension ? extension->manifest_version() : 1; | 1087 int manifest_version = extension ? extension->manifest_version() : 1; |
1047 bool send_request_disabled = | 1088 bool send_request_disabled = |
1048 (extension && Manifest::IsUnpackedLocation(extension->location()) && | 1089 (extension && Manifest::IsUnpackedLocation(extension->location()) && |
1049 BackgroundInfo::HasLazyBackgroundPage(extension)); | 1090 BackgroundInfo::HasLazyBackgroundPage(extension)); |
1050 module_system->RegisterNativeHandler("process", | 1091 context->module_system()->RegisterNativeHandler("process", |
1051 scoped_ptr<NativeHandler>(new ProcessInfoNativeHandler( | 1092 scoped_ptr<NativeHandler>(new ProcessInfoNativeHandler( |
1052 this, context, context->GetExtensionID(), | 1093 this, context, context->GetExtensionID(), |
1053 context->GetContextTypeDescription(), | 1094 context->GetContextTypeDescription(), |
1054 ChromeRenderProcessObserver::is_incognito_process(), | 1095 ChromeRenderProcessObserver::is_incognito_process(), |
1055 manifest_version, send_request_disabled))); | 1096 manifest_version, send_request_disabled))); |
1056 | 1097 |
1057 GetOrCreateChrome(v8_context); | 1098 GetOrCreateChrome(v8_context); |
1058 | 1099 |
1059 // Loading JavaScript is expensive, so only run the full API bindings | 1100 // Loading JavaScript is expensive, so only run the full API bindings |
1060 // generation mechanisms in extension pages (NOT all web pages). | 1101 // generation mechanisms in extension pages (NOT all web pages). |
1061 switch (context_type) { | 1102 switch (context_type) { |
1062 case Feature::UNSPECIFIED_CONTEXT: | 1103 case Feature::UNSPECIFIED_CONTEXT: |
1063 case Feature::WEB_PAGE_CONTEXT: | 1104 case Feature::WEB_PAGE_CONTEXT: |
1064 // TODO(kalman): see comment below about ExtensionAPI. | 1105 // TODO(kalman): see comment below about ExtensionAPI. |
1065 InstallBindings(module_system.get(), v8_context, "app"); | 1106 InstallBindings(context->module_system(), v8_context, "app"); |
1066 InstallBindings(module_system.get(), v8_context, "webstore"); | 1107 InstallBindings(context->module_system(), v8_context, "webstore"); |
1067 break; | 1108 break; |
1068 case Feature::BLESSED_EXTENSION_CONTEXT: | 1109 case Feature::BLESSED_EXTENSION_CONTEXT: |
1069 case Feature::UNBLESSED_EXTENSION_CONTEXT: | 1110 case Feature::UNBLESSED_EXTENSION_CONTEXT: |
1070 case Feature::CONTENT_SCRIPT_CONTEXT: | 1111 case Feature::CONTENT_SCRIPT_CONTEXT: |
1071 module_system->Require("json"); // see paranoid comment in json.js | 1112 if (extension && !extension->is_platform_app()) |
1113 context->module_system()->Require("miscellaneous_bindings"); | |
1114 // See paranoid comment in json.js. | |
1115 context->module_system()->Require("json"); | |
1072 | 1116 |
1073 // TODO(kalman): move this code back out of the switch and execute it | 1117 // TODO(kalman): move this code back out of the switch and execute it |
1074 // regardless of |context_type|. ExtensionAPI knows how to return the | 1118 // regardless of |context_type|. ExtensionAPI knows how to return the |
1075 // correct APIs, however, until it doesn't have a 2MB overhead we can't | 1119 // correct APIs, however, until it doesn't have a 2MB overhead we can't |
1076 // load it in every process. | 1120 // load it in every process. |
1077 RegisterSchemaGeneratedBindings(module_system.get(), context); | 1121 AddOrRemoveBindings(context); |
1078 break; | 1122 break; |
1079 } | 1123 } |
1080 | 1124 |
1081 bool is_within_platform_app = IsWithinPlatformApp(frame); | 1125 bool is_within_platform_app = IsWithinPlatformApp(frame); |
1082 // Inject custom JS into the platform app context. | 1126 // Inject custom JS into the platform app context. |
1083 if (is_within_platform_app) | 1127 if (is_within_platform_app) |
1084 module_system->Require("platformApp"); | 1128 context->module_system()->Require("platformApp"); |
1085 | 1129 |
1086 // Only platform apps support the <webview> tag, because the "webView" and | 1130 // Only platform apps support the <webview> tag, because the "webView" and |
1087 // "denyWebView" modules will affect the performance of DOM modifications | 1131 // "denyWebView" modules will affect the performance of DOM modifications |
1088 // (http://crbug.com/196453). | 1132 // (http://crbug.com/196453). |
1089 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && | 1133 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && |
1090 is_within_platform_app) { | 1134 is_within_platform_app) { |
1091 // Note: setting up the WebView class here, not the chrome.webview API. | 1135 // Note: setting up the WebView class here, not the chrome.webview API. |
1092 // The API will be automatically set up when first used. | 1136 // The API will be automatically set up when first used. |
1093 if (extension->HasAPIPermission(APIPermission::kWebView)) { | 1137 if (extension->HasAPIPermission(APIPermission::kWebView)) { |
1094 module_system->Require("webView"); | 1138 context->module_system()->Require("webView"); |
1095 if (Feature::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) | 1139 if (Feature::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) |
1096 module_system->Require("webViewExperimental"); | 1140 context->module_system()->Require("webViewExperimental"); |
1097 } else { | 1141 } else { |
1098 module_system->Require("denyWebView"); | 1142 context->module_system()->Require("denyWebView"); |
1099 } | 1143 } |
1100 } | 1144 } |
1101 | 1145 |
1102 // Same comment as above for <adview> tag. | 1146 // Same comment as above for <adview> tag. |
1103 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && | 1147 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && |
1104 is_within_platform_app) { | 1148 is_within_platform_app) { |
1105 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdview)) { | 1149 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdview)) { |
1106 if (extension->HasAPIPermission(APIPermission::kAdView)) { | 1150 if (extension->HasAPIPermission(APIPermission::kAdView)) { |
1107 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1151 if (CommandLine::ForCurrentProcess()->HasSwitch( |
1108 switches::kEnableAdviewSrcAttribute)) { | 1152 switches::kEnableAdviewSrcAttribute)) { |
1109 module_system->Require("adViewCustom"); | 1153 context->module_system()->Require("adViewCustom"); |
1110 } | 1154 } |
1111 module_system->Require("adView"); | 1155 context->module_system()->Require("adView"); |
1112 } else { | 1156 } else { |
1113 module_system->Require("denyAdView"); | 1157 context->module_system()->Require("denyAdView"); |
1114 } | 1158 } |
1115 } | 1159 } |
1116 } | 1160 } |
1117 | 1161 |
1118 context->set_module_system(module_system.Pass()); | |
1119 | |
1120 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); | 1162 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); |
1121 } | 1163 } |
1122 | 1164 |
1123 std::string Dispatcher::GetExtensionID(const WebFrame* frame, int world_id) { | 1165 std::string Dispatcher::GetExtensionID(const WebFrame* frame, int world_id) { |
1124 if (world_id != 0) { | 1166 if (world_id != 0) { |
1125 // Isolated worlds (content script). | 1167 // Isolated worlds (content script). |
1126 return user_script_slave_->GetExtensionIdForIsolatedWorld(world_id); | 1168 return user_script_slave_->GetExtensionIdForIsolatedWorld(world_id); |
1127 } | 1169 } |
1128 | 1170 |
1129 // Extension pages (chrome-extension:// URLs). | 1171 // Extension pages (chrome-extension:// URLs). |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1272 new_active = PermissionSet::CreateUnion(old_active.get(), delta.get()); | 1314 new_active = PermissionSet::CreateUnion(old_active.get(), delta.get()); |
1273 break; | 1315 break; |
1274 case UpdatedExtensionPermissionsInfo::REMOVED: | 1316 case UpdatedExtensionPermissionsInfo::REMOVED: |
1275 new_active = | 1317 new_active = |
1276 PermissionSet::CreateDifference(old_active.get(), delta.get()); | 1318 PermissionSet::CreateDifference(old_active.get(), delta.get()); |
1277 break; | 1319 break; |
1278 } | 1320 } |
1279 | 1321 |
1280 PermissionsData::SetActivePermissions(extension, new_active); | 1322 PermissionsData::SetActivePermissions(extension, new_active); |
1281 AddOrRemoveOriginPermissions(reason, extension, explicit_hosts); | 1323 AddOrRemoveOriginPermissions(reason, extension, explicit_hosts); |
1324 v8_context_set().ForEach( | |
1325 extension_id, | |
1326 NULL, | |
1327 base::Bind(&Dispatcher::AddOrRemoveBindings, base::Unretained(this))); | |
1282 } | 1328 } |
1283 | 1329 |
1284 void Dispatcher::OnUpdateTabSpecificPermissions( | 1330 void Dispatcher::OnUpdateTabSpecificPermissions( |
1285 int page_id, | 1331 int page_id, |
1286 int tab_id, | 1332 int tab_id, |
1287 const std::string& extension_id, | 1333 const std::string& extension_id, |
1288 const URLPatternSet& origin_set) { | 1334 const URLPatternSet& origin_set) { |
1289 RenderView* view = TabFinder::Find(tab_id); | 1335 RenderView* view = TabFinder::Find(tab_id); |
1290 | 1336 |
1291 // For now, the message should only be sent to the render view that contains | 1337 // For now, the message should only be sent to the render view that contains |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1499 RenderView* background_view = | 1545 RenderView* background_view = |
1500 ExtensionHelper::GetBackgroundPage(extension_id); | 1546 ExtensionHelper::GetBackgroundPage(extension_id); |
1501 if (background_view) { | 1547 if (background_view) { |
1502 background_view->Send(new ExtensionHostMsg_EventAck( | 1548 background_view->Send(new ExtensionHostMsg_EventAck( |
1503 background_view->GetRoutingID())); | 1549 background_view->GetRoutingID())); |
1504 } | 1550 } |
1505 } | 1551 } |
1506 } | 1552 } |
1507 | 1553 |
1508 } // namespace extensions | 1554 } // namespace extensions |
OLD | NEW |