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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 elapsed); | 299 elapsed); |
300 break; | 300 break; |
301 case Feature::WEBUI_CONTEXT: | 301 case Feature::WEBUI_CONTEXT: |
302 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_WebUI", elapsed); | 302 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_WebUI", elapsed); |
303 break; | 303 break; |
304 } | 304 } |
305 | 305 |
306 VLOG(1) << "Num tracked contexts: " << script_context_set_->size(); | 306 VLOG(1) << "Num tracked contexts: " << script_context_set_->size(); |
307 } | 307 } |
308 | 308 |
309 void Dispatcher::DidInitializeWorkerContext(v8::Local<v8::Context> context, | |
not at google - send to devlin
2015/07/30 22:00:14
Make sure to disambiguate between workers and serv
Devlin
2015/07/30 22:07:24
Being notified about every worker context is a lit
| |
310 const GURL& url) { | |
311 const Extension* extension = extensions_.GetExtensionOrAppByURL(url); | |
312 if (extension) { | |
313 v8::Local<v8::String> key; | |
314 if (v8::String::NewFromUtf8(context->GetIsolate(), "chrome", | |
315 v8::NewStringType::kNormal) | |
not at google - send to devlin
2015/07/30 22:00:14
You can use v8_helpers here (v8_helpers::ToV8Strin
| |
316 .ToLocal(&key)) { | |
317 v8::Local<v8::Number> value = v8::Number::New(context->GetIsolate(), 42); | |
Devlin
2015/07/30 21:31:08
While this is fun, let's go ahead and initialize c
annekao
2015/07/30 22:54:18
Done. Tested that chrome was type object.
| |
318 if (context->Global()->Set(context, key, value).IsJust()) { | |
not at google - send to devlin
2015/07/30 22:00:14
I presume you did this because it has the V8_WARN_
annekao
2015/07/30 22:54:18
Done.
| |
319 } | |
320 } | |
321 } | |
322 } | |
323 | |
309 void Dispatcher::WillReleaseScriptContext( | 324 void Dispatcher::WillReleaseScriptContext( |
310 blink::WebLocalFrame* frame, | 325 blink::WebLocalFrame* frame, |
311 const v8::Local<v8::Context>& v8_context, | 326 const v8::Local<v8::Context>& v8_context, |
312 int world_id) { | 327 int world_id) { |
313 ScriptContext* context = script_context_set_->GetByV8Context(v8_context); | 328 ScriptContext* context = script_context_set_->GetByV8Context(v8_context); |
314 if (!context) | 329 if (!context) |
315 return; | 330 return; |
316 | 331 |
317 context->DispatchOnUnloadEvent(); | 332 context->DispatchOnUnloadEvent(); |
318 // TODO(kalman): Make |request_sender| use |context->AddInvalidationObserver|. | 333 // TODO(kalman): Make |request_sender| use |context->AddInvalidationObserver|. |
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1452 void Dispatcher::AddChannelSpecificFeatures() { | 1467 void Dispatcher::AddChannelSpecificFeatures() { |
1453 // chrome-extension: resources should be allowed to register a Service Worker. | 1468 // chrome-extension: resources should be allowed to register a Service Worker. |
1454 if (FeatureProvider::GetBehaviorFeature(BehaviorFeature::kServiceWorker) | 1469 if (FeatureProvider::GetBehaviorFeature(BehaviorFeature::kServiceWorker) |
1455 ->IsAvailableToEnvironment() | 1470 ->IsAvailableToEnvironment() |
1456 .is_available()) | 1471 .is_available()) |
1457 WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers( | 1472 WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers( |
1458 WebString::fromUTF8(kExtensionScheme)); | 1473 WebString::fromUTF8(kExtensionScheme)); |
1459 } | 1474 } |
1460 | 1475 |
1461 } // namespace extensions | 1476 } // namespace extensions |
OLD | NEW |