%bcond_with x
%bcond_with wayland
-### NACL permanently disable for Tizen build
-
-#%ifarch x86_64 %{arm}
+%ifarch x86_64 %{arm}
### x86_64
# NaCl build on 64bit system require libc 32bit to build the 32 IRT.
# While Tizen 64bit image does not offer 32bit packages at all,
# Due to OBS build for ARM some files needed by NaCl to be build
# are not present.
%define _disable_nacl 1
-#%else
-#%define _disable_nacl 0
-#%endif
+%else
+%define _disable_nacl 0
+%endif
Name: crosswalk
-Version: 8.36.155.0
+Version: 8.36.156.0
Release: 0
Summary: Crosswalk is an app runtime based on Chromium
License: (BSD-3-Clause and LGPL-2.1+)
['exclude', '_nss\\.cc$'],
],
}],
- ['use_glib==1', {
+ ['use_glib==1 or <(use_ozone)==1', {
'dependencies': [
'../build/linux/system.gyp:glib',
],
'atomicops_internals_x86_gcc.cc',
],
}],
- ['<(use_glib)==0 or >(nacl_untrusted_build)==1', {
+ ['(<(use_glib)==0 and <(use_ozone)==0) or >(nacl_untrusted_build)==1', {
'sources!': [
'message_loop/message_pump_glib.cc',
],
// Android does not yet support NavigatorContentUtils.
WebRuntimeFeatures::enableNavigatorContentUtils(false);
WebRuntimeFeatures::enableTouchIconLoading(true);
+ WebRuntimeFeatures::enableScreenOrientation(true);
WebRuntimeFeatures::enableOrientationEvent(true);
#else
WebRuntimeFeatures::enableNavigatorContentUtils(true);
gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_2D, texture_id_);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ unsigned int al = 4 * size_.width();
+ if (al != va_image_.pitches[0]) {
+ // Not aligned phenomenon occurs only in special size video in None-X11.
+ // So re-check RGBA data alignment and realign filled video frame in need.
+ unsigned char* bhandle = static_cast<unsigned char*>(buffer);
+ for (int i = 0; i < size_.height(); i++) {
+ memcpy(bhandle + (i * al), bhandle + (i * (va_image_.pitches[0])), al);
+ }
+ }
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size_.width(), size_.height(),
0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
========================================================================
-Milestone Easter.
-Release Date: 15 May 2014.
+Milestone Spring.
+Release Date: 23 May 2014.
========================================================================
Based on Chromium-
-Version: 35.0.1916.114.
+Version: 36.0.1985.18.
Channel: Beta.
Branch: 1985.
Revision: f333a503890b0a904f4a543946282408d8fceeff.
}
void WaylandInputDevice::SetCursorType(int cursor_type) {
- DCHECK(input_pointer_);
+ if (!input_pointer_) {
+ LOG(WARNING) << "Tried to change cursor without input configured";
+ return;
+ }
input_pointer_->Cursor()->Update(CursorShapeFromNative(cursor_type),
WaylandDisplay::GetInstance()->GetSerial());
}
# Use 'Trunk' for trunk.
# If using trunk, will use '.DEPS.git' for gclient.
chromium_version = '36.0.1985.18'
-chromium_crosswalk_point = '00026639160639f24b3fc3e0d29b6540ba0dcb0a'
+chromium_crosswalk_point = '6488cb72d9cc33832af16d65d75f16e06f0bdd88'
blink_crosswalk_point = '07920aa9d1a9ae404ba8fb574ae1a9b109b22083'
v8_crosswalk_point = '535cd006e5174ff00fd7b745a581980b1d371a9f'
-ozone_wayland_point = 'a5ca2e9203e6a0567751cc0400995982b703dde4'
+ozone_wayland_point = '5047b6ea8843bfd439a9f5adf2e270cd6fa6db7c'
deps_xwalk = {
'src': 'https://github.com/crosswalk-project/chromium-crosswalk.git@%s' % chromium_crosswalk_point,
MAJOR=8
MINOR=36
-BUILD=155
+BUILD=156
PATCH=0
'android.permission.WRITE_SMS'],
'devicecapabilities': [],
'fullscreen': [],
+ 'iap': ['com.android.vending.BILLING'],
'presentation': [],
'rawsockets': [],
'screenorientation': [],
print('Use %s in %s.' % (aapt_str, sdk_root_path))
break
except Exception:
- print('There doesn\'t exist %s in %s.' % (aapt_str, sdk_root_path))
+ pass
if not aapt_path:
print('Your Android SDK may be ruined, please reinstall it.')
sys.exit(2)
'xwalk.pak',
'device_capabilities_api.js',
'launch_screen_api.js',
- 'presentation_api.js',
- 'screen_orientation_api.js']
+ 'presentation_api.js']
for res_file in embedded_related_files:
self.assertTrue(out.find(res_file) != -1)
if arch == 'x86':
content::RenderProcessHost* render_process_host_;
bool security_mode_enabled_;
+ base::WeakPtr<Application> GetWeakPtr() {
+ return weak_factory_.GetWeakPtr();
+ }
+
private:
// Runtime::Observer implementation.
virtual void OnRuntimeAdded(Runtime* runtime) OVERRIDE;
const std::string& application_id = request->url().host();
scoped_refptr<ApplicationData> application =
cache_.GetApplicationData(application_id);
+
+ if (!application)
+ return new net::URLRequestErrorJob(
+ request, network_delegate, net::ERR_FILE_NOT_FOUND);
+
base::FilePath relative_path =
ApplicationURLToRelativeFilePath(request->url());
base::FilePath directory_path;
#include "content/public/browser/web_contents.h"
#include "content/public/browser/render_process_host.h"
#include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h"
+#include "content/browser/screen_orientation/screen_orientation_provider.h"
#include "xwalk/runtime/browser/ui/native_app_window.h"
#include "xwalk/runtime/browser/ui/native_app_window_tizen.h"
namespace application {
+class ScreenOrientationProviderTizen :
+ public content::ScreenOrientationProvider {
+ public:
+ explicit ScreenOrientationProviderTizen(const base::WeakPtr<Application>& app)
+ : app_(app) {
+ }
+
+ virtual void LockOrientation(
+ blink::WebScreenOrientationLockType lock) OVERRIDE {
+ if (!app_)
+ return;
+ const std::set<Runtime*>& runtimes = app_->runtimes();
+ DCHECK(!runtimes.empty());
+ // FIXME: Probably need better alignment with
+ // https://w3c.github.io/screen-orientation/#screen-orientation-lock-lifetime
+ std::set<Runtime*>::iterator it = runtimes.begin();
+ for (; it != runtimes.end(); ++it) {
+ NativeAppWindow* window = (*it)->window();
+ if (window && window->IsActive()) {
+ ToNativeAppWindowTizen(window)->LockOrientation(lock);
+ break;
+ }
+ }
+ }
+
+ virtual void UnlockOrientation() OVERRIDE {
+ LockOrientation(blink::WebScreenOrientationLockDefault);
+ }
+
+ private:
+ base::WeakPtr<Application> app_;
+};
+
ApplicationTizen::ApplicationTizen(
scoped_refptr<ApplicationData> data,
RuntimeContext* runtime_context,
if (Application::Launch(launch_params)) {
DCHECK(render_process_host_);
render_process_host_->GetScreenOrientationDispatcherHost()->
- SetProviderForTests(this);
+ SetProviderForTests(new ScreenOrientationProviderTizen(GetWeakPtr()));
return true;
}
return false;
}
#endif
-void ApplicationTizen::LockOrientation(
- blink::WebScreenOrientationLockType lock) {
- DCHECK(!runtimes_.empty());
- // FIXME: Probably need better alignment with
- // https://w3c.github.io/screen-orientation/#screen-orientation-lock-lifetime
- std::set<Runtime*>::iterator it = runtimes_.begin();
- for (; it != runtimes_.end(); ++it) {
- NativeAppWindow* window = (*it)->window();
- if (window && window->IsActive()) {
- ToNativeAppWindowTizen(window)->LockOrientation(lock);
- break;
- }
- }
-}
-
-void ApplicationTizen::UnlockOrientation() {
- LockOrientation(blink::WebScreenOrientationLockDefault);
-}
-
} // namespace application
} // namespace xwalk
#define XWALK_APPLICATION_BROWSER_APPLICATION_TIZEN_H_
#include "base/event_types.h"
-#include "content/browser/screen_orientation/screen_orientation_provider.h"
#include "xwalk/application/browser/application.h"
#if defined(USE_OZONE)
#if defined(USE_OZONE)
public ui::PlatformEventObserver,
#endif
- public Application, public content::ScreenOrientationProvider {
+ public Application {
public:
virtual ~ApplicationTizen();
void Hide();
virtual void WillProcessEvent(const ui::PlatformEvent& event) OVERRIDE;
virtual void DidProcessEvent(const ui::PlatformEvent& event) OVERRIDE;
#endif
-
- // content::ScreenOrientationProvider overrides:
- virtual void LockOrientation(
- blink::WebScreenOrientationLockType orientations) OVERRIDE;
- virtual void UnlockOrientation() OVERRIDE;
};
inline ApplicationTizen* ToApplicationTizen(Application* app) {
const char* scp_key = GetCSPKey(package_type);
CSPInfo* csp_info =
static_cast<CSPInfo*>(app_->data()->GetManifestData(scp_key));
- if (package_type = Package::WGT) {
+ if (package_type == Package::WGT) {
#if defined(OS_TIZEN)
if (!csp_info || csp_info->GetDirectives().empty())
app_->data()->SetManifestData(scp_key, GetDefaultCSPInfo());
jsfiles_to_copy = [
'xwalk/experimental/launch_screen/launch_screen_api.js',
'xwalk/experimental/presentation/presentation_api.js',
- 'xwalk/runtime/extension/screen_orientation_api.js',
'xwalk/sysapps/device_capabilities/device_capabilities_api.js'
]
#if defined(OS_LINUX)
#include <signal.h>
#include <sys/prctl.h>
+
+#include "base/message_loop/message_pump_glib.h"
#endif
#include "base/debug/stack_trace.h"
VLOG(1) << "Extension process running!";
+#if defined(OS_LINUX)
// FIXME(jeez): This fixes the zombie-process-on-^C issue that we are facing
// on Linux. However, we must find a cleaner way of doing this, perhaps using
// something from Chromium and ensuring this process dies when its parent die.
-#if defined(OS_LINUX)
prctl(PR_SET_PDEATHSIG, SIGTERM);
-#endif
- // On Linux-based platforms, we want the Glib message pump running so we need
- // a TYPE_UI MessageLoop. For other platforms we will stick with TYPE_DEFAULT
- // for now.
- base::MessageLoop::Type message_loop_type;
-#if defined(OS_POSIX)
- message_loop_type = base::MessageLoop::TYPE_UI;
+ // On Linux-based platforms, we want the Glib message pump running so we force
+ // it by declaring it explicitly. For other platforms we will stick with
+ // TYPE_DEFAULT for now.
+ base::MessageLoop main_message_loop(
+ make_scoped_ptr<base::MessagePump>(new base::MessagePumpGlib()));
#else
- message_loop_type = base::MessageLoop::TYPE_DEFAULT;
+ base::MessageLoop main_message_loop(base::MessageLoop::TYPE_DEFAULT);
#endif
- base::MessageLoop main_message_loop(message_loop_type);
xwalk::extensions::XWalkExtensionProcess extension_process;
#ifndef NDEBUG
%endif
Name: crosswalk
-Version: 8.36.155.0
+Version: 8.36.156.0
Release: 0
Summary: Crosswalk is an app runtime based on Chromium
License: (BSD-3-Clause and LGPL-2.1+)
import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
+import android.os.Environment;
import android.os.Looper;
import android.util.AttributeSet;
import android.view.KeyEvent;
XWalkPathHelper.initialize();
XWalkPathHelper.setCacheDirectory(
mContext.getApplicationContext().getCacheDir().getPath());
- XWalkPathHelper.setExternalCacheDirectory(
- mContext.getApplicationContext().getExternalCacheDir().getPath());
+
+ String state = Environment.getExternalStorageState();
+ if (Environment.MEDIA_MOUNTED.equals(state) ||
+ Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
+ XWalkPathHelper.setExternalCacheDirectory(
+ mContext.getApplicationContext().getExternalCacheDir().getPath());
+ }
}
/**
import org.xwalk.core.extension.api.launchscreen.LaunchScreenExtension;
import org.xwalk.core.extension.api.messaging.Messaging;
import org.xwalk.core.extension.api.presentation.PresentationExtension;
-import org.xwalk.core.extension.api.screenorientation.ScreenOrientationExtension;
/**
* This internal class acts a manager to manage extensions.
}
{
- String jsApiContent = ScreenOrientationExtension.getInsertedString();
- try {
- jsApiContent += getExtensionJSFileContent(
- mContext, ScreenOrientationExtension.JS_API_PATH, true);
- new ScreenOrientationExtension(ScreenOrientationExtension.NAME, jsApiContent,
- ScreenOrientationExtension.JS_ENTRY_POINTS, this);
- } catch (IOException e) {
- Log.w(TAG, "Failed to read JS API file: " + ScreenOrientationExtension.JS_API_PATH);
- }
- }
-
- {
String jsApiContent = "";
try {
jsApiContent = getExtensionJSFileContent(
+++ /dev/null
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.xwalk.core.extension.api.screenorientation;
-
-import android.app.Activity;
-import android.content.pm.ActivityInfo;
-import android.util.Log;
-
-import org.json.JSONObject;
-import org.xwalk.core.extension.XWalkExtension;
-import org.xwalk.core.extension.XWalkExtensionContext;
-
-/**
- * XWalk extension for screen orientation api implementation on Android.
- */
-public class ScreenOrientationExtension extends XWalkExtension {
- public final static String TAG = "ScreenOrientationExtension";
- public final static String NAME = "xwalk.screen";
- public final static String JS_API_PATH = "jsapi/screen_orientation_api.js";
- public final static String JS_VALUE_TYPE = "value";
- public final static String[] JS_ENTRY_POINTS = {
- "window.screen.lockOrientation",
- "window.screen.unlockOrientation"
- };
- public final static int PORTRAIT_PRIMARY = 1 << 0;
- public final static int LANDSCAPE_PRIMARY = 1 << 1;
- public final static int PORTRAIT_SECONDARY = 1 << 2;
- public final static int LANDSCAPE_SECONDARY = 1 << 3;
- public final static int PORTRAIT = PORTRAIT_PRIMARY | PORTRAIT_SECONDARY;
- public final static int LANDSCAPE = LANDSCAPE_PRIMARY | LANDSCAPE_SECONDARY;
- public final static int ANY = PORTRAIT | LANDSCAPE;
- public final static int UA_DEFAULTS = 0;
-
- private String getValueString(String message, String type) {
- if (message.isEmpty() || type.isEmpty()) {
- return "";
- }
-
- try {
- return new JSONObject(message).getString(type);
- } catch (Exception e) {
- e.printStackTrace();
- return "";
- }
- }
-
- public static String getInsertedString() {
- String insertedString = "var isAndroid = true;\n";
- insertedString += "var uaDefault = ";
- insertedString += ANY;
- insertedString += ";\n";
-
- return insertedString;
- }
-
- public ScreenOrientationExtension(String name, String jsApi, String[] entryPoints, XWalkExtensionContext context) {
- super(name, jsApi, entryPoints, context);
- }
-
- @Override
- public void onMessage(int instanceId, String message) {
- String value = getValueString(message, JS_VALUE_TYPE);
- if (value.isEmpty())
- return;
-
- int orientation;
- try {
- orientation = Integer.valueOf(value);
- } catch (Exception e) {
- e.printStackTrace();
- return;
- }
-
- int screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
- switch (orientation) {
- case ANY:
- case UA_DEFAULTS: {
- screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
- break;
- }
- case LANDSCAPE_PRIMARY: {
- screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
- break;
- }
- case PORTRAIT_PRIMARY: {
- screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
- break;
- }
- case LANDSCAPE_SECONDARY: {
- screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
- break;
- }
- case PORTRAIT_SECONDARY: {
- screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
- break;
- }
- case LANDSCAPE: {
- screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
- break;
- }
- case PORTRAIT: {
- screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
- break;
- }
- default:
- Log.e(TAG, "Invalid orientation value.");
- return;
- }
- mExtensionContext.getActivity().setRequestedOrientation(screen_orientation_value);
- }
-
- @Override
- public String onSyncMessage(int instanceId, String message) {
- Log.e(TAG, "Unexpected sync message received: " + message);
- return "";
- }
-}
command_line->AppendSwitch(switches::kIgnoreGpuBlacklist);
#endif
- // Disable HW encoding acceleration for WebRTC on Android.
- // FIXME: Remove this switch for Android when Android OS is removed from
+ // Disable HW encoding/decoding acceleration for WebRTC on Android.
+ // FIXME: Remove these switches for Android when Android OS is removed from
// GPU accelerated_video_decode blacklist or we stop ignoring the GPU
// blacklist.
+ command_line->AppendSwitch(switches::kDisableWebRtcHWDecoding);
command_line->AppendSwitch(switches::kDisableWebRtcHWEncoding);
// For fullscreen video playback, the ContentVideoView is still buggy, so
+++ /dev/null
-// Copyright (c) 2013 Intel Corporation. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-var internal = requireNative('internal');
-internal.setupInternalExtension(extension);
-
-// These constants must correspond with C++ side:
-// xwalk/runtime/browser/ui/screen_orientation.h
-var PORTRAIT_PRIMARY = 1 << 0;
-var LANDSCAPE_PRIMARY = 1 << 1;
-var PORTRAIT_SECONDARY = 1 << 2;
-var LANDSCAPE_SECONDARY = 1 << 3;
-var PORTRAIT = PORTRAIT_PRIMARY | PORTRAIT_SECONDARY;
-var LANDSCAPE = LANDSCAPE_PRIMARY | LANDSCAPE_SECONDARY;
-var ANY = PORTRAIT | LANDSCAPE;
-
-// Values that can be set externally.
-var uaDefault = uaDefault || ANY;
-var isAndroid = isAndroid || false;
-
-// Store the real Screen object.
-var realScreen = window.screen;
-
-function cloneProperties(target, source) {
- var props = Object.getOwnPropertyNames(source);
- props.forEach(function(item) {
- target[item] = source[item];
- });
-}
-
-// Create replacement Screen and make it an EventTarget.
-function Screen() { cloneProperties(this, realScreen); };
-Screen.prototype = Object.create(EventTarget.prototype);
-Screen.prototype.constructor = Screen;
-
-// Replace it.
-window.screen = new Screen();
-
-function postMessage(command, value) {
- // Currently, internal.postMessage can't work on Android.
- // https://crosswalk-project.org/jira/browse/XWALK-855
- if (isAndroid) {
- var message = JSON.stringify({
- cmd: command,
- value: value.toString()
- });
- extension.postMessage(message);
- } else {
- internal.postMessage(command, value, null);
- }
-}
-
-window.screen.lockOrientation = function(orientations) {
- if (!Array.isArray(orientations)) {
- if (typeof orientations != 'string')
- return false;
- orientations = [orientations];
- }
-
- var value = 0;
- for (var i = 0; i < orientations.length; ++i) {
- switch (orientations[i]) {
- case 'portrait-primary':
- value |= PORTRAIT_PRIMARY;
- break;
- case 'portrait-secondary':
- value |= PORTRAIT_SECONDARY;
- break;
- case 'landscape-primary':
- value |= LANDSCAPE_PRIMARY;
- break;
- case 'landscape-secondary':
- value |= LANDSCAPE_SECONDARY;
- break;
- case 'portrait':
- value |= PORTRAIT;
- break;
- case 'landscape':
- value |= LANDSCAPE;
- break;
- default:
- console.error('Invalid screen orientation');
- return false;
- }
- // If the orientations aren't all part of the default allowed
- // orientations, the steps must stop here and return false.
- if ((uaDefault & value) != value)
- return false;
- }
- postMessage('lock', [value]);
- return true;
-};
-
-window.screen.unlockOrientation = function() {
- postMessage('lock', [uaDefault]);
-};
-
-// Create a HTMLUnknownElement and do not attach it to the DOM.
-var dispatcher = document.createElement('xwalk-EventDispatcher');
-
-// Implement EventTarget interface on object.
-Object.defineProperty(window.screen, 'addEventListener', {
- value: function(type, callback, capture) {
- dispatcher.addEventListener(type, callback, capture);
- }
-});
-
-Object.defineProperty(window.screen, 'removeEventListener', {
- value: function(type, callback, capture) {
- dispatcher.removeEventListener(type, callback, capture);
- }
-});
-
-Object.defineProperty(window.screen, 'dispatchEvent', {
- value: function(e) {
- dispatcher.dispatchEvent(e);
- }
-});
-
-var orientationchangeCallback = null;
-var orientationchangeCallbackWrapper = null;
-
-Object.defineProperty(window.screen, 'onorientationchange', {
- configurable: false,
- enumerable: true,
- get: function() { return orientationchangeCallback; },
- set: function(callback) {
- // We must add the on* event as an event listener so that
- // it is called at the right point between potential
- // event listeners, but it cannot be the exact method
- // as that would allow removeEventListener to remove it.
-
- // Remove existing (wrapped) listener.
- window.screen.removeEventListener('orientationchange',
- orientationchangeCallbackWrapper);
-
- // If valid, store and add a wrapped version as listener.
- if (callback instanceof Function) {
- orientationchangeCallback = callback;
- orientationchangeCallbackWrapper = function() { callback(); };
- window.screen.addEventListener('orientationchange',
- orientationchangeCallbackWrapper);
- }
- // If not valid, reset to null.
- else {
- orientationchangeCallback = null;
- orientationchangeCallbackWrapper = null;
- }
- }
-});
-
-function handleOrientationChange(newOrientation) {
- switch (newOrientation) {
- case PORTRAIT_PRIMARY:
- orientationValue = 'portrait-primary';
- break;
- case PORTRAIT_SECONDARY:
- orientationValue = 'portrait-secondary';
- break;
- case LANDSCAPE_PRIMARY:
- orientationValue = 'landscape-primary';
- break;
- case LANDSCAPE_SECONDARY:
- orientationValue = 'landscape-secondary';
- break;
- default:
- console.error('Received unknown value for current orientation');
- return;
- }
-
- // The first time the listener is called it is to set the current
- // orientation, so do not dispatch the orientationchange in that case.
- if (handleOrientationChange.shouldDispatchEvent) {
- var event = new Event('orientationchange');
- dispatcher.dispatchEvent(event);
- }
-
- handleOrientationChange.shouldDispatchEvent = true;
-}
-
-var orientationValue;
-
-Object.defineProperty(window.screen, 'orientation', {
- configurable: false,
- enumerable: true,
- get: function() {
- if (typeof orientationValue == 'undefined') {
- var msg = JSON.stringify({
- cmd: 'GetScreenOrientation'
- });
- var newOrientation = extension.internal.sendSyncMessage(msg);
- handleOrientationChange(newOrientation);
- }
- return orientationValue;
- }
-});
-
-// FIXME: Extend message listener to handle screen changes.
-extension.setMessageListener(handleOrientationChange);
+++ /dev/null
-// Copyright (c) 2013 Intel Corporation. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "xwalk/runtime/extension/screen_orientation_extension.h"
-
-#include <set>
-#include <string>
-#include <sstream>
-#include <vector>
-
-#include "content/public/browser/browser_thread.h"
-#include "grit/xwalk_resources.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "third_party/jsoncpp/source/include/json/json.h"
-
-#include "xwalk/application/browser/application.h"
-#include "xwalk/runtime/browser/runtime.h"
-#include "xwalk/runtime/browser/ui/native_app_window_tizen.h"
-
-using content::BrowserThread;
-
-namespace xwalk {
-
-using application::Application;
-
-namespace {
-
-MultiOrientationScreen* GetMultiOrientationScreen(Application*) { // NOLINT
- NOTREACHED();
- return NULL;
-}
-
-} // namespace.
-
-ScreenOrientationExtension::ScreenOrientationExtension(
- Application* app, OrientationMask ua_default)
- : application_(app) {
- DCHECK(application_);
-
- std::vector<std::string> entry_points;
- entry_points.push_back("screen.orientation");
- entry_points.push_back("screen.lockOrientation");
- entry_points.push_back("screen.unlockOrientation");
- entry_points.push_back("screen.onorientationchange");
-
- set_name("xwalk.screen");
- set_entry_points(entry_points);
-
- std::ostringstream js_source;
- js_source << "var uaDefault = ";
- js_source << ua_default;
- js_source << ";\n";
- js_source << ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_XWALK_SCREEN_ORIENTATION_API).as_string();
-
- set_javascript_api(js_source.str());
-}
-
-ScreenOrientationExtension::~ScreenOrientationExtension() {
-}
-
-XWalkExtensionInstance* ScreenOrientationExtension::CreateInstance() {
- return new ScreenOrientationInstance(application_);
-}
-
-ScreenOrientationInstance::ScreenOrientationInstance(Application* app)
- : handler_(this)
- , screen_(GetMultiOrientationScreen(app))
- , application_(app) {
- screen_->SetObserver(this);
-
- handler_.Register("lock",
- base::Bind(&ScreenOrientationInstance::OnAllowedOrientationsChanged,
- base::Unretained(this)));
-
- // If the orientation property is not queried immediately after loading
- // we can avoid querying it synchronously.
- // FIXME: Make sure the .orientation property is 100% correct when queried.
- content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
- base::Bind(&ScreenOrientationInstance::OnOrientationChanged,
- base::Unretained(this), screen_->GetCurrentOrientation()));
-}
-
-ScreenOrientationInstance::~ScreenOrientationInstance() {
-}
-
-void ScreenOrientationInstance::OnOrientationChanged(Orientation orientation) {
- PostMessageToJS(scoped_ptr<base::Value>(
- base::Value::CreateIntegerValue(orientation)));
-}
-
-void ScreenOrientationInstance::HandleMessage(
- scoped_ptr<base::Value> msg) {
- handler_.HandleMessage(msg.Pass());
-}
-
-void ScreenOrientationInstance::HandleSyncMessage(
- scoped_ptr<base::Value> msg) {
- std::string message;
- msg->GetAsString(&message);
-
- Json::Value input;
- Json::Reader reader;
- if (!reader.parse(message, input))
- LOG(ERROR) << "Failed to parse message: " << message;
- else if (input["cmd"].asString() != "GetScreenOrientation")
- LOG(ERROR) << "Got unknown command: " << input["cmd"].asString();
-
- SendSyncReplyToJS(scoped_ptr<base::Value>(
- base::Value::CreateIntegerValue(screen_->GetCurrentOrientation())));
-}
-
-void ScreenOrientationInstance::OnAllowedOrientationsChanged(
- scoped_ptr<XWalkExtensionFunctionInfo> info) {
- int value;
- if (!info->arguments()->GetInteger(0, &value)) {
- LOG(WARNING) << "Malformed message passed to " << info->name();
- return;
- }
-
- OrientationMask orientations = static_cast<OrientationMask>(value);
- screen_->OnAllowedOrientationsChanged(orientations);
-}
-
-} // namespace xwalk
+++ /dev/null
-// Copyright (c) 2013 Intel Corporation. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef XWALK_RUNTIME_EXTENSION_SCREEN_ORIENTATION_EXTENSION_H_
-#define XWALK_RUNTIME_EXTENSION_SCREEN_ORIENTATION_EXTENSION_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "base/values.h"
-
-#include "xwalk/extensions/browser/xwalk_extension_function_handler.h"
-#include "xwalk/extensions/common/xwalk_extension.h"
-#include "xwalk/runtime/browser/ui/screen_orientation.h"
-
-namespace xwalk {
-
-namespace application {
-class Application;
-}
-
-class Runtime;
-class NativeAppWindowTizen;
-
-using extensions::XWalkExtension;
-using extensions::XWalkExtensionFunctionHandler;
-using extensions::XWalkExtensionFunctionInfo;
-using extensions::XWalkExtensionInstance;
-
-// NOTE : This class will be removed (and content::ScreenOrientationProvider
-// used instead).
-class ScreenOrientationExtension : public XWalkExtension {
- public:
- explicit ScreenOrientationExtension(
- application::Application* app, OrientationMask ua_default);
- virtual ~ScreenOrientationExtension();
-
- private:
- // XWalkExtension overrides:
- virtual XWalkExtensionInstance* CreateInstance() OVERRIDE;
-
- application::Application* application_;
-};
-
-class ScreenOrientationInstance : public XWalkExtensionInstance,
- public MultiOrientationScreen::Observer {
- public:
- explicit ScreenOrientationInstance(application::Application* app);
- virtual ~ScreenOrientationInstance();
-
- private:
- // XWalkExtensionInstance overrides:
- virtual void HandleMessage(scoped_ptr<base::Value> msg) OVERRIDE;
- virtual void HandleSyncMessage(scoped_ptr<base::Value> msg) OVERRIDE;
-
- // MultiOrientationScreen::Observer overrides:
- virtual void OnOrientationChanged(Orientation orientation) OVERRIDE;
-
- void OnAllowedOrientationsChanged(
- scoped_ptr<XWalkExtensionFunctionInfo> info);
-
- XWalkExtensionFunctionHandler handler_;
- MultiOrientationScreen* screen_;
-
- application::Application* application_;
-};
-
-} // namespace xwalk
-
-#endif // XWALK_RUNTIME_EXTENSION_SCREEN_ORIENTATION_EXTENSION_H_
<include file="icons/crosswalk_48x48.png" name="IDR_XWALK_ICON_48" type="BINDATA" />
<include file="devtools_discovery_page.html" name="IDR_DEVTOOLS_FRONTEND_PAGE_HTML" type="BINDATA"/>
<include name="IDR_XWALK_NATIVE_FILE_SYSTEM_API" file="../../experimental/native_file_system/native_file_system_api.js" type="BINDATA" />
- <include name="IDR_XWALK_SCREEN_ORIENTATION_API" file="../extension/screen_orientation_api.js" type="BINDATA" />
</includes>
<messages fallback_to_english="true">
<message name="IDS_IMAGE_FILES" desc="The description of the image file extensions in the select file dialog.">
'<(PRODUCT_DIR)/xwalk_runtime_lib/assets/jsapi/launch_screen_api.js',
'<(PRODUCT_DIR)/xwalk_runtime_lib/assets/jsapi/messaging_api.js',
'<(PRODUCT_DIR)/xwalk_runtime_lib/assets/jsapi/presentation_api.js',
- '<(PRODUCT_DIR)/xwalk_runtime_lib/assets/jsapi/screen_orientation_api.js',
'<(PRODUCT_DIR)/xwalk_runtime_lib/assets/xwalk.pak',
],
'conditions': [
'runtime/android/core/src/org/xwalk/core/extension/api/contacts/contacts_api.js',
'runtime/android/core/src/org/xwalk/core/extension/api/device_capabilities/device_capabilities_api.js',
'runtime/android/core/src/org/xwalk/core/extension/api/messaging/messaging_api.js',
- 'runtime/extension/screen_orientation_api.js',
],
},
],
'<(PRODUCT_DIR)/runtime_client_embedded_shell/assets/jsapi/device_capabilities_api.js',
'<(PRODUCT_DIR)/runtime_client_embedded_shell/assets/jsapi/launch_screen_api.js',
'<(PRODUCT_DIR)/runtime_client_embedded_shell/assets/jsapi/presentation_api.js',
- '<(PRODUCT_DIR)/runtime_client_embedded_shell/assets/jsapi/screen_orientation_api.js',
'<(PRODUCT_DIR)/runtime_client_embedded_shell/assets/manifest.json',
'<(PRODUCT_DIR)/runtime_client_embedded_shell/assets/myextension/myextension.js',
'<(PRODUCT_DIR)/runtime_client_embedded_shell/assets/sampapp-icon-helloworld.png',
'experimental/launch_screen/launch_screen_api.js',
'experimental/presentation/presentation_api.js',
'sysapps/device_capabilities/device_capabilities_api.js',
- 'runtime/extension/screen_orientation_api.js',
],
},
{