0
|
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 "Navigator.h"
|
|
25 |
|
|
26 |
#include "CookieJar.h"
|
|
27 |
#include "Frame.h"
|
|
28 |
#include "FrameLoader.h"
|
|
29 |
#include "FrameLoaderClient.h"
|
|
30 |
#include "Geolocation.h"
|
|
31 |
#include "Language.h"
|
|
32 |
#include "MimeTypeArray.h"
|
|
33 |
#include "Page.h"
|
|
34 |
#include "PageGroup.h"
|
|
35 |
#include "PlatformString.h"
|
|
36 |
#include "PluginArray.h"
|
|
37 |
#include "PluginData.h"
|
|
38 |
#include "ScriptController.h"
|
|
39 |
#include "Settings.h"
|
|
40 |
#include "StorageNamespace.h"
|
|
41 |
|
|
42 |
namespace WebCore {
|
|
43 |
|
|
44 |
Navigator::Navigator(Frame* frame)
|
|
45 |
: m_frame(frame)
|
|
46 |
{
|
|
47 |
}
|
|
48 |
|
|
49 |
Navigator::~Navigator()
|
|
50 |
{
|
|
51 |
disconnectFrame();
|
|
52 |
}
|
|
53 |
|
|
54 |
void Navigator::disconnectFrame()
|
|
55 |
{
|
|
56 |
if (m_plugins) {
|
|
57 |
m_plugins->disconnectFrame();
|
|
58 |
m_plugins = 0;
|
|
59 |
}
|
|
60 |
if (m_mimeTypes) {
|
|
61 |
m_mimeTypes->disconnectFrame();
|
|
62 |
m_mimeTypes = 0;
|
|
63 |
}
|
|
64 |
if (m_geolocation) {
|
|
65 |
m_geolocation->disconnectFrame();
|
|
66 |
m_geolocation = 0;
|
|
67 |
}
|
|
68 |
m_frame = 0;
|
|
69 |
}
|
|
70 |
|
|
71 |
// If this function returns true, we need to hide the substring "4." that would otherwise
|
|
72 |
// appear in the appVersion string. This is to avoid problems with old versions of a
|
|
73 |
// library called OpenCube QuickMenu, which as of this writing is still being used on
|
|
74 |
// sites such as nwa.com -- the library thinks Safari is Netscape 4 if we don't do this!
|
|
75 |
static bool shouldHideFourDot(Frame* frame)
|
|
76 |
{
|
|
77 |
const String* sourceURL = frame->script()->sourceURL();
|
|
78 |
if (!sourceURL)
|
|
79 |
return false;
|
|
80 |
if (!(sourceURL->endsWith("/dqm_script.js") || sourceURL->endsWith("/dqm_loader.js") || sourceURL->endsWith("/tdqm_loader.js")))
|
|
81 |
return false;
|
|
82 |
Settings* settings = frame->settings();
|
|
83 |
if (!settings)
|
|
84 |
return false;
|
|
85 |
return settings->needsSiteSpecificQuirks();
|
|
86 |
}
|
|
87 |
|
|
88 |
String Navigator::appVersion() const
|
|
89 |
{
|
|
90 |
if (!m_frame)
|
|
91 |
return String();
|
|
92 |
String appVersion = NavigatorBase::appVersion();
|
|
93 |
if (shouldHideFourDot(m_frame))
|
|
94 |
appVersion.replace("4.", "4_");
|
|
95 |
return appVersion;
|
|
96 |
}
|
|
97 |
|
|
98 |
String Navigator::language() const
|
|
99 |
{
|
|
100 |
return defaultLanguage();
|
|
101 |
}
|
|
102 |
|
|
103 |
String Navigator::userAgent() const
|
|
104 |
{
|
|
105 |
if (!m_frame)
|
|
106 |
return String();
|
|
107 |
|
|
108 |
// If the frame is already detached, FrameLoader::userAgent may malfunction, because it calls a client method
|
|
109 |
// that uses frame's WebView (at least, in Mac WebKit).
|
|
110 |
if (!m_frame->page())
|
|
111 |
return String();
|
|
112 |
|
|
113 |
return m_frame->loader()->userAgent(m_frame->document()->url());
|
|
114 |
}
|
|
115 |
|
|
116 |
PluginArray* Navigator::plugins() const
|
|
117 |
{
|
|
118 |
if (!m_plugins)
|
|
119 |
m_plugins = PluginArray::create(m_frame);
|
|
120 |
return m_plugins.get();
|
|
121 |
}
|
|
122 |
|
|
123 |
MimeTypeArray* Navigator::mimeTypes() const
|
|
124 |
{
|
|
125 |
if (!m_mimeTypes)
|
|
126 |
m_mimeTypes = MimeTypeArray::create(m_frame);
|
|
127 |
return m_mimeTypes.get();
|
|
128 |
}
|
|
129 |
|
|
130 |
bool Navigator::cookieEnabled() const
|
|
131 |
{
|
|
132 |
if (!m_frame)
|
|
133 |
return false;
|
|
134 |
|
|
135 |
if (m_frame->page() && !m_frame->page()->cookieEnabled())
|
|
136 |
return false;
|
|
137 |
|
|
138 |
return cookiesEnabled(m_frame->document());
|
|
139 |
}
|
|
140 |
|
|
141 |
bool Navigator::javaEnabled() const
|
|
142 |
{
|
|
143 |
if (!m_frame || !m_frame->settings())
|
|
144 |
return false;
|
|
145 |
|
|
146 |
return m_frame->settings()->isJavaEnabled();
|
|
147 |
}
|
|
148 |
|
|
149 |
Geolocation* Navigator::geolocation() const
|
|
150 |
{
|
|
151 |
if (!m_geolocation)
|
|
152 |
m_geolocation = Geolocation::create(m_frame);
|
|
153 |
return m_geolocation.get();
|
|
154 |
}
|
|
155 |
|
|
156 |
#if ENABLE(DOM_STORAGE)
|
|
157 |
void Navigator::getStorageUpdates()
|
|
158 |
{
|
|
159 |
if (!m_frame)
|
|
160 |
return;
|
|
161 |
|
|
162 |
Page* page = m_frame->page();
|
|
163 |
if (!page)
|
|
164 |
return;
|
|
165 |
|
|
166 |
StorageNamespace* localStorage = page->group().localStorage();
|
|
167 |
if (localStorage)
|
|
168 |
localStorage->unlock();
|
|
169 |
}
|
|
170 |
#endif
|
|
171 |
|
|
172 |
} // namespace WebCore
|