PageGroup.h 2.76 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

darin@apple.com's avatar
darin@apple.com committed
34
namespace WebCore {
darin's avatar
darin committed
35

darin@apple.com's avatar
darin@apple.com committed
36
    class KURL;
37
    class LocalStorage;
darin@apple.com's avatar
darin@apple.com committed
38
    class Page;
39

darin@apple.com's avatar
darin@apple.com committed
40 41
    class PageGroup : Noncopyable {
    public:
42
        PageGroup(const String& name);
darin@apple.com's avatar
darin@apple.com committed
43 44
        PageGroup(Page*);

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

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

brettw@chromium.org's avatar
brettw@chromium.org committed
53
        bool isLinkVisited(LinkHash);
54

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

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

62
        const String& name() { return m_name; }
kmccullough@apple.com's avatar
kmccullough@apple.com committed
63 64
        unsigned identifier() { return m_identifier; }

65
#if ENABLE(DOM_STORAGE)
66
        LocalStorage* localStorage();
67
#endif
darin@apple.com's avatar
darin@apple.com committed
68 69

    private:
brettw@chromium.org's avatar
brettw@chromium.org committed
70
        void addVisitedLink(LinkHash stringHash);
71 72 73
#if ENABLE(DOM_STORAGE)
        bool hasLocalStorage() { return m_localStorage; }
#endif
74 75
        String m_name;

darin@apple.com's avatar
darin@apple.com committed
76
        HashSet<Page*> m_pages;
brettw@chromium.org's avatar
brettw@chromium.org committed
77 78

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

kmccullough@apple.com's avatar
kmccullough@apple.com committed
81
        unsigned m_identifier;
82
#if ENABLE(DOM_STORAGE)
83
        RefPtr<LocalStorage> m_localStorage;
84
#endif
darin@apple.com's avatar
darin@apple.com committed
85 86 87 88 89
    };

} // namespace WebCore
    
#endif // PageGroup_h