WebCore/page/PageGroup.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2  * Copyright (C) 2008 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. ``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 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 PageGroup_h
       
    27 #define PageGroup_h
       
    28 
       
    29 #include <wtf/HashSet.h>
       
    30 #include <wtf/Noncopyable.h>
       
    31 #include "LinkHash.h"
       
    32 #include "StringHash.h"
       
    33 #include "UserScript.h"
       
    34 #include "UserStyleSheet.h"
       
    35 
       
    36 namespace WebCore {
       
    37 
       
    38     class KURL;
       
    39     class IndexedDatabase;
       
    40     class Page;
       
    41     class StorageNamespace;
       
    42 
       
    43     class PageGroup : public Noncopyable {
       
    44     public:
       
    45         PageGroup(const String& name);
       
    46         PageGroup(Page*);
       
    47         ~PageGroup();
       
    48 
       
    49         static PageGroup* pageGroup(const String& groupName);
       
    50         static void closeLocalStorage();
       
    51         
       
    52         const HashSet<Page*>& pages() const { return m_pages; }
       
    53 
       
    54         void addPage(Page*);
       
    55         void removePage(Page*);
       
    56 
       
    57         bool isLinkVisited(LinkHash);
       
    58 
       
    59         void addVisitedLink(const KURL&);
       
    60         void addVisitedLink(const UChar*, size_t);
       
    61         void removeVisitedLinks();
       
    62 
       
    63         static void setShouldTrackVisitedLinks(bool);
       
    64         static void removeAllVisitedLinks();
       
    65 
       
    66         const String& name() { return m_name; }
       
    67         unsigned identifier() { return m_identifier; }
       
    68 
       
    69 #if ENABLE(DOM_STORAGE)
       
    70         StorageNamespace* localStorage();
       
    71         bool hasLocalStorage() { return m_localStorage; }
       
    72 #endif
       
    73 #if ENABLE(INDEXED_DATABASE)
       
    74         IndexedDatabase* indexedDatabase();
       
    75 #endif
       
    76 
       
    77         void addUserScriptToWorld(DOMWrapperWorld*, const String& source, const KURL&,
       
    78                                   PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
       
    79                                   UserScriptInjectionTime, UserContentInjectedFrames);
       
    80         void addUserStyleSheetToWorld(DOMWrapperWorld*, const String& source, const KURL&,
       
    81                                       PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
       
    82                                       UserContentInjectedFrames);
       
    83 
       
    84         void removeUserScriptFromWorld(DOMWrapperWorld*, const KURL&);
       
    85         void removeUserStyleSheetFromWorld(DOMWrapperWorld*, const KURL&);
       
    86 
       
    87         void removeUserScriptsFromWorld(DOMWrapperWorld*);
       
    88         void removeUserStyleSheetsFromWorld(DOMWrapperWorld*);
       
    89 
       
    90         void removeAllUserContent();
       
    91 
       
    92         const UserScriptMap* userScripts() const { return m_userScripts.get(); }
       
    93         const UserStyleSheetMap* userStyleSheets() const { return m_userStyleSheets.get(); }
       
    94 
       
    95     private:
       
    96         void addVisitedLink(LinkHash stringHash);
       
    97         void resetUserStyleCacheInAllFrames();
       
    98   
       
    99         String m_name;
       
   100 
       
   101         HashSet<Page*> m_pages;
       
   102 
       
   103         HashSet<LinkHash, LinkHashHash> m_visitedLinkHashes;
       
   104         bool m_visitedLinksPopulated;
       
   105 
       
   106         unsigned m_identifier;
       
   107 #if ENABLE(DOM_STORAGE)
       
   108         RefPtr<StorageNamespace> m_localStorage;
       
   109 #endif
       
   110 #if ENABLE(INDEXED_DATABASE)
       
   111         RefPtr<IndexedDatabase> m_indexedDatabase;
       
   112 #endif
       
   113 
       
   114         OwnPtr<UserScriptMap> m_userScripts;
       
   115         OwnPtr<UserStyleSheetMap> m_userStyleSheets;
       
   116     };
       
   117 
       
   118 } // namespace WebCore
       
   119     
       
   120 #endif // PageGroup_h