1 /* 2 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #ifndef WebIconDatabaseProxy_h 27 #define WebIconDatabaseProxy_h 28 29 #include "APIObject.h" 30 31 #include <WebCore/IconDatabaseBase.h> 32 33 #include <wtf/HashMap.h> 34 #include <wtf/PassRefPtr.h> 35 #include <wtf/RefPtr.h> 36 #include <wtf/Vector.h> 37 38 namespace CoreIPC { 39 class ArgumentDecoder; 40 class Connection; 41 class MessageID; 42 } 43 44 namespace WebKit { 45 46 class WebProcess; 47 48 class WebIconDatabaseProxy : public WebCore::IconDatabaseBase { 49 public: 50 explicit WebIconDatabaseProxy(WebProcess*); 51 virtual ~WebIconDatabaseProxy(); 52 53 virtual bool isEnabled() const; 54 void setEnabled(bool); 55 56 57 virtual void retainIconForPageURL(const String&); 58 virtual void releaseIconForPageURL(const String&); 59 virtual void setIconURLForPageURL(const String&, const String&); 60 virtual void setIconDataForIconURL(PassRefPtr<WebCore::SharedBuffer>, const String&); 61 62 virtual String synchronousIconURLForPageURL(const String&); 63 virtual bool synchronousIconDataKnownForIconURL(const String&); 64 virtual WebCore::IconLoadDecision synchronousLoadDecisionForIconURL(const String&, WebCore::DocumentLoader*); 65 virtual WebCore::Image* synchronousIconForPageURL(const String&, const WebCore::IntSize&); 66 67 // Asynchronous calls we should use to replace the above when supported. 68 virtual bool supportsAsynchronousMode(); 69 virtual void loadDecisionForIconURL(const String&, PassRefPtr<WebCore::IconLoadDecisionCallback>); 70 void receivedIconLoadDecision(int decision, uint64_t callbackID); 71 virtual void iconDataForIconURL(const String&, PassRefPtr<WebCore::IconDataCallback>); 72 73 void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); 74 75 private: 76 void didReceiveWebIconDatabaseProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); 77 78 // Callbacks from the UIProcess 79 void urlImportFinished(); 80 81 bool m_isEnabled; 82 WebProcess* m_process; 83 84 HashMap<uint64_t, RefPtr<WebCore::IconLoadDecisionCallback> > m_iconLoadDecisionCallbacks; 85 }; 86 87 } // namespace WebKit 88 89 #endif // WebIconDatabaseProxy_h 90