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, which can't be |
| 262 // initialized in |OnActivateExtension|. |
| 263 if (context_type == Feature::CONTENT_SCRIPT_CONTEXT) |
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 InitOriginPermissions(extension); |
555 } | 560 } |
556 | 561 |
557 UpdateActiveExtensions(); | 562 UpdateActiveExtensions(); |
558 } | 563 } |
559 | 564 |
560 void Dispatcher::OnCancelSuspend(const std::string& extension_id) { | 565 void Dispatcher::OnCancelSuspend(const std::string& extension_id) { |
561 DispatchEvent(extension_id, kOnSuspendCanceledEvent); | 566 DispatchEvent(extension_id, kOnSuspendCanceledEvent); |
562 } | 567 } |
563 | 568 |
564 void Dispatcher::OnClearTabSpecificPermissions( | 569 void Dispatcher::OnClearTabSpecificPermissions( |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 return v8::Handle<v8::Object>(); | 1238 return v8::Handle<v8::Object>(); |
1234 | 1239 |
1235 if (bind_name) | 1240 if (bind_name) |
1236 *bind_name = split.back(); | 1241 *bind_name = split.back(); |
1237 | 1242 |
1238 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) | 1243 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) |
1239 : bind_object; | 1244 : bind_object; |
1240 } | 1245 } |
1241 | 1246 |
1242 } // namespace extensions | 1247 } // namespace extensions |
OLD | NEW |