Teach MiniBrowser how to enable the mock content filter
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Nov 2015 08:48:36 +0000 (08:48 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Nov 2015 08:48:36 +0000 (08:48 +0000)
commitae09bc2120a01c227db002dbc60eecda3d7a7987
treebfbf956a925a1633f7036cbcb104051853f01599
parent7bd18b5e5638caddd7a04da2a4cfbea771aabbd9
Teach MiniBrowser how to enable the mock content filter
https://bugs.webkit.org/show_bug.cgi?id=151540

Reviewed by Andreas Kling.

Source/WebCore:

Moved the implementation of MockContentFilterEnabler from TestWebKitAPI to here, renamed it to
WebMockContentFilterEnabler, and made it compatible with the legacy Objective-C runtime. Renamed Decision and
DecisionPoint to WebMockContentFilterDecision and WebMockContentFilterDecisionPoint, and changed them from enum
classes to CF_ENUMs so that they can be used by both C++ and Objective-C source files.

* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSMockContentFilterSettingsCustom.cpp:
(WebCore::JSMockContentFilterSettings::decisionPoint):
(WebCore::JSMockContentFilterSettings::setDecisionPoint):
(WebCore::toDecision):
(WebCore::JSMockContentFilterSettings::decision):
(WebCore::JSMockContentFilterSettings::setDecision):
(WebCore::JSMockContentFilterSettings::unblockRequestDecision):
(WebCore::JSMockContentFilterSettings::setUnblockRequestDecision):
(WebCore::toJSValue): Deleted.
* testing/MockContentFilter.cpp:
(WebCore::MockContentFilter::willSendRequest):
(WebCore::MockContentFilter::responseReceived):
(WebCore::MockContentFilter::addData):
(WebCore::MockContentFilter::finishedAddingData):
(WebCore::MockContentFilter::unblockHandler):
(WebCore::MockContentFilter::maybeDetermineStatus):
* testing/MockContentFilter.h:
* testing/MockContentFilterEnabler.h: Added.
* testing/MockContentFilterEnabler.mm: Added.
(-[WebMockContentFilterEnabler initWithDecision:decisionPoint:blockedString:]):
(-[WebMockContentFilterEnabler initWithCoder:]):
(-[WebMockContentFilterEnabler encodeWithCoder:]):
(-[WebMockContentFilterEnabler enable]):
(-[WebMockContentFilterEnabler dealloc]):
(+[WebMockContentFilterEnabler supportsSecureCoding]):
(-[WebMockContentFilterEnabler copyWithZone:]):
* testing/MockContentFilterSettings.h:
(WebCore::MockContentFilterSettings::decisionPoint):
(WebCore::MockContentFilterSettings::setDecisionPoint):
(WebCore::MockContentFilterSettings::decision):
(WebCore::MockContentFilterSettings::setDecision):
(WebCore::MockContentFilterSettings::unblockRequestDecision):
(WebCore::MockContentFilterSettings::setUnblockRequestDecision):

Tools:

* MiniBrowser/Configurations/Base.xcconfig: Added WebCoreTestSupport and WTF to HEADER_SEARCH_PATHS.
* MiniBrowser/Configurations/MiniBrowser.xcconfig: Linked against libWebCoreTestSupport.
* MiniBrowser/Configurations/MiniBrowserBundle.xcconfig: Ditto.
* MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj: Added blocked-page.html.
* MiniBrowser/MiniBrowserWebProcessPlugIn.m:
(-[MiniBrowserWebProcessPlugIn webProcessPlugIn:initializeWithObject:]): Observed the WebMockContentFilterEnabler key path.
(-[MiniBrowserWebProcessPlugIn dealloc]):
(-[MiniBrowserWebProcessPlugIn observeValueForKeyPath:ofObject:change:context:]): Stored the value in _contentFilterEnabler.
* MiniBrowser/blocked-page.html: Added.
* MiniBrowser/mac/AppDelegate.m:
(defaultConfiguration): Created a _WKProcessPoolConfiguration with MiniBrowser.wkbundle as the injected bundle.
* MiniBrowser/mac/BrowserWindowController.h:
* MiniBrowser/mac/BrowserWindowController.m:
(+[BrowserWindowController contentFilteringBlockedString]): Returned an NSString containing blocked-page.html.
* MiniBrowser/mac/SettingsController.h:
* MiniBrowser/mac/SettingsController.m:
(-[SettingsController _populateMenu]): Added [self _contentFilteringMenuItem] to the Settings menu.
(-[SettingsController validateMenuItem:]): Validated the new menu items. Disabled Decision and Decision Point items if filtering is disabled.
(-[SettingsController _contentFilteringMenuItem]): Returned a new Content Filtering menu item with a submenu.
(-[SettingsController toggleContentFilteringEnabled:]): Toggled ContentFilteringEnabledKey.
(-[SettingsController contentFilteringEnabled]): Returned value of ContentFilteringEnabledKey.
(-[SettingsController setContentFilteringDecision:]): Set ContentFilterDecisionKey and called -[BrowserAppDelegate didChangeSettings].
(-[SettingsController contentFilteringDecision]): Returned the value of ContentFilterDecisionKey as a WebMockContentFilterDecision.
Defaulted to WebMockContentFilterDecisionAllow if the value is invalid.
(-[SettingsController setContentFilteringDecisionPoint:]): Set ContentFilterDecisionPointKey and called -[BrowserAppDelegate didChangeSettings].
(-[SettingsController contentFilteringDecisionPoint]): Returned the value of ContentFilterDecisionPointKey as a WebMockContentFilterDecisionPoint.
Defaulted to WebMockContentFilterDecisionPointAfterWillSendRequest if the value is invalid.
* MiniBrowser/mac/WK1BrowserWindowController.h:
* MiniBrowser/mac/WK1BrowserWindowController.m:
(-[WK1BrowserWindowController dealloc]):
(-[WK1BrowserWindowController didChangeSettings]): Created a WebMockContentFilterEnabler with the current settings and stored it in _contentFilterEnabler.
* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController didChangeSettings]): Created a WebMockContentFilterEnabler and set it as the object for the eponymous bundle parameter.
* TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig: Linked against libWebCoreTestSupport.
* TestWebKitAPI/Tests/WebKit2Cocoa/ContentFiltering.mm:
(configurationWithContentFilterSettings): Converted to use WebMockContentFilterEnabler, WebMockContentFilterDecision, and WebMockContentFilterDecisionPoint.
(TEST): Ditto.
(downloadTest): Ditto.
(+[MockContentFilterEnabler supportsSecureCoding]): Deleted.
(-[MockContentFilterEnabler copyWithZone:]): Deleted.
(-[MockContentFilterEnabler initWithCoder:]): Deleted.
(-[MockContentFilterEnabler initWithDecision:decisionPoint:]): Deleted.
(-[MockContentFilterEnabler encodeWithCoder:]): Deleted.
* TestWebKitAPI/Tests/WebKit2Cocoa/ContentFilteringPlugIn.mm:
(-[ContentFilteringPlugIn webProcessPlugIn:initializeWithObject:]): Converted to use WebMockContentFilterEnabler.
(-[ContentFilteringPlugIn dealloc]): Ditto.
(-[ContentFilteringPlugIn observeValueForKeyPath:ofObject:change:context:]): Ditto.
(+[MockContentFilterEnabler supportsSecureCoding]): Deleted.
(-[MockContentFilterEnabler copyWithZone:]): Deleted.
(-[MockContentFilterEnabler initWithCoder:]): Deleted.
(-[MockContentFilterEnabler dealloc]): Deleted.
(-[MockContentFilterEnabler encodeWithCoder:]): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192769 268f45cc-cd09-0410-ab3c-d52691b4dbfc
28 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSMockContentFilterSettingsCustom.cpp
Source/WebCore/testing/MockContentFilter.cpp
Source/WebCore/testing/MockContentFilter.h
Source/WebCore/testing/MockContentFilterEnabler.h [new file with mode: 0644]
Source/WebCore/testing/MockContentFilterEnabler.mm [new file with mode: 0644]
Source/WebCore/testing/MockContentFilterSettings.h
Tools/ChangeLog
Tools/MiniBrowser/Configurations/Base.xcconfig
Tools/MiniBrowser/Configurations/MiniBrowser.xcconfig
Tools/MiniBrowser/Configurations/MiniBrowserBundle.xcconfig
Tools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj
Tools/MiniBrowser/MiniBrowserWebProcessPlugIn.m
Tools/MiniBrowser/blocked-page.html [new file with mode: 0644]
Tools/MiniBrowser/mac/AppDelegate.m
Tools/MiniBrowser/mac/BrowserWindowController.h
Tools/MiniBrowser/mac/BrowserWindowController.m
Tools/MiniBrowser/mac/Bundle/MiniBrowserBundle_Prefix.pch
Tools/MiniBrowser/mac/MiniBrowser_Prefix.pch
Tools/MiniBrowser/mac/SettingsController.h
Tools/MiniBrowser/mac/SettingsController.m
Tools/MiniBrowser/mac/WK1BrowserWindowController.h
Tools/MiniBrowser/mac/WK1BrowserWindowController.m
Tools/MiniBrowser/mac/WK2BrowserWindowController.m
Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/ContentFiltering.mm
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/ContentFilteringPlugIn.mm