⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 126899 in webkit


Ignore:
Timestamp:
Aug 28, 2012, 11:11:53 AM (14 years ago)
Author:
jonlee@apple.com
Message:

[WK2] Add SPI for injected bundle to manually set permissions
https://bugs.webkit.org/show_bug.cgi?id=95127
<rdar://problem/12182635>

Reviewed by Jessie Berlin.

This is work toward providing Mac support for web notifications in DRT and WTR (77969).

Add support functions to WebKit2 which maintain the map of permissions to origins for web notifications.
For WebKit1 the map is managed by DumpRenderTree.

  • WebProcess/InjectedBundle/InjectedBundle.h: Add TestRunner SPI.
  • WebProcess/InjectedBundle/InjectedBundle.cpp:

(WebKit::InjectedBundle::setWebNotificationPermission):
(WebKit::InjectedBundle::removeAllWebNotificationPermissions):

  • WebProcess/InjectedBundle/API/c/WKBundlePrivate.h: Expose as WK API. Also, rearrange the ordering of the

functions so that it reflects the same order found in InjectedBundle.h.

  • WebProcess/InjectedBundle/API/c/WKBundle.cpp:
  • WebProcess/Notifications/NotificationPermissionRequestManager.cpp:

(WebKit::NotificationPermissionRequestManager::setPermissionLevelForTesting): Manually set the permission
level for an origin.
(WebKit::NotificationPermissionRequestManager::removeAllPermissionsForTesting):

  • WebProcess/Notifications/NotificationPermissionRequestManager.h:

(NotificationPermissionRequestManager):

  • WebProcess/Notifications/WebNotificationManager.cpp:

(WebKit::WebNotificationManager::removeAllPermissionsForTesting): Clear the permission map.

  • WebProcess/Notifications/WebNotificationManager.h: Promote didUpdateNotificationDecision message as public

function, so that NotificationPermissionRequestManager can update the permission map.

Location:
trunk/Source/WebKit2
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r126884 r126899  
     12012-08-28  Jon Lee  <jonlee@apple.com>
     2
     3        [WK2] Add SPI for injected bundle to manually set permissions
     4        https://bugs.webkit.org/show_bug.cgi?id=95127
     5        <rdar://problem/12182635>
     6
     7        Reviewed by Jessie Berlin.
     8
     9        This is work toward providing Mac support for web notifications in DRT and WTR (77969).
     10
     11        Add support functions to WebKit2 which maintain the map of permissions to origins for web notifications.
     12        For WebKit1 the map is managed by DumpRenderTree.
     13
     14        * WebProcess/InjectedBundle/InjectedBundle.h: Add TestRunner SPI.
     15        * WebProcess/InjectedBundle/InjectedBundle.cpp:
     16        (WebKit::InjectedBundle::setWebNotificationPermission):
     17        (WebKit::InjectedBundle::removeAllWebNotificationPermissions):
     18
     19        * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h: Expose as WK API. Also, rearrange the ordering of the
     20        functions so that it reflects the same order found in InjectedBundle.h.
     21        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
     22
     23        * WebProcess/Notifications/NotificationPermissionRequestManager.cpp:
     24        (WebKit::NotificationPermissionRequestManager::setPermissionLevelForTesting): Manually set the permission
     25        level for an origin.
     26        (WebKit::NotificationPermissionRequestManager::removeAllPermissionsForTesting):
     27        * WebProcess/Notifications/NotificationPermissionRequestManager.h:
     28        (NotificationPermissionRequestManager):
     29        * WebProcess/Notifications/WebNotificationManager.cpp:
     30        (WebKit::WebNotificationManager::removeAllPermissionsForTesting): Clear the permission map.
     31        * WebProcess/Notifications/WebNotificationManager.h: Promote didUpdateNotificationDecision message as public
     32        function, so that NotificationPermissionRequestManager can update the permission map.
     33
    1342012-08-28  Christophe Dumez  <christophe.dumez@intel.com>
    235
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp

    r124477 r126899  
    261261    toImpl(bundleRef)->setUserStyleSheetLocation(toImpl(pageGroupRef), toImpl(location)->string());
    262262}
     263
     264void WKBundleSetWebNotificationPermission(WKBundleRef bundleRef, WKBundlePageRef pageRef, WKStringRef originStringRef, bool allowed)
     265{
     266    toImpl(bundleRef)->setWebNotificationPermission(toImpl(pageRef), toImpl(originStringRef)->string(), allowed);
     267}
     268
     269void WKBundleRemoveAllWebNotificationPermissions(WKBundleRef bundleRef, WKBundlePageRef pageRef)
     270{
     271    toImpl(bundleRef)->removeAllWebNotificationPermissions(toImpl(pageRef));
     272}
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h

    r124477 r126899  
    3737#endif
    3838
    39 WK_EXPORT void WKBundleSetShouldTrackVisitedLinks(WKBundleRef bundle, bool shouldTrackVisitedLinks);
    40 WK_EXPORT void WKBundleRemoveAllVisitedLinks(WKBundleRef bundle);
    41 WK_EXPORT void WKBundleActivateMacFontAscentHack(WKBundleRef bundle);
    42 WK_EXPORT void WKBundleGarbageCollectJavaScriptObjects(WKBundleRef bundle);
    43 WK_EXPORT void WKBundleGarbageCollectJavaScriptObjectsOnAlternateThreadForDebugging(WKBundleRef bundle, bool waitUntilDone);
    44 WK_EXPORT size_t WKBundleGetJavaScriptObjectsCount(WKBundleRef bundle);
    45 
    4639enum WKUserScriptInjectionTime {
    4740    kWKInjectAtDocumentStart,
     
    5649typedef enum WKUserContentInjectedFrames WKUserContentInjectedFrames;
    5750
     51// TestRunner only SPI
     52WK_EXPORT void WKBundleSetShouldTrackVisitedLinks(WKBundleRef bundle, bool shouldTrackVisitedLinks);
     53WK_EXPORT void WKBundleSetAlwaysAcceptCookies(WKBundleRef bundle, bool);
     54WK_EXPORT void WKBundleRemoveAllVisitedLinks(WKBundleRef bundle);
     55WK_EXPORT void WKBundleActivateMacFontAscentHack(WKBundleRef bundle);
     56// Will make WebProcess ignore this preference until a preferences change notification, only for WebKitTestRunner use.
     57WK_EXPORT void WKBundleOverrideBoolPreferenceForTestRunner(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKStringRef preference, bool enabled);
     58WK_EXPORT void WKBundleSetAllowUniversalAccessFromFileURLs(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
     59WK_EXPORT void WKBundleSetAllowFileAccessFromFileURLs(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
     60WK_EXPORT void WKBundleSetFrameFlatteningEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
     61WK_EXPORT void WKBundleSetPluginsEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
     62WK_EXPORT void WKBundleSetGeolocationPermission(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
     63WK_EXPORT void WKBundleSetJavaScriptCanAccessClipboard(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
     64WK_EXPORT void WKBundleSetPrivateBrowsingEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
     65WK_EXPORT void WKBundleSetPopupBlockingEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
     66WK_EXPORT void WKBundleSwitchNetworkLoaderToNewTestingSession(WKBundleRef bundle);
     67WK_EXPORT void WKBundleSetAuthorAndUserStylesEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
     68WK_EXPORT void WKBundleAddOriginAccessWhitelistEntry(WKBundleRef bundle, WKStringRef, WKStringRef, WKStringRef, bool);
     69WK_EXPORT void WKBundleRemoveOriginAccessWhitelistEntry(WKBundleRef bundle, WKStringRef, WKStringRef, WKStringRef, bool);
     70WK_EXPORT void WKBundleResetOriginAccessWhitelists(WKBundleRef bundle);
     71WK_EXPORT int WKBundleNumberOfPages(WKBundleRef bundle, WKBundleFrameRef frameRef, double pageWidthInPixels, double pageHeightInPixels);
     72WK_EXPORT int WKBundlePageNumberForElementById(WKBundleRef bundle, WKBundleFrameRef frameRef, WKStringRef idRef, double pageWidthInPixels, double pageHeightInPixels);
     73WK_EXPORT WKStringRef WKBundlePageSizeAndMarginsInPixels(WKBundleRef bundle, WKBundleFrameRef frameRef, int, int, int, int, int, int, int);
     74WK_EXPORT bool WKBundleIsPageBoxVisible(WKBundleRef bundle, WKBundleFrameRef frameRef, int);
     75WK_EXPORT void WKBundleSetUserStyleSheetLocation(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKStringRef location);
     76WK_EXPORT void WKBundleSetWebNotificationPermission(WKBundleRef bundle, WKBundlePageRef page, WKStringRef originStringRef, bool allowed);
     77WK_EXPORT void WKBundleRemoveAllWebNotificationPermissions(WKBundleRef bundle, WKBundlePageRef page);
     78
     79// UserContent API
    5880WK_EXPORT void WKBundleAddUserScript(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKBundleScriptWorldRef scriptWorld, WKStringRef source, WKURLRef url, WKArrayRef whitelist, WKArrayRef blacklist, WKUserScriptInjectionTime injectionTime, WKUserContentInjectedFrames injectedFrames);
    5981WK_EXPORT void WKBundleAddUserStyleSheet(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKBundleScriptWorldRef scriptWorld, WKStringRef source, WKURLRef url, WKArrayRef whitelist, WKArrayRef blacklist, WKUserContentInjectedFrames injectedFrames);
     
    6486WK_EXPORT void WKBundleRemoveAllUserContent(WKBundleRef bundle, WKBundlePageGroupRef pageGroup);
    6587
    66 // Will make WebProcess ignore this preference until a preferences change notification, only for WebKitTestRunner use.
    67 WK_EXPORT void WKBundleOverrideBoolPreferenceForTestRunner(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKStringRef preference, bool enabled);
    68 
    69 WK_EXPORT void WKBundleSetAllowUniversalAccessFromFileURLs(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
    70 WK_EXPORT void WKBundleSetAllowFileAccessFromFileURLs(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
    71 WK_EXPORT void WKBundleSetFrameFlatteningEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
    72 WK_EXPORT void WKBundleSetPluginsEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
    73 WK_EXPORT void WKBundleSetGeolocationPermission(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
    74 WK_EXPORT void WKBundleSetJavaScriptCanAccessClipboard(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
    75 WK_EXPORT void WKBundleSetPrivateBrowsingEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
    76 WK_EXPORT void WKBundleSetPopupBlockingEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
    77 WK_EXPORT void WKBundleSetUserStyleSheetLocation(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKStringRef location);
    78 WK_EXPORT void WKBundleSetAuthorAndUserStylesEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
     88// Local storage API
    7989WK_EXPORT void WKBundleClearAllDatabases(WKBundleRef bundle);
    8090WK_EXPORT void WKBundleSetDatabaseQuota(WKBundleRef bundle, uint64_t);
     91
     92// Application Cache API
    8193WK_EXPORT void WKBundleClearApplicationCache(WKBundleRef bundle);
    8294WK_EXPORT void WKBundleSetAppCacheMaximumSize(WKBundleRef bundle, uint64_t size);
    83 WK_EXPORT int WKBundleNumberOfPages(WKBundleRef bundle, WKBundleFrameRef frameRef, double pageWidthInPixels, double pageHeightInPixels);
    84 WK_EXPORT int WKBundlePageNumberForElementById(WKBundleRef bundle, WKBundleFrameRef frameRef, WKStringRef idRef, double pageWidthInPixels, double pageHeightInPixels);
    85 WK_EXPORT WKStringRef WKBundlePageSizeAndMarginsInPixels(WKBundleRef bundle, WKBundleFrameRef frameRef, int, int, int, int, int, int, int);
    86 WK_EXPORT bool WKBundleIsPageBoxVisible(WKBundleRef bundle, WKBundleFrameRef frameRef, int);
    87 WK_EXPORT void WKBundleAddOriginAccessWhitelistEntry(WKBundleRef bundle, WKStringRef, WKStringRef, WKStringRef, bool);
    88 WK_EXPORT void WKBundleRemoveOriginAccessWhitelistEntry(WKBundleRef bundle, WKStringRef, WKStringRef, WKStringRef, bool);
    89 WK_EXPORT void WKBundleResetOriginAccessWhitelists(WKBundleRef bundle);
    90 WK_EXPORT void WKBundleSetAlwaysAcceptCookies(WKBundleRef bundle, bool);
     95
     96// Garbage collection API
     97WK_EXPORT void WKBundleGarbageCollectJavaScriptObjects(WKBundleRef bundle);
     98WK_EXPORT void WKBundleGarbageCollectJavaScriptObjectsOnAlternateThreadForDebugging(WKBundleRef bundle, bool waitUntilDone);
     99WK_EXPORT size_t WKBundleGetJavaScriptObjectsCount(WKBundleRef bundle);
    91100
    92101WK_EXPORT bool WKBundleIsProcessingUserGesture(WKBundleRef bundle);
    93 
    94 WK_EXPORT void WKBundleSwitchNetworkLoaderToNewTestingSession(WKBundleRef bundle);
    95102
    96103WK_EXPORT void WKBundleSetPageVisibilityState(WKBundleRef bundle, WKBundlePageRef page, int state, bool isInitialState);
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp

    r126311 r126899  
    3333#include "InjectedBundleUserMessageCoders.h"
    3434#include "LayerTreeHost.h"
     35#include "NotificationPermissionRequestManager.h"
    3536#include "WKAPICast.h"
    3637#include "WKBundleAPICast.h"
     
    535536}
    536537
     538void InjectedBundle::setWebNotificationPermission(WebPage* page, const String& originString, bool allowed)
     539{
     540#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     541    page->notificationPermissionRequestManager()->setPermissionLevelForTesting(originString, allowed ? NotificationClient::PermissionAllowed : NotificationClient::PermissionDenied);
     542#else
     543    UNUSED_PARAM(page);
     544    UNUSED_PARAM(originString);
     545    UNUSED_PARAM(allowed);
     546#endif
     547}
     548
     549void InjectedBundle::removeAllWebNotificationPermissions(WebPage* page)
     550{
     551#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     552    page->notificationPermissionRequestManager()->removeAllPermissionsForTesting();
     553#else
     554    UNUSED_PARAM(page);
     555#endif
     556}
     557
    537558} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h

    r126311 r126899  
    125125    bool isPageBoxVisible(WebFrame*, int);
    126126    void setUserStyleSheetLocation(WebPageGroupProxy*, const String&);
     127    void setWebNotificationPermission(WebPage*, const String& originString, bool allowed);
     128    void removeAllWebNotificationPermissions(WebPage*);
    127129
    128130    // UserContent API
  • trunk/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp

    r125370 r126899  
    129129}
    130130
     131void NotificationPermissionRequestManager::setPermissionLevelForTesting(const String& originString, WebCore::NotificationClient::Permission permission)
     132{
     133#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     134    WebProcess::shared().notificationManager().didUpdateNotificationDecision(originString, permission);
     135#else
     136    UNUSED_PARAM(originString);
     137    UNUSED_PARAM(permission);
     138#endif
     139}
     140
     141void NotificationPermissionRequestManager::removeAllPermissionsForTesting()
     142{
     143#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     144    WebProcess::shared().notificationManager().removeAllPermissionsForTesting();
     145#endif
     146}
     147
    131148void NotificationPermissionRequestManager::didReceiveNotificationPermissionDecision(uint64_t requestID, bool allowed)
    132149{
  • trunk/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.h

    r125370 r126899  
    3333#include <wtf/RefCounted.h>
    3434#include <wtf/RefPtr.h>
     35#include <wtf/text/WTFString.h>
    3536
    3637namespace WebCore {
     
    5657    void cancelRequest(WebCore::SecurityOrigin*);
    5758   
    58     // Synchronous call to retrieve permission level for given security origin
    5959    WebCore::NotificationClient::Permission permissionLevel(WebCore::SecurityOrigin*);
     60
     61    // For testing purposes only.
     62    void setPermissionLevelForTesting(const String& originString, WebCore::NotificationClient::Permission);
     63    void removeAllPermissionsForTesting();
    6064   
    6165    void didReceiveNotificationPermissionDecision(uint64_t notificationID, bool allowed);
  • trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp

    r126837 r126899  
    106106}
    107107
     108void WebNotificationManager::removeAllPermissionsForTesting()
     109{
     110#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     111    m_permissionsMap.clear();
     112#endif
     113}
     114
    108115bool WebNotificationManager::show(Notification* notification, WebPage* page)
    109116{
  • trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h

    r110784 r126899  
    6969    WebCore::NotificationClient::Permission policyForOrigin(WebCore::SecurityOrigin*) const;
    7070
     71    void didUpdateNotificationDecision(const String& originString, bool allowed);
     72
     73    // For testing purposes only.
     74    void removeAllPermissionsForTesting();
     75
    7176private:
    7277    // Implemented in generated WebNotificationManagerMessageReceiver.cpp
     
    7681    void didClickNotification(uint64_t notificationID);
    7782    void didCloseNotifications(const Vector<uint64_t>& notificationIDs);
    78     void didUpdateNotificationDecision(const String& originString, bool allowed);
    7983    void didRemoveNotificationDecisions(const Vector<String>& originStrings);
    8084   
Note: See TracChangeset for help on using the changeset viewer.