OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Harri Porten (porten@kde.org) | 2 * Copyright (C) 2000 Harri Porten (porten@kde.org) |
3 * Copyright (c) 2000 Daniel Molkentin (molkentin@kde.org) | 3 * Copyright (c) 2000 Daniel Molkentin (molkentin@kde.org) |
4 * Copyright (c) 2000 Stefan Schimanski (schimmi@kde.org) | 4 * Copyright (c) 2000 Stefan Schimanski (schimmi@kde.org) |
5 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. | 5 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. |
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
12 * | 12 * |
13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 * Lesser General Public License for more details. | 16 * Lesser General Public License for more details. |
17 * | 17 * |
18 * You should have received a copy of the GNU Lesser General Public | 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 | 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 | 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 U
SA |
21 */ | 21 */ |
22 | 22 |
23 #include "config.h" | 23 #include "config.h" |
24 #include "core/frame/Navigator.h" | 24 #include "core/frame/Navigator.h" |
25 | 25 |
26 #include "bindings/v8/ScriptController.h" | 26 #include "bindings/v8/ScriptController.h" |
27 #include "core/dom/Document.h" | 27 #include "core/dom/Document.h" |
| 28 #include "core/frame/FrameHost.h" |
28 #include "core/frame/LocalFrame.h" | 29 #include "core/frame/LocalFrame.h" |
29 #include "core/frame/NavigatorID.h" | 30 #include "core/frame/NavigatorID.h" |
30 #include "core/frame/Settings.h" | 31 #include "core/frame/Settings.h" |
31 #include "core/loader/CookieJar.h" | 32 #include "core/loader/CookieJar.h" |
32 #include "core/loader/FrameLoader.h" | 33 #include "core/loader/FrameLoader.h" |
| 34 #include "core/page/Chrome.h" |
| 35 #include "core/page/ChromeClient.h" |
33 #include "core/plugins/DOMMimeTypeArray.h" | 36 #include "core/plugins/DOMMimeTypeArray.h" |
34 #include "core/plugins/DOMPluginArray.h" | 37 #include "core/plugins/DOMPluginArray.h" |
| 38 #include "platform/Language.h" |
35 | 39 |
36 #ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB | 40 #ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB |
37 #define WEBCORE_NAVIGATOR_PRODUCT_SUB "20030107" | 41 #define WEBCORE_NAVIGATOR_PRODUCT_SUB "20030107" |
38 #endif // ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB | 42 #endif // ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB |
39 | 43 |
40 #ifndef WEBCORE_NAVIGATOR_VENDOR | 44 #ifndef WEBCORE_NAVIGATOR_VENDOR |
41 #define WEBCORE_NAVIGATOR_VENDOR "Google Inc." | 45 #define WEBCORE_NAVIGATOR_VENDOR "Google Inc." |
42 #endif // ifndef WEBCORE_NAVIGATOR_VENDOR | 46 #endif // ifndef WEBCORE_NAVIGATOR_VENDOR |
43 | 47 |
44 #ifndef WEBCORE_NAVIGATOR_VENDOR_SUB | 48 #ifndef WEBCORE_NAVIGATOR_VENDOR_SUB |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 return false; | 120 return false; |
117 | 121 |
118 return true; | 122 return true; |
119 } | 123 } |
120 | 124 |
121 void Navigator::getStorageUpdates() | 125 void Navigator::getStorageUpdates() |
122 { | 126 { |
123 // FIXME: Remove this method or rename to yieldForStorageUpdates. | 127 // FIXME: Remove this method or rename to yieldForStorageUpdates. |
124 } | 128 } |
125 | 129 |
| 130 Vector<String> Navigator::languages() |
| 131 { |
| 132 Vector<String> languages; |
| 133 |
| 134 if (!m_frame || !m_frame->host()) { |
| 135 languages.append(defaultLanguage()); |
| 136 return languages; |
| 137 } |
| 138 |
| 139 String acceptLanguages = m_frame->host()->chrome().client().acceptLanguages(
); |
| 140 acceptLanguages.split(",", languages); |
| 141 |
| 142 // Sanitizing tokens. We could do that more extensively but we should assume |
| 143 // that the accept languages are already sane and support BCP47. It is |
| 144 // likely a waste of time to make sure the tokens matches that spec here. |
| 145 for (size_t i = 0; i < languages.size(); ++i) { |
| 146 String& token = languages[i]; |
| 147 token = token.stripWhiteSpace(); |
| 148 if (token.length() >= 3 && token[2] == '_') |
| 149 token.replace(2, 1, "-"); |
| 150 } |
| 151 |
| 152 return languages; |
| 153 } |
| 154 |
126 void Navigator::trace(Visitor* visitor) | 155 void Navigator::trace(Visitor* visitor) |
127 { | 156 { |
128 visitor->trace(m_plugins); | 157 visitor->trace(m_plugins); |
129 visitor->trace(m_mimeTypes); | 158 visitor->trace(m_mimeTypes); |
130 WillBeHeapSupplementable<Navigator>::trace(visitor); | 159 WillBeHeapSupplementable<Navigator>::trace(visitor); |
131 } | 160 } |
132 | 161 |
133 } // namespace WebCore | 162 } // namespace WebCore |
OLD | NEW |