Skip to content

Commit bd37f14

Browse files
committed
<rdar://problem/9287880> and https://bugs.webkit.org/show_bug.cgi?id=58596
WK2: Past searches not remembered for <input type=search results="5" autosave="foo"> Reviewed by Sam Weinig. Add SaveRecentSearches and LoadRecentSearches messages: * UIProcess/WebPageProxy.messages.in: * UIProcess/WebPageProxy.h: Message up to the UIProcess for the save/load operations: * WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp: (WebKit::WebSearchPopupMenu::saveRecentSearches): (WebKit::WebSearchPopupMenu::loadRecentSearches): * WebProcess/WebCoreSupport/WebPopupMenu.h: (WebKit::WebPopupMenu::page): Save the values to disk CFPreference-style: * UIProcess/cf/WebPageProxyCF.cpp: (WebKit::autosaveKey): (WebKit::WebPageProxy::saveRecentSearches): (WebKit::WebPageProxy::loadRecentSearches): Stubbed out for non-CF platforms: * UIProcess/gtk/WebPageProxyGtk.cpp: (WebKit::WebPageProxy::saveRecentSearches): (WebKit::WebPageProxy::loadRecentSearches): * UIProcess/qt/WebPageProxyQt.cpp: (WebKit::WebPageProxy::saveRecentSearches): (WebKit::WebPageProxy::loadRecentSearches): Canonical link: https://commits.webkit.org/73755@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@84011 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent fa2738c commit bd37f14

8 files changed

Lines changed: 132 additions & 2 deletions

File tree

Source/WebKit2/ChangeLog

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
2011-04-15 Brady Eidson <beidson@apple.com>
2+
3+
Reviewed by Sam Weinig.
4+
5+
<rdar://problem/9287880> and https://bugs.webkit.org/show_bug.cgi?id=58596
6+
WK2: Past searches not remembered for <input type=search results="5" autosave="foo">
7+
8+
Add SaveRecentSearches and LoadRecentSearches messages:
9+
* UIProcess/WebPageProxy.messages.in:
10+
* UIProcess/WebPageProxy.h:
11+
12+
Message up to the UIProcess for the save/load operations:
13+
* WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp:
14+
(WebKit::WebSearchPopupMenu::saveRecentSearches):
15+
(WebKit::WebSearchPopupMenu::loadRecentSearches):
16+
* WebProcess/WebCoreSupport/WebPopupMenu.h:
17+
(WebKit::WebPopupMenu::page):
18+
19+
Save the values to disk CFPreference-style:
20+
* UIProcess/cf/WebPageProxyCF.cpp:
21+
(WebKit::autosaveKey):
22+
(WebKit::WebPageProxy::saveRecentSearches):
23+
(WebKit::WebPageProxy::loadRecentSearches):
24+
25+
Stubbed out for non-CF platforms:
26+
* UIProcess/gtk/WebPageProxyGtk.cpp:
27+
(WebKit::WebPageProxy::saveRecentSearches):
28+
(WebKit::WebPageProxy::loadRecentSearches):
29+
* UIProcess/qt/WebPageProxyQt.cpp:
30+
(WebKit::WebPageProxy::saveRecentSearches):
31+
(WebKit::WebPageProxy::loadRecentSearches):
32+
133
2011-04-14 Alexey Proskuryakov <ap@apple.com>
234

335
Reviewed by Dan Bernstein.

Source/WebKit2/UIProcess/WebPageProxy.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,10 @@ class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client {
625625
void showContextMenu(const WebCore::IntPoint& menuLocation, const ContextMenuState&, const Vector<WebContextMenuItemData>&, CoreIPC::ArgumentDecoder*);
626626
void internalShowContextMenu(const WebCore::IntPoint& menuLocation, const ContextMenuState&, const Vector<WebContextMenuItemData>&, CoreIPC::ArgumentDecoder*);
627627

628+
// Search popup results
629+
void saveRecentSearches(const String&, const Vector<String>&);
630+
void loadRecentSearches(const String&, Vector<String>&);
631+
628632
#if PLATFORM(MAC)
629633
// Speech.
630634
void getIsSpeaking(bool&);

Source/WebKit2/UIProcess/WebPageProxy.messages.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,8 @@ messages -> WebPageProxy {
238238
# Windows 7 Gesture Messages
239239
SetGestureReachedScrollingLimit(bool limitReached)
240240
#endif
241+
242+
# Search popup menus
243+
SaveRecentSearches(WTF::String name, Vector<String> searchItems)
244+
LoadRecentSearches(WTF::String name) -> (Vector<String> result)
241245
}

Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,48 @@ void WebPageProxy::restoreFromSessionStateData(WebData* webData)
180180
loadURL(provisionalURL);
181181
}
182182

183+
static RetainPtr<CFStringRef> autosaveKey(const String& name)
184+
{
185+
String key = "com.apple.WebKit.searchField:" + name;
186+
return RetainPtr<CFStringRef>(AdoptCF, key.createCFString());
187+
}
188+
189+
void WebPageProxy::saveRecentSearches(const String& name, const Vector<String>& searchItems)
190+
{
191+
// The WebProcess shouldn't have bothered to send this message if the name was empty.
192+
ASSERT(!name.isEmpty());
193+
194+
RetainPtr<CFMutableArrayRef> items;
195+
196+
if (size_t size = searchItems.size()) {
197+
items.adoptCF(CFArrayCreateMutable(0, size, &kCFTypeArrayCallBacks));
198+
for (size_t i = 0; i < size; ++i) {
199+
RetainPtr<CFStringRef> item(AdoptCF, searchItems[i].createCFString());
200+
CFArrayAppendValue(items.get(), item.get());
201+
}
202+
}
203+
204+
CFPreferencesSetAppValue(autosaveKey(name).get(), items.get(), kCFPreferencesCurrentApplication);
205+
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
206+
}
207+
208+
void WebPageProxy::loadRecentSearches(const String& name, Vector<String>& searchItems)
209+
{
210+
// The WebProcess shouldn't have bothered to send this message if the name was empty.
211+
ASSERT(!name.isEmpty());
212+
213+
searchItems.clear();
214+
RetainPtr<CFArrayRef> items(AdoptCF, reinterpret_cast<CFArrayRef>(CFPreferencesCopyAppValue(autosaveKey(name).get(), kCFPreferencesCurrentApplication)));
215+
216+
if (!items || CFGetTypeID(items.get()) != CFArrayGetTypeID())
217+
return;
218+
219+
size_t size = CFArrayGetCount(items.get());
220+
for (size_t i = 0; i < size; ++i) {
221+
CFStringRef item = (CFStringRef)CFArrayGetValueAtIndex(items.get(), i);
222+
if (CFGetTypeID(item) == CFStringGetTypeID())
223+
searchItems.append(item);
224+
}
225+
}
226+
183227
} // namespace WebKit

Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "WebPageProxy.h"
2929

3030
#include "NativeWebKeyboardEvent.h"
31+
#include "NotImplemented.h"
3132
#include "PageClient.h"
3233

3334
namespace WebKit {
@@ -43,4 +44,14 @@ void WebPageProxy::getEditorCommandsForKeyEvent(Vector<WTF::String>& commandsLis
4344
m_pageClient->getEditorCommandsForKeyEvent(m_keyEventQueue.first(), commandsList);
4445
}
4546

47+
void WebPageProxy::saveRecentSearches(const String&, const Vector<String>&)
48+
{
49+
notImplemented();
50+
}
51+
52+
void WebPageProxy::loadRecentSearches(const String&, Vector<String>&)
53+
{
54+
notImplemented();
55+
}
56+
4657
} // namespace WebKit

Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include "config.h"
2727
#include "WebPageProxy.h"
2828

29+
#include <WebCore/NotImplemented.h>
30+
2931
namespace WebKit {
3032

3133
String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
@@ -34,4 +36,14 @@ String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent
3436
return "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6) AppleWebKit/531.4 (KHTML, like Gecko) Version/4.0.3 Safari/531.4";
3537
}
3638

39+
void WebPageProxy::saveRecentSearches(const String&, const Vector<String>&)
40+
{
41+
notImplemented();
42+
}
43+
44+
void WebPageProxy::loadRecentSearches(const String&, Vector<String>&)
45+
{
46+
notImplemented();
47+
}
48+
3749
} // namespace WebKit

Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class WebPopupMenu : public WebCore::PopupMenu {
4343
static PassRefPtr<WebPopupMenu> create(WebPage*, WebCore::PopupMenuClient*);
4444
~WebPopupMenu();
4545

46+
WebPage* page() { return m_page; }
47+
4648
void disconnectFromPage() { m_page = 0; }
4749
void didChangeSelectedIndex(int newIndex);
4850
void setTextForIndex(int newIndex);

Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
#include "config.h"
2424
#include "WebSearchPopupMenu.h"
2525

26+
#include "WebPage.h"
27+
#include "WebPageProxyMessages.h"
28+
#include "WebProcess.h"
29+
#include <wtf/text/AtomicString.h>
30+
2631
using namespace WebCore;
2732

2833
namespace WebKit {
@@ -42,12 +47,28 @@ PopupMenu* WebSearchPopupMenu::popupMenu()
4247
return m_popup.get();
4348
}
4449

45-
void WebSearchPopupMenu::saveRecentSearches(const AtomicString&, const Vector<String>&)
50+
void WebSearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
4651
{
52+
if (name.isEmpty())
53+
return;
54+
55+
WebPage* page = m_popup->page();
56+
if (!page)
57+
return;
58+
59+
WebProcess::shared().connection()->send(Messages::WebPageProxy::SaveRecentSearches(name, searchItems), page->pageID());
4760
}
4861

49-
void WebSearchPopupMenu::loadRecentSearches(const AtomicString&, Vector<String>&)
62+
void WebSearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& resultItems)
5063
{
64+
if (name.isEmpty())
65+
return;
66+
67+
WebPage* page = m_popup->page();
68+
if (!page)
69+
return;
70+
71+
WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::LoadRecentSearches(name), Messages::WebPageProxy::LoadRecentSearches::Reply(resultItems), page->pageID());
5172
}
5273

5374
bool WebSearchPopupMenu::enabled()

0 commit comments

Comments
 (0)