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

Side by Side Diff: third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp

Issue 2130883002: [OriginTrials] Allow origin trials to be installed without an instance object. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 (*s_originalInstallOriginTrialsFunction)(scriptState); 536 (*s_originalInstallOriginTrialsFunction)(scriptState);
537 537
538 v8::Local<v8::Context> context = scriptState->context(); 538 v8::Local<v8::Context> context = scriptState->context();
539 ExecutionContext* executionContext = toExecutionContext(context); 539 ExecutionContext* executionContext = toExecutionContext(context);
540 OriginTrialContext* originTrialContext = OriginTrialContext::from(executionC ontext, OriginTrialContext::DontCreateIfNotExists); 540 OriginTrialContext* originTrialContext = OriginTrialContext::from(executionC ontext, OriginTrialContext::DontCreateIfNotExists);
541 if (!originTrialContext) 541 if (!originTrialContext)
542 return; 542 return;
543 543
544 ScriptState::Scope scope(scriptState); 544 ScriptState::Scope scope(scriptState);
545 v8::Local<v8::Object> global = context->Global(); 545 v8::Local<v8::Object> global = context->Global();
546 v8::Isolate* isolate = scriptState->isolate();
547 546
548 if (!originTrialContext->featureBindingsInstalled("DurableStorage") && (Runt imeEnabledFeatures::durableStorageEnabled() || originTrialContext->isFeatureEnab led("DurableStorage", nullptr))) { 547 if (!originTrialContext->featureBindingsInstalled("DurableStorage") && (Runt imeEnabledFeatures::durableStorageEnabled() || originTrialContext->isFeatureEnab led("DurableStorage", nullptr))) {
549 v8::Local<v8::String> navigatorName = v8::String::NewFromOneByte(isolate , reinterpret_cast<const uint8_t*>("navigator"), v8::NewStringType::kNormal).ToL ocalChecked();
550 if (executionContext->isDocument()) { 548 if (executionContext->isDocument()) {
551 v8::Local<v8::Object> navigator = global->Get(context, navigatorName ).ToLocalChecked()->ToObject();
552 V8WindowPartial::installDurableStorage(scriptState, global); 549 V8WindowPartial::installDurableStorage(scriptState, global);
553 V8NavigatorPartial::installDurableStorage(scriptState, navigator); 550 V8NavigatorPartial::installDurableStorage(scriptState);
554 } else if (executionContext->isSharedWorkerGlobalScope()) { 551 } else if (executionContext->isSharedWorkerGlobalScope()) {
555 v8::Local<v8::Object> navigator = global->Get(context, navigatorName ).ToLocalChecked()->ToObject();
556 V8SharedWorkerGlobalScopePartial::installDurableStorage(scriptState, global); 552 V8SharedWorkerGlobalScopePartial::installDurableStorage(scriptState, global);
557 V8WorkerNavigatorPartial::installDurableStorage(scriptState, navigat or); 553 V8WorkerNavigatorPartial::installDurableStorage(scriptState);
558 } else if (executionContext->isDedicatedWorkerGlobalScope()) { 554 } else if (executionContext->isDedicatedWorkerGlobalScope()) {
559 v8::Local<v8::Object> navigator = global->Get(context, navigatorName ).ToLocalChecked()->ToObject();
560 V8DedicatedWorkerGlobalScopePartial::installDurableStorage(scriptSta te, global); 555 V8DedicatedWorkerGlobalScopePartial::installDurableStorage(scriptSta te, global);
561 V8WorkerNavigatorPartial::installDurableStorage(scriptState, navigat or); 556 V8WorkerNavigatorPartial::installDurableStorage(scriptState);
562 } else if (executionContext->isServiceWorkerGlobalScope()) { 557 } else if (executionContext->isServiceWorkerGlobalScope()) {
563 v8::Local<v8::Object> navigator = global->Get(context, navigatorName ).ToLocalChecked()->ToObject();
564 V8ServiceWorkerGlobalScope::installDurableStorage(scriptState, globa l); 558 V8ServiceWorkerGlobalScope::installDurableStorage(scriptState, globa l);
565 V8WorkerNavigatorPartial::installDurableStorage(scriptState, navigat or); 559 V8WorkerNavigatorPartial::installDurableStorage(scriptState);
566 } 560 }
567 } 561 }
568 562
569 if (!originTrialContext->featureBindingsInstalled("WebBluetooth") && (Runtim eEnabledFeatures::webBluetoothEnabled() || originTrialContext->isFeatureEnabled( "WebBluetooth", nullptr))) { 563 if (!originTrialContext->featureBindingsInstalled("WebBluetooth") && (Runtim eEnabledFeatures::webBluetoothEnabled() || originTrialContext->isFeatureEnabled( "WebBluetooth", nullptr))) {
570 v8::Local<v8::String> navigatorName = v8::String::NewFromOneByte(isolate , reinterpret_cast<const uint8_t*>("navigator"), v8::NewStringType::kNormal).ToL ocalChecked();
571 if (executionContext->isDocument()) { 564 if (executionContext->isDocument()) {
572 v8::Local<v8::Object> navigator = global->Get(context, navigatorName ).ToLocalChecked()->ToObject();
573 // For global interfaces e.g. BluetoothUUID. 565 // For global interfaces e.g. BluetoothUUID.
574 V8WindowPartial::installWebBluetooth(scriptState, global); 566 V8WindowPartial::installWebBluetooth(scriptState, global);
575 // For navigator interfaces e.g. navigator.bluetooth. 567 // For navigator interfaces e.g. navigator.bluetooth.
576 V8NavigatorPartial::installWebBluetooth(scriptState, navigator); 568 V8NavigatorPartial::installWebBluetooth(scriptState);
577 } 569 }
578 } 570 }
579 } 571 }
580 572
581 void registerInstallOriginTrialsForModules() 573 void registerInstallOriginTrialsForModules()
582 { 574 {
583 s_originalInstallOriginTrialsFunction = setInstallOriginTrialsFunction(&inst allOriginTrialsForModules); 575 s_originalInstallOriginTrialsFunction = setInstallOriginTrialsFunction(&inst allOriginTrialsForModules);
584 } 576 }
585 } // namespace blink 577 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698