Add WebKit API to clear data type Search Field Recent Searches.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Oct 2015 18:49:58 +0000 (18:49 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Oct 2015 18:49:58 +0000 (18:49 +0000)
commit63cec3b1300e1a18a1a75b5e355624934f017e14
tree3fe073a55cc341309bae9f03110a605ea8939fc4
parent11a7d9d409485042a09d1f7c53cb166ff6e883c8
Add WebKit API to clear data type Search Field Recent Searches.
https://bugs.webkit.org/show_bug.cgi?id=150019.

Patch by Zhuo Li <zachli@apple.com> on 2015-10-27
Reviewed by Anders Carlsson.

Source/WebCore:

* platform/cocoa/SearchPopupMenuCocoa.h: Add a function to remove recent searches based on
time.
* platform/cocoa/SearchPopupMenuCocoa.mm:
(WebCore::typeCheckedRecentSearchesArray): Return nil if the recent searches array is
corrupted, otherwise return the array.
(WebCore::typeCheckedDateInRecentSearch): Return nil if the date in recent search is
corrupted, otherwise return the date.
(WebCore::typeCheckedRecentSearchesRemovingRecentSearchesAddedAfterDate): Return nil if the recent searches plist is
corrupted, otherwise return the recent searches plist.
(WebCore::writeEmptyRecentSearchesPlist): Replace the existing recent searches plist if there is
any with a clean one.
(WebCore::loadRecentSearches): Use -typeCheckedRecentSearchesArray and -typeCheckedDateInRecentSearch.
(WebCore::removeRecentlyModifiedRecentSearches):
When the time passed in is equivalent to [NSDate distantPast], clear all recent searches in
the Recent Searches plist. Otherwise, we only clear the recent searches that were created
after or at the time that is passed in as the parameter. If all recent searches associated
with an autosave name were created after or at the time that is passed in as the parameter,
remove this autosave name key and all of its values in the plist. If all recent searches
associated with every autosave name in the plist were created after or at the time that is
passed in as the parameter, clear all recent searches in the Recent Searches plist.

Also, we clear all recent searches in the Recent Searches plist when we find the plist is
corrupted.

Source/WebKit2:

* Shared/WebsiteData/WebsiteDataTypes.h: Add data type Search Field Recent Searches.
* UIProcess/API/Cocoa/WKWebsiteDataRecord.mm:
(dataTypesToString): Ditto.
* UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h:
(WebKit::toWebsiteDataTypes): Ditto.
(WebKit::toWKWebsiteDataTypes): Ditto.
* UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h: Ditto.
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::removeData): Handle the case when data type is Search
Field Recent Searches.
* UIProcess/WebsiteData/WebsiteDataStore.h: Add a private function for removing
recent searches based on time.
* UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
(WebKit::WebsiteDataStoreCocoa::platformRemoveRecentSearches): Call the removing
recent searches logic in WebCore.
* UIProcess/efl/WebPageProxyEfl.cpp:
(WebKit::WebsiteDataStore::platformRemoveRecentSearches): Not implemented.
* UIProcess/gtk/WebPageProxyGtk.cpp:
(WebKit::WebsiteDataStore::platformRemoveRecentSearches): Not implemented.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191628 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/cocoa/SearchPopupMenuCocoa.h
Source/WebCore/platform/cocoa/SearchPopupMenuCocoa.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebsiteData/WebsiteDataTypes.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecord.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h
Source/WebKit2/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h
Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp
Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp