1/*
2 * Copyright (C) 2013 Google 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 are
6 * met:
7 *
8 *     * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *     * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 *     * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef FrameHost_h
32#define FrameHost_h
33
34#include "core/frame/PinchViewport.h"
35#include "platform/heap/Handle.h"
36#include "wtf/FastAllocBase.h"
37#include "wtf/Noncopyable.h"
38#include "wtf/OwnPtr.h"
39#include "wtf/PassOwnPtr.h"
40
41namespace blink {
42
43class Chrome;
44class EventHandlerRegistry;
45class Page;
46class PinchViewport;
47class Settings;
48class UseCounter;
49class Visitor;
50
51// FrameHost is the set of global data shared between multiple frames
52// and is provided by the embedder to each frame when created.
53// FrameHost currently corresponds to the Page object in core/page
54// however the concept of a Page is moving up out of Blink.
55// In an out-of-process iframe world, a single Page may have
56// multiple frames in different process, thus Page becomes a
57// browser-level concept and Blink core/ only knows about its LocalFrame (and FrameHost).
58// Separating Page from the rest of core/ through this indirection
59// allows us to slowly refactor Page without breaking the rest of core.
60class FrameHost FINAL : public NoBaseWillBeGarbageCollectedFinalized<FrameHost> {
61    WTF_MAKE_NONCOPYABLE(FrameHost); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
62public:
63    static PassOwnPtrWillBeRawPtr<FrameHost> create(Page&);
64    ~FrameHost();
65
66    // Careful: This function will eventually be removed.
67    Page& page() const { return *m_page; }
68    Settings& settings() const;
69    Chrome& chrome() const;
70    UseCounter& useCounter() const;
71
72    // Corresponds to pixel density of the device where this Page is
73    // being displayed. In multi-monitor setups this can vary between pages.
74    // This value does not account for Page zoom, use LocalFrame::devicePixelRatio instead.
75    float deviceScaleFactor() const;
76
77    PinchViewport& pinchViewport() const;
78    EventHandlerRegistry& eventHandlerRegistry() const;
79
80    void trace(Visitor*);
81
82private:
83    explicit FrameHost(Page&);
84
85    RawPtrWillBeMember<Page> m_page;
86    const OwnPtr<PinchViewport> m_pinchViewport;
87    const OwnPtrWillBeMember<EventHandlerRegistry> m_eventHandlerRegistry;
88};
89
90}
91
92#endif // FrameHost_h
93