Skip to content

Commit

Permalink
[EFL] Add UserAgentEFl.cpp|h
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=151007

Reviewed by Darin Adler.

As other ports EFL port starts to have UserAgentEfl class in order to support more detailed
UA.

Source/WebCore:

No new tests, no behavior change.

* PlatformEfl.cmake:
* platform/efl/UserAgentEfl.cpp: Added.
(WebCore::platformForUAString):
(WebCore::platformVersionForUAString):
(WebCore::versionForUAString):
(WebCore::standardUserAgent):
* platform/efl/UserAgentEfl.h: Added.

Source/WebKit2:

* UIProcess/efl/WebPageProxyEfl.cpp:
(WebKit::WebPageProxy::standardUserAgent): Call WebCore::standardUserAgent().


Canonical link: https://commits.webkit.org/169225@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192148 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Gyuyoung committed Nov 9, 2015
1 parent f9bf2a7 commit fd285ca
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 25 deletions.
20 changes: 20 additions & 0 deletions Source/WebCore/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
2015-11-08 Gyuyoung Kim <gyuyoung.kim@webkit.org>

[EFL] Add UserAgentEFl.cpp|h
https://bugs.webkit.org/show_bug.cgi?id=151007

Reviewed by Darin Adler.

As other ports EFL port starts to have UserAgentEfl class in order to support more detailed
UA.

No new tests, no behavior change.

* PlatformEfl.cmake:
* platform/efl/UserAgentEfl.cpp: Added.
(WebCore::platformForUAString):
(WebCore::platformVersionForUAString):
(WebCore::versionForUAString):
(WebCore::standardUserAgent):
* platform/efl/UserAgentEfl.h: Added.

2015-11-08 David Kilzer <ddkilzer@apple.com>

REGRESSION (r192140): Windows build broke after removing ColorSpace argument to all drawing calls
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/PlatformEfl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ list(APPEND WebCore_SOURCES
platform/efl/ScrollbarThemeEfl.cpp
platform/efl/SoundEfl.cpp
platform/efl/TemporaryLinkStubs.cpp
platform/efl/UserAgentEfl.cpp
platform/efl/WidgetEfl.cpp

platform/geoclue/GeolocationProviderGeoclue1.cpp
Expand Down
74 changes: 74 additions & 0 deletions Source/WebCore/platform/efl/UserAgentEfl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (C) 2015 Naver Corp. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "config.h"
#include "UserAgentEfl.h"

#include "WebKitVersion.h"
#include <wtf/NeverDestroyed.h>

#if OS(UNIX)
#include <sys/utsname.h>
#endif

namespace WebCore {

static const char* platformForUAString()
{
#if PLATFORM(X11)
return "X11";
#else
return "Unknown";
#endif
}

static String platformVersionForUAString()
{
String version;
struct utsname name;
if (uname(&name) != -1)
version = makeString(name.sysname, ' ', name.machine);
else
version = "Unknown";
return version;
}

static const String versionForUAString()
{
static NeverDestroyed<String> version(String::format("%i.%i", WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION));
return version;
}

String standardUserAgent(const String& applicationName, const String&)
{
String version = versionForUAString();
static NeverDestroyed<String> standardUserAgentString = makeString("Mozilla/5.0 (", platformForUAString(), "; ", platformVersionForUAString(),
") AppleWebKit/", version, " (KHTML, like Gecko) Version/8.0 Safari/601.2.7");

return applicationName.isEmpty() ? standardUserAgentString : standardUserAgentString + ' ' + applicationName;
}

} // namespace WebCore

38 changes: 38 additions & 0 deletions Source/WebCore/platform/efl/UserAgentEfl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2015 Naver Corp. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef UserAgentEfl_h
#define UserAgentEfl_h

#include <wtf/text/WTFString.h>

namespace WebCore {

String standardUserAgent(const String& applicationName = emptyString(), const String& applicationVersion = emptyString());

}

#endif // UserAgentEfl_h

13 changes: 13 additions & 0 deletions Source/WebKit2/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
2015-11-08 Gyuyoung Kim <gyuyoung.kim@webkit.org>

[EFL] Add UserAgentEFl.cpp|h
https://bugs.webkit.org/show_bug.cgi?id=151007

Reviewed by Darin Adler.

As other ports EFL port starts to have UserAgentEfl class in order to support more detailed
UA.

* UIProcess/efl/WebPageProxyEfl.cpp:
(WebKit::WebPageProxy::standardUserAgent): Call WebCore::standardUserAgent().

2015-11-07 Simon Fraser <simon.fraser@apple.com>

Remove ColorSpace argument to all the drawing calls
Expand Down
27 changes: 2 additions & 25 deletions Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@
#include "EwkView.h"
#include "NativeWebKeyboardEvent.h"
#include "NotImplemented.h"
#include "WebKitVersion.h"
#include "UserAgentEfl.h"
#include "WebPageMessages.h"
#include "WebProcessProxy.h"
#include "WebView.h"
#include "WebsiteDataStore.h"

#include <sys/utsname.h>

namespace WebKit {

void WebPageProxy::platformInitialize()
Expand All @@ -45,28 +43,7 @@ void WebPageProxy::platformInitialize()

String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
{
String platform;
String version;
String osVersion;
String standardUserAgentString;

#if PLATFORM(X11)
platform = "X11";
#else
platform = "Unknown";
#endif

version = String::number(WEBKIT_MAJOR_VERSION) + '.' + String::number(WEBKIT_MINOR_VERSION) + '+';
struct utsname name;
if (uname(&name) != -1)
osVersion = WTF::String(name.sysname) + " " + WTF::String(name.machine);
else
osVersion = "Unknown";

standardUserAgentString = "Mozilla/5.0 (" + platform + "; " + osVersion + ") AppleWebKit/" + version
+ " (KHTML, like Gecko) Version/8.0 Safari/" + version;

return applicationNameForUserAgent.isEmpty() ? standardUserAgentString : standardUserAgentString + ' ' + applicationNameForUserAgent;
return WebCore::standardUserAgent(applicationNameForUserAgent);
}

void WebPageProxy::getEditorCommandsForKeyEvent(Vector<WTF::String>& /*commandsList*/)
Expand Down

0 comments on commit fd285ca

Please sign in to comment.