webengine/osswebengine/WebKit/win/WebIconDatabase.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2  * Copyright (C) 2006, 2007 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 COMPUTER, INC. ``AS IS'' AND ANY
       
    14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
       
    15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
       
    16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
       
    17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
       
    18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
       
    19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
       
    20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
       
    21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       
    22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
       
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
       
    24  */
       
    25 
       
    26 #ifndef WebIconDatabase_H
       
    27 #define WebIconDatabase_H
       
    28 
       
    29 #include "IWebIconDatabase.h"
       
    30 
       
    31 #pragma warning(push, 0)
       
    32 #include <WebCore/IconDatabaseClient.h>
       
    33 #include <WebCore/IntSize.h>
       
    34 #include <WebCore/IntSizeHash.h>
       
    35 #include <WebCore/Threading.h>
       
    36 #pragma warning(pop)
       
    37 
       
    38 #include <WTF/HashMap.h>
       
    39 
       
    40 #include <windows.h>
       
    41 
       
    42 typedef const struct __CFString * CFStringRef;
       
    43 
       
    44 namespace WebCore
       
    45 {
       
    46     class IconDatabase;
       
    47 }; //namespace WebCore
       
    48 using namespace WebCore;
       
    49 using namespace WTF;
       
    50 
       
    51 class WebIconDatabase : public IWebIconDatabase, public WebCore::IconDatabaseClient
       
    52 {
       
    53 public:
       
    54     static WebIconDatabase* createInstance();
       
    55     static WebIconDatabase* sharedWebIconDatabase();
       
    56 private:
       
    57     WebIconDatabase();
       
    58     ~WebIconDatabase();
       
    59     void init();
       
    60 public:
       
    61 
       
    62     // IUnknown
       
    63     virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
       
    64     virtual ULONG STDMETHODCALLTYPE AddRef(void);
       
    65     virtual ULONG STDMETHODCALLTYPE Release(void);
       
    66 
       
    67     // IWebIconDatabase
       
    68     virtual HRESULT STDMETHODCALLTYPE sharedIconDatabase( 
       
    69         /* [retval][out] */ IWebIconDatabase **result);
       
    70     
       
    71     virtual HRESULT STDMETHODCALLTYPE iconForURL( 
       
    72         /* [in] */ BSTR url,
       
    73         /* [optional][in] */ LPSIZE size,
       
    74         /* [optional][in] */ BOOL cache,
       
    75         /* [retval][out] */ OLE_HANDLE *image);
       
    76     
       
    77     virtual HRESULT STDMETHODCALLTYPE defaultIconWithSize( 
       
    78         /* [in] */ LPSIZE size,
       
    79         /* [retval][out] */ OLE_HANDLE *result);
       
    80     
       
    81     virtual HRESULT STDMETHODCALLTYPE retainIconForURL( 
       
    82         /* [in] */ BSTR url);
       
    83     
       
    84     virtual HRESULT STDMETHODCALLTYPE releaseIconForURL( 
       
    85         /* [in] */ BSTR url);
       
    86 
       
    87     virtual HRESULT STDMETHODCALLTYPE removeAllIcons( void);
       
    88     
       
    89     virtual HRESULT STDMETHODCALLTYPE delayDatabaseCleanup( void);
       
    90     
       
    91     virtual HRESULT STDMETHODCALLTYPE allowDatabaseCleanup( void);
       
    92 
       
    93     virtual HRESULT STDMETHODCALLTYPE iconURLForURL( 
       
    94         /* [in] */ BSTR url,
       
    95         /* [retval][out] */ BSTR *iconURL);
       
    96 
       
    97     // IconDatabaseClient
       
    98     virtual void dispatchDidRemoveAllIcons();
       
    99     virtual void dispatchDidAddIconForPageURL(const WebCore::String&);
       
   100 
       
   101     static BSTR iconDatabaseDidAddIconNotification();
       
   102     static BSTR iconDatabaseDidRemoveAllIconsNotification();
       
   103     static CFStringRef iconDatabaseNotificationUserInfoURLKey();
       
   104 protected:
       
   105     ULONG m_refCount;
       
   106     static WebIconDatabase* m_sharedWebIconDatabase;
       
   107 
       
   108     // Keep a set of HBITMAPs around for the default icon, and another
       
   109     // to share amongst present site icons
       
   110     HBITMAP getOrCreateSharedBitmap(LPSIZE size);
       
   111     HBITMAP getOrCreateDefaultIconBitmap(LPSIZE size);
       
   112     HashMap<IntSize, HBITMAP> m_defaultIconMap;
       
   113     HashMap<IntSize, HBITMAP> m_sharedIconMap;
       
   114 
       
   115     Mutex m_notificationMutex;
       
   116     Vector<String> m_notificationQueue;
       
   117     void scheduleNotificationDelivery();
       
   118     bool m_deliveryRequested;
       
   119 
       
   120     static void deliverNotifications();
       
   121 };
       
   122 
       
   123 #endif