15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/*
2926b001d589ce2f10facb93dd4b87578ea35a855Torne (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)
3109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#ifndef FrameHost_h
3209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#define FrameHost_h
335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
34d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/frame/PinchViewport.h"
35323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)#include "platform/heap/Handle.h"
3609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "wtf/FastAllocBase.h"
3709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "wtf/Noncopyable.h"
3809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "wtf/OwnPtr.h"
391e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "wtf/PassOwnPtr.h"
405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
41c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
43d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class Chrome;
44323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)class EventHandlerRegistry;
4509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)class Page;
46d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class PinchViewport;
4709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)class Settings;
4809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)class UseCounter;
49323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)class Visitor;
501e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)
5109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// FrameHost is the set of global data shared between multiple frames
5209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// and is provided by the embedder to each frame when created.
5309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// FrameHost currently corresponds to the Page object in core/page
5409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// however the concept of a Page is moving up out of Blink.
5509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// In an out-of-process iframe world, a single Page may have
5609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// multiple frames in different process, thus Page becomes a
57d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)// browser-level concept and Blink core/ only knows about its LocalFrame (and FrameHost).
5809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// Separating Page from the rest of core/ through this indirection
5909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// allows us to slowly refactor Page without breaking the rest of core.
60323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)class FrameHost FINAL : public NoBaseWillBeGarbageCollectedFinalized<FrameHost> {
61323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)    WTF_MAKE_NONCOPYABLE(FrameHost); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)public:
63323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)    static PassOwnPtrWillBeRawPtr<FrameHost> create(Page&);
6409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    ~FrameHost();
655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
6609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    // Careful: This function will eventually be removed.
67323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)    Page& page() const { return *m_page; }
6809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    Settings& settings() const;
6909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    Chrome& chrome() const;
7009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    UseCounter& useCounter() const;
7109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
7209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    // Corresponds to pixel density of the device where this Page is
7309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    // being displayed. In multi-monitor setups this can vary between pages.
74d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    // This value does not account for Page zoom, use LocalFrame::devicePixelRatio instead.
7509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    float deviceScaleFactor() const;
7653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
7710f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch    PinchViewport& pinchViewport() const;
78323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)    EventHandlerRegistry& eventHandlerRegistry() const;
79323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)
80323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)    void trace(Visitor*);
81d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
8253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)private:
8309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    explicit FrameHost(Page&);
8453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
85323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)    RawPtrWillBeMember<Page> m_page;
8610f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch    const OwnPtr<PinchViewport> m_pinchViewport;
87323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)    const OwnPtrWillBeMember<EventHandlerRegistry> m_eventHandlerRegistry;
8853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)};
895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
9009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
9209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#endif // FrameHost_h
93