Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: extensions/renderer/dispatcher.cc

Issue 1256323008: [Extension ServiceWorkers] Chrome: Passing v8::context to extensions dispatcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/dispatcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 #include "extensions/renderer/script_context.h" 77 #include "extensions/renderer/script_context.h"
78 #include "extensions/renderer/script_context_set.h" 78 #include "extensions/renderer/script_context_set.h"
79 #include "extensions/renderer/script_injection.h" 79 #include "extensions/renderer/script_injection.h"
80 #include "extensions/renderer/script_injection_manager.h" 80 #include "extensions/renderer/script_injection_manager.h"
81 #include "extensions/renderer/send_request_natives.h" 81 #include "extensions/renderer/send_request_natives.h"
82 #include "extensions/renderer/set_icon_natives.h" 82 #include "extensions/renderer/set_icon_natives.h"
83 #include "extensions/renderer/test_features_native_handler.h" 83 #include "extensions/renderer/test_features_native_handler.h"
84 #include "extensions/renderer/user_gestures_native_handler.h" 84 #include "extensions/renderer/user_gestures_native_handler.h"
85 #include "extensions/renderer/utils_native_handler.h" 85 #include "extensions/renderer/utils_native_handler.h"
86 #include "extensions/renderer/v8_context_native_handler.h" 86 #include "extensions/renderer/v8_context_native_handler.h"
87 #include "extensions/renderer/v8_helpers.h"
87 #include "grit/extensions_renderer_resources.h" 88 #include "grit/extensions_renderer_resources.h"
88 #include "third_party/WebKit/public/platform/WebString.h" 89 #include "third_party/WebKit/public/platform/WebString.h"
89 #include "third_party/WebKit/public/platform/WebURLRequest.h" 90 #include "third_party/WebKit/public/platform/WebURLRequest.h"
90 #include "third_party/WebKit/public/web/WebCustomElement.h" 91 #include "third_party/WebKit/public/web/WebCustomElement.h"
91 #include "third_party/WebKit/public/web/WebDataSource.h" 92 #include "third_party/WebKit/public/web/WebDataSource.h"
92 #include "third_party/WebKit/public/web/WebDocument.h" 93 #include "third_party/WebKit/public/web/WebDocument.h"
93 #include "third_party/WebKit/public/web/WebFrame.h" 94 #include "third_party/WebKit/public/web/WebFrame.h"
94 #include "third_party/WebKit/public/web/WebLocalFrame.h" 95 #include "third_party/WebKit/public/web/WebLocalFrame.h"
95 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 96 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
96 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" 97 #include "third_party/WebKit/public/web/WebScopedUserGesture.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 elapsed); 300 elapsed);
300 break; 301 break;
301 case Feature::WEBUI_CONTEXT: 302 case Feature::WEBUI_CONTEXT:
302 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_WebUI", elapsed); 303 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_WebUI", elapsed);
303 break; 304 break;
304 } 305 }
305 306
306 VLOG(1) << "Num tracked contexts: " << script_context_set_->size(); 307 VLOG(1) << "Num tracked contexts: " << script_context_set_->size();
307 } 308 }
308 309
310 // static
311 void Dispatcher::DidInitializeServiceWorkerContextOnWorkerThread(
312 v8::Local<v8::Context> context,
313 const GURL& url) {
314 if (url.SchemeIs(extensions::kExtensionScheme)) {
315 v8_helpers::SetProperty(context, context->Global(), "chrome",
316 v8::Object::New(context->GetIsolate()));
317 }
318 }
319
309 void Dispatcher::WillReleaseScriptContext( 320 void Dispatcher::WillReleaseScriptContext(
310 blink::WebLocalFrame* frame, 321 blink::WebLocalFrame* frame,
311 const v8::Local<v8::Context>& v8_context, 322 const v8::Local<v8::Context>& v8_context,
312 int world_id) { 323 int world_id) {
313 ScriptContext* context = script_context_set_->GetByV8Context(v8_context); 324 ScriptContext* context = script_context_set_->GetByV8Context(v8_context);
314 if (!context) 325 if (!context)
315 return; 326 return;
316 327
317 context->DispatchOnUnloadEvent(); 328 context->DispatchOnUnloadEvent();
318 // TODO(kalman): Make |request_sender| use |context->AddInvalidationObserver|. 329 // TODO(kalman): Make |request_sender| use |context->AddInvalidationObserver|.
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 void Dispatcher::AddChannelSpecificFeatures() { 1463 void Dispatcher::AddChannelSpecificFeatures() {
1453 // chrome-extension: resources should be allowed to register a Service Worker. 1464 // chrome-extension: resources should be allowed to register a Service Worker.
1454 if (FeatureProvider::GetBehaviorFeature(BehaviorFeature::kServiceWorker) 1465 if (FeatureProvider::GetBehaviorFeature(BehaviorFeature::kServiceWorker)
1455 ->IsAvailableToEnvironment() 1466 ->IsAvailableToEnvironment()
1456 .is_available()) 1467 .is_available())
1457 WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers( 1468 WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers(
1458 WebString::fromUTF8(kExtensionScheme)); 1469 WebString::fromUTF8(kExtensionScheme));
1459 } 1470 }
1460 1471
1461 } // namespace extensions 1472 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698