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

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

Issue 986503004: Some cleanup in extensions/renderer/dispatcher.cc . (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 } 317 }
318 318
319 UpdateBindingsForContext(context); 319 UpdateBindingsForContext(context);
320 320
321 bool is_within_platform_app = IsWithinPlatformApp(); 321 bool is_within_platform_app = IsWithinPlatformApp();
322 // Inject custom JS into the platform app context. 322 // Inject custom JS into the platform app context.
323 if (is_within_platform_app) { 323 if (is_within_platform_app) {
324 module_system->Require("platformApp"); 324 module_system->Require("platformApp");
325 } 325 }
326 326
327 if (context->GetAvailability("appViewEmbedderInternal").is_available()) { 327 RequireGuestViewModules(context);
328 module_system->Require("appView");
329 } else if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) {
330 module_system->Require("appViewDeny");
331 }
332
333 if (extensions::FeatureSwitch::surface_worker()->IsEnabled() &&
334 context->GetAvailability("surfaceWorkerInternal").is_available()) {
335 module_system->Require("surfaceWorker");
336 }
337
338 if (context->GetAvailability("extensionViewInternal").is_available()) {
339 module_system->Require("extensionView");
340 module_system->Require("extensionViewApiMethods");
341 module_system->Require("extensionViewAttributes");
342 }
343
344 // Note: setting up the WebView class here, not the chrome.webview API.
345 // The API will be automatically set up when first used.
346 if (context->GetAvailability("webViewInternal").is_available()) {
347 module_system->Require("webView");
348 module_system->Require("webViewApiMethods");
349 module_system->Require("webViewAttributes");
350 if (context->GetAvailability("webViewExperimentalInternal")
351 .is_available()) {
352 module_system->Require("webViewExperimental");
353 }
354 } else if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) {
355 module_system->Require("webViewDeny");
356 }
357
358 delegate_->RequireAdditionalModules(context, is_within_platform_app); 328 delegate_->RequireAdditionalModules(context, is_within_platform_app);
359 329
360 const base::TimeDelta elapsed = base::TimeTicks::Now() - start_time; 330 const base::TimeDelta elapsed = base::TimeTicks::Now() - start_time;
361 switch (context_type) { 331 switch (context_type) {
362 case Feature::UNSPECIFIED_CONTEXT: 332 case Feature::UNSPECIFIED_CONTEXT:
363 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_Unspecified", 333 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_Unspecified",
364 elapsed); 334 elapsed);
365 break; 335 break;
366 case Feature::BLESSED_EXTENSION_CONTEXT: 336 case Feature::BLESSED_EXTENSION_CONTEXT:
367 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_Blessed", elapsed); 337 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_Blessed", elapsed);
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 if (only_ancestor_available) 1522 if (only_ancestor_available)
1553 return v8::Handle<v8::Object>(); 1523 return v8::Handle<v8::Object>();
1554 1524
1555 if (bind_name) 1525 if (bind_name)
1556 *bind_name = split.back(); 1526 *bind_name = split.back();
1557 1527
1558 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) 1528 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context))
1559 : bind_object; 1529 : bind_object;
1560 } 1530 }
1561 1531
1532 void Dispatcher::RequireGuestViewModules(ScriptContext* context) {
1533 Feature::Context context_type = context->context_type();
1534 ModuleSystem* module_system = context->module_system();
1535
1536 // Require AppView.
1537 if (context->GetAvailability("appViewEmbedderInternal").is_available()) {
1538 module_system->Require("appView");
1539 } else if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) {
1540 module_system->Require("appViewDeny");
1541 }
1542
1543 // Require ExtensionOptions.
1544 if (context->GetAvailability("extensionOptionsInternal").is_available()) {
1545 module_system->Require("extensionOptions");
1546 }
1547
1548 // Require ExtensionView.
1549 if (context->GetAvailability("extensionViewInternal").is_available()) {
1550 module_system->Require("extensionView");
1551 module_system->Require("extensionViewApiMethods");
1552 module_system->Require("extensionViewAttributes");
1553 }
1554
1555 // Require SurfaceView.
1556 if (extensions::FeatureSwitch::surface_worker()->IsEnabled() &&
1557 context->GetAvailability("surfaceWorkerInternal").is_available()) {
1558 module_system->Require("surfaceWorker");
1559 }
1560
1561 // Require WebView.
1562 if (context->GetAvailability("webViewInternal").is_available()) {
1563 module_system->Require("webView");
1564 module_system->Require("webViewApiMethods");
1565 module_system->Require("webViewAttributes");
1566 if (context->GetAvailability("webViewExperimentalInternal")
1567 .is_available()) {
1568 module_system->Require("webViewExperimental");
1569 }
1570 } else if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) {
1571 module_system->Require("webViewDeny");
1572 }
1573 }
1574
1562 } // namespace extensions 1575 } // 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