PageGroup.h 3.86 KB
Newer Older
1
/*
darin@apple.com's avatar
darin@apple.com committed
2
 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 4 5 6 7 8 9 10 11 12
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
darin@apple.com's avatar
darin@apple.com committed
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 15
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
darin@apple.com's avatar
darin@apple.com committed
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17 18 19 20 21 22 23 24 25
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

darin@apple.com's avatar
darin@apple.com committed
26 27
#ifndef PageGroup_h
#define PageGroup_h
28

darin@apple.com's avatar
darin@apple.com committed
29 30
#include <wtf/HashSet.h>
#include <wtf/Noncopyable.h>
brettw@chromium.org's avatar
brettw@chromium.org committed
31
#include "LinkHash.h"
darin@apple.com's avatar
darin@apple.com committed
32
#include "StringHash.h"
33
#include "UserScript.h"
34
#include "UserStyleSheet.h"
35

darin@apple.com's avatar
darin@apple.com committed
36
namespace WebCore {
darin's avatar
darin committed
37

darin@apple.com's avatar
darin@apple.com committed
38 39
    class KURL;
    class Page;
40
    class StorageNamespace;
41

bfulgham@webkit.org's avatar
bfulgham@webkit.org committed
42
    class PageGroup : public Noncopyable {
darin@apple.com's avatar
darin@apple.com committed
43
    public:
44
        PageGroup(const String& name);
darin@apple.com's avatar
darin@apple.com committed
45
        PageGroup(Page*);
46
        ~PageGroup();
darin@apple.com's avatar
darin@apple.com committed
47

48
        static PageGroup* pageGroup(const String& groupName);
beidson@apple.com's avatar
beidson@apple.com committed
49
        static void closeLocalStorage();
50
        
darin@apple.com's avatar
darin@apple.com committed
51 52 53 54 55
        const HashSet<Page*>& pages() const { return m_pages; }

        void addPage(Page*);
        void removePage(Page*);

brettw@chromium.org's avatar
brettw@chromium.org committed
56
        bool isLinkVisited(LinkHash);
57

darin@apple.com's avatar
darin@apple.com committed
58 59 60
        void addVisitedLink(const KURL&);
        void addVisitedLink(const UChar*, size_t);
        void removeVisitedLinks();
darin@apple.com's avatar
darin@apple.com committed
61 62

        static void setShouldTrackVisitedLinks(bool);
darin@apple.com's avatar
darin@apple.com committed
63
        static void removeAllVisitedLinks();
64

65
        const String& name() { return m_name; }
kmccullough@apple.com's avatar
kmccullough@apple.com committed
66 67
        unsigned identifier() { return m_identifier; }

68
#if ENABLE(DOM_STORAGE)
69
        StorageNamespace* localStorage();
70
        bool hasLocalStorage() { return m_localStorage; }
71
#endif
darin@apple.com's avatar
darin@apple.com committed
72

73
        void addUserScriptToWorld(DOMWrapperWorld*, const String& source, const KURL&, 
74 75
                                  PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
                                  UserScriptInjectionTime);
76
        void addUserStyleSheetToWorld(DOMWrapperWorld*, const String& source, const KURL&,
77
                               PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist);
78
        
79 80
        void removeUserScriptFromWorld(DOMWrapperWorld*, const KURL&);
        void removeUserStyleSheetFromWorld(DOMWrapperWorld*, const KURL&);
81
        
82 83
        void removeUserScriptsFromWorld(DOMWrapperWorld*);
        void removeUserStyleSheetsFromWorld(DOMWrapperWorld*);
84
    
85 86
        void removeAllUserContent();
        
87 88 89
        const UserScriptMap* userScripts() const { return m_userScripts.get(); }
        const UserStyleSheetMap* userStyleSheets() const { return m_userStyleSheets.get(); }

darin@apple.com's avatar
darin@apple.com committed
90
    private:
brettw@chromium.org's avatar
brettw@chromium.org committed
91
        void addVisitedLink(LinkHash stringHash);
92

93 94
        String m_name;

darin@apple.com's avatar
darin@apple.com committed
95
        HashSet<Page*> m_pages;
brettw@chromium.org's avatar
brettw@chromium.org committed
96 97

        HashSet<LinkHash, LinkHashHash> m_visitedLinkHashes;
darin@apple.com's avatar
darin@apple.com committed
98
        bool m_visitedLinksPopulated;
99

kmccullough@apple.com's avatar
kmccullough@apple.com committed
100
        unsigned m_identifier;
101
#if ENABLE(DOM_STORAGE)
102
        RefPtr<StorageNamespace> m_localStorage;
103
#endif
104 105

        OwnPtr<UserScriptMap> m_userScripts;
106
        OwnPtr<UserStyleSheetMap> m_userStyleSheets;
darin@apple.com's avatar
darin@apple.com committed
107 108 109 110 111
    };

} // namespace WebCore
    
#endif // PageGroup_h