Merge pull request #11227 from emmkimme/Fix_10470_sandbox_preload
🐞 #10470 - prevent from loading preload in each iframe context
This commit is contained in:
		
				commit
				
					
						124667c29b
					
				
			
		
					 1 changed files with 10 additions and 1 deletions
				
			
		|  | @ -38,7 +38,6 @@ namespace { | ||||||
| const std::string kIpcKey = "ipcNative"; | const std::string kIpcKey = "ipcNative"; | ||||||
| const std::string kModuleCacheKey = "native-module-cache"; | const std::string kModuleCacheKey = "native-module-cache"; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| v8::Local<v8::Object> GetModuleCache(v8::Isolate* isolate) { | v8::Local<v8::Object> GetModuleCache(v8::Isolate* isolate) { | ||||||
|   mate::Dictionary global(isolate, isolate->GetCurrentContext()->Global()); |   mate::Dictionary global(isolate, isolate->GetCurrentContext()->Global()); | ||||||
|   v8::Local<v8::Value> cache; |   v8::Local<v8::Value> cache; | ||||||
|  | @ -155,6 +154,11 @@ void AtomSandboxedRendererClient::RenderViewCreated( | ||||||
| 
 | 
 | ||||||
| void AtomSandboxedRendererClient::DidCreateScriptContext( | void AtomSandboxedRendererClient::DidCreateScriptContext( | ||||||
|     v8::Handle<v8::Context> context, content::RenderFrame* render_frame) { |     v8::Handle<v8::Context> context, content::RenderFrame* render_frame) { | ||||||
|  | 
 | ||||||
|  |   // Only allow preload for the main frame
 | ||||||
|  |   if (!render_frame->IsMainFrame()) | ||||||
|  |     return; | ||||||
|  | 
 | ||||||
|   base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |   base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | ||||||
|   std::string preload_script = command_line->GetSwitchValueASCII( |   std::string preload_script = command_line->GetSwitchValueASCII( | ||||||
|       switches::kPreloadScript); |       switches::kPreloadScript); | ||||||
|  | @ -192,6 +196,11 @@ void AtomSandboxedRendererClient::DidCreateScriptContext( | ||||||
| 
 | 
 | ||||||
| void AtomSandboxedRendererClient::WillReleaseScriptContext( | void AtomSandboxedRendererClient::WillReleaseScriptContext( | ||||||
|     v8::Handle<v8::Context> context, content::RenderFrame* render_frame) { |     v8::Handle<v8::Context> context, content::RenderFrame* render_frame) { | ||||||
|  | 
 | ||||||
|  |   // Only allow preload for the main frame
 | ||||||
|  |   if (!render_frame->IsMainFrame()) | ||||||
|  |     return; | ||||||
|  | 
 | ||||||
|   auto isolate = context->GetIsolate(); |   auto isolate = context->GetIsolate(); | ||||||
|   v8::HandleScope handle_scope(isolate); |   v8::HandleScope handle_scope(isolate); | ||||||
|   v8::Context::Scope context_scope(context); |   v8::Context::Scope context_scope(context); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Cheng Zhao
				Cheng Zhao