Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / frame / Navigator.cpp
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 #include "core/frame/Navigator.h"
25
26 #include "bindings/v8/ScriptController.h"
27 #include "core/dom/Document.h"
28 #include "core/frame/NavigatorID.h"
29 #include "core/loader/CookieJar.h"
30 #include "core/loader/FrameLoader.h"
31 #include "core/frame/Frame.h"
32 #include "core/frame/Settings.h"
33 #include "core/plugins/DOMMimeTypeArray.h"
34 #include "core/plugins/DOMPluginArray.h"
35 #include "platform/Language.h"
36
37 #ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB
38 #define WEBCORE_NAVIGATOR_PRODUCT_SUB "20030107"
39 #endif // ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB
40
41 #ifndef WEBCORE_NAVIGATOR_VENDOR
42 #define WEBCORE_NAVIGATOR_VENDOR "Google Inc."
43 #endif // ifndef WEBCORE_NAVIGATOR_VENDOR
44
45 #ifndef WEBCORE_NAVIGATOR_VENDOR_SUB
46 #define WEBCORE_NAVIGATOR_VENDOR_SUB ""
47 #endif // ifndef WEBCORE_NAVIGATOR_VENDOR_SUB
48
49 namespace WebCore {
50
51 Navigator::Navigator(Frame* frame)
52     : DOMWindowProperty(frame)
53 {
54     ScriptWrappable::init(this);
55 }
56
57 Navigator::~Navigator()
58 {
59 }
60
61 AtomicString Navigator::language() const
62 {
63     return defaultLanguage();
64 }
65
66 String Navigator::productSub() const
67 {
68     return WEBCORE_NAVIGATOR_PRODUCT_SUB;
69 }
70
71 String Navigator::vendor() const
72 {
73     return WEBCORE_NAVIGATOR_VENDOR;
74 }
75
76 String Navigator::vendorSub() const
77 {
78     return WEBCORE_NAVIGATOR_VENDOR_SUB;
79 }
80
81 String Navigator::userAgent() const
82 {
83     // If the frame is already detached it no longer has a meaningful useragent.
84     if (!m_frame || !m_frame->page())
85         return String();
86
87     return m_frame->loader().userAgent(m_frame->document()->url());
88 }
89
90 DOMPluginArray* Navigator::plugins() const
91 {
92     if (!m_plugins)
93         m_plugins = DOMPluginArray::create(m_frame);
94     return m_plugins.get();
95 }
96
97 DOMMimeTypeArray* Navigator::mimeTypes() const
98 {
99     if (!m_mimeTypes)
100         m_mimeTypes = DOMMimeTypeArray::create(m_frame);
101     return m_mimeTypes.get();
102 }
103
104 bool Navigator::cookieEnabled() const
105 {
106     if (!m_frame)
107         return false;
108
109     Settings* settings = m_frame->settings();
110     if (!settings || !settings->cookieEnabled())
111         return false;
112
113     return cookiesEnabled(m_frame->document());
114 }
115
116 bool Navigator::javaEnabled() const
117 {
118     if (!m_frame || !m_frame->settings())
119         return false;
120
121     if (!m_frame->settings()->javaEnabled())
122         return false;
123
124     return true;
125 }
126
127 void Navigator::getStorageUpdates()
128 {
129     // FIXME: Remove this method or rename to yieldForStorageUpdates.
130 }
131
132 } // namespace WebCore