Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp

    r269111 r269236  
    151151}
    152152
    153 void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* pageGroup, const String& preference, bool enabled)
    154 {
    155     const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();
    156 
    157     if (preference == "WebKit2AsynchronousPluginInitializationEnabled") {
    158         WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::asynchronousPluginInitializationEnabledKey(), enabled);
    159         for (auto* page : pages)
    160             WebPage::fromCorePage(*page).setAsynchronousPluginInitializationEnabled(enabled);
    161     }
    162 
    163     if (preference == "WebKit2AsynchronousPluginInitializationEnabledForAllPlugins") {
    164         WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::asynchronousPluginInitializationEnabledForAllPluginsKey(), enabled);
    165         for (auto* page : pages)
    166             WebPage::fromCorePage(*page).setAsynchronousPluginInitializationEnabledForAllPlugins(enabled);
    167     }
    168 
    169     if (preference == "WebKit2ArtificialPluginInitializationDelayEnabled") {
    170         WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::artificialPluginInitializationDelayEnabledKey(), enabled);
    171         for (auto* page : pages)
    172             WebPage::fromCorePage(*page).setArtificialPluginInitializationDelayEnabled(enabled);
    173     }
    174 
    175 #if ENABLE(SERVICE_CONTROLS)
    176     if (preference == "WebKitImageControlsEnabled") {
    177         WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::imageControlsEnabledKey(), enabled);
    178         for (auto* page : pages)
    179             page->settings().setImageControlsEnabled(enabled);
    180         return;
    181     }
    182 #endif
    183 
    184     if (preference == "WebKitCacheAPIEnabled")
    185         RuntimeEnabledFeatures::sharedFeatures().setCacheAPIEnabled(enabled);
    186 
    187     if (preference == "WebKitReadableByteStreamAPIEnabled")
    188         RuntimeEnabledFeatures::sharedFeatures().setReadableByteStreamAPIEnabled(enabled);
    189     if (preference == "WebKitWritableStreamAPIEnabled")
    190         RuntimeEnabledFeatures::sharedFeatures().setWritableStreamAPIEnabled(enabled);
    191     if (preference == "WebKitTransformStreamAPIEnabled")
    192         RuntimeEnabledFeatures::sharedFeatures().setTransformStreamAPIEnabled(enabled);
    193 
    194 #if ENABLE(WEBGL2)
    195     if (preference == "WebKitWebGL2Enabled")
    196         RuntimeEnabledFeatures::sharedFeatures().setWebGL2Enabled(enabled);
    197 #endif
    198 
    199 #if ENABLE(WEBGPU)
    200     if (preference == "WebKitWebGPUEnabled")
    201         RuntimeEnabledFeatures::sharedFeatures().setWebGPUEnabled(enabled);
    202 #endif
    203 
    204     if (preference == "WebKitModernMediaControlsEnabled")
    205         RuntimeEnabledFeatures::sharedFeatures().setModernMediaControlsEnabled(enabled);
    206 
    207 #if ENABLE(WEB_RTC)
    208     if (preference == "WebKitWebRTCMDNSICECandidatesEnabled")
    209         RuntimeEnabledFeatures::sharedFeatures().setWebRTCMDNSICECandidatesEnabled(enabled);
    210 #endif
    211 
    212     if (preference == "WebKitGenericCueAPIEnabled") {
    213         WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::genericCueAPIEnabledKey(), enabled);
    214         for (auto* page : pages)
    215             page->settings().setGenericCueAPIEnabled(enabled);
    216         return;
    217     }
    218 
    219 #if ENABLE(GPU_PROCESS)
    220     if (preference == "WebKitUseGPUProcessForMediaEnabled" || preference == "WebKitCaptureAudioInGPUProcessEnabledKey") {
    221         WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::useGPUProcessForMediaEnabledKey(), enabled);
    222         for (auto* page : pages)
    223             page->settings().setUseGPUProcessForMediaEnabled(enabled);
    224         return;
    225     }
    226 #endif
    227 
    228     if (preference == "WebKitWebAPIStatisticsEnabled")
    229         RuntimeEnabledFeatures::sharedFeatures().setWebAPIStatisticsEnabled(enabled);
    230 
    231 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    232     if (preference == "LayoutFormattingContextEnabled")
    233         RuntimeEnabledFeatures::sharedFeatures().setLayoutFormattingContextEnabled(enabled);
    234     if (preference == "LayoutFormattingContextIntegrationEnabled")
    235         RuntimeEnabledFeatures::sharedFeatures().setLayoutFormattingContextIntegrationEnabled(enabled);
    236 #endif
    237 
    238 #if ENABLE(CSS_PAINTING_API)
    239     if (preference == "CSSPaintingAPIEnabled")
    240         RuntimeEnabledFeatures::sharedFeatures().setCSSPaintingAPIEnabled(enabled);
    241 #endif
    242 
    243 #if ENABLE(CSS_TYPED_OM)
    244     if (preference == "CSSTypedOMEnabled")
    245         RuntimeEnabledFeatures::sharedFeatures().setCSSTypedOMEnabled(enabled);
    246 #endif
    247 
    248 #if ENABLE(OFFSCREEN_CANVAS)
    249     if (preference == "OffscreenCanvasEnabled")
    250         RuntimeEnabledFeatures::sharedFeatures().setOffscreenCanvasEnabled(enabled);
    251 #endif
    252 
    253 #if ENABLE(WEBXR)
    254     if (preference == "WebKitWebXREnabled")
    255         RuntimeEnabledFeatures::sharedFeatures().setWebXREnabled(enabled);
    256 #endif
    257 
    258 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
    259     if (preference == "IsAccessibilityIsolatedTreeEnabled")
    260         RuntimeEnabledFeatures::sharedFeatures().setIsAccessibilityIsolatedTreeEnabled(enabled);
    261 #endif
    262 
    263     // Map the names used in LayoutTests with the names used in WebCore::Settings and WebPreferencesStore.
    264 
    265 #define OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(TestRunnerName, SettingsName, WebPreferencesName) \
    266     if (preference == #TestRunnerName) { \
    267         WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::WebPreferencesName##Key(), enabled); \
    268         for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter) \
    269             (*iter)->settings().set##SettingsName(enabled); \
    270         return; \
    271     }
    272 
    273     OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(WebKitAnimatedImageAsyncDecodingEnabled, AnimatedImageAsyncDecodingEnabled, animatedImageAsyncDecodingEnabled)
    274     OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(WebKitDisplayImagesKey, LoadsImagesAutomatically, loadsImagesAutomatically)
    275     OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(WebKitHiddenPageDOMTimerThrottlingEnabled, HiddenPageDOMTimerThrottlingEnabled, hiddenPageDOMTimerThrottlingEnabled)
    276     OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(WebKitJavaEnabled, JavaEnabled, javaEnabled)
    277     OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(WebKitJavaScriptEnabled, ScriptEnabled, javaScriptEnabled)
    278     OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(WebKitLargeImageAsyncDecodingEnabled, LargeImageAsyncDecodingEnabled, largeImageAsyncDecodingEnabled)
    279     OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(WebKitPluginsEnabled, PluginsEnabled, pluginsEnabled)
    280     OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(WebKitShouldRespectImageOrientation, ShouldRespectImageOrientation, shouldRespectImageOrientation)
    281     OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(WebKitWebGLEnabled, WebGLEnabled, webGLEnabled)
    282     OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(WebKitXSSAuditorEnabled, XSSAuditorEnabled, xssAuditorEnabled)
    283 
    284 #if ENABLE(WEB_AUDIO)
    285     OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(WebKitWebAudioEnabled, WebAudioEnabled, webAudioEnabled)
    286 #endif
    287 
    288 #undef OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES
    289 }
    290 
    291 void InjectedBundle::setAllowUniversalAccessFromFileURLs(WebPageGroupProxy* pageGroup, bool enabled)
    292 {
    293     const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();
    294     for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter)
    295         (*iter)->settings().setAllowUniversalAccessFromFileURLs(enabled);
    296 }
    297 
    298 void InjectedBundle::setAllowFileAccessFromFileURLs(WebPageGroupProxy* pageGroup, bool enabled)
    299 {
    300     const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();
    301     for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter)
    302         (*iter)->settings().setAllowFileAccessFromFileURLs(enabled);
    303 }
    304 
    305 void InjectedBundle::setNeedsStorageAccessFromFileURLsQuirk(WebPageGroupProxy* pageGroup, bool needsQuirk)
    306 {
    307     const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();
    308     for (auto page : pages)
    309         page->settings().setNeedsStorageAccessFromFileURLsQuirk(needsQuirk);
    310 }
    311 
    312 void InjectedBundle::setMinimumLogicalFontSize(WebPageGroupProxy* pageGroup, int size)
    313 {
    314     const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();
    315     for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter)
    316         (*iter)->settings().setMinimumLogicalFontSize(size);
    317 }
    318 
    319 void InjectedBundle::setFrameFlatteningEnabled(WebPageGroupProxy* pageGroup, bool enabled)
    320 {
    321     const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();
    322     for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter)
    323         (*iter)->settings().setFrameFlattening(enabled ? FrameFlattening::FullyEnabled : FrameFlattening::Disabled);
    324 }
    325 
    326 void InjectedBundle::setAsyncFrameScrollingEnabled(WebPageGroupProxy* pageGroup, bool enabled)
    327 {
    328     const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();
    329     for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter)
    330         (*iter)->settings().setAsyncFrameScrollingEnabled(enabled);
    331 }
    332 
    333 void InjectedBundle::setJavaScriptCanAccessClipboard(WebPageGroupProxy* pageGroup, bool enabled)
    334 {
    335     const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();
    336     for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter)
    337         (*iter)->settings().setJavaScriptCanAccessClipboard(enabled);
    338 }
    339 
    340 void InjectedBundle::setPopupBlockingEnabled(WebPageGroupProxy* pageGroup, bool enabled)
    341 {
    342     const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();
    343     HashSet<Page*>::const_iterator end = pages.end();
    344     for (HashSet<Page*>::const_iterator iter = pages.begin(); iter != end; ++iter)
    345         (*iter)->settings().setJavaScriptCanOpenWindowsAutomatically(!enabled);
    346 }
    347 
    348 void InjectedBundle::setAuthorAndUserStylesEnabled(WebPageGroupProxy* pageGroup, bool enabled)
    349 {
    350     const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();
    351     for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter)
    352         (*iter)->settings().setAuthorAndUserStylesEnabled(enabled);
    353 }
    354 
    355153void InjectedBundle::addOriginAccessAllowListEntry(const String& sourceOrigin, const String& destinationProtocol, const String& destinationHost, bool allowDestinationSubdomains)
    356154{
    357155    SecurityPolicy::addOriginAccessAllowlistEntry(SecurityOrigin::createFromString(sourceOrigin).get(), destinationProtocol, destinationHost, allowDestinationSubdomains);
    358156    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::AddOriginAccessAllowListEntry { sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains }, 0);
    359 
    360157}
    361158
Note: See TracChangeset for help on using the changeset viewer.