~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/Modules/geolocation/NavigatorGeolocation.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 2000 Harri Porten (porten@kde.org)
 
3
 *  Copyright (c) 2000 Daniel Molkentin (molkentin@kde.org)
 
4
 *  Copyright (c) 2000 Stefan Schimanski (schimmi@kde.org)
 
5
 *  Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
 
6
 *  Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
 
7
 *
 
8
 *  This library is free software; you can redistribute it and/or
 
9
 *  modify it under the terms of the GNU Lesser General Public
 
10
 *  License as published by the Free Software Foundation; either
 
11
 *  version 2 of the License, or (at your option) any later version.
 
12
 *
 
13
 *  This library is distributed in the hope that it will be useful,
 
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 *  Lesser General Public License for more details.
 
17
 *
 
18
 *  You should have received a copy of the GNU Lesser General Public
 
19
 *  License along with this library; if not, write to the Free Software
 
20
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
21
 */
 
22
 
 
23
#include "config.h"
 
24
 
 
25
#if ENABLE(GEOLOCATION)
 
26
 
 
27
#include "NavigatorGeolocation.h"
 
28
 
 
29
#include "Document.h"
 
30
#include "Frame.h"
 
31
#include "Geolocation.h"
 
32
#include "Navigator.h"
 
33
 
 
34
namespace WebCore {
 
35
 
 
36
NavigatorGeolocation::NavigatorGeolocation(Frame* frame)
 
37
    : DOMWindowProperty(frame)
 
38
{
 
39
}
 
40
 
 
41
NavigatorGeolocation::~NavigatorGeolocation()
 
42
{
 
43
}
 
44
 
 
45
NavigatorGeolocation* NavigatorGeolocation::from(Navigator* navigator)
 
46
{
 
47
    DEFINE_STATIC_LOCAL(AtomicString, name, ("NavigatorGeolocation", AtomicString::ConstructFromLiteral));
 
48
    NavigatorGeolocation* supplement = static_cast<NavigatorGeolocation*>(Supplement<Navigator>::from(navigator, name));
 
49
    if (!supplement) {
 
50
        supplement = new NavigatorGeolocation(navigator->frame());
 
51
        provideTo(navigator, name, adoptPtr(supplement));
 
52
    }
 
53
    return supplement;
 
54
}
 
55
 
 
56
Geolocation* NavigatorGeolocation::geolocation(Navigator* navigator)
 
57
{
 
58
    return NavigatorGeolocation::from(navigator)->geolocation();
 
59
}
 
60
 
 
61
Geolocation* NavigatorGeolocation::geolocation() const
 
62
{
 
63
    if (!m_geolocation && frame())
 
64
        m_geolocation = Geolocation::create(frame()->document());
 
65
    return m_geolocation.get();
 
66
}
 
67
 
 
68
} // namespace WebCore
 
69
 
 
70
#endif // ENABLE(GEOLOCATION)