Changeset 84011 in webkit


Ignore:
Timestamp:
Apr 15, 2011 12:24:16 PM (13 years ago)
Author:
beidson@apple.com
Message:

<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):

Location:
trunk/Source/WebKit2
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r83997 r84011  
     12011-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
    1332011-04-14  Alexey Proskuryakov  <ap@apple.com>
    234
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r83687 r84011  
    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.
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r83460 r84011  
    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}
  • trunk/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp

    r80829 r84011  
    181181}
    182182
     183static RetainPtr<CFStringRef> autosaveKey(const String& name)
     184{
     185    String key = "com.apple.WebKit.searchField:" + name;
     186    return RetainPtr<CFStringRef>(AdoptCF, key.createCFString());
     187}
     188
     189void 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
     208void 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
  • trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp

    r82929 r84011  
    2929
    3030#include "NativeWebKeyboardEvent.h"
     31#include "NotImplemented.h"
    3132#include "PageClient.h"
    3233
     
    4445}
    4546
     47void WebPageProxy::saveRecentSearches(const String&, const Vector<String>&)
     48{
     49    notImplemented();
     50}
     51
     52void WebPageProxy::loadRecentSearches(const String&, Vector<String>&)
     53{
     54    notImplemented();
     55}
     56
    4657} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp

    r79589 r84011  
    2727#include "WebPageProxy.h"
    2828
     29#include <WebCore/NotImplemented.h>
     30
    2931namespace WebKit {
    3032
     
    3537}
    3638
     39void WebPageProxy::saveRecentSearches(const String&, const Vector<String>&)
     40{
     41    notImplemented();
     42}
     43
     44void WebPageProxy::loadRecentSearches(const String&, Vector<String>&)
     45{
     46    notImplemented();
     47}
     48
    3749} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.h

    r74285 r84011  
    4444    ~WebPopupMenu();
    4545
     46    WebPage* page() { return m_page; }
     47
    4648    void disconnectFromPage() { m_page = 0; }
    4749    void didChangeSelectedIndex(int newIndex);
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp

    r83909 r84011  
    2424#include "WebSearchPopupMenu.h"
    2525
     26#include "WebPage.h"
     27#include "WebPageProxyMessages.h"
     28#include "WebProcess.h"
     29#include <wtf/text/AtomicString.h>
     30
    2631using namespace WebCore;
    2732
     
    4348}
    4449
    45 void WebSearchPopupMenu::saveRecentSearches(const AtomicString&, const Vector<String>&)
     50void 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>&)
     62void 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
Note: See TracChangeset for help on using the changeset viewer.