Home | History | Annotate | Download | only in geolocation
      1 /*
      2  *  Copyright (C) 2000 Harri Porten (porten (at) kde.org)
      3  *  Copyright (c) 2000 Daniel Molkentin (molkentin (at) kde.org)
      4  *  Copyright (c) 2000 Stefan Schimanski (schimmi (at) 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 #include "modules/geolocation/NavigatorGeolocation.h"
     25 
     26 #include "core/dom/Document.h"
     27 #include "core/frame/LocalFrame.h"
     28 #include "core/frame/Navigator.h"
     29 #include "modules/geolocation/Geolocation.h"
     30 
     31 namespace blink {
     32 
     33 NavigatorGeolocation::NavigatorGeolocation(LocalFrame* frame)
     34     : DOMWindowProperty(frame)
     35 {
     36 }
     37 
     38 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(NavigatorGeolocation);
     39 
     40 const char* NavigatorGeolocation::supplementName()
     41 {
     42     return "NavigatorGeolocation";
     43 }
     44 
     45 NavigatorGeolocation& NavigatorGeolocation::from(Navigator& navigator)
     46 {
     47     NavigatorGeolocation* supplement = static_cast<NavigatorGeolocation*>(WillBeHeapSupplement<Navigator>::from(navigator, supplementName()));
     48     if (!supplement) {
     49         supplement = new NavigatorGeolocation(navigator.frame());
     50         provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement));
     51     }
     52     return *supplement;
     53 }
     54 
     55 Geolocation* NavigatorGeolocation::geolocation(Navigator& navigator)
     56 {
     57     return NavigatorGeolocation::from(navigator).geolocation();
     58 }
     59 
     60 Geolocation* NavigatorGeolocation::geolocation() const
     61 {
     62     if (!m_geolocation && frame())
     63         m_geolocation = Geolocation::create(frame()->document());
     64     return m_geolocation.get();
     65 }
     66 
     67 void NavigatorGeolocation::trace(Visitor* visitor)
     68 {
     69     visitor->trace(m_geolocation);
     70     WillBeHeapSupplement<Navigator>::trace(visitor);
     71     DOMWindowProperty::trace(visitor);
     72 }
     73 
     74 } // namespace blink
     75