OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/renderer/dispatcher.h" | 5 #include "extensions/renderer/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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 ClassifyJavaScriptContext(extension, | 251 ClassifyJavaScriptContext(extension, |
252 extension_group, | 252 extension_group, |
253 ScriptContext::GetDataSourceURLForFrame(frame), | 253 ScriptContext::GetDataSourceURLForFrame(frame), |
254 frame->document().securityOrigin()); | 254 frame->document().securityOrigin()); |
255 | 255 |
256 ScriptContext* context = | 256 ScriptContext* context = |
257 delegate_->CreateScriptContext(v8_context, frame, extension, context_type) | 257 delegate_->CreateScriptContext(v8_context, frame, extension, context_type) |
258 .release(); | 258 .release(); |
259 script_context_set_.Add(context); | 259 script_context_set_.Add(context); |
260 | 260 |
261 if (extension) { | 261 // Initialize origin permissions for content scripts. |
262 // Skip active extensions which are already set up at |OnActivateExtension|. | |
263 if (!extension && IsExtensionActive(extension->id())) | |
not at google - send to devlin
2014/06/11 14:41:15
a better check here would be "context_type == Feat
kouhei (in TOK)
2014/06/12 01:07:38
Done.
| |
262 InitOriginPermissions(extension); | 264 InitOriginPermissions(extension); |
263 } | |
264 | 265 |
265 { | 266 { |
266 scoped_ptr<ModuleSystem> module_system( | 267 scoped_ptr<ModuleSystem> module_system( |
267 new ModuleSystem(context, &source_map_)); | 268 new ModuleSystem(context, &source_map_)); |
268 context->set_module_system(module_system.Pass()); | 269 context->set_module_system(module_system.Pass()); |
269 } | 270 } |
270 ModuleSystem* module_system = context->module_system(); | 271 ModuleSystem* module_system = context->module_system(); |
271 | 272 |
272 // Enable natives in startup. | 273 // Enable natives in startup. |
273 ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system); | 274 ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 &RenderThread::IdleHandler); | 490 &RenderThread::IdleHandler); |
490 } | 491 } |
491 | 492 |
492 // Initialize host permissions for any extensions that were activated before | 493 // Initialize host permissions for any extensions that were activated before |
493 // WebKit was initialized. | 494 // WebKit was initialized. |
494 for (std::set<std::string>::iterator iter = active_extension_ids_.begin(); | 495 for (std::set<std::string>::iterator iter = active_extension_ids_.begin(); |
495 iter != active_extension_ids_.end(); | 496 iter != active_extension_ids_.end(); |
496 ++iter) { | 497 ++iter) { |
497 const Extension* extension = extensions_.GetByID(*iter); | 498 const Extension* extension = extensions_.GetByID(*iter); |
498 CHECK(extension); | 499 CHECK(extension); |
500 | |
501 InitOriginPermissions(extension); | |
499 } | 502 } |
500 | 503 |
501 EnableCustomElementWhiteList(); | 504 EnableCustomElementWhiteList(); |
502 | 505 |
503 is_webkit_initialized_ = true; | 506 is_webkit_initialized_ = true; |
504 } | 507 } |
505 | 508 |
506 void Dispatcher::IdleNotification() { | 509 void Dispatcher::IdleNotification() { |
507 if (is_extension_process_) { | 510 if (is_extension_process_) { |
508 // Dampen the forced delay as well if the extension stays idle for long | 511 // Dampen the forced delay as well if the extension stays idle for long |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 | 548 |
546 active_extension_ids_.insert(extension_id); | 549 active_extension_ids_.insert(extension_id); |
547 | 550 |
548 // This is called when starting a new extension page, so start the idle | 551 // This is called when starting a new extension page, so start the idle |
549 // handler ticking. | 552 // handler ticking. |
550 RenderThread::Get()->ScheduleIdleHandler(kInitialExtensionIdleHandlerDelayMs); | 553 RenderThread::Get()->ScheduleIdleHandler(kInitialExtensionIdleHandlerDelayMs); |
551 | 554 |
552 if (is_webkit_initialized_) { | 555 if (is_webkit_initialized_) { |
553 extensions::DOMActivityLogger::AttachToWorld( | 556 extensions::DOMActivityLogger::AttachToWorld( |
554 extensions::DOMActivityLogger::kMainWorldId, extension_id); | 557 extensions::DOMActivityLogger::kMainWorldId, extension_id); |
558 | |
559 if (extension) | |
not at google - send to devlin
2014/06/11 14:41:15
there will always be an extension, because the CHE
kouhei (in TOK)
2014/06/12 01:07:38
Done.
| |
560 InitOriginPermissions(extension); | |
555 } | 561 } |
556 | 562 |
557 UpdateActiveExtensions(); | 563 UpdateActiveExtensions(); |
558 } | 564 } |
559 | 565 |
560 void Dispatcher::OnCancelSuspend(const std::string& extension_id) { | 566 void Dispatcher::OnCancelSuspend(const std::string& extension_id) { |
561 DispatchEvent(extension_id, kOnSuspendCanceledEvent); | 567 DispatchEvent(extension_id, kOnSuspendCanceledEvent); |
562 } | 568 } |
563 | 569 |
564 void Dispatcher::OnClearTabSpecificPermissions( | 570 void Dispatcher::OnClearTabSpecificPermissions( |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1233 return v8::Handle<v8::Object>(); | 1239 return v8::Handle<v8::Object>(); |
1234 | 1240 |
1235 if (bind_name) | 1241 if (bind_name) |
1236 *bind_name = split.back(); | 1242 *bind_name = split.back(); |
1237 | 1243 |
1238 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) | 1244 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) |
1239 : bind_object; | 1245 : bind_object; |
1240 } | 1246 } |
1241 | 1247 |
1242 } // namespace extensions | 1248 } // namespace extensions |
OLD | NEW |