Augment <input type=search>’s recent search history with the time each entry was...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Oct 2015 05:19:02 +0000 (05:19 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Oct 2015 05:19:02 +0000 (05:19 +0000)
commit8e294ac0c5c4c5e73fca24f77a5b9a0bdaa36c6f
tree920e5f888f10358595e3c23174c724fa29c0dea5
parent8c5f7c9a6c7c6277c0974b36ac7e9d392939cebe
Augment <input type=search>’s recent search history with the time each entry was added,
in order to allow time-based clearing of search history.
https://bugs.webkit.org/show_bug.cgi?id=148388.

Patch by Zhuo Li <zachli@apple.com> on 2015-10-14
Reviewed by Darin Adler.

Replace Vector<String> with Vector<RecentSearch>, where RecentSearch is a struct
Source/WebCore:

that consists search string and time, for recent searches in order to store additional time
information.

* WebCore.xcodeproj/project.pbxproj: Added SearchPopupMenuCocoa.h and SearchPopupMenuCocoa.mm
and sort the project file.
* loader/EmptyClients.cpp:
(WebCore::EmptySearchPopupMenu::saveRecentSearches):
(WebCore::EmptySearchPopupMenu::loadRecentSearches):
* platform/SearchPopupMenu.h:
* platform/cocoa/SearchPopupMenuCocoa.h: Added methods for SeachPopupMenuMac in WebKit
and WebPageProxyCocoa in WebKit2 to call.
* platform/cocoa/SearchPopupMenuCocoa.mm: Added.
(WebCore::searchFieldRecentSearchesStorageDirectory): Recent searches with the new structure
are stored in a new location.
(WebCore::searchFieldRecentSearchesPlistPath): Get the path for the plist of the recent
searches entries.
(WebCore::RetainPtr<NSMutableDictionary> readSearchFieldRecentSearchesPlist): Return the
recent searches plist as NSMutableDictionary.
(WebCore::fromNSDatetoSystemClockTime): Convert from NSDate to system_clock::time_point.
(WebCore::fromSystemClockTimetoNSDate): Convert from system_clock::time_point to NSDate.
(WebCore::SearchPopupMenuCocoa::saveRecentSearches): Add a dictionary where it has two pairs
that the first one is the search string and the second one is the time.
(WebCore::SearchPopupMenuCocoa::loadRecentSearches): We expect the recent search item in the
plist to be a two-pair dictionary, and convert the dictionary to the struct RecentSearch.
* platform/win/SearchPopupMenuWin.cpp:
(WebCore::SearchPopupMenuWin::saveRecentSearches): Only save the RecentSearch's search
string on Windows platform, which is what we used to do.
(WebCore::SearchPopupMenuWin::loadRecentSearches): Since we need to construct a
RecentSearch, we get the string from the app's preferences, and set the time to be
std::chrono::system_clock::time_point::min().
* platform/win/SearchPopupMenuWin.h:
* rendering/RenderSearchField.cpp: Now that m_recentSearches are Vector<RecentSearch>,
we cannot use -removeAll with a search string. Use -removeAllMatching instead to remove the
item that has its member search string equal to the search string user inputs.
(WebCore::RenderSearchField::addSearchResult):
(WebCore::RenderSearchField::itemText):

Source/WebKit/ios:

that consists search string and time, for recent searches in order to store additional time information.

* WebCoreSupport/SearchPopupMenuIOS.cpp:
(SearchPopupMenuIOS::saveRecentSearches):
(SearchPopupMenuIOS::loadRecentSearches):
* WebCoreSupport/SearchPopupMenuIOS.h:

Source/WebKit/mac:

that consists search string and time, for recent searches in order to store additional time information.

All these new RecentSearches are stored in a plist in which the structure looks like:
Root {
    "items": {
        autosave name: {
            "searches": [
                { "searchString": searchString, "date": date },
                ...
            ]
        }
    }
}

* WebCoreSupport/SearchPopupMenuMac.h:
* WebCoreSupport/SearchPopupMenuMac.mm:
(SearchPopupMenuMac::saveRecentSearches): Call saveRecentSearches in WebCore::SearchPopupMenuCocoa.
(SearchPopupMenuMac::loadRecentSearches): Call loadRecentSearches in WebCore::SearchPopupMenuCocoa.
(autosaveKey): Deleted.

Source/WebKit2:

that consists search string and time, for recent searches in order to store additional time
information.

All these new RecentSearches are stored in a plist in which the structure looks like:
Root {
    "items": {
        autosave name: {
            "searches": [
                { "searchString": searchString, "date": date },
                ...
            ]
        }
    }
}

* Scripts/webkit/messages.py:
(headers_for_type):
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<RecentSearch>::encode): Encode the new struct RecentSearch
(IPC::ArgumentCoder<RecentSearch>::decode): Decode the new struct RecentSearch
* Shared/WebCoreArgumentCoders.h:
* UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::saveRecentSearches): Call saveRecentSearches in WebCore::SearchPopupMenuCocoa.
(WebKit::WebPageProxy::loadRecentSearches): Call loadRecentSearches in WebCore::SearchPopupMenuCocoa.
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/efl/WebPageProxyEfl.cpp:
(WebKit::WebPageProxy::saveRecentSearches):
(WebKit::WebPageProxy::loadRecentSearches):
* UIProcess/gtk/WebPageProxyGtk.cpp:
(WebKit::WebPageProxy::saveRecentSearches):
(WebKit::WebPageProxy::loadRecentSearches):
* WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp:
(WebKit::WebSearchPopupMenu::saveRecentSearches):
(WebKit::WebSearchPopupMenu::loadRecentSearches):
* WebProcess/WebCoreSupport/WebSearchPopupMenu.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191084 268f45cc-cd09-0410-ab3c-d52691b4dbfc
27 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/platform/SearchPopupMenu.h
Source/WebCore/platform/cocoa/SearchPopupMenuCocoa.h [new file with mode: 0644]
Source/WebCore/platform/cocoa/SearchPopupMenuCocoa.mm [new file with mode: 0644]
Source/WebCore/platform/win/SearchPopupMenuWin.cpp
Source/WebCore/platform/win/SearchPopupMenuWin.h
Source/WebCore/rendering/RenderSearchField.cpp
Source/WebCore/rendering/RenderSearchField.h
Source/WebKit/ios/ChangeLog
Source/WebKit/ios/WebCoreSupport/SearchPopupMenuIOS.cpp
Source/WebKit/ios/WebCoreSupport/SearchPopupMenuIOS.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/SearchPopupMenuMac.h
Source/WebKit/mac/WebCoreSupport/SearchPopupMenuMac.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Scripts/webkit/messages.py
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Source/WebKit2/Shared/WebCoreArgumentCoders.h
Source/WebKit2/UIProcess/Cocoa/WebPageProxyCocoa.mm
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp
Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.h