Upstream version 11.40.277.0 63/33363/1 master
authorEurogiciel-BOT <eurogiciel.tizen@gmail.com>
Thu, 8 Jan 2015 14:45:34 +0000 (14:45 +0000)
committerEurogiciel-BOT <eurogiciel.tizen@gmail.com>
Thu, 8 Jan 2015 14:45:34 +0000 (14:45 +0000)
Upstream commit-id d0df8b6c11be5f4e8830dee83566785f8c0d2151

Change-Id: Ia1751733ac0b051757d3a7d19e310e5652e4e72f
Signed-off-by: Eurogiciel-BOT <eurogiciel.tizen@gmail.com>
43 files changed:
packaging/crosswalk.spec
src/build/util/LASTCHANGE
src/media/audio/pulse/pulse_util.cc
src/ui/platform_window/platform_window.h
src/xwalk/CONTRIBUTING.md [new file with mode: 0644]
src/xwalk/DEPS.xwalk
src/xwalk/VERSION
src/xwalk/app/android/app_hello_world/AndroidManifest.xml
src/xwalk/app/android/app_template/AndroidManifest.xml
src/xwalk/app/android/runtime_client_embedded_shell/AndroidManifest.xml
src/xwalk/app/android/runtime_client_shell/AndroidManifest.xml
src/xwalk/app/tools/android/make_apk.py
src/xwalk/application/extension/application_widget_extension.cc
src/xwalk/application/tools/linux/dbus_connection.cc [new file with mode: 0644]
src/xwalk/application/tools/linux/dbus_connection.h [new file with mode: 0644]
src/xwalk/application/tools/linux/dbus_object_manager.cc [deleted file]
src/xwalk/application/tools/linux/dbus_object_manager.h [deleted file]
src/xwalk/application/tools/linux/xwalk_application_tools.gyp
src/xwalk/application/tools/linux/xwalk_launcher.cc [deleted file]
src/xwalk/application/tools/linux/xwalk_launcher.h [deleted file]
src/xwalk/application/tools/linux/xwalk_launcher_main.cc
src/xwalk/application/tools/linux/xwalk_launcher_tizen.cc
src/xwalk/application/tools/linux/xwalk_launcher_tizen.h
src/xwalk/application/tools/tizen/xwalk_backend.cc
src/xwalk/build/android/xwalkcore_library_template/AndroidManifest.xml
src/xwalk/packaging/crosswalk.spec
src/xwalk/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkWebChromeClient.java
src/xwalk/runtime/android/core_internal_empty/AndroidManifest.xml
src/xwalk/runtime/android/core_internal_shell/AndroidManifest.xml
src/xwalk/runtime/android/core_shell/AndroidManifest.xml
src/xwalk/runtime/android/runtime_lib/AndroidManifest.xml
src/xwalk/runtime/android/sample/AndroidManifest.xml
src/xwalk/runtime/browser/android/net/android_stream_reader_url_request_job.cc
src/xwalk/runtime/browser/xwalk_browser_main_parts.cc
src/xwalk/runtime/browser/xwalk_browser_main_parts_android.cc
src/xwalk/runtime/common/xwalk_runtime_features.cc
src/xwalk/runtime/common/xwalk_runtime_features.h
src/xwalk/runtime/renderer/xwalk_content_renderer_client.cc
src/xwalk/test/android/core/javatests/AndroidManifest.xml
src/xwalk/test/android/core_internal/javatests/AndroidManifest.xml
src/xwalk/test/android/runtime_client/javatests/AndroidManifest.xml
src/xwalk/test/android/runtime_client_embedded/javatests/AndroidManifest.xml
src/xwalk/tizen/browser/media/murphy_resource.cc

index 2651642..820d816 100644 (file)
@@ -24,7 +24,7 @@
 %define _binary_payload w3.gzdio
 
 Name:           crosswalk
-Version:        11.40.271.0
+Version:        11.40.277.0
 Release:        0
 Summary:        Chromium-based app runtime
 License:        (BSD-3-Clause and LGPL-2.1+)
@@ -156,6 +156,12 @@ cp -a src/xwalk/LICENSE LICENSE.xwalk
 # does not expect -Wall to be passed to the compiler (see webrtc issue 3307).
 export CXXFLAGS=`echo $CXXFLAGS | sed s,-Wall,,g`
 
+# Do not use -finline-functions: it breaks the build because it causes -Wall to
+# warn about some conditions that cannot really be reached (ie. variables that
+# may be used uninitialized while in fact thay cannot be uninitialized). See
+# TC-2299.
+export CXXFLAGS=`echo $CXXFLAGS | sed s,-finline-functions,,g`
+
 # For ffmpeg on ia32. The original CFLAGS set by the gyp and config files in
 # src/third_party/ffmpeg already pass -O2 -fomit-frame-pointer, but Tizen's
 # CFLAGS end up appending -fno-omit-frame-pointer. See http://crbug.com/37246
index d17a682..72b3d1d 100644 (file)
@@ -1 +1 @@
-LASTCHANGE=e36755cc26d8a8fcb4f4c3cca52c242297326917
+LASTCHANGE=5557d5159b3ed591f53887db1de564d2c07725b9
index 020ad3d..1cfb038 100644 (file)
@@ -268,7 +268,7 @@ bool CreateOutputStream(pa_threaded_mainloop** mainloop,
   PulseAudioOutputStream* data =
       static_cast<PulseAudioOutputStream*>(user_data);
   pa_proplist* proplist = pa_proplist_new();
-  pa_proplist_sets(proplist, "resource.set.appid", data->app_id().c_str());
+  pa_proplist_sets(proplist, "resource.set.name", data->app_id().c_str());
   pa_proplist_sets(proplist, PA_PROP_MEDIA_ROLE, data->app_class().c_str());
   *stream = pa_stream_new_with_proplist(*context, "Playback",
                                         &sample_specifications,
index 14aada4..4642c10 100644 (file)
@@ -22,15 +22,15 @@ class PlatformWindowDelegate;
 // underlying platform windowing system (i.e. X11/Win/OSX).
 class PlatformWindow {
  public:
-   enum PlatformWindowType {
-     PLATFORM_WINDOW_UNKNOWN,
-     PLATFORM_WINDOW_TYPE_TOOLTIP,
-     PLATFORM_WINDOW_TYPE_POPUP,
-     PLATFORM_WINDOW_TYPE_MENU,
-     PLATFORM_WINDOW_TYPE_BUBBLE,
-     PLATFORM_WINDOW_TYPE_WINDOW,
-     PLATFORM_WINDOW_TYPE_WINDOW_FRAMELESS
-   };
+  enum PlatformWindowType {
+    PLATFORM_WINDOW_UNKNOWN,
+    PLATFORM_WINDOW_TYPE_TOOLTIP,
+    PLATFORM_WINDOW_TYPE_POPUP,
+    PLATFORM_WINDOW_TYPE_MENU,
+    PLATFORM_WINDOW_TYPE_BUBBLE,
+    PLATFORM_WINDOW_TYPE_WINDOW,
+    PLATFORM_WINDOW_TYPE_WINDOW_FRAMELESS
+  };
 
   virtual ~PlatformWindow() {}
 
diff --git a/src/xwalk/CONTRIBUTING.md b/src/xwalk/CONTRIBUTING.md
new file mode 100644 (file)
index 0000000..052d91a
--- /dev/null
@@ -0,0 +1,84 @@
+# Contributing to Crosswalk
+
+Thanks a lot for contributing to Crosswalk, you rock!
+
+This page lists some guidelines for the contribution process to help you send
+an awesome patch that gets reviewed and merged quickly.
+[Crosswalk's website](https://crosswalk-project.org/contribute/) also has a
+whole section dedicated to this, be sure to check it out.
+
+## License
+
+Crosswalk is licensed under the
+[3-clause BSD license](http://opensource.org/licenses/BSD-3-Clause). When you
+submit a patch, you agree to license your contribution to Intel under this
+license.
+
+## Submitting pull requests
+
+* If it applies, add the platform your change affects in both the commit
+  message and the pull request title. For example, _"[Android] Update target
+  SDK to android-21"_ or _"[Tizen] Add unit test for metadata element
+  handler"_.
+
+* If you know them, be sure to mention the people you would like to review your
+  patch in a comment. You can check the `OWNERS` files in the tree to know the
+  best people to look at your changes.
+
+* Do not use your `master` branch in your pull request. This means you will not
+  be able to send multiple pull requests at the same time without changing all
+  of them at once, and they will also be changed when you update your branch to
+  track Crosswalk's latest changes. Instead, use a separate branch for each
+  pull request.
+
+* If someone asks you to make a change to your pull request, **DO NOT** close
+  it and open a new one. Instead, make the changes to your branch, amending and
+  rebasing when necessary, and then use `git push -f` to push the changes to
+  the same branch you have used in your existing pull request.
+
+## Commit messages
+
+* Use the present tense ("Add feature" not "Added feature").
+
+* Use the imperative mood ("Move cursor to..." not "Moves cursor to...").
+
+* Limit the first line to 72 characters or less.
+
+* If your pull request fixes an open issue in
+  [our bug tracker](https://crosswalk-project.org/jira), please reference it in
+  your commit message as well as your pull request message, like this:
+  ```
+  Fix something.
+
+  Yadda, yadda, yadda.
+
+  BUG=XWALK-123456
+  ```
+  This way, the issue will be updated when the pull request is sent and, once
+  it is merged, the issue will be closed automatically.
+  If you simply want the issue to be updated but do **not** want it to be
+  closed, use a different construct in your message, like _"Related to:
+  XWALK-123"_.
+
+## Coding style
+
+* C++: We follow
+  [Chromium's coding style](http://dev.chromium.org/developers/coding-style),
+  which basically mean's
+  [Google's](https://google-styleguide.googlecode.com/svn/trunk/cppguide.html).
+  Please take some time to get familiar with it, particularly with the amount
+  of space used for indentation and the position of asterisks and braces. If in
+  doubt, check the rest of the code around what you are changing.
+
+* Java: We also follow
+  [Chromium's guidelines](http://www.chromium.org/developers/coding-style/java),
+  which are very similar to
+  [Android's style guide](http://source.android.com/source/code-style.html), so
+  there should not be any big surprises.
+
+* Python: Just like
+  [Chromium's](http://dev.chromium.org/developers/coding-style), our Python
+  code mostly follows [PEP-8](https://www.python.org/dev/peps/pep-0008/), the
+  exceptions being the amount of space used for indentation (2 instead of 4)
+  and the use of `MixedCase` functions and methods instead of
+  `lower_case_ones`.
index 13aabd8..0c03656 100644 (file)
@@ -17,7 +17,7 @@
 # Edit these when rolling DEPS.xwalk.
 # -----------------------------------
 
-chromium_crosswalk_rev = 'e36755cc26d8a8fcb4f4c3cca52c242297326917'
+chromium_crosswalk_rev = '5557d5159b3ed591f53887db1de564d2c07725b9'
 v8_crosswalk_rev = '11bb7b400ff9e0179ecf6fe358b9d9452d297234'
 ozone_wayland_rev = '597c8dfffd6058589db481c9d3beb1120eaf2b6b'
 
index c5b1dbf..d934f5d 100644 (file)
@@ -1,4 +1,4 @@
 MAJOR=11
 MINOR=40
-BUILD=271
+BUILD=277
 PATCH=0
index 391a7cc..37714d8 100644 (file)
@@ -23,7 +23,7 @@
         </activity>
     </application>
 
-  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
+  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
   <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
   <uses-permission android:name="android.permission.CAMERA"/>
index 5fd2cbb..c1f4468 100644 (file)
@@ -24,7 +24,7 @@
         </activity>
     </application>
 
-  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
+  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
   <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
   <uses-permission android:name="android.permission.CAMERA"/>
index 2bf677a..fcb66a9 100644 (file)
@@ -28,7 +28,7 @@
         </activity>
     </application>
 
-  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
+  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
   <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
index 0a8f874..bff0b5c 100644 (file)
@@ -28,7 +28,7 @@
         </activity>
     </application>
 
-  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
+  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
   <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
index ba76b30..04143aa 100755 (executable)
@@ -459,7 +459,7 @@ def MakeApk(options, app_info, manifest):
             options.arch = 'arm'
           else:
             options.arch = arch
-          print "options.arch:", options.arch
+          print("options.arch:", options.arch)
           Execution(options, name)
           packaged_archs.append(options.arch)
         else:
index fb94b01..284d9d2 100644 (file)
@@ -102,7 +102,9 @@ AppWidgetExtensionInstance::AppWidgetExtensionInstance(
 
   content::RenderProcessHost* rph =
       content::RenderProcessHost::FromID(application->GetRenderProcessHostID());
+  CHECK(rph);
   content::StoragePartition* partition = rph->GetStoragePartition();
+  CHECK(partition);
   base::FilePath path = partition->GetPath().Append(
       FILE_PATH_LITERAL("WidgetStorage"));
   widget_storage_.reset(new AppWidgetStorage(application_, path));
diff --git a/src/xwalk/application/tools/linux/dbus_connection.cc b/src/xwalk/application/tools/linux/dbus_connection.cc
new file mode 100644 (file)
index 0000000..2e7f3c3
--- /dev/null
@@ -0,0 +1,21 @@
+// 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/application/tools/linux/dbus_connection.h"
+
+GDBusConnection* get_session_bus_connection(GError** error) {
+#if defined(OS_TIZEN_MOBILE)
+  // In Tizen the session bus is created in /run/user/app/dbus/user_bus_socket
+  // but this information isn't set in DBUS_SESSION_BUS_ADDRESS, neither when
+  // logging via 'sdb shell' and changing user to 'app', nor when an application
+  // is launched.
+  return g_dbus_connection_new_for_address_sync(
+      "unix:path=/run/user/app/dbus/user_bus_socket",
+      GDBusConnectionFlags(G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT
+                           | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION),
+      NULL, NULL, error);
+#else
+  return g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, error);
+#endif
+}
diff --git a/src/xwalk/application/tools/linux/dbus_connection.h b/src/xwalk/application/tools/linux/dbus_connection.h
new file mode 100644 (file)
index 0000000..022eee5
--- /dev/null
@@ -0,0 +1,12 @@
+// 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_APPLICATION_TOOLS_LINUX_DBUS_CONNECTION_H_
+#define XWALK_APPLICATION_TOOLS_LINUX_DBUS_CONNECTION_H_
+
+#include <gio/gio.h>
+
+GDBusConnection* get_session_bus_connection(GError** error);
+
+#endif  // XWALK_APPLICATION_TOOLS_LINUX_DBUS_CONNECTION_H_
diff --git a/src/xwalk/application/tools/linux/dbus_object_manager.cc b/src/xwalk/application/tools/linux/dbus_object_manager.cc
deleted file mode 100644 (file)
index feccbcc..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-// 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/application/tools/linux/dbus_object_manager.h"
-
-#include "base/message_loop/message_loop.h"
-
-namespace {
-
-const char kServiceName[] = "org.crosswalkproject.Runtime1";
-const char kRunningManagerIface[] = "org.crosswalkproject.Running.Manager1";
-const char kRunningAppIface[] = "org.crosswalkproject.Running.Application1";
-const char kRunningManagerDBusPath[] = "/running1";
-const char kEPChannelCreatedSignalName[] = "EPChannelCreated";
-
-struct Properties : public dbus::PropertySet {
-  dbus::Property<std::string> app_id;
-
-  Properties(dbus::ObjectProxy* object_proxy,
-             const std::string& interface_name,
-             PropertyChangedCallback property_changed_callback)
-      : PropertySet(object_proxy, interface_name, property_changed_callback) {
-    RegisterProperty("AppID", &app_id);
-  }
-};
-
-}  // namespace
-
-DBusObjectManager::DBusObjectManager(dbus::Bus* bus,
-                                     base::MessageLoop* main_loop)
-    : bus_(bus),
-      main_loop_(main_loop),
-      weak_ptr_factory_(this) {
-  ConnectToApplicationManager();
-}
-
-bool DBusObjectManager::Launch(const std::string& appid_or_url,
-     int launcher_pid, bool fullscreen, bool remote_debugging) {
-  if (!running_proxy_)
-    return false;
-  dbus::MethodCall method_call(
-      kRunningManagerIface, "Launch");
-  dbus::MessageWriter writer(&method_call);
-  writer.AppendString(appid_or_url);
-  writer.AppendUint32(launcher_pid);
-  writer.AppendBool(fullscreen);
-  writer.AppendBool(remote_debugging);
-  scoped_ptr<dbus::Response> response(
-      running_proxy_->CallMethodAndBlock(&method_call,
-      dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
-  if (!response.get())
-    return false;
-  if (!response->GetErrorName().empty()) {
-    LOG(ERROR) << "Error during call to 'Launch': "
-               << response->GetErrorName();
-    return false;
-  }
-
-  dbus::MessageReader reader(response.get());
-  dbus::ObjectPath running_application_path;
-  if (!reader.PopObjectPath(&running_application_path)) {
-    LOG(WARNING) << "Failed to create app proxy.";
-  } else {
-    app_proxy_ = bus_->GetObjectProxy(kServiceName, running_application_path);
-    if (app_proxy_)
-      ConnectToApplicationSignal(kEPChannelCreatedSignalName);
-  }
-  return true;
-}
-
-std::pair<std::string, int> DBusObjectManager::GetEPChannel() const {
-  std::pair<std::string, int> fd;
-  if (!app_proxy_) {
-    fd.second = -1;
-    return fd;
-  }
-  dbus::MethodCall method_call(kRunningAppIface, "GetEPChannel");
-  scoped_ptr<dbus::Response> response = app_proxy_->CallMethodAndBlock(
-      &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT);
-  const std::string& error = response->GetErrorName();
-  if (!error.empty()) {
-    LOG(ERROR) << "Error during call to 'GetEPChannel': "
-               << error;
-    fd.second = -1;
-    return fd;
-  }
-  dbus::MessageReader reader(response.release());
-  dbus::FileDescriptor extension_process_fd_;
-  if (!reader.PopString(&fd.first) ||
-      !reader.PopFileDescriptor(&extension_process_fd_)) {
-    LOG(ERROR) << "Couldn't get EP Channel";
-    fd.second = -1;
-    return fd;
-  }
-  extension_process_fd_.CheckValidity();
-  fd.second = extension_process_fd_.TakeValue();
-  return fd;
-}
-
-bool DBusObjectManager::Suspend() {
-  if (!app_proxy_)
-    return false;
-  dbus::MethodCall method_call(kRunningAppIface, "Suspend");
-  scoped_ptr<dbus::Response> response = app_proxy_->CallMethodAndBlock(
-      &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT);
-  if (!response->GetErrorName().empty()) {
-    LOG(ERROR) << "Error during call to 'Suspend': "
-               << response->GetErrorName();
-    return false;
-  }
-  return true;
-}
-
-bool DBusObjectManager::Resume() {
-  if (!app_proxy_)
-    return false;
-  dbus::MethodCall method_call(kRunningAppIface, "Resume");
-  scoped_ptr<dbus::Response> response = app_proxy_->CallMethodAndBlock(
-      &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT);
-  if (!response->GetErrorName().empty()) {
-    LOG(ERROR) << "Error during call to 'Resume': "
-               << response->GetErrorName();
-    return false;
-  }
-  return true;
-}
-
-void DBusObjectManager::OnOwnershipCallback(const std::string& service_name,
-                                            bool success) {
-  LOG(WARNING) << "Couldn't get ownership of D-Bus service name: "
-               << service_name << ".";
-}
-
-void DBusObjectManager::ConnectToApplicationManager() {
-  running_apps_manager_ = bus_->GetObjectManager(kServiceName,
-      dbus::ObjectPath(kRunningManagerDBusPath));
-  running_apps_manager_->RegisterInterface(kRunningAppIface, this);
-  running_proxy_ = bus_->GetObjectProxy(kServiceName,
-      dbus::ObjectPath(kRunningManagerDBusPath));
-}
-
-void DBusObjectManager::ObjectAdded(const dbus::ObjectPath& object_path,
-    const std::string& interface_name) {
-}
-
-void DBusObjectManager::ObjectRemoved(const dbus::ObjectPath& object_path,
-    const std::string& interface_name) {
-  if (object_path != app_proxy_->object_path())
-    return;
-  LOG(INFO) << "Application '" << object_path.value()
-            << "' disappeared, exiting.";
-  main_loop_->QuitNow();
-}
-
-dbus::PropertySet* DBusObjectManager::CreateProperties(
-    dbus::ObjectProxy *object_proxy,
-    const dbus::ObjectPath& object_path,
-    const std::string& interface_name) {
-  Properties* properties = new Properties(
-      object_proxy, interface_name,
-      base::Bind(&DBusObjectManager::OnPropertyChanged,
-                 base::Unretained(this), object_path));
-  return static_cast<dbus::PropertySet*>(properties);
-}
-
-void DBusObjectManager::OnPropertyChanged(const dbus::ObjectPath& object_path,
-    const std::string& name) {
-  if (!running_apps_manager_)
-    ConnectToApplicationManager();
-}
-
-void DBusObjectManager::ConnectToApplicationSignal(
-    const std::string& signal_name) {
-  DCHECK(app_proxy_);
-  app_proxy_->ConnectToSignal(kRunningAppIface, signal_name,
-      base::Bind(&DBusObjectManager::OnAppSignal,
-                 weak_ptr_factory_.GetWeakPtr()),
-      base::Bind(&DBusObjectManager::OnAppSignalConnected,
-                 weak_ptr_factory_.GetWeakPtr()));
-}
-
-bool DBusObjectManager::IsApplicationRunning(const std::string& app_id) {
-  std::vector<dbus::ObjectPath> objects = running_apps_manager_->GetObjects();
-  bool is_running = false;
-  for (dbus::ObjectPath obj : objects) {
-    Properties* properties =
-        static_cast<Properties*>(
-            running_apps_manager_->GetProperties(
-                obj, kRunningAppIface));
-    if (!properties)
-      continue;
-    if (properties->app_id.value() == app_id) {
-      is_running = true;
-      break;
-    }
-  }
-  LOG(INFO) << "Application " << app_id << " is "
-            << (is_running ? "running." : "not running.");
-  return is_running;
-}
-
-void DBusObjectManager::OnAppSignal(dbus::Signal* signal) {
-  std::string signal_name = signal->GetMember();
-  if (signal_name == kEPChannelCreatedSignalName) {
-    if (observer_)
-      observer_->OnEPChannelCreated();
-  } else {
-    LOG(INFO) << "Unknown signal received: " << signal_name;
-  }
-}
-
-void DBusObjectManager::OnAppSignalConnected(
-    const std::string& interface_name,
-    const std::string& signal_name,
-    bool success) {
-  if (!success)
-    LOG(WARNING) << "Failed to connect signal: " << signal_name;
-}
diff --git a/src/xwalk/application/tools/linux/dbus_object_manager.h b/src/xwalk/application/tools/linux/dbus_object_manager.h
deleted file mode 100644 (file)
index ccb9fb2..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-// 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_APPLICATION_TOOLS_LINUX_DBUS_OBJECT_MANAGER_H_
-#define XWALK_APPLICATION_TOOLS_LINUX_DBUS_OBJECT_MANAGER_H_
-
-#include <map>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "base/macros.h"
-#include "base/threading/thread.h"
-#include "base/values.h"
-#include "dbus/bus.h"
-#include "dbus/exported_object.h"
-#include "dbus/message.h"
-#include "dbus/object_manager.h"
-#include "dbus/object_path.h"
-#include "dbus/object_proxy.h"
-#include "dbus/property.h"
-
-class DBusObjectManager : public dbus::ObjectManager::Interface {
- public:
-  class Observer {
-   public:
-    virtual void OnEPChannelCreated() = 0;
-
-   protected:
-    virtual ~Observer() {}
-  };
-
-  DBusObjectManager(dbus::Bus* bus, base::MessageLoop* main_loop);
-
-  bool Launch(const std::string& appid_or_url, int launcher_pid,
-              bool fullscreen, bool remote_debugging);
-  std::pair<std::string, int> GetEPChannel() const;
-  bool Suspend();
-  bool Resume();
-
-  bool IsApplicationRunning(const std::string& app_id);
-
-  void SetObserver(Observer* observer) { observer_ = observer; }
-
- private:
-  void OnOwnershipCallback(const std::string& service_name, bool success);
-  void ObjectAdded(const dbus::ObjectPath& object_path,
-                   const std::string& interface_name) override;
-  void ObjectRemoved(const dbus::ObjectPath& object_path,
-                     const std::string& interface_name) override;
-  dbus::PropertySet* CreateProperties(
-      dbus::ObjectProxy* object_proxy,
-      const dbus::ObjectPath& object_path,
-      const std::string& interface_name) override;
-
-  void OnPropertyChanged(const dbus::ObjectPath& object_path,
-                         const std::string& name);
-
-  void ConnectToApplicationManager();
-  void ConnectToApplicationSignal(const std::string& signal_name);
-  void OnAppSignal(dbus::Signal* signal);
-  void OnAppSignalConnected(const std::string& interface_name,
-                            const std::string& signal_name,
-                            bool success);
-
-  scoped_refptr<dbus::Bus> bus_;
-  dbus::ObjectManager* running_apps_manager_;
-  dbus::ObjectProxy* running_proxy_;
-  dbus::ObjectProxy* app_proxy_;
-
-  // this is needed for exit events which come via dbus interface
-  base::MessageLoop* main_loop_;
-
-  base::WeakPtrFactory<DBusObjectManager> weak_ptr_factory_;
-
-  Observer* observer_;
-
-  DISALLOW_COPY_AND_ASSIGN(DBusObjectManager);
-};
-
-#endif  // XWALK_APPLICATION_TOOLS_LINUX_DBUS_OBJECT_MANAGER_H_
index e3bc48d..06d755f 100644 (file)
         '../../../build/system.gyp:gio',
         '../../../extensions/extensions.gyp:xwalk_extensions',
         '../../../application/common/xwalk_application_common.gypi:xwalk_application_common_lib',
-        '../../../dbus/xwalk_dbus.gyp:xwalk_dbus'
       ],
       'sources': [
-        'dbus_object_manager.cc',
-        'dbus_object_manager.h',
+        'dbus_connection.cc',
+        'dbus_connection.h',
         'xwalk_extension_process_launcher.cc',
         'xwalk_extension_process_launcher.h',
         'xwalk_launcher_main.cc',
@@ -28,8 +27,6 @@
             '../../../build/system.gyp:tizen_appcore_common'
           ],
           'sources': [
-            'xwalk_launcher.cc',
-            'xwalk_launcher.h',
             'xwalk_launcher_tizen.cc',
             'xwalk_launcher_tizen.h',
             '../tizen/xwalk_tizen_user.cc',
diff --git a/src/xwalk/application/tools/linux/xwalk_launcher.cc b/src/xwalk/application/tools/linux/xwalk_launcher.cc
deleted file mode 100644 (file)
index 04964d5..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright (c) 2013 Intel Corporation. All rights reserved.
-// Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <unistd.h>
-
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "dbus/object_proxy.h"
-
-#include "base/logging.h"
-
-#include "xwalk/application/tools/linux/xwalk_launcher.h"
-
-namespace {
-
-const char xwalk_service_name[] = "org.crosswalkproject.Runtime1";
-const char xwalk_running_path[] = "/running1";
-const char xwalk_running_manager_iface[] =
-    "org.crosswalkproject.Running.Manager1";
-const char xwalk_running_app_iface[] =
-    "org.crosswalkproject.Running.Application1";
-
-}  // namespace
-
-XWalkLauncher::XWalkLauncher(bool query_running, base::MessageLoop* main_loop)
-    : ep_launcher_(nullptr),
-      query_running_(query_running),
-      main_loop_(main_loop) {
-  base::Thread::Options thread_options;
-  thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
-  dbus_thread_.reset(new base::Thread("Crosswalk D-Bus thread"));
-  dbus_thread_->StartWithOptions(thread_options);
-
-  dbus::Bus::Options options;
-#if defined (OS_TIZEN_MOBILE)
-  options.bus_type = dbus::Bus::CUSTOM_ADDRESS;
-  options.address.assign("unix:path=/run/user/app/dbus/user_bus_socket");
-#endif
-  options.bus_type = dbus::Bus::SESSION;
-  options.connection_type = dbus::Bus::PRIVATE;
-  options.dbus_task_runner = dbus_thread_->message_loop_proxy();
-  dbus::Bus* bus = new dbus::Bus(options);
-  bus->Connect();
-  bus->GetManagedObjects();
-
-  dbus_object_manager_.reset(new DBusObjectManager(bus, main_loop));
-  dbus_object_manager_->SetObserver(this);
-}
-
-XWalkLauncher::~XWalkLauncher() {
-}
-
-int XWalkLauncher::Launch(const std::string& appid_or_url, bool fullscreen,
-                          bool remote_debugging, int argc, char* argv[]) {
-  appid_or_url_ = appid_or_url;
-  fullscreen_ = fullscreen;
-  remote_debugging_ = remote_debugging;
-
-  // Query app.
-  if (query_running_) {
-    return dbus_object_manager_->IsApplicationRunning(appid_or_url_);
-  }
-
-  return !LaunchApplication();
-}
-
-int XWalkLauncher::LaunchApplication() {
-  ep_launcher_.reset(new XWalkExtensionProcessLauncher());
-
-  launcher_pid_ = getpid();
-  if (!dbus_object_manager_->Launch(appid_or_url_, launcher_pid_,
-                                    fullscreen_, remote_debugging_))
-    return 1;
-  return InitExtensionProcessChannel();
-}
-
-bool XWalkLauncher::InitExtensionProcessChannel() {
-  if (ep_launcher_->is_started())
-    return false;
-
-  // Need to call method via DBus to get EP channel
-  std::pair<std::string, int> fd = dbus_object_manager_->GetEPChannel();
-  if (fd.first.empty() || fd.second < 0)
-    return false;
-  ep_launcher_->Launch(fd.first, fd.second);
-  return true;
-}
-
-void XWalkLauncher::OnEPChannelCreated() {
-  InitExtensionProcessChannel();
-}
diff --git a/src/xwalk/application/tools/linux/xwalk_launcher.h b/src/xwalk/application/tools/linux/xwalk_launcher.h
deleted file mode 100644 (file)
index e4c0533..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2013 Intel Corporation. All rights reserved.
-// Copyright (c) 2014 Samsung Electronics Co., Ltd 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_APPLICATION_TOOLS_LINUX_XWALK_LAUNCHER_H_
-#define XWALK_APPLICATION_TOOLS_LINUX_XWALK_LAUNCHER_H_
-
-#include <memory>
-#include <string>
-
-#include "base/threading/thread.h"
-#include "dbus/bus.h"
-#include "dbus/message.h"
-
-#include "xwalk/application/tools/linux/dbus_object_manager.h"
-#include "xwalk/application/tools/linux/xwalk_extension_process_launcher.h"
-
-class XWalkLauncher : public DBusObjectManager::Observer {
- public:
-  XWalkLauncher(bool query_running, base::MessageLoop* main_loop);
-  virtual ~XWalkLauncher();
-  virtual int Launch(const std::string& appid_or_url, bool fullscreen,
-                     bool remote_debugging, int argc = 0,
-                     char* argv[] = nullptr);
-
- protected:
-  int LaunchApplication();
-
-  std::unique_ptr<XWalkExtensionProcessLauncher> ep_launcher_;
-
-  unsigned int launcher_pid_;
-  std::string appid_or_url_;
-  bool fullscreen_;
-  bool remote_debugging_;
-  bool query_running_;
-
-  base::MessageLoop* main_loop_;
-
-  std::unique_ptr<DBusObjectManager> dbus_object_manager_;
-
- private:
-  bool InitExtensionProcessChannel();
-  virtual void OnEPChannelCreated() override;
-
-  std::unique_ptr<base::Thread> dbus_thread_;
-};
-
-#endif  // XWALK_APPLICATION_TOOLS_LINUX_XWALK_LAUNCHER_H_
index 8ea14b7..46c956b 100644 (file)
 // Copyright (c) 2013 Intel Corporation. All rights reserved.
-// Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include <glib.h>
-
-#include <memory>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <pwd.h>
+#include <libgen.h>
 
-#include "base/message_loop/message_loop.h"
-#include "base/message_loop/message_pump.h"
-#include "base/message_loop/message_pump_glib.h"
-#include "base/run_loop.h"
+#include <glib.h>
+#include <gio/gio.h>
+#include <gio/gunixfdlist.h>
 
-#include "xwalk/application/tools/linux/xwalk_launcher.h"
+#include "xwalk/application/tools/linux/dbus_connection.h"
+#include "xwalk/application/tools/linux/xwalk_extension_process_launcher.h"
 #if defined(OS_TIZEN)
+#include "url/gurl.h"
 #include "xwalk/application/tools/linux/xwalk_launcher_tizen.h"
+#include "xwalk/application/tools/tizen/xwalk_tizen_user.h"
 #endif
 
-namespace {
+static const char* xwalk_service_name = "org.crosswalkproject.Runtime1";
+static const char* xwalk_running_path = "/running1";
+static const char* xwalk_running_manager_iface =
+    "org.crosswalkproject.Running.Manager1";
+static const char* xwalk_running_app_iface =
+    "org.crosswalkproject.Running.Application1";
 
-int g_argc;
-char** g_argv;
-gboolean query_running = FALSE;
-gboolean fullscreen = FALSE;
-gboolean remote_debugging = FALSE;
-gchar** cmd_appid_or_url;
-char* application_object_path;
+static char* application_object_path;
 
-}  // namespace
+static GMainLoop* mainloop;
+static GDBusConnection* g_connection;
+static GDBusObjectManager* g_running_apps_manager;
+static XWalkExtensionProcessLauncher* ep_launcher = NULL;
 
-static const GOptionEntry entries[] {
+static int g_argc;
+static char** g_argv;
+static gboolean query_running = FALSE;
+static gboolean fullscreen = FALSE;
+static gboolean remote_debugging = FALSE;
+static gchar** cmd_appid_or_url;
+
+static GOptionEntry entries[] = {
   { "running", 'r', 0, G_OPTION_ARG_NONE, &query_running,
-    "Check whether the application is running", nullptr },
+    "Check whether the application is running", NULL },
   { "fullscreen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen,
-    "Run the application as fullscreen", nullptr },
+    "Run the application as fullscreen", NULL },
   { "debugging_port", 'd', 0, G_OPTION_ARG_NONE, &remote_debugging,
-    "Enable remote debugging for the application", nullptr },
-  { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY,
-    &cmd_appid_or_url,
-    "ID of the application to be launched or URL to open", nullptr },
-  { nullptr }
+    "Enable remote debugging for the application", NULL },
+  { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &cmd_appid_or_url,
+    "ID of the application to be launched or URL to open", NULL },
+  { NULL }
 };
 
+static void object_removed(GDBusObjectManager* manager, GDBusObject* object,
+                           gpointer user_data) {
+  const char* path = g_dbus_object_get_object_path(object);
+
+  if (g_strcmp0(path, application_object_path))
+    return;
+
+  fprintf(stderr, "Application '%s' disappeared, exiting.\n", path);
+
+  delete ep_launcher;
+  g_main_loop_quit(mainloop);
+}
+
+static void on_app_properties_changed(GDBusProxy* proxy,
+                                      GVariant* changed_properties,
+                                      GStrv invalidated_properties,
+                                      gpointer user_data) {
+  const char* interface = g_dbus_proxy_get_interface_name(proxy);
+
+  fprintf(stderr, "properties changed %s\n", interface);
+
+  if (g_variant_n_children(changed_properties) == 0)
+    return;
+
+  if (g_strcmp0(interface, xwalk_running_app_iface))
+    return;
+
+  GVariantIter* iter;
+  const gchar* key;
+  GVariant* value;
+
+  g_variant_get(changed_properties, "a{sv}", &iter);
+
+  while (g_variant_iter_loop(iter, "{&sv}", &key, &value)) {
+    if (g_strcmp0(key, "State"))
+      continue;
+
+    const gchar* state = g_variant_get_string(value, NULL);
+
+    fprintf(stderr, "Application state %s\n", state);
+  }
+}
+
+static gboolean init_extension_process_channel(GDBusProxy* app_proxy) {
+  if (ep_launcher->is_started())
+    return FALSE;
+
+  // Get the client socket file descriptor from fd_list. The reply will
+  // contains an index to the list.
+  GUnixFDList* fd_list;
+  GVariant* res = g_dbus_proxy_call_with_unix_fd_list_sync(
+      app_proxy, "GetEPChannel", NULL, G_DBUS_CALL_FLAGS_NONE,
+      -1, NULL, &fd_list, NULL, NULL);
+  if (!res || g_variant_n_children(res) != 2)
+    return FALSE;
+
+  const gchar* channel_id =
+      g_variant_get_string(g_variant_get_child_value(res, 0), NULL);
+  if (!channel_id || !strlen(channel_id))
+    return FALSE;
+
+  gint32 client_fd_idx =
+      g_variant_get_handle(g_variant_get_child_value(res, 1));
+  int client_fd = g_unix_fd_list_get(fd_list, client_fd_idx, NULL);
+
+  ep_launcher->Launch(channel_id, client_fd);
+  return TRUE;
+}
+
+static void on_app_signal(GDBusProxy* proxy,
+                          gchar* sender_name,
+                          gchar* signal_name,
+                          GVariant* parameters,
+                          gpointer user_data) {
+  if (!strcmp(signal_name, "EPChannelCreated")) {
+    init_extension_process_channel(proxy);
+  } else {
+    fprintf(stderr, "Unkown signal received: %s\n", signal_name);
+  }
+}
+
+static int query_application_running(const char* app_id) {
+  GList* objects = g_dbus_object_manager_get_objects(g_running_apps_manager);
+  GList* it;
+  bool is_running = FALSE;
+
+  for (it = objects; it; it = it->next) {
+    GDBusObject* object = reinterpret_cast<GDBusObject*>(it->data);
+    GDBusInterface* iface = g_dbus_object_get_interface(
+        object,
+        xwalk_running_app_iface);
+    if (!iface)
+      continue;
+
+    GDBusProxy* proxy = G_DBUS_PROXY(iface);
+    GVariant* id_variant;
+    id_variant = g_dbus_proxy_get_cached_property(proxy, "AppID");
+    if (!id_variant) {
+      g_object_unref(iface);
+      continue;
+    }
+
+    const gchar* id;
+    g_variant_get(id_variant, "s", &id);
+    if (!strcmp(app_id, id)) {
+      is_running = TRUE;
+      break;
+    }
+
+    g_object_unref(iface);
+  }
+  const char* str = is_running ? "running" : "not running";
+  g_print("Application %s is %s.\n", app_id, str);
+
+  g_list_free_full(objects, g_object_unref);
+  return is_running ? 0 : 1;
+}
+
+static void launch_application(const char* appid_or_url,
+                               gboolean fullscreen,
+                               gboolean remote_debugging) {
+  ep_launcher = new XWalkExtensionProcessLauncher();
+  GError* error = NULL;
+  g_signal_connect(g_running_apps_manager, "object-removed",
+                   G_CALLBACK(object_removed), NULL);
+
+  GDBusProxy* running_proxy = g_dbus_proxy_new_sync(
+      g_connection,
+      G_DBUS_PROXY_FLAGS_NONE, NULL, xwalk_service_name,
+      xwalk_running_path, xwalk_running_manager_iface, NULL, &error);
+  if (!running_proxy) {
+    g_print("Couldn't create proxy for '%s': %s\n", xwalk_running_manager_iface,
+            error->message);
+    g_error_free(error);
+    exit(1);
+  }
+
+  unsigned int launcher_pid = getpid();
+
+  GVariant* result  = g_dbus_proxy_call_sync(running_proxy, "Launch",
+      g_variant_new("(subb)", appid_or_url, launcher_pid, fullscreen,
+                    remote_debugging),
+      G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+  if (!result) {
+    fprintf(stderr, "Couldn't call 'Launch' method: %s\n", error->message);
+    exit(1);
+  }
+
+  g_variant_get(result, "(o)", &application_object_path);
+  fprintf(stderr, "Application launched with path '%s'\n",
+          application_object_path);
+
+  GDBusProxy* app_proxy = g_dbus_proxy_new_sync(
+      g_connection,
+      G_DBUS_PROXY_FLAGS_NONE, NULL, xwalk_service_name,
+      application_object_path, xwalk_running_app_iface, NULL, &error);
+  if (!app_proxy) {
+    g_print("Couldn't create proxy for '%s': %s\n", xwalk_running_app_iface,
+            error->message);
+    g_error_free(error);
+    exit(1);
+  }
+
+  g_signal_connect(app_proxy, "g-properties-changed",
+                   G_CALLBACK(on_app_properties_changed), NULL);
+
+  mainloop = g_main_loop_new(NULL, FALSE);
+  g_signal_connect(app_proxy, "g-signal", G_CALLBACK(on_app_signal), NULL);
+
+#if defined(OS_TIZEN)
+  char name[128];
+  snprintf(name, sizeof(name), "xwalk-%s", appid_or_url);
+
+  if (xwalk_appcore_init(g_argc, g_argv, name, app_proxy)) {
+    fprintf(stderr, "Failed to initialize appcore");
+    exit(1);
+  }
+#endif
+
+  init_extension_process_channel(app_proxy);
+  g_main_loop_run(mainloop);
+}
+
+void connect_to_application_manager() {
+  GError* error = NULL;
+  g_connection = get_session_bus_connection(&error);
+  if (!g_connection) {
+    fprintf(stderr, "Couldn't get the session bus connection: %s\n",
+            error->message);
+    exit(1);
+  }
+
+  g_running_apps_manager =
+      g_dbus_object_manager_client_new_sync(
+          g_connection, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
+          xwalk_service_name, xwalk_running_path,
+          NULL, NULL, NULL, NULL, &error);
+  if (!g_running_apps_manager) {
+    fprintf(stderr, "Service '%s' does could not be reached: %s\n",
+            xwalk_service_name, error->message);
+    exit(1);
+  }
+}
+
 int main(int argc, char** argv) {
+  GError* error = NULL;
+  char* appid_or_url;
+
+  g_argc = argc;
+  g_argv = argv;
+
 #if !GLIB_CHECK_VERSION(2, 36, 0)
   // g_type_init() is deprecated on GLib since 2.36.
   g_type_init();
@@ -50,43 +274,42 @@ int main(int argc, char** argv) {
 
 #if defined(OS_TIZEN)
   if (xwalk_tizen_check_group_users())
-    return 1;
+    exit(1);
 #endif
-  base::MessageLoop msg_loop(
-      make_scoped_ptr<base::MessagePump>(new base::MessagePumpGlib()));
-
-  g_argc = argc;
-  g_argv = argv;
 
-  GError* error = nullptr;
   GOptionContext* context =
       g_option_context_new("- Crosswalk Application Launcher");
-  g_option_context_add_main_entries(context, entries, nullptr);
+  g_option_context_add_main_entries(context, entries, NULL);
   if (!g_option_context_parse(context, &argc, &argv, &error)) {
-    LOG(ERROR) << "Option parsing failed: " << error->message;
+    fprintf(stderr, "Option parsing failed: %s\n", error->message);
     exit(1);
   }
 
-  std::string appid_or_url;
-  if (!strcmp(basename(g_argv[0]), "xwalk-launcher")) {
-    if (!cmd_appid_or_url) {
-      LOG(ERROR) << "No AppID informed, nothing to do.";
-      exit(1);
+  connect_to_application_manager();
+
+  // Launch app.
+  if (!strcmp(basename(argv[0]), "xwalk-launcher")) {
+    if (cmd_appid_or_url == NULL) {
+      fprintf(stderr, "No AppID informed, nothing to do.\n");
+      return 0;
     }
-    appid_or_url = std::string(cmd_appid_or_url[0]);
+    appid_or_url = strdup(cmd_appid_or_url[0]);
+#if defined(OS_TIZEN)
+    if (GURL(appid_or_url).spec().empty()
+       && xwalk_change_cmdline(argc, argv, appid_or_url))
+      exit(1);
+#endif
   } else {
-    appid_or_url = std::string(basename(g_argv[0]));
+    appid_or_url = strdup(basename(argv[0]));
   }
 
-  std::unique_ptr<XWalkLauncher> launcher;
-#if defined(OS_TIZEN)
-  launcher.reset(new XWalkLauncherTizen(query_running, &msg_loop));
-#else
-  launcher.reset(new XWalkLauncher(query_running, &msg_loop));
-#endif
-  int result = launcher->Launch(appid_or_url, fullscreen, remote_debugging,
-                                argc, argv);
-  if (!result)
-    msg_loop.Run();
-  return result;
+
+  // Query app.
+  if (query_running) {
+    return query_application_running(appid_or_url);
+  }
+
+  launch_application(appid_or_url, fullscreen, remote_debugging);
+  free(appid_or_url);
+  return 0;
 }
index 8aa67b7..a26b053 100644 (file)
@@ -1,31 +1,40 @@
 // Copyright (c) 2013 Intel Corporation. All rights reserved.
-// Copyright (c) 2014 Samsung Electronics Co., Ltd 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/application/tools/linux/xwalk_launcher_tizen.h"
-
-#include <unistd.h>
-#include <pkgmgr-info.h>
+#include <glib.h>
+#include <gio/gio.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
+#include <stdlib.h>
+#include <appcore/appcore-common.h>
+#include <pkgmgr-info.h>
 
-#include <string>
+#include "xwalk/application/common/id_util.h"
+#include "xwalk/application/tools/linux/xwalk_launcher_tizen.h"
 
-#include "base/logging.h"
-#include "url/gurl.h"
+enum app_event {
+  AE_UNKNOWN,
+  AE_CREATE,
+  AE_TERMINATE,
+  AE_PAUSE,
+  AE_RESUME,
+  AE_RESET,
+  AE_LOWMEM_POST,
+  AE_MEM_FLUSH,
+  AE_MAX
+};
 
 // Private struct from appcore-internal, necessary to get events from
 // the system.
 struct ui_ops {
   void* data;
-  void (*cb_app)(app_event evnt, void* data, bundle* b);
+  void (*cb_app)(enum app_event evnt, void* data, bundle* b);
 };
 
-namespace {
+static struct ui_ops appcore_ops;
 
-const char* Event2Str(app_event event) {
+static const char* event2str(enum app_event event) {
   switch (event) {
     case AE_UNKNOWN:
       return "AE_UNKNOWN";
@@ -50,68 +59,33 @@ const char* Event2Str(app_event event) {
   return "INVALID EVENT";
 }
 
-ui_ops app_ops;
-
-}  // namespace
+static void application_event_cb(enum app_event event, void* data, bundle* b) {
+  fprintf(stderr, "event '%s'\n", event2str(event));
+  GDBusProxy* app_proxy = reinterpret_cast<GDBusProxy*>(data);
 
-XWalkLauncherTizen::XWalkLauncherTizen(bool query_running,
-    base::MessageLoop* main_loop)
-    : XWalkLauncher(query_running, main_loop) {
-}
-
-int XWalkLauncherTizen::Launch(const std::string& appid_or_url, bool fullscreen,
-                               bool remote_debugging, int argc, char* argv[]) {
-  appid_or_url_ = appid_or_url;
-  fullscreen_ = fullscreen;
-  remote_debugging_ = remote_debugging;
-  // Query app.
-  if (query_running_) {
-    return dbus_object_manager_->IsApplicationRunning(appid_or_url_);
+  if (!app_proxy) {
+    fprintf(stderr, "Invalid DBus proxy.");
+    return;
   }
-  std::string name = "xwalk-" + appid_or_url_;
-
-  if (XwalkAppcoreInit(name, argc, argv)) {
-    LOG(ERROR) << "Failed to initialize appcore.";
-    return 1;
-  }
-  if (GURL(appid_or_url_).spec().empty()
-      && XwalkChangeCmdline(appid_or_url_, argc, argv))
-    return 1;
-  return 0;
-}
-
-bool XWalkLauncherTizen::Suspend() {
-  return dbus_object_manager_->Suspend();
-}
-
-bool XWalkLauncherTizen::Resume() {
-  return dbus_object_manager_->Resume();
-}
-
-void XWalkLauncherTizen::application_event_cb(app_event event,
-                                              void* data, bundle* b) {
-  XWalkLauncherTizen* xwalk_launcher = static_cast<XWalkLauncherTizen*>(data);
-  LOG(INFO) << "event '" << Event2Str(event) << "'";
 
   switch (event) {
     case AE_UNKNOWN:
     case AE_CREATE:
       break;
     case AE_TERMINATE:
-      xwalk_launcher->main_loop_->QuitNow();
+      exit(0);
       break;
     case AE_PAUSE:
-      if (!xwalk_launcher->Suspend())
-        LOG(ERROR) << "Suspending application failed";
+      g_dbus_proxy_call(
+          app_proxy, "Suspend", NULL,
+          G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
       break;
     case AE_RESUME:
-      if (!xwalk_launcher->Resume())
-        LOG(ERROR) << "Resuming application failed";
+      g_dbus_proxy_call(
+          app_proxy, "Resume", NULL,
+          G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
       break;
     case AE_RESET:
-      if (!xwalk_launcher->LaunchApplication())
-        xwalk_launcher->main_loop_->QuitNow();
-      break;
     case AE_LOWMEM_POST:
     case AE_MEM_FLUSH:
     case AE_MAX:
@@ -119,37 +93,34 @@ void XWalkLauncherTizen::application_event_cb(app_event event,
   }
 }
 
-int XWalkLauncherTizen::XwalkAppcoreInit(const std::string& name,
-                                         int argc, char* argv[]) {
-  app_ops.cb_app = application_event_cb;
-  app_ops.data = this;
-  return appcore_init(name.c_str(), &app_ops, argc, argv);
+int xwalk_appcore_init(
+    int argc, char** argv, const char* name, GDBusProxy* app_proxy) {
+  appcore_ops.cb_app = application_event_cb;
+  appcore_ops.data = app_proxy;
+
+  return appcore_init(name, &appcore_ops, argc, argv);
 }
 
-int XWalkLauncherTizen::XwalkChangeCmdline(const std::string& app_id,
-                                           int argc, char* argv[]) {
+int xwalk_change_cmdline(int argc, char** argv, const char* app_id) {
   // Change /proc/<pid>/cmdline to app exec path. See XWALK-1722 for details.
   pkgmgrinfo_appinfo_h handle;
-  char* exec_path = nullptr;
+  char* exec_path = NULL;
   // todo : add is_admin
-  if (pkgmgrinfo_appinfo_get_usr_appinfo(app_id.c_str(),
+  if (pkgmgrinfo_appinfo_get_usr_appinfo(app_id,
       getuid(), &handle) != PMINFO_R_OK ||
       pkgmgrinfo_appinfo_get_exec(handle, &exec_path) != PMINFO_R_OK ||
       !exec_path) {
-    if (pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(), &handle) !=
-        PMINFO_R_OK ||
+    if (pkgmgrinfo_appinfo_get_appinfo(app_id, &handle) != PMINFO_R_OK ||
         pkgmgrinfo_appinfo_get_exec(handle, &exec_path) != PMINFO_R_OK ||
         !exec_path) {
-      LOG(ERROR) << "Couldn't find exec path for application: " << app_id;
+      fprintf(stderr, "Couldn't find exec path for application: %s\n", app_id);
       return -1;
     }
   }
 
-  // zeros g_argv_
   for (int i = 0; i < argc; ++i)
     memset(argv[i], 0, strlen(argv[i]));
-
-  strncpy(argv[0], exec_path, strlen(exec_path) + 1);
+  strncpy(argv[0], exec_path, strlen(exec_path)+1);
   pkgmgrinfo_appinfo_destroy_appinfo(handle);
   return 0;
 }
index a0c8f3f..75237bd 100644 (file)
@@ -1,50 +1,13 @@
 // Copyright (c) 2013 Intel Corporation. All rights reserved.
-// Copyright (c) 2014 Samsung Electronics Co., Ltd 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_APPLICATION_TOOLS_LINUX_XWALK_LAUNCHER_TIZEN_H_
 #define XWALK_APPLICATION_TOOLS_LINUX_XWALK_LAUNCHER_TIZEN_H_
 
-#include <appcore-common.h>
-#include <glib.h>
+int xwalk_appcore_init(int argc, char** argv,
+                       const char* name, GDBusProxy* app_proxy);
 
-#include <memory>
-#include <string>
-
-#include "base/message_loop/message_loop.h"
-
-#include "xwalk/application/common/id_util.h"
-#include "xwalk/application/tools/linux/xwalk_launcher.h"
-#include "xwalk/application/tools/tizen/xwalk_tizen_user.h"
-
-// Private enum from appcore-internal
-extern "C" enum app_event {
-  AE_UNKNOWN,
-  AE_CREATE,
-  AE_TERMINATE,
-  AE_PAUSE,
-  AE_RESUME,
-  AE_RESET,
-  AE_LOWMEM_POST,
-  AE_MEM_FLUSH,
-  AE_MAX
-};
-
-class XWalkLauncherTizen : public XWalkLauncher {
- public:
-  XWalkLauncherTizen(bool query_running, base::MessageLoop* main_loop);
-  int Launch(const std::string& appid_or_url, bool fullscreen,
-             bool remote_debugging, int argc, char* argv[]);
-  bool Suspend();
-  bool Resume();
-
- private:
-  static void application_event_cb(app_event event, void* data, bundle* b);
-  int XwalkAppcoreInit(const std::string& name, int argc, char* argv[]);
-  int XwalkChangeCmdline(const std::string& app_id, int argc, char* argv[]);
-
-  base::MessageLoop* main_loop_;
-};
+int xwalk_change_cmdline(int argc, char** argv, const char* app_id);
 
 #endif  // XWALK_APPLICATION_TOOLS_LINUX_XWALK_LAUNCHER_TIZEN_H_
index 148155b..862a47b 100644 (file)
@@ -16,6 +16,7 @@
 #include "base/path_service.h"
 #include "xwalk/application/common/id_util.h"
 #include "xwalk/application/common/tizen/application_storage.h"
+#include "xwalk/application/tools/linux/dbus_connection.h"
 #include "xwalk/application/tools/tizen/xwalk_package_installer.h"
 #include "xwalk/application/tools/tizen/xwalk_tizen_user.h"
 #include "xwalk/runtime/common/xwalk_paths.h"
index e5f9622..68f1850 100644 (file)
@@ -5,5 +5,5 @@
 
     <uses-sdk
         android:minSdkVersion="14"
-        android:targetSdkVersion="19" />
+        android:targetSdkVersion="21" />
 </manifest>
index 2651642..820d816 100644 (file)
@@ -24,7 +24,7 @@
 %define _binary_payload w3.gzdio
 
 Name:           crosswalk
-Version:        11.40.271.0
+Version:        11.40.277.0
 Release:        0
 Summary:        Chromium-based app runtime
 License:        (BSD-3-Clause and LGPL-2.1+)
@@ -156,6 +156,12 @@ cp -a src/xwalk/LICENSE LICENSE.xwalk
 # does not expect -Wall to be passed to the compiler (see webrtc issue 3307).
 export CXXFLAGS=`echo $CXXFLAGS | sed s,-Wall,,g`
 
+# Do not use -finline-functions: it breaks the build because it causes -Wall to
+# warn about some conditions that cannot really be reached (ie. variables that
+# may be used uninitialized while in fact thay cannot be uninitialized). See
+# TC-2299.
+export CXXFLAGS=`echo $CXXFLAGS | sed s,-finline-functions,,g`
+
 # For ffmpeg on ia32. The original CFLAGS set by the gyp and config files in
 # src/third_party/ffmpeg already pass -O2 -fomit-frame-pointer, but Tizen's
 # CFLAGS end up appending -fno-omit-frame-pointer. See http://crbug.com/37246
index 9dd22f3..b17d1fd 100644 (file)
@@ -90,8 +90,9 @@ public class XWalkWebChromeClient {
             mContentsClient.onToggleFullscreen(true);
         }
 
-        // Add the video view to the activity's ContentView.
-        activity.getWindow().addContentView(view,
+        // Add the video view to the activity's DecorView.
+        FrameLayout decor = (FrameLayout) activity.getWindow().getDecorView();
+        decor.addView(mCustomXWalkView, 0,
                 new FrameLayout.LayoutParams(
                         ViewGroup.LayoutParams.MATCH_PARENT,
                         ViewGroup.LayoutParams.MATCH_PARENT,
index 57353a8..2183219 100644 (file)
@@ -13,5 +13,5 @@
         android:label="XWalkCoreLibraryEmpty" android:hardwareAccelerated="true">
     </application>
 
-  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
+  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
 </manifest>
index 4176a60..0a7f4be 100644 (file)
@@ -31,7 +31,7 @@
             android:authorities="org.xwalk.core.internal.xwview.test.TestContentProvider" />
     </application>
 
-  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
+  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
   <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
index bc32751..568fd8a 100644 (file)
@@ -31,7 +31,7 @@
             android:authorities="org.xwalk.core.xwview.test.TestContentProvider" />
     </application>
 
-  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
+  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
   <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
index 7d6261c..1fbd041 100644 (file)
@@ -13,5 +13,5 @@
         android:label="XWalkCoreLibrary" android:hardwareAccelerated="true" android:icon="@drawable/crosswalk">
     </application>
 
-  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
+  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
 </manifest>
index c9be134..16157e9 100644 (file)
@@ -14,7 +14,7 @@
 
     <uses-sdk
         android:minSdkVersion="14"
-        android:targetSdkVersion="19" />
+        android:targetSdkVersion="21" />
 
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
index c44cac3..7f9112a 100644 (file)
@@ -34,6 +34,7 @@
 #include "xwalk/runtime/browser/android/net/url_constants.h"
 
 using base::android::AttachCurrentThread;
+using base::android::DetachFromVM;
 using base::PostTaskAndReplyWithResult;
 using content::BrowserThread;
 using xwalk::InputStream;
@@ -129,6 +130,8 @@ void OpenInputStreamOnWorkerThread(
                              base::Bind(callback,
                                         base::Passed(delegate.Pass()),
                                         base::Passed(input_stream.Pass())));
+
+  DetachFromVM();
 }
 
 }  // namespace
index 0ce693d..083773c 100644 (file)
@@ -111,13 +111,13 @@ void XWalkBrowserMainParts::PreMainMessageLoopStart() {
   command_line->AppendSwitch(switches::kAllowFileAccessFromFiles);
 
   // Enable SIMD.JS API by default.
-  /*std::string js_flags("--simd_object");
+  std::string js_flags("--simd_object");
   if (command_line->HasSwitch(switches::kJavaScriptFlags)) {
     js_flags += " ";
     js_flags +=
         command_line->GetSwitchValueASCII(switches::kJavaScriptFlags);
   }
-  command_line->AppendSwitchASCII(switches::kJavaScriptFlags, js_flags);*/
+  command_line->AppendSwitchASCII(switches::kJavaScriptFlags, js_flags);
 
   startup_url_ = GetURLFromCommandLine(*command_line);
 }
index 07c784a..9002828 100644 (file)
@@ -49,6 +49,31 @@ base::StringPiece PlatformResourceProvider(int key) {
   return base::StringPiece();
 }
 
+void MoveUserDataDirIfNecessary(const base::FilePath& user_data_dir,
+                                const base::FilePath& profile) {
+  if (base::DirectoryExists(profile))
+    return;
+
+  if (!base::CreateDirectory(profile))
+    return;
+
+  const char* possible_data_dir_names[] = {
+      "Cache",
+      "Cookies",
+      "Cookies-journal",
+      "Local Storage",
+  };
+  for (int i = 0; i < 4; i++) {
+    base::FilePath dir = user_data_dir.Append(possible_data_dir_names[i]);
+    if (base::PathExists(dir)) {
+      if (!base::Move(dir, profile.Append(possible_data_dir_names[i]))) {
+        NOTREACHED() << "Failed to import previous user data: "
+                     << possible_data_dir_names[i];
+      }
+    }
+  }
+}
+
 }  // namespace
 
 namespace xwalk {
@@ -132,9 +157,12 @@ void XWalkBrowserMainPartsAndroid::PreMainMessageLoopRun() {
     NOTREACHED() << "Failed to get app data directory for Crosswalk";
   }
   CommandLine* command_line = CommandLine::ForCurrentProcess();
-  if (command_line->HasSwitch(switches::kXWalkProfileName))
-    user_data_dir = user_data_dir.Append(
+  if (command_line->HasSwitch(switches::kXWalkProfileName)) {
+    base::FilePath profile = user_data_dir.Append(
         command_line->GetSwitchValuePath(switches::kXWalkProfileName));
+    MoveUserDataDirIfNecessary(user_data_dir, profile);
+    user_data_dir = profile;
+  }
 
   base::FilePath cookie_store_path = user_data_dir.Append(
       FILE_PATH_LITERAL("Cookies"));
index 63c6c36..c3057ec 100644 (file)
@@ -22,6 +22,11 @@ struct MatchRuntimeFeature
   const std::string name;
 };
 
+XWalkRuntimeFeatures::RuntimeFeature::RuntimeFeature()
+    : status(Experimental),
+      enabled(false) {
+}
+
 // static
 XWalkRuntimeFeatures* XWalkRuntimeFeatures::GetInstance() {
   return Singleton<XWalkRuntimeFeatures>::get();
index 7945138..6edca0d 100644 (file)
@@ -34,14 +34,14 @@ class XWalkRuntimeFeatures {
     Experimental
   };
 
-
   struct RuntimeFeature {
     std::string name;
     std::string description;
     std::string command_line_switch;
     RuntimeFeatureStatus status;
     bool enabled;
-    RuntimeFeature() = default;
+
+    RuntimeFeature();
   };
 
  private:
index 96d15e4..c52d288 100644 (file)
@@ -248,7 +248,7 @@ bool XWalkContentRendererClient::WillSendRequest(blink::WebFrame* frame,
   // if under WARP mode.
   if (url.GetOrigin() == app_url.GetOrigin() ||
       blink::WebSecurityOrigin::create(app_url).canRequest(url)) {
-    LOG(INFO) << "[PASS] " << origin_url.spec() << " request " << url.spec();
+    DLOG(INFO) << "[PASS] " << origin_url.spec() << " request " << url.spec();
     return false;
   }
 
index af4b4c7..3195aa7 100644 (file)
@@ -12,7 +12,7 @@
         <uses-library android:name="android.test.runner" />
     </application>
 
-    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
+    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
     <instrumentation android:name="android.test.InstrumentationTestRunner"
         android:targetPackage="org.xwalk.core.xwview.shell"
         android:label="Test for org.xwalk.core.xwview" />
index 5869976..9a027fa 100644 (file)
@@ -12,7 +12,7 @@
         <uses-library android:name="android.test.runner" />
     </application>
 
-    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
+    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
     <instrumentation android:name="android.test.InstrumentationTestRunner"
         android:targetPackage="org.xwalk.core.internal.xwview.shell"
         android:label="Test for org.xwalk.core.internal.xwview" />
index fe013ed..f50e5bb 100644 (file)
@@ -14,7 +14,7 @@
             android:authorities="org.xwalk.runtime.client.test.TestContentProvider" />
     </application>
 
-    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
+    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
     <instrumentation android:name="android.test.InstrumentationTestRunner"
         android:targetPackage="org.xwalk.runtime.client.shell"
         android:label="Test for org.xwalk.runtime.client" />
index f839aa4..f823f5d 100644 (file)
@@ -14,7 +14,7 @@
             android:authorities="org.xwalk.runtime.client.embedded.test.TestContentProvider" />
     </application>
 
-    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
+    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
     <instrumentation android:name="android.test.InstrumentationTestRunner"
         android:targetPackage="org.xwalk.runtime.client.embedded.shell"
         android:label="Test for org.xwalk.runtime.client.embedded" />
index 2201ff5..e49b29a 100644 (file)
@@ -53,7 +53,7 @@ MurphyResource::MurphyResource(
   if (attr)
     mrp_res_set_attribute_string(attr, app_class.c_str());
 
-  attr = mrp_res_get_attribute_by_name(resource, "resource.set.appid");
+  attr = mrp_res_get_attribute_by_name(resource, "name");
   if (attr)
     mrp_res_set_attribute_string(attr, app_id.c_str());