Oilpan: fix build after r202625.
[chromium-blink-merge.git] / third_party / WebKit / Source / core / frame / Navigator.cpp
blob3d1e5660ac721fa9c8fdd6fba763d77727a4d67f
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)
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.
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.
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
23 #include "config.h"
24 #include "core/frame/Navigator.h"
26 #include "bindings/core/v8/ScriptController.h"
27 #include "core/dom/Document.h"
28 #include "core/frame/FrameHost.h"
29 #include "core/frame/LocalFrame.h"
30 #include "core/frame/NavigatorID.h"
31 #include "core/frame/Settings.h"
32 #include "core/loader/CookieJar.h"
33 #include "core/loader/FrameLoader.h"
34 #include "core/page/ChromeClient.h"
35 #include "platform/Language.h"
37 namespace blink {
39 Navigator::Navigator(LocalFrame* frame)
40 : DOMWindowProperty(frame)
44 Navigator::~Navigator()
48 String Navigator::productSub() const
50 return "20030107";
53 String Navigator::vendor() const
55 // Do not change without good cause. History:
56 // https://code.google.com/p/chromium/issues/detail?id=276813
57 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=27786
58 // https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/QrgyulnqvmE
59 return "Google Inc.";
62 String Navigator::vendorSub() const
64 return "";
67 String Navigator::userAgent() const
69 // If the frame is already detached it no longer has a meaningful useragent.
70 if (!m_frame || !m_frame->page())
71 return String();
73 return m_frame->loader().userAgent(m_frame->document()->url());
76 bool Navigator::cookieEnabled() const
78 if (!m_frame)
79 return false;
81 Settings* settings = m_frame->settings();
82 if (!settings || !settings->cookieEnabled())
83 return false;
85 return cookiesEnabled(m_frame->document());
88 void Navigator::getStorageUpdates()
90 // FIXME: Remove this method or rename to yieldForStorageUpdates.
93 Vector<String> Navigator::languages()
95 Vector<String> languages;
97 if (!m_frame || !m_frame->host()) {
98 languages.append(defaultLanguage());
99 return languages;
102 String acceptLanguages = m_frame->host()->chromeClient().acceptLanguages();
103 acceptLanguages.split(',', languages);
105 // Sanitizing tokens. We could do that more extensively but we should assume
106 // that the accept languages are already sane and support BCP47. It is
107 // likely a waste of time to make sure the tokens matches that spec here.
108 for (size_t i = 0; i < languages.size(); ++i) {
109 String& token = languages[i];
110 token = token.stripWhiteSpace();
111 if (token.length() >= 3 && token[2] == '_')
112 token.replace(2, 1, "-");
115 return languages;
118 DEFINE_TRACE(Navigator)
120 HeapSupplementable<Navigator>::trace(visitor);
121 DOMWindowProperty::trace(visitor);
124 } // namespace blink