| OLD | NEW |
| (Empty) |
| 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 U
SA | |
| 21 */ | |
| 22 | |
| 23 #include "config.h" | |
| 24 #include "core/page/Navigator.h" | |
| 25 | |
| 26 #include "bindings/v8/ScriptController.h" | |
| 27 #include "core/dom/Document.h" | |
| 28 #include "core/loader/CookieJar.h" | |
| 29 #include "core/loader/FrameLoader.h" | |
| 30 #include "core/page/Frame.h" | |
| 31 #include "core/page/NavigatorID.h" | |
| 32 #include "core/page/Page.h" | |
| 33 #include "core/page/Settings.h" | |
| 34 #include "platform/Language.h" | |
| 35 #include "core/plugins/DOMMimeTypeArray.h" | |
| 36 #include "core/plugins/DOMPluginArray.h" | |
| 37 | |
| 38 #ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB | |
| 39 #define WEBCORE_NAVIGATOR_PRODUCT_SUB "20030107" | |
| 40 #endif // ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB | |
| 41 | |
| 42 #ifndef WEBCORE_NAVIGATOR_VENDOR | |
| 43 #define WEBCORE_NAVIGATOR_VENDOR "Google Inc." | |
| 44 #endif // ifndef WEBCORE_NAVIGATOR_VENDOR | |
| 45 | |
| 46 #ifndef WEBCORE_NAVIGATOR_VENDOR_SUB | |
| 47 #define WEBCORE_NAVIGATOR_VENDOR_SUB "" | |
| 48 #endif // ifndef WEBCORE_NAVIGATOR_VENDOR_SUB | |
| 49 | |
| 50 namespace WebCore { | |
| 51 | |
| 52 Navigator::Navigator(Frame* frame) | |
| 53 : DOMWindowProperty(frame) | |
| 54 { | |
| 55 ScriptWrappable::init(this); | |
| 56 } | |
| 57 | |
| 58 Navigator::~Navigator() | |
| 59 { | |
| 60 } | |
| 61 | |
| 62 // If this function returns true, we need to hide the substring "4." that would
otherwise | |
| 63 // appear in the appVersion string. This is to avoid problems with old versions
of a | |
| 64 // library called OpenCube QuickMenu, which as of this writing is still being us
ed on | |
| 65 // sites such as nwa.com -- the library thinks Safari is Netscape 4 if we don't
do this! | |
| 66 static bool shouldHideFourDot(Frame* frame) | |
| 67 { | |
| 68 const String* sourceURL = frame->script()->sourceURL(); | |
| 69 if (!sourceURL) | |
| 70 return false; | |
| 71 if (!(sourceURL->endsWith("/dqm_script.js") || sourceURL->endsWith("/dqm_loa
der.js") || sourceURL->endsWith("/tdqm_loader.js"))) | |
| 72 return false; | |
| 73 Settings* settings = frame->settings(); | |
| 74 if (!settings) | |
| 75 return false; | |
| 76 return settings->needsSiteSpecificQuirks(); | |
| 77 } | |
| 78 | |
| 79 String Navigator::appVersion() const | |
| 80 { | |
| 81 if (!m_frame) | |
| 82 return String(); | |
| 83 String appVersion = NavigatorID::appVersion(this); | |
| 84 if (shouldHideFourDot(m_frame)) | |
| 85 appVersion.replace("4.", "4_"); | |
| 86 return appVersion; | |
| 87 } | |
| 88 | |
| 89 String Navigator::language() const | |
| 90 { | |
| 91 return defaultLanguage(); | |
| 92 } | |
| 93 | |
| 94 String Navigator::productSub() const | |
| 95 { | |
| 96 return WEBCORE_NAVIGATOR_PRODUCT_SUB; | |
| 97 } | |
| 98 | |
| 99 String Navigator::vendor() const | |
| 100 { | |
| 101 return WEBCORE_NAVIGATOR_VENDOR; | |
| 102 } | |
| 103 | |
| 104 String Navigator::vendorSub() const | |
| 105 { | |
| 106 return WEBCORE_NAVIGATOR_VENDOR_SUB; | |
| 107 } | |
| 108 | |
| 109 String Navigator::userAgent() const | |
| 110 { | |
| 111 if (!m_frame) | |
| 112 return String(); | |
| 113 | |
| 114 // If the frame is already detached, FrameLoader::userAgent may malfunction,
because it calls a client method | |
| 115 // that uses frame's WebView (at least, in Mac WebKit). | |
| 116 if (!m_frame->page()) | |
| 117 return String(); | |
| 118 | |
| 119 return m_frame->loader()->userAgent(m_frame->document()->url()); | |
| 120 } | |
| 121 | |
| 122 DOMPluginArray* Navigator::plugins() const | |
| 123 { | |
| 124 if (!m_plugins) | |
| 125 m_plugins = DOMPluginArray::create(m_frame); | |
| 126 return m_plugins.get(); | |
| 127 } | |
| 128 | |
| 129 DOMMimeTypeArray* Navigator::mimeTypes() const | |
| 130 { | |
| 131 if (!m_mimeTypes) | |
| 132 m_mimeTypes = DOMMimeTypeArray::create(m_frame); | |
| 133 return m_mimeTypes.get(); | |
| 134 } | |
| 135 | |
| 136 bool Navigator::cookieEnabled() const | |
| 137 { | |
| 138 if (!m_frame) | |
| 139 return false; | |
| 140 | |
| 141 if (m_frame->page() && !m_frame->page()->settings().cookieEnabled()) | |
| 142 return false; | |
| 143 | |
| 144 return cookiesEnabled(m_frame->document()); | |
| 145 } | |
| 146 | |
| 147 bool Navigator::javaEnabled() const | |
| 148 { | |
| 149 if (!m_frame || !m_frame->settings()) | |
| 150 return false; | |
| 151 | |
| 152 if (!m_frame->settings()->isJavaEnabled()) | |
| 153 return false; | |
| 154 | |
| 155 return true; | |
| 156 } | |
| 157 | |
| 158 void Navigator::getStorageUpdates() | |
| 159 { | |
| 160 // FIXME: Remove this method or rename to yieldForStorageUpdates. | |
| 161 } | |
| 162 | |
| 163 } // namespace WebCore | |
| OLD | NEW |