15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/*
253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) * Copyright (C) 2013 Google Inc. All rights reserved.
35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions are
65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * met:
75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *     * Redistributions of source code must retain the above copyright
95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer.
105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *     * Redistributions in binary form must reproduce the above
115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer
125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * in the documentation and/or other materials provided with the
135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * distribution.
145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *     * Neither the name of Google Inc. nor the names of its
155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * contributors may be used to endorse or promote products derived from
165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * this software without specific prior written permission.
175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */
305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
315267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#ifndef LinkResource_h
325267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#define LinkResource_h
335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
34e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles)#include "core/fetch/FetchRequest.h"
35323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)#include "platform/heap/Handle.h"
3651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)#include "platform/weborigin/KURL.h"
375267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#include "wtf/text/WTFString.h"
385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
39c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
415267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class HTMLLinkElement;
425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
43323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)class LinkResource : public NoBaseWillBeGarbageCollectedFinalized<LinkResource>  {
44323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)    WTF_MAKE_NONCOPYABLE(LinkResource); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)public:
465267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    enum Type {
475267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        Style,
48323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)        Import,
49323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)        Manifest
505267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    };
515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
525267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    explicit LinkResource(HTMLLinkElement*);
535267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual ~LinkResource();
545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
55a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    bool shouldLoadResource() const;
56d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    LocalFrame* loadingFrame() const;
57a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)
585267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual Type type() const = 0;
595267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual void process() = 0;
60d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    virtual void ownerRemoved() { }
615d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    virtual void ownerInserted() { }
623c9e4aeaee9f9b0a9a814da07bcb33319c7ea363Ben Murdoch    virtual bool hasLoaded() const = 0;
635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
64323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)    virtual void trace(Visitor*);
65323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)
665267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)protected:
67323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)    RawPtrWillBeMember<HTMLLinkElement> m_owner;
685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)};
695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
705267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class LinkRequestBuilder {
71f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles)    STACK_ALLOCATED();
725267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)public:
735267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    explicit LinkRequestBuilder(HTMLLinkElement* owner);
745267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
755267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    bool isValid() const { return !m_url.isEmpty() && m_url.isValid(); }
765267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    const KURL& url() const { return m_url; }
77a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    const AtomicString& charset() const { return m_charset; }
783464d02a173573db42f8ee6bb07bb74fabf4f5f2Ben Murdoch    FetchRequest build(bool blocking) const;
795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
805267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)private:
81f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles)    RawPtrWillBeMember<HTMLLinkElement> m_owner;
825267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    KURL m_url;
83a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    AtomicString m_charset;
845267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)};
855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
86c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink
875267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
885267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#endif // LinkResource_h
89