Upstream version 10.38.210.0 03/28003/1
authorEurogiciel-BOT <eurogiciel.tizen@gmail.com>
Wed, 24 Sep 2014 08:24:32 +0000 (08:24 +0000)
committerEurogiciel-BOT <eurogiciel.tizen@gmail.com>
Wed, 24 Sep 2014 08:24:32 +0000 (08:24 +0000)
Upstream commit-id fbb09a42a04d8d1611e08c2787bff5caf43d6799

Change-Id: I5b27df106702b36ef9769a70a2b0e6806f82f884
Signed-off-by: Eurogiciel-BOT <eurogiciel.tizen@gmail.com>
37 files changed:
packaging/crosswalk.spec
src/xwalk/VERSION
src/xwalk/application/browser/application.h
src/xwalk/application/browser/application_service.cc
src/xwalk/application/browser/application_tizen.cc
src/xwalk/application/browser/application_tizen.h
src/xwalk/application/browser/linux/running_application_object.cc
src/xwalk/application/browser/linux/running_application_object.h
src/xwalk/application/common/application_data.cc
src/xwalk/application/common/tizen/cookie_manager.cc [new file with mode: 0644]
src/xwalk/application/common/tizen/cookie_manager.h [new file with mode: 0644]
src/xwalk/application/common/xwalk_application_common.gypi
src/xwalk/application/tools/tizen/xwalk_backend_wrapper.sh
src/xwalk/application/tools/tizen/xwalk_tizen_user.cc
src/xwalk/application/tools/tizen/xwalk_tizen_user.h
src/xwalk/application/tools/tizen/xwalkctl_main.cc
src/xwalk/build/system.gyp
src/xwalk/packaging/crosswalk.spec
src/xwalk/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContent.java
src/xwalk/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkContentsClientBridge.java
src/xwalk/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkUIClientInternal.java
src/xwalk/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkViewInternal.java
src/xwalk/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkWebContentsDelegateAdapter.java
src/xwalk/runtime/browser/android/xwalk_content.cc
src/xwalk/runtime/browser/android/xwalk_content.h
src/xwalk/runtime/browser/android/xwalk_web_contents_delegate.cc
src/xwalk/runtime/browser/runtime_context.cc
src/xwalk/runtime/browser/runtime_context.h
src/xwalk/runtime/common/xwalk_common_messages.h
src/xwalk/runtime/common/xwalk_content_client.cc [changed mode: 0644->0755]
src/xwalk/runtime/renderer/tizen/xwalk_content_renderer_client_tizen.cc
src/xwalk/runtime/renderer/tizen/xwalk_content_renderer_client_tizen.h
src/xwalk/runtime/renderer/xwalk_content_renderer_client.h
src/xwalk/runtime/renderer/xwalk_render_process_observer_generic.cc
src/xwalk/runtime/renderer/xwalk_render_process_observer_generic.h
src/xwalk/tools/reflection_generator/java_class.py
src/xwalk/tools/reflection_generator/java_method.py

index 6b19c90..faeca0b 100644 (file)
@@ -16,7 +16,7 @@
 %endif
 
 Name:           crosswalk
-Version:        10.38.208.0
+Version:        10.38.210.0
 Release:        0
 Summary:        Chromium-based app runtime
 License:        (BSD-3-Clause and LGPL-2.1+)
@@ -238,7 +238,7 @@ install -p -D src/out/Release/xwalk %{buildroot}%{_libdir}/xwalk/xwalk
 install -p -D src/out/Release/xwalkctl %{buildroot}%{_bindir}/xwalkctl
 install -p -D src/out/Release/xwalk-launcher %{buildroot}%{_bindir}/xwalk-launcher
 # xwalk-pkg-helper needs to be set-user-ID-root so it can finish the installation process.
-install -m 06755 -p -D src/out/Release/xwalk-pkg-helper %{buildroot}%{_bindir}/xwalk-pkg-helper
+install -m 0755 -p -D src/out/Release/xwalk-pkg-helper %{buildroot}%{_bindir}/xwalk-pkg-helper
 install -p -D src/out/Release/lib/libxwalk-backendlib.so %{buildroot}%{_libdir}/xwalk/libxwalk-backendlib.so
 install -p -D src/xwalk/application/tools/tizen/xwalk_backend_wrapper.sh %{buildroot}%{_libdir}/xwalk/xwalk_backend_wrapper.sh
 
index 90600cd..a4fd7f2 100644 (file)
@@ -1,4 +1,4 @@
 MAJOR=10
 MINOR=38
-BUILD=208
+BUILD=210
 PATCH=0
index 854ea94..76a5967 100644 (file)
@@ -1,4 +1,5 @@
 // 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.
 
@@ -121,6 +122,7 @@ class Application : public Runtime::Observer,
   virtual base::FilePath GetSplashScreenPath();
 
   std::set<Runtime*> runtimes_;
+  RuntimeContext* runtime_context_;
   scoped_refptr<ApplicationData> const data_;
   // The application's render process host.
   content::RenderProcessHost* render_process_host_;
@@ -159,7 +161,6 @@ class Application : public Runtime::Observer,
 
   void NotifyTermination();
 
-  RuntimeContext* runtime_context_;
   Observer* observer_;
 
   std::map<std::string, std::string> name_perm_map_;
index effe141..62289d9 100644 (file)
@@ -10,6 +10,7 @@
 #include <vector>
 
 #include "base/file_util.h"
+#include "base/strings/utf_string_conversions.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/web_contents.h"
 #include "content/public/browser/web_contents_observer.h"
@@ -115,7 +116,12 @@ Application* ApplicationService::LaunchFromPackagePath(
     return NULL;
   }
 
+#if defined (OS_WIN)
+  base::CreateTemporaryDirInDir(tmp_dir,
+      base::UTF8ToWide(package->name()), &target_dir);
+#else
   base::CreateTemporaryDirInDir(tmp_dir, package->name(), &target_dir);
+#endif
   if (!package->ExtractTo(target_dir)) {
     LOG(ERROR) << "Failed to unpack to a temporary directory: "
                << target_dir.MaybeAsASCII();
index a7e0587..cc8b7c5 100644 (file)
@@ -1,4 +1,5 @@
 // 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.
 
@@ -13,6 +14,8 @@
 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h"
 #include "content/browser/screen_orientation/screen_orientation_provider.h"
 
+#include "xwalk/runtime/browser/runtime_context.h"
+#include "xwalk/runtime/browser/runtime_url_request_context_getter.h"
 #include "xwalk/runtime/browser/ui/native_app_window.h"
 #include "xwalk/runtime/browser/ui/native_app_window_tizen.h"
 #include "xwalk/runtime/common/xwalk_common_messages.h"
@@ -101,6 +104,8 @@ ApplicationTizen::ApplicationTizen(
 #if defined(USE_OZONE)
   ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
 #endif
+  cookie_manager_ = scoped_ptr<CookieManager>(
+      new CookieManager(id(), runtime_context_));
 }
 
 ApplicationTizen::~ApplicationTizen() {
@@ -204,5 +209,14 @@ void ApplicationTizen::DidProcessEvent(
 }
 #endif
 
+void ApplicationTizen::RemoveAllCookies() {
+  cookie_manager_->RemoveAllCookies();
+}
+
+void ApplicationTizen::SetUserAgentString(
+    const std::string& user_agent_string) {
+  cookie_manager_->SetUserAgentString(render_process_host_, user_agent_string);
+}
+
 }  // namespace application
 }  // namespace xwalk
index 755b674..64767c3 100644 (file)
@@ -1,11 +1,15 @@
 // 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_BROWSER_APPLICATION_TIZEN_H_
 #define XWALK_APPLICATION_BROWSER_APPLICATION_TIZEN_H_
 
+#include <string>
+
 #include "base/event_types.h"
 #include "xwalk/application/browser/application.h"
+#include "xwalk/application/common/tizen/cookie_manager.h"
 
 #if defined(USE_OZONE)
 #include "ui/events/platform/platform_event_observer.h"
@@ -26,6 +30,9 @@ class ApplicationTizen :  // NOLINT
   void Suspend();
   void Resume();
 
+  void RemoveAllCookies();
+  void SetUserAgentString(const std::string& user_agent_string);
+
  private:
   friend class Application;
   ApplicationTizen(scoped_refptr<ApplicationData> data,
@@ -39,6 +46,7 @@ class ApplicationTizen :  // NOLINT
   virtual void DidProcessEvent(const ui::PlatformEvent& event) OVERRIDE;
 #endif
 
+  scoped_ptr<CookieManager> cookie_manager_;
   bool is_suspended_;
 };
 
index 1841c37..2437f48 100644 (file)
@@ -1,4 +1,5 @@
 // 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.
 
@@ -55,6 +56,25 @@ RunningApplicationObject::RunningApplicationObject(
       kRunningApplicationDBusInterface, "AppID",
       scoped_ptr<base::Value>(new base::StringValue(app_id)));
 
+  // FIXME: RemoveAllCookies and SetUserAgentString
+  // are exported for web_setting extension usage.
+  // This is a temporary solution - when another
+  // IPC on extension process side is implemented,
+  // these methods have to be removed.
+  dbus_object()->ExportMethod(
+      kRunningApplicationDBusInterface, "RemoveAllCookies",
+      base::Bind(&RunningApplicationObject::OnRemoveAllCookies,
+                 base::Unretained(this)),
+      base::Bind(&RunningApplicationObject::OnExported,
+                 base::Unretained(this)));
+
+  dbus_object()->ExportMethod(
+      kRunningApplicationDBusInterface, "SetUserAgentString",
+      base::Bind(&RunningApplicationObject::OnSetUserAgentString,
+                 base::Unretained(this)),
+      base::Bind(&RunningApplicationObject::OnExported,
+                 base::Unretained(this)));
+
   dbus_object()->ExportMethod(
       kRunningApplicationDBusInterface, "Terminate",
       base::Bind(&RunningApplicationObject::OnTerminate,
@@ -111,6 +131,60 @@ void RunningApplicationObject::OnExported(const std::string& interface_name,
   }
 }
 
+void RunningApplicationObject::SetUserAgentStringOnIOThread(
+    const std::string& user_agent_string) {
+  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  ToApplicationTizen(application_)->SetUserAgentString(user_agent_string);
+}
+
+void RunningApplicationObject::OnRemoveAllCookies(dbus::MethodCall* method_call,
+    dbus::ExportedObject::ResponseSender response_sender) {
+  if (method_call->GetSender() != launcher_name_) {
+    scoped_ptr<dbus::ErrorResponse> error_response =
+        dbus::ErrorResponse::FromMethodCall(method_call,
+                                            kRunningApplicationDBusError,
+                                            "Not permitted");
+    response_sender.Run(error_response.PassAs<dbus::Response>());
+    return;
+  }
+
+  ToApplicationTizen(application_)->RemoveAllCookies();
+
+  scoped_ptr<dbus::Response> response =
+      dbus::Response::FromMethodCall(method_call);
+  response_sender.Run(response.Pass());
+}
+
+void RunningApplicationObject::OnSetUserAgentString(
+    dbus::MethodCall* method_call,
+    dbus::ExportedObject::ResponseSender response_sender) {
+  if (method_call->GetSender() != launcher_name_) {
+    scoped_ptr<dbus::ErrorResponse> error_response =
+        dbus::ErrorResponse::FromMethodCall(method_call,
+                                            kRunningApplicationDBusError,
+                                            "Not permitted");
+    response_sender.Run(error_response.PassAs<dbus::Response>());
+    return;
+  }
+  dbus::MessageReader reader(method_call);
+  std::string new_user_agent;
+  if (reader.PopString(&new_user_agent)) {
+    content::BrowserThread::PostTask(
+        content::BrowserThread::IO, FROM_HERE,
+        base::Bind(&RunningApplicationObject::SetUserAgentStringOnIOThread,
+                   base::Unretained(this), new_user_agent));
+    scoped_ptr<dbus::Response> response =
+        dbus::Response::FromMethodCall(method_call);
+    response_sender.Run(response.Pass());
+  } else {
+    scoped_ptr<dbus::ErrorResponse> error_response =
+        dbus::ErrorResponse::FromMethodCall(method_call,
+                                            kRunningApplicationDBusError,
+                                            "Wrong user agent string");
+    response_sender.Run(error_response.PassAs<dbus::Response>());
+  }
+}
+
 void RunningApplicationObject::OnTerminate(
     dbus::MethodCall* method_call,
     dbus::ExportedObject::ResponseSender response_sender) {
index 70db94f..3406d33 100644 (file)
@@ -1,4 +1,5 @@
 // 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.
 
@@ -46,6 +47,14 @@ class RunningApplicationObject : public dbus::ManagedObject {
   void OnTerminate(dbus::MethodCall* method_call,
                    dbus::ExportedObject::ResponseSender response_sender);
 
+  void SetUserAgentStringOnIOThread(const std::string& user_agent_string);
+
+  void OnRemoveAllCookies(dbus::MethodCall* method_call,
+                   dbus::ExportedObject::ResponseSender response_sender);
+
+  void OnSetUserAgentString(dbus::MethodCall* method_call,
+                   dbus::ExportedObject::ResponseSender response_sender);
+
   void OnGetExtensionProcessChannel(
       dbus::MethodCall* method_call,
       dbus::ExportedObject::ResponseSender response_sender);
index a94d68c..7ef3f00 100644 (file)
@@ -149,7 +149,11 @@ GURL ApplicationData::GetResourceURL(const GURL& application_url,
 }
 
 GURL ApplicationData::GetResourceURL(const std::string& relative_path) const {
+#if defined (OS_WIN)
+  if (!base::PathExists(path_.Append(base::UTF8ToWide(relative_path)))) {
+#else
   if (!base::PathExists(path_.Append(relative_path))) {
+#endif
     LOG(ERROR) << "The path does not exist in the application directory: "
                << relative_path;
     return GURL();
diff --git a/src/xwalk/application/common/tizen/cookie_manager.cc b/src/xwalk/application/common/tizen/cookie_manager.cc
new file mode 100644 (file)
index 0000000..954fef5
--- /dev/null
@@ -0,0 +1,75 @@
+// 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/common/tizen/cookie_manager.h"
+
+#include "base/bind.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_process_host.h"
+#include "net/cookies/cookie_monster.h"
+#include "net/cookies/cookie_store.h"
+#include "net/url_request/url_request_context.h"
+#include "net/url_request/url_request_context_getter.h"
+
+#include "xwalk/runtime/browser/runtime_url_request_context_getter.h"
+#include "xwalk/runtime/common/xwalk_common_messages.h"
+
+namespace xwalk {
+
+CookieManager::CookieManager(
+    const std::string& app_id,
+    RuntimeContext* runtime_context)
+      : app_id_(app_id),
+        runtime_context_(runtime_context) {
+}
+
+void CookieManager::CookieDeleted(bool success) {
+  if (!success)
+    LOG(ERROR) << "Removal of cookie failed.";
+}
+
+void CookieManager::DeleteSessionOnlyOriginCookies(
+    const net::CookieList& cookies) {
+  net::URLRequestContext* request_context = runtime_context_->
+      GetURLRequestContextGetterById(
+          std::string(app_id_))->GetURLRequestContext();
+  if (!request_context)
+    return;
+  net::CookieMonster* cookie_monster =
+      request_context->cookie_store()->GetCookieMonster();
+  for (net::CookieList::const_iterator it = cookies.begin();
+       it != cookies.end(); ++it) {
+    cookie_monster->DeleteCanonicalCookieAsync(*it,
+        base::Bind(&CookieManager::CookieDeleted,
+                   base::Unretained(this)));
+  }
+}
+
+void CookieManager::DeleteCookiesOnIOThread(
+    const std::string& url,
+    const std::string& cookie_name) {
+  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  net::URLRequestContext* request_context = runtime_context_->
+      GetURLRequestContextGetterById(app_id_)->GetURLRequestContext();
+  net::CookieStore* cookie_store = request_context->cookie_store();
+  cookie_store->GetCookieMonster()->GetAllCookiesAsync(
+      base::Bind(&CookieManager::DeleteSessionOnlyOriginCookies,
+                 base::Unretained(this)));
+}
+
+void CookieManager::RemoveAllCookies() {
+  content::BrowserThread::PostTask(
+      content::BrowserThread::IO, FROM_HERE, base::Bind(
+          &CookieManager::DeleteCookiesOnIOThread,
+          base::Unretained(this), "", ""));
+}
+
+void CookieManager::SetUserAgentString(
+    content::RenderProcessHost* render_process_host,
+    const std::string& user_agent_string) {
+  render_process_host->Send(
+      new ViewMsg_UserAgentStringChanged(user_agent_string));
+}
+
+}  // namespace xwalk
diff --git a/src/xwalk/application/common/tizen/cookie_manager.h b/src/xwalk/application/common/tizen/cookie_manager.h
new file mode 100644 (file)
index 0000000..05d472f
--- /dev/null
@@ -0,0 +1,33 @@
+// 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_COMMON_TIZEN_COOKIE_MANAGER_H_
+#define XWALK_APPLICATION_COMMON_TIZEN_COOKIE_MANAGER_H_
+
+#include <string>
+
+#include "net/cookies/canonical_cookie.h"
+
+#include "xwalk/runtime/browser/runtime_context.h"
+
+namespace xwalk {
+
+class CookieManager {
+ public:
+  CookieManager(const std::string& app_id, RuntimeContext* runtime_context);
+  void RemoveAllCookies();
+  void SetUserAgentString(content::RenderProcessHost* render_process_host,
+                          const std::string& user_agent_string);
+ private:
+  void CookieDeleted(bool success);
+  void DeleteSessionOnlyOriginCookies(const net::CookieList& cookies);
+  void DeleteCookiesOnIOThread(const std::string& url,
+                               const std::string& cookie_name);
+
+  const std::string app_id_;
+  RuntimeContext* runtime_context_;
+};
+
+}  // namespace xwalk
+#endif  // XWALK_APPLICATION_COMMON_TIZEN_COOKIE_MANAGER_H_
index b9d1036..62c4092 100644 (file)
@@ -82,6 +82,8 @@
             'tizen/application_storage.h',
             'tizen/application_storage_impl.cc',
             'tizen/application_storage_impl.h',
+            'tizen/cookie_manager.cc',
+            'tizen/cookie_manager.h',
             'tizen/package_query.cc',
             'tizen/package_query.h',
             'tizen/signature_data.h',
index 4c4c050..b6f0b2c 100644 (file)
@@ -31,20 +31,7 @@ done
 
 if [ "`whoami`" == "root" ]
 then
-    #
-    # TODO(t.iwanek): fix me
-    # this is workaround that will work only for 'app' user
-    # pkgmgr-server is running as root and then backend too
-    # 1) backend need to know the user
-    #  or
-    # 2) pkgmgr must change user before launching backend
-    #
-
-    # Find requesting process...
-    #  (will fail for multiple installation at same time)
-    user=`ps aux | grep -v 'grep' | grep pkgcmd | cut -f1 -d" "`
-
-    su - ${user} -c "/usr/bin/xwalkctl ${option} ${id} ${key} ${keyvalue} ${quiet}"
+       exit 1
 else
     # correct UID was set by pkgmgr
     /usr/bin/xwalkctl ${option} ${id} ${key} ${keyvalue} ${quiet}
index 2b89db6..f02e61f 100644 (file)
@@ -11,6 +11,7 @@
 #include <errno.h>
 #include <pwd.h>
 #include <grp.h>
+#include <tzplatform_config.h>
 
 int xwalk_tizen_check_user_app(void) {
   char* buffer = NULL;
@@ -33,7 +34,41 @@ int xwalk_tizen_check_user_app(void) {
   } else {
     if ( (!current_g) || (
         strcmp(current_g->gr_name, "users") &&
-        strcmp(current_g->gr_name, "app"))) {
+        strcmp(current_g->gr_name, "app") )) {
+      fprintf(stderr, "group '%s' is not allowed :",
+          current_g ? current_g->gr_name : "<NULL>");
+      fprintf(stderr, "launching an application will not work\n");
+      free(buffer);
+      return -EINVAL;
+    }
+  }
+  return 0;
+}
+
+int xwalk_tizen_check_user_for_xwalkctl(void) {
+  char* buffer = NULL;
+  int err = 0;
+  struct group grp;
+  struct group* current_g;
+  int64_t len = sysconf(_SC_GETGR_R_SIZE_MAX);
+  if (len == -1)
+    len = 1024;
+  buffer = reinterpret_cast<char*>(malloc((size_t)len));
+  if (!buffer)
+    return -EINVAL;
+
+  err = getgrgid_r(getgid(), &grp, buffer, len, &current_g);
+  if (err) {
+  fprintf(stderr, "group can't be determined");
+    fprintf(stderr, "launching an application will not work\n");
+    free(buffer);
+    return -EINVAL;
+  } else {
+    if ( (!current_g) || (
+        strcmp(current_g->gr_name, "users") &&
+        strcmp(current_g->gr_name, "app") &&
+        (strcmp(current_g->gr_name, "root") &&
+         getuid() == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)))) {
       fprintf(stderr, "group '%s' is not allowed :",
             current_g ? current_g->gr_name : "<NULL>");
       fprintf(stderr, "launching an application will not work\n");
index 4802467..7da72e7 100644 (file)
@@ -12,5 +12,6 @@
 // This is a Tizen specific workaround.
 
 int xwalk_tizen_check_user_app(void);
+int xwalk_tizen_check_user_for_xwalkctl(void);
 
 #endif  // XWALK_APPLICATION_TOOLS_TIZEN_XWALK_TIZEN_USER_H_
index 37560a4..9fcd32f 100644 (file)
@@ -134,7 +134,7 @@ int main(int argc, char* argv[]) {
   g_type_init();
 #endif
 
-  if (xwalk_tizen_check_user_app())
+  if (xwalk_tizen_check_user_for_xwalkctl())
     exit(1);
 
   context = g_option_context_new("- Crosswalk Application Management");
index 4a4f3bc..f538dea 100644 (file)
@@ -56,6 +56,7 @@
           'type': 'none',
           'variables': {
             'packages': [
+              'libtzplatform-config',
               'ail',
               'dlog',
               'pkgmgr-parser',
index 6b19c90..faeca0b 100644 (file)
@@ -16,7 +16,7 @@
 %endif
 
 Name:           crosswalk
-Version:        10.38.208.0
+Version:        10.38.210.0
 Release:        0
 Summary:        Chromium-based app runtime
 License:        (BSD-3-Clause and LGPL-2.1+)
@@ -238,7 +238,7 @@ install -p -D src/out/Release/xwalk %{buildroot}%{_libdir}/xwalk/xwalk
 install -p -D src/out/Release/xwalkctl %{buildroot}%{_bindir}/xwalkctl
 install -p -D src/out/Release/xwalk-launcher %{buildroot}%{_bindir}/xwalk-launcher
 # xwalk-pkg-helper needs to be set-user-ID-root so it can finish the installation process.
-install -m 06755 -p -D src/out/Release/xwalk-pkg-helper %{buildroot}%{_bindir}/xwalk-pkg-helper
+install -m 0755 -p -D src/out/Release/xwalk-pkg-helper %{buildroot}%{_bindir}/xwalk-pkg-helper
 install -p -D src/out/Release/lib/libxwalk-backendlib.so %{buildroot}%{_libdir}/xwalk/libxwalk-backendlib.so
 install -p -D src/xwalk/application/tools/tizen/xwalk_backend_wrapper.sh %{buildroot}%{_libdir}/xwalk/xwalk_backend_wrapper.sh
 
index a25ec49..610ea0e 100644 (file)
@@ -66,7 +66,7 @@ class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyVa
     private XWalkGeolocationPermissions mGeolocationPermissions;
     private XWalkLaunchScreenManager mLaunchScreenManager;
 
-    long mXWalkContent;
+    long mNativeContent;
     long mWebContents;
 
     static void setJavascriptInterfaceClass(Class<? extends Annotation> clazz) {
@@ -75,18 +75,18 @@ class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyVa
     }
 
     private static final class DestroyRunnable implements Runnable {
-        private final long mXWalkContent;
+        private final long mNativeContent;
         private DestroyRunnable(long nativeXWalkContent) {
-            mXWalkContent = nativeXWalkContent;
+            mNativeContent = nativeXWalkContent;
         }
 
         @Override
         public void run() {
-            nativeDestroy(mXWalkContent);
+            nativeDestroy(mNativeContent);
         }
     }
 
-    // Reference to the active mXWalkContent pointer while it is active use
+    // Reference to the active mNativeContent pointer while it is active use
     // (ie before it is destroyed).
     private CleanupReference mCleanupReference;
 
@@ -103,48 +103,66 @@ class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyVa
         // Initialize mWindow which is needed by content
         mWindow = new ActivityWindowAndroid(xwView.getActivity());
 
+        SharedPreferences sharedPreferences = new InMemorySharedPreferences();
+        mGeolocationPermissions = new XWalkGeolocationPermissions(sharedPreferences);
+
+        MediaPlayerBridge.setResourceLoadingFilter(
+                new XWalkMediaPlayerResourceLoadingFilter());
+
+        XWalkPreferencesInternal.load(this);
+
+        setNativeContent(nativeInit());
+    }
+
+    private void setNativeContent(long newNativeContent) {
+        if (mNativeContent != 0) {
+            destroy();
+            mContentViewCore = null;
+        }
+
+        assert mNativeContent == 0 && mCleanupReference == null && mContentViewCore == null;
+
         // Initialize ContentViewRenderView
-        boolean animated = XWalkPreferencesInternal.getValue(XWalkPreferencesInternal.ANIMATABLE_XWALK_VIEW);
+        boolean animated = XWalkPreferencesInternal.getValue(
+                XWalkPreferencesInternal.ANIMATABLE_XWALK_VIEW);
         CompositingSurfaceType surfaceType =
                 animated ? CompositingSurfaceType.TEXTURE_VIEW : CompositingSurfaceType.SURFACE_VIEW;
-        mContentViewRenderView = new ContentViewRenderView(context, surfaceType) {
+        mContentViewRenderView = new ContentViewRenderView(getContext(), surfaceType) {
             protected void onReadyToRender() {
                 // Anything depending on the underlying Surface readiness should
                 // be placed here.
             }
         };
         mContentViewRenderView.onNativeLibraryLoaded(mWindow);
-        mLaunchScreenManager = new XWalkLaunchScreenManager(context, mXWalkView);
+        mLaunchScreenManager = new XWalkLaunchScreenManager(getContext(), mXWalkView);
         mContentViewRenderView.registerFirstRenderedFrameListener(mLaunchScreenManager);
-        addView(mContentViewRenderView,
-                new FrameLayout.LayoutParams(
-                        FrameLayout.LayoutParams.MATCH_PARENT,
-                        FrameLayout.LayoutParams.MATCH_PARENT));
+        addView(mContentViewRenderView, new FrameLayout.LayoutParams(
+                FrameLayout.LayoutParams.MATCH_PARENT,
+                FrameLayout.LayoutParams.MATCH_PARENT));
 
-        mXWalkContent = nativeInit(mXWalkContentsDelegateAdapter, mContentsClientBridge);
+        mNativeContent = newNativeContent;
 
         // The native side object has been bound to this java instance, so now is the time to
         // bind all the native->java relationships.
-        mCleanupReference = new CleanupReference(this, new DestroyRunnable(mXWalkContent));
+        mCleanupReference = new CleanupReference(this, new DestroyRunnable(mNativeContent));
+
+        mWebContents = nativeGetWebContents(mNativeContent);
 
-        mWebContents = nativeGetWebContents(mXWalkContent, mIoThreadClient,
-                mContentsClientBridge.getInterceptNavigationDelegate());
 
         // Initialize ContentView.
         mContentViewCore = new ContentViewCore(getContext());
         mContentView = ContentView.newInstance(getContext(), mContentViewCore);
         mContentViewCore.initialize(mContentView, mContentView, mWebContents, mWindow);
-        addView(mContentView,
-                new FrameLayout.LayoutParams(
-                        FrameLayout.LayoutParams.MATCH_PARENT,
-                        FrameLayout.LayoutParams.MATCH_PARENT));
+        addView(mContentView, new FrameLayout.LayoutParams(
+                FrameLayout.LayoutParams.MATCH_PARENT,
+                FrameLayout.LayoutParams.MATCH_PARENT));
         mContentViewCore.setContentViewClient(mContentsClientBridge);
         mContentViewRenderView.setCurrentContentViewCore(mContentViewCore);
         // For addJavascriptInterface
         mContentsClientBridge.installWebContentsObserver(mContentViewCore.getWebContents());
 
         // Set DIP scale.
-        mContentsClientBridge.setDIPScale(DeviceDisplayInfo.create(context).getDIPScale());
+        mContentsClientBridge.setDIPScale(DeviceDisplayInfo.create(getContext()).getDIPScale());
 
         mContentViewCore.setDownloadDelegate(mContentsClientBridge);
 
@@ -156,14 +174,32 @@ class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyVa
         // Enable AllowFileAccessFromFileURLs, so that files under file:// path could be
         // loaded by XMLHttpRequest.
         mSettings.setAllowFileAccessFromFileURLs(true);
+        // Enable this by default to suppport new window creation
+        mSettings.setSupportMultipleWindows(true);
 
-        SharedPreferences sharedPreferences = new InMemorySharedPreferences();
-        mGeolocationPermissions = new XWalkGeolocationPermissions(sharedPreferences);
+        nativeSetJavaPeers(mNativeContent, this, mXWalkContentsDelegateAdapter, mContentsClientBridge,
+                mIoThreadClient, mContentsClientBridge.getInterceptNavigationDelegate());
+    }
 
-        MediaPlayerBridge.setResourceLoadingFilter(
-                new XWalkMediaPlayerResourceLoadingFilter());
+    public void supplyContentsForPopup(XWalkContent newContents) {
+        long popupNativeXWalkContent = nativeReleasePopupXWalkContent(mNativeContent);
+        if (popupNativeXWalkContent == 0) {
+            Log.w(TAG, "Popup XWalkView bind failed: no pending content.");
+            if (newContents != null) newContents.destroy();
+            return;
+        }
+        if (newContents == null) {
+            nativeDestroy(popupNativeXWalkContent);
+            return;
+        }
 
-        XWalkPreferencesInternal.load(this);
+        newContents.receivePopupContents(popupNativeXWalkContent);
+    }
+
+    private void receivePopupContents(long popupNativeXWalkContents) {
+        setNativeContent(popupNativeXWalkContents);
+
+        mContentViewCore.onShow();
     }
 
     void doLoadUrl(String url, String content) {
@@ -286,8 +322,8 @@ class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyVa
     }
 
     public void clearCache(boolean includeDiskFiles) {
-        if (mXWalkContent == 0) return;
-        nativeClearCache(mXWalkContent, includeDiskFiles);
+        if (mNativeContent == 0) return;
+        nativeClearCache(mNativeContent, includeDiskFiles);
     }
 
     public void clearHistory() {
@@ -350,13 +386,13 @@ class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyVa
     }
 
     public String getXWalkVersion() {
-        if (mXWalkContent == 0) return "";
-        return nativeGetVersion(mXWalkContent);
+        if (mNativeContent == 0) return "";
+        return nativeGetVersion(mNativeContent);
     }
 
     public void setNetworkAvailable(boolean networkUp) {
-        if (mXWalkContent == 0) return;
-        nativeSetJsOnlineProperty(mXWalkContent, networkUp);
+        if (mNativeContent == 0) return;
+        nativeSetJsOnlineProperty(mNativeContent, networkUp);
     }
 
     // For instrumentation test.
@@ -370,8 +406,8 @@ class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyVa
     }
 
     public String devToolsAgentId() {
-        if (mXWalkContent == 0) return "";
-        return nativeDevToolsAgentId(mXWalkContent);
+        if (mNativeContent == 0) return "";
+        return nativeDevToolsAgentId(mNativeContent);
     }
 
     public XWalkSettings getSettings() {
@@ -379,7 +415,7 @@ class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyVa
     }
 
     public void loadAppFromManifest(String url, String data) {
-        if (mXWalkContent == 0 ||
+        if (mNativeContent == 0 ||
                 ((url == null || url.isEmpty()) &&
                         (data == null || data.isEmpty()))) {
             return;
@@ -406,7 +442,7 @@ class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyVa
             Log.w(TAG, "The url of manifest.json is probably not set correctly.");
         }
 
-        if (!nativeSetManifest(mXWalkContent, baseUrl, content)) {
+        if (!nativeSetManifest(mNativeContent, baseUrl, content)) {
             throw new RuntimeException("Failed to parse the manifest file: " + url);
         }
     }
@@ -420,7 +456,7 @@ class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyVa
     public XWalkNavigationHistoryInternal saveState(Bundle outState) {
         if (outState == null) return null;
 
-        byte[] state = nativeGetState(mXWalkContent);
+        byte[] state = nativeGetState(mNativeContent);
         if (state == null) return null;
 
         outState.putByteArray(SAVE_RESTORE_STATE_KEY, state);
@@ -433,7 +469,7 @@ class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyVa
         byte[] state = inState.getByteArray(SAVE_RESTORE_STATE_KEY);
         if (state == null) return null;
 
-        boolean result = nativeSetState(mXWalkContent, state);
+        boolean result = nativeSetState(mNativeContent, state);
 
         // The onUpdateTitle callback normally happens when a page is loaded,
         // but is optimized out in the restoreState case because the title is
@@ -490,7 +526,7 @@ class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyVa
     }
 
     public void destroy() {
-        if (mXWalkContent == 0) return;
+        if (mNativeContent == 0) return;
 
         XWalkPreferencesInternal.unload(this);
         // Reset existing notification service in order to destruct it.
@@ -506,11 +542,11 @@ class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyVa
 
         mCleanupReference.cleanupNow();
         mCleanupReference = null;
-        mXWalkContent = 0;
+        mNativeContent = 0;
     }
 
     public int getRoutingID() {
-        return nativeGetRoutingID(mXWalkContent);
+        return nativeGetRoutingID(mNativeContent);
     }
 
     //--------------------------------------------------------------------------------------------
@@ -591,7 +627,7 @@ class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyVa
                             mGeolocationPermissions.deny(origin);
                         }
                     }
-                    nativeInvokeGeolocationCallback(mXWalkContent, allow, origin);
+                    nativeInvokeGeolocationCallback(mNativeContent, allow, origin);
                 }
             });
         }
@@ -601,12 +637,12 @@ class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyVa
     private void onGeolocationPermissionsShowPrompt(String origin) {
         // Reject if geolocation is disabled, or the origin has a retained deny.
         if (!mSettings.getGeolocationEnabled()) {
-            nativeInvokeGeolocationCallback(mXWalkContent, false, origin);
+            nativeInvokeGeolocationCallback(mNativeContent, false, origin);
             return;
         }
         // Allow if the origin has a retained allow.
         if (mGeolocationPermissions.hasOrigin(origin)) {
-            nativeInvokeGeolocationCallback(mXWalkContent,
+            nativeInvokeGeolocationCallback(mNativeContent,
                     mGeolocationPermissions.isOriginAllowed(origin),
                     origin);
             return;
@@ -680,12 +716,17 @@ class XWalkContent extends FrameLayout implements XWalkPreferencesInternal.KeyVa
         }
     }
 
-    private native long nativeInit(XWalkWebContentsDelegate webViewContentsDelegate,
-            XWalkContentsClientBridge bridge);
+    private native long nativeInit();
     private static native void nativeDestroy(long nativeXWalkContent);
-    private native long nativeGetWebContents(long nativeXWalkContent,
+    private native long nativeGetWebContents(long nativeXWalkContent);
+    private native long nativeReleasePopupXWalkContent(long nativeXWalkContent);
+    private native void nativeSetJavaPeers(
+            long nativeXWalkContent,
+            XWalkContent xwalkContent,
+            XWalkWebContentsDelegateAdapter xwalkContentsDelegate,
+            XWalkContentsClientBridge contentsClientBridge,
             XWalkContentsIoThreadClient ioThreadClient,
-            InterceptNavigationDelegate delegate);
+            InterceptNavigationDelegate navigationInterceptionDelegate);
     private native void nativeClearCache(long nativeXWalkContent, boolean includeDiskFiles);
     private native String nativeDevToolsAgentId(long nativeXWalkContent);
     private native String nativeGetVersion(long nativeXWalkContent);
index 38c623f..b00d31f 100644 (file)
@@ -15,6 +15,7 @@ import android.net.Uri;
 import android.net.http.SslCertificate;
 import android.net.http.SslError;
 import android.os.Message;
+import android.os.Handler;
 import android.provider.MediaStore;
 import android.util.Log;
 import android.view.KeyEvent;
@@ -39,6 +40,7 @@ import org.xwalk.core.internal.XWalkUIClientInternal.LoadStatusInternal;
 class XWalkContentsClientBridge extends XWalkContentsClient
         implements ContentViewDownloadDelegate {
     private static final String TAG = XWalkContentsClientBridge.class.getName();
+    private static final int NEW_XWALKVIEW_CREATED = 100;
 
     private XWalkViewInternal mXWalkView;
     private XWalkUIClientInternal mXWalkUIClient;
@@ -51,6 +53,7 @@ class XWalkContentsClientBridge extends XWalkContentsClient
     private PageLoadListener mPageLoadListener;
     private XWalkNavigationHandler mNavigationHandler;
     private XWalkNotificationService mNotificationService;
+    private Handler mUiThreadHandler;
 
     /** State recording variables */
     // For fullscreen state.
@@ -90,6 +93,29 @@ class XWalkContentsClientBridge extends XWalkContentsClient
         mXWalkView = xwView;
 
         mInterceptNavigationDelegate = new InterceptNavigationDelegateImpl(this);
+
+        mUiThreadHandler = new Handler() {
+            @Override
+            public void handleMessage(Message msg) {
+                switch(msg.what) {
+                    case NEW_XWALKVIEW_CREATED:
+                        XWalkViewInternal newXWalkView = (XWalkViewInternal) msg.obj;
+                        if (newXWalkView == mXWalkView) {
+                            throw new IllegalArgumentException("Parent XWalkView cannot host it's own popup window");
+                        }
+
+                        if (newXWalkView != null && newXWalkView.getNavigationHistory().size() != 0) {
+                            throw new IllegalArgumentException("New WebView for popup window must not have been previously navigated.");
+                        }
+
+                        mXWalkView.completeWindowCreation(newXWalkView);
+                        break;
+                    default:
+                        throw new IllegalStateException();
+                }
+            }
+        };
+
     }
 
     public void setUIClient(XWalkUIClientInternal client) {
@@ -346,7 +372,23 @@ class XWalkContentsClientBridge extends XWalkContentsClient
 
     @Override
     public boolean onCreateWindow(boolean isDialog, boolean isUserGesture) {
-        return false;
+        if (isDialog) return false;
+        
+        XWalkUIClientInternal.InitiateByInternal initiator =
+                XWalkUIClientInternal.InitiateByInternal.BY_JAVASCRIPT;
+        if (isUserGesture) {
+            initiator = XWalkUIClientInternal.InitiateByInternal.BY_USER_GESTURE;
+        }
+
+        ValueCallback<XWalkViewInternal> callback = new ValueCallback<XWalkViewInternal>() {
+            @Override
+            public void onReceiveValue(XWalkViewInternal newXWalkView) {
+                Message m = mUiThreadHandler.obtainMessage(NEW_XWALKVIEW_CREATED, newXWalkView);
+                m.sendToTarget();
+            }
+        };
+
+        return mXWalkUIClient.onCreateWindowRequested(mXWalkView, initiator, callback);
     }
 
     @Override
index f4ce916..72ee258 100644 (file)
@@ -40,6 +40,16 @@ public class XWalkUIClientInternal {
     private boolean mOriginalForceNotFullscreen;
 
     /**
+     * Initiator
+     * @since 4.0
+     */
+    @XWalkAPI
+    public enum InitiateByInternal {
+        BY_USER_GESTURE,
+        BY_JAVASCRIPT
+    }
+
+    /**
      * Constructor.
      * @param view the owner XWalkViewInternal instance.
      * @since 1.0
@@ -67,6 +77,20 @@ public class XWalkUIClientInternal {
     }
 
     /**
+     * Request the host application to create a new window
+     * @param view The XWalkView from which the request for a new window originated
+     * @param initiator The request was initiated by a user gesture of javascript
+     * @param callback Callback when once a new XWalkView has been created
+     * @return Return true if the host application will create a new window
+     * @since 4.0
+     */
+    @XWalkAPI
+    public boolean onCreateWindowRequested(XWalkViewInternal view, InitiateByInternal initiator,
+            ValueCallback<XWalkViewInternal> callback) {
+        return false;
+    }
+
+    /**
      * Request display and focus for this XWalkViewInternal.
      * @param view the owner XWalkViewInternal instance.
      * @since 1.0
index bd0def2..9f9bb02 100644 (file)
@@ -250,6 +250,10 @@ public class XWalkViewInternal extends android.widget.FrameLayout {
         return mContext;
     }
 
+    public void completeWindowCreation(XWalkViewInternal newXWalkView) {
+        mContent.supplyContentsForPopup(newXWalkView == null ? null : newXWalkView.mContent);
+    }
+
     private void init(Context context, AttributeSet attrs) {
         // Initialize chromium resources. Assign them the correct ids in
         // xwalk core.
index fe5e303..4a60081 100644 (file)
@@ -32,8 +32,7 @@ class XWalkWebContentsDelegateAdapter extends XWalkWebContentsDelegate {
 
     @Override
     public boolean addNewContents(boolean isDialog, boolean isUserGesture) {
-        // TODO: implement.
-        return false;
+        return mXWalkContentsClient.onCreateWindow(isDialog, isUserGesture);
     }
 
     @Override
index fa3089c..4450014 100644 (file)
@@ -106,20 +106,6 @@ bool ManifestGetString(const xwalk::application::Manifest& manifest,
 
 }  // namespace
 
-XWalkContent::XWalkContent(JNIEnv* env,
-                           jobject obj,
-                           jobject web_contents_delegate,
-                           jobject contents_client_bridge)
-    : java_ref_(env, obj),
-      web_contents_delegate_(
-          new XWalkWebContentsDelegate(env, web_contents_delegate)),
-      contents_client_bridge_(
-          new XWalkContentsClientBridge(env, contents_client_bridge)) {
-}
-
-XWalkContent::~XWalkContent() {
-}
-
 // static
 XWalkContent* XWalkContent::FromID(int render_process_id,
                                    int render_view_id) {
@@ -139,54 +125,77 @@ XWalkContent* XWalkContent::FromWebContents(
   return XWalkContentUserData::GetContents(web_contents);
 }
 
-jlong XWalkContent::GetWebContents(
-    JNIEnv* env, jobject obj, jobject io_thread_client,
-    jobject intercept_navigation_delegate) {
-  if (!web_contents_) {
-    web_contents_.reset(CreateWebContents(env, io_thread_client,
-                                          intercept_navigation_delegate));
-
-    render_view_host_ext_.reset(
-        new XWalkRenderViewHostExt(web_contents_.get()));
-  }
-  return reinterpret_cast<intptr_t>(web_contents_.get());
+XWalkContent::XWalkContent(scoped_ptr<content::WebContents> web_contents)
+    : web_contents_(web_contents.Pass()) {
 }
 
-content::WebContents* XWalkContent::CreateWebContents(
-    JNIEnv* env, jobject io_thread_client,
-    jobject intercept_navigation_delegate) {
+XWalkContent::~XWalkContent() {
+}
 
-  RuntimeContext* runtime_context =
-      XWalkRunner::GetInstance()->runtime_context();
-  CHECK(runtime_context);
+void XWalkContent::SetJavaPeers(JNIEnv* env,
+                                jobject obj,
+                                jobject xwalk_content,
+                                jobject web_contents_delegate,
+                                jobject contents_client_bridge,
+                                jobject io_thread_client,
+                                jobject intercept_navigation_delegate) {
+  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  java_ref_ = JavaObjectWeakGlobalRef(env, xwalk_content);
 
-  content::WebContents* web_contents = content::WebContents::Create(
-      content::WebContents::CreateParams(runtime_context));
+  web_contents_delegate_.reset(
+      new XWalkWebContentsDelegate(env, web_contents_delegate));
+  contents_client_bridge_.reset(
+      new XWalkContentsClientBridge(env, contents_client_bridge));
 
-  web_contents->SetUserData(kXWalkContentUserDataKey,
-                            new XWalkContentUserData(this));
+  web_contents_->SetUserData(
+      kXWalkContentUserDataKey, new XWalkContentUserData(this));
 
-  XWalkContentsIoThreadClientImpl::RegisterPendingContents(web_contents);
+  XWalkContentsIoThreadClientImpl::RegisterPendingContents(web_contents_.get());
 
   // XWalk does not use disambiguation popup for multiple targets.
   content::RendererPreferences* prefs =
-      web_contents->GetMutableRendererPrefs();
+      web_contents_->GetMutableRendererPrefs();
   prefs->tap_multiple_targets_strategy =
       content::TAP_MULTIPLE_TARGETS_STRATEGY_NONE;
 
-  XWalkContentsClientBridgeBase::Associate(web_contents,
+  XWalkContentsClientBridgeBase::Associate(web_contents_.get(),
       contents_client_bridge_.get());
-  XWalkContentsIoThreadClientImpl::Associate(web_contents,
+  XWalkContentsIoThreadClientImpl::Associate(web_contents_.get(),
       ScopedJavaLocalRef<jobject>(env, io_thread_client));
-  int render_process_id = web_contents->GetRenderProcessHost()->GetID();
-  int render_frame_id = web_contents->GetRoutingID();
+  int render_process_id = web_contents_->GetRenderProcessHost()->GetID();
+  int render_frame_id = web_contents_->GetRoutingID();
   RuntimeResourceDispatcherHostDelegateAndroid::OnIoThreadClientReady(
       render_process_id, render_frame_id);
-  InterceptNavigationDelegate::Associate(web_contents,
+  InterceptNavigationDelegate::Associate(web_contents_.get(),
       make_scoped_ptr(new InterceptNavigationDelegate(
           env, intercept_navigation_delegate)));
-  web_contents->SetDelegate(web_contents_delegate_.get());
-  return web_contents;
+  web_contents_->SetDelegate(web_contents_delegate_.get());
+
+  render_view_host_ext_.reset(new XWalkRenderViewHostExt(web_contents_.get()));
+}
+
+jlong XWalkContent::GetWebContents(JNIEnv* env, jobject obj) {
+  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK(web_contents_);
+  return reinterpret_cast<intptr_t>(web_contents_.get());
+}
+
+void XWalkContent::SetPendingWebContentsForPopup(
+    scoped_ptr<content::WebContents> pending) {
+  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  if (pending_contents_.get()) {
+    // TODO(benm): Support holding multiple pop up window requests.
+    LOG(WARNING) << "Blocking popup window creation as an outstanding "
+                 << "popup window is still pending.";
+    base::MessageLoop::current()->DeleteSoon(FROM_HERE, pending.release());
+    return;
+  }
+  pending_contents_.reset(new XWalkContent(pending.Pass()));
+}
+
+jlong XWalkContent::ReleasePopupXWalkContent(JNIEnv* env, jobject obj) {
+  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  return reinterpret_cast<intptr_t>(pending_contents_.release());
 }
 
 void XWalkContent::ClearCache(
@@ -396,11 +405,11 @@ jboolean XWalkContent::SetState(JNIEnv* env, jobject obj, jbyteArray state) {
   return RestoreFromPickle(&iterator, web_contents_.get());
 }
 
-static jlong Init(JNIEnv* env, jobject obj, jobject web_contents_delegate,
-    jobject contents_client_bridge) {
-  XWalkContent* xwalk_core_content =
-    new XWalkContent(env, obj, web_contents_delegate, contents_client_bridge);
-  return reinterpret_cast<intptr_t>(xwalk_core_content);
+static jlong Init(JNIEnv* env, jobject obj) {
+  scoped_ptr<WebContents> web_contents(content::WebContents::Create(
+      content::WebContents::CreateParams(
+          XWalkRunner::GetInstance()->runtime_context())));
+  return reinterpret_cast<intptr_t>(new XWalkContent(web_contents.Pass()));
 }
 
 bool RegisterXWalkContent(JNIEnv* env) {
@@ -491,4 +500,5 @@ void XWalkContent::HideGeolocationPrompt(const GURL& origin) {
     }
   }
 }
+
 }  // namespace xwalk
index 2fff15b..0a738d4 100644 (file)
@@ -28,15 +28,22 @@ class XWalkContentsClientBridge;
 
 class XWalkContent {
  public:
-  XWalkContent(JNIEnv* env, jobject obj, jobject web_contents_delegate,
-      jobject contents_client_bridge);
+  explicit XWalkContent(scoped_ptr<content::WebContents> web_contents);
   ~XWalkContent();
 
   static XWalkContent* FromID(int render_process_id, int render_view_id);
   static XWalkContent* FromWebContents(content::WebContents* web_contents);
 
-  jlong GetWebContents(JNIEnv* env, jobject obj, jobject io_thread_client,
-                      jobject delegate);
+  jlong GetWebContents(JNIEnv* env, jobject obj);
+  void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending);
+  jlong ReleasePopupXWalkContent(JNIEnv* env, jobject obj);
+  void SetJavaPeers(JNIEnv* env,
+                    jobject obj,
+                    jobject xwalk_content,
+                    jobject web_contents_delegate,
+                    jobject contents_client_bridge,
+                    jobject io_thread_client,
+                    jobject intercept_navigation_delegate);
   void ClearCache(JNIEnv* env, jobject obj, jboolean include_disk_files);
   ScopedJavaLocalRef<jstring> DevToolsAgentId(JNIEnv* env, jobject obj);
   void Destroy(JNIEnv* env, jobject obj);
@@ -70,9 +77,6 @@ class XWalkContent {
                                  jstring origin);
 
  private:
-  content::WebContents* CreateWebContents(JNIEnv* env, jobject io_thread_client,
-                                          jobject delegate);
-
   JavaObjectWeakGlobalRef java_ref_;
   // TODO(guangzhen): The WebContentsDelegate need to take ownership of
   // WebContents as chrome content design. For xwalk, XWalkContent owns
@@ -83,6 +87,7 @@ class XWalkContent {
   scoped_ptr<XWalkRenderViewHostExt> render_view_host_ext_;
   scoped_ptr<XWalkContentsClientBridge> contents_client_bridge_;
   scoped_ptr<content::WebContents> web_contents_;
+  scoped_ptr<XWalkContent> pending_contents_;
 
   // GURL is supplied by the content layer as requesting frame.
   // Callback is supplied by the content layer, and is invoked with the result
index d084554..10e63c3 100644 (file)
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "xwalk/runtime/browser/android/xwalk_content.h"
 #include "xwalk/runtime/browser/android/xwalk_web_contents_delegate.h"
 
 #include <string>
@@ -46,13 +47,27 @@ void XWalkWebContentsDelegate::AddNewContents(
     bool user_gesture,
     bool* was_blocked) {
   JNIEnv* env = AttachCurrentThread();
+
   bool is_dialog = disposition == NEW_POPUP;
   ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env);
+  bool create_popup = false;
 
   if (java_delegate.obj()) {
-    Java_XWalkWebContentsDelegate_addNewContents(env,
+    create_popup = Java_XWalkWebContentsDelegate_addNewContents(env,
         java_delegate.obj(), is_dialog, user_gesture);
   }
+
+  if (create_popup) {
+    XWalkContent::FromWebContents(source)->SetPendingWebContentsForPopup(
+        make_scoped_ptr(new_contents));
+    new_contents->WasHidden();
+  } else {
+    base::MessageLoop::current()->DeleteSoon(FROM_HERE, new_contents);
+  }
+
+  if (was_blocked) {
+    *was_blocked = !create_popup;
+  }
 }
 
 void XWalkWebContentsDelegate::CloseContents(content::WebContents* source) {
index 6d17fc4..85b98b3 100644 (file)
@@ -1,4 +1,5 @@
 // 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.
 
@@ -197,6 +198,16 @@ content::SSLHostStateDelegate* RuntimeContext::GetSSLHostStateDelegate() {
   return NULL;
 }
 
+RuntimeURLRequestContextGetter* RuntimeContext::GetURLRequestContextGetterById(
+    const std::string& pkg_id) {
+  for (PartitionPathContextGetterMap::iterator it = context_getters_.begin();
+       it != context_getters_.end(); ++it) {
+    if (it->first.find(pkg_id))
+      return it->second.get();
+  }
+  return 0;
+}
+
 net::URLRequestContextGetter* RuntimeContext::CreateRequestContext(
     content::ProtocolHandlerMap* protocol_handlers,
     content::URLRequestInterceptorScopedVector request_interceptors) {
index 63d7934..87eda95 100644 (file)
@@ -1,4 +1,5 @@
 // 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.
 
@@ -72,6 +73,9 @@ class RuntimeContext
   virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
   virtual content::PushMessagingService* GetPushMessagingService() OVERRIDE;
   virtual content::SSLHostStateDelegate* GetSSLHostStateDelegate() OVERRIDE;
+
+  RuntimeURLRequestContextGetter* GetURLRequestContextGetterById(
+      const std::string& pkg_id);
   net::URLRequestContextGetter* CreateRequestContext(
       content::ProtocolHandlerMap* protocol_handlers,
       content::URLRequestInterceptorScopedVector request_interceptors);
index ca440b1..ba45c02 100644 (file)
@@ -1,8 +1,11 @@
 // Copyright (c) 2012 The Chromium Authors. 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.
 
 // Multiply-included file, no traditional include guard.
+#include <string>
+
 #include "content/public/common/common_param_traits.h"
 #include "ipc/ipc_channel_handle.h"
 #include "ipc/ipc_message_macros.h"
@@ -42,6 +45,11 @@ IPC_MESSAGE_CONTROL2(ViewMsg_EnableSecurityMode,    // NOLINT
 IPC_MESSAGE_CONTROL1(ViewMsg_SuspendJSEngine,  // NOLINT
                      bool /* is suspend */)
 
+#if defined(OS_TIZEN)
+IPC_MESSAGE_CONTROL1(ViewMsg_UserAgentStringChanged,  // NOLINT
+                     std::string /*new user agent string*/)
+#endif
+
 IPC_MESSAGE_ROUTED1(ViewMsg_HWKeyPressed, int /*keycode*/)  // NOLINT
 
 // These are messages sent from the renderer to the browser process.
old mode 100644 (file)
new mode 100755 (executable)
index 9fe1ee0..e0f306a
@@ -1,4 +1,5 @@
 // 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/common/constants.h"
 #include "xwalk/runtime/common/xwalk_switches.h"
 #include "xwalk/runtime/common/xwalk_paths.h"
+#if (defined(OS_TIZEN))
+#include "xwalk/runtime/renderer/xwalk_content_renderer_client.h"
+#include "xwalk/runtime/renderer/tizen/xwalk_content_renderer_client_tizen.h"
+#endif
 
 const char* const xwalk::XWalkContentClient::kNaClPluginName = "Native Client";
 
@@ -111,6 +116,25 @@ std::string XWalkContentClient::GetProduct() const {
 }
 
 std::string XWalkContentClient::GetUserAgent() const {
+#if (defined(OS_TIZEN))
+  // TODO(jizydorczyk):
+  // const_cast below is required to invoke ContentClient::renderer() method,
+  // I think there is no reason for ContentClient::renderer() in content API
+  // to be non-const as it doesn't change any data, so it should be changed in
+  // chromium code later.
+  XWalkContentClient* content_client = const_cast<XWalkContentClient*>(this);
+  content::ContentRendererClient* content_renderer_client =
+      content_client->renderer();
+  if (content_renderer_client) {
+    XWalkContentRendererClientTizen* content_renderer_client_tizen =
+        static_cast<XWalkContentRendererClientTizen*>(
+            content_renderer_client);
+    const std::string& user_agent_string = content_renderer_client_tizen->
+        GetOverridenUserAgent();
+    if (!user_agent_string.empty())
+      return user_agent_string;
+  }
+#endif
   return xwalk::GetUserAgent();
 }
 
index f45788e..83a0be2 100644 (file)
@@ -1,4 +1,5 @@
 // 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.
 
@@ -111,4 +112,10 @@ void XWalkContentRendererClientTizen::GetNavigationErrorStrings(
   }
 }
 
+std::string XWalkContentRendererClientTizen::GetOverridenUserAgent() const {
+  if (!xwalk_render_process_observer_)
+    return "";
+  return xwalk_render_process_observer_->GetOverridenUserAgent();
+}
+
 }  // namespace xwalk
index 22cf7d5..c7e7365 100644 (file)
@@ -1,4 +1,5 @@
 // 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.
 
@@ -31,6 +32,7 @@ class XWalkContentRendererClientTizen : public XWalkContentRendererClient {
       const blink::WebURLError& error,
       std::string* error_html,
       base::string16* error_description) OVERRIDE;
+  std::string GetOverridenUserAgent() const;
 
  private:
   DISALLOW_COPY_AND_ASSIGN(XWalkContentRendererClientTizen);
index 6b62a6d..1f7097b 100644 (file)
@@ -1,4 +1,5 @@
 // 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.
 
@@ -61,6 +62,9 @@ class XWalkContentRendererClient
                                const GURL& first_party_for_cookies,
                                GURL* new_url) OVERRIDE;
 
+ protected:
+  scoped_ptr<XWalkRenderProcessObserver> xwalk_render_process_observer_;
+
  private:
   // XWalkExtensionRendererController::Delegate implementation.
   virtual void DidCreateModuleSystem(
@@ -69,7 +73,6 @@ class XWalkContentRendererClient
   scoped_ptr<extensions::XWalkExtensionRendererController>
       extension_controller_;
 
-  scoped_ptr<XWalkRenderProcessObserver> xwalk_render_process_observer_;
 #if defined(OS_ANDROID)
   scoped_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
 #endif
index 3579956..7723358 100644 (file)
@@ -1,4 +1,5 @@
 // Copyright (c) 2012 The Chromium Authors. 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.
 
@@ -12,6 +13,7 @@
 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
 #include "third_party/WebKit/public/platform/WebString.h"
 #include "xwalk/runtime/common/xwalk_common_messages.h"
+#include "xwalk/runtime/common/xwalk_content_client.h"
 
 
 namespace xwalk {
@@ -59,6 +61,9 @@ bool XWalkRenderProcessObserver::OnControlMessageReceived(
     IPC_MESSAGE_HANDLER(ViewMsg_SetAccessWhiteList, OnSetAccessWhiteList)
     IPC_MESSAGE_HANDLER(ViewMsg_EnableSecurityMode, OnEnableSecurityMode)
     IPC_MESSAGE_HANDLER(ViewMsg_SuspendJSEngine, OnSuspendJSEngine)
+#if defined(OS_TIZEN)
+    IPC_MESSAGE_HANDLER(ViewMsg_UserAgentStringChanged, OnUserAgentChanged)
+#endif
     IPC_MESSAGE_UNHANDLED(handled = false)
   IPC_END_MESSAGE_MAP()
   return handled;
@@ -105,4 +110,15 @@ void XWalkRenderProcessObserver::OnSuspendJSEngine(bool is_suspend) {
   is_suspended_ = is_suspend;
 }
 
+#if defined(OS_TIZEN)
+void XWalkRenderProcessObserver::OnUserAgentChanged(
+    const std::string& userAgentString) {
+  overriden_user_agent_ = userAgentString;
+}
+
+std::string XWalkRenderProcessObserver::GetOverridenUserAgent() const {
+  return overriden_user_agent_;
+}
+#endif
+
 }  // namespace xwalk
index 661c3dd..4a28977 100644 (file)
@@ -1,4 +1,5 @@
 // Copyright (c) 2012 The Chromium Authors. 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.
 
@@ -41,6 +42,9 @@ class XWalkRenderProcessObserver : public content::RenderProcessObserver {
   }
 
   const GURL& app_url() const { return app_url_; }
+#if defined(OS_TIZEN)
+  std::string GetOverridenUserAgent() const;
+#endif
 
  private:
   void OnSetAccessWhiteList(
@@ -48,6 +52,10 @@ class XWalkRenderProcessObserver : public content::RenderProcessObserver {
   void OnEnableSecurityMode(
       const GURL& url, application::SecurityPolicy::SecurityMode mode);
   void OnSuspendJSEngine(bool is_pause);
+#if defined(OS_TIZEN)
+  void OnUserAgentChanged(const std::string& userAgentString);
+  std::string overriden_user_agent_;
+#endif
 
   bool is_webkit_initialized_;
   bool is_suspended_;
index a702ec6..9e19dee 100644 (file)
@@ -376,6 +376,9 @@ class InternalJavaFileData(object):
   def UseAsInstanceInBridgeOverrideCall(self, var):
     clazz = self._class_annotations.get('instance', self._class_name)
     clazz = clazz.replace('.class', '')
+    if self.LoadJavaClass(clazz).class_annotations.get(
+        'createInternally', False):
+      return self.UseAsReturnInBridgeSuperCall(var)
     return '(%s) %s' % (self.LoadJavaClass(clazz).bridge_name, var)
 
   def UseAsReturnInBridgeSuperCall(self, var):
@@ -437,3 +440,10 @@ class InternalJavaFileData(object):
       else:
         return "org.xwalk.core.%s$%s" % (self._wrapper_name,
                                          subclass.replace('Internal', ''))
+
+  def GetInstanceJavaData(self):
+    clazz = self._class_annotations.get('instance', None)
+    if clazz:
+      clazz = clazz.replace('.class', '')
+      return self.LoadJavaClass(clazz)
+    return None
index 4824eff..2540bc4 100644 (file)
@@ -28,6 +28,14 @@ def ConvertPrimitiveTypeToObject(class_name):
   return primitive_map.get(class_name, class_name)
 
 
+def HasCreateInternally(java_data):
+  java_data_instance = java_data.GetInstanceJavaData()
+  if java_data_instance:
+    return java_data_instance.HasCreateInternallyAnnotation()
+  else:
+    return java_data.HasCreateInternallyAnnotation()
+
+
 class ParamStringType(object):
   INTERNAL_DECLARE = 1
   BRIDGE_DECLARE = 2
@@ -296,7 +304,7 @@ class Method(object):
       # the way bridge uses as the condition for whether call super or
       # call wrapper in override call
       #   XWalkViewInternal view => (view instanceof XWalkViewBridge)
-      if is_internal_class:
+      if is_internal_class and not HasCreateInternally(java_data):
         return'(%s instanceof %s)' % (
             param_name,
             java_data.UseAsTypeInBridgeAndBridgeSuperCall())
@@ -418,11 +426,48 @@ class Method(object):
     if return_is_internal:
       return_type_java_data = self.LoadJavaClass(self._method_return)
 
-    template = Template(
-        '    public ${RETURN_TYPE} ${NAME}(${PARAMS}) {\n' +
-        '        ${RETURN}ReflectionHelper.invokeMethod(\n' +
-        '            ${METHOD_DECLARE_NAME}, wrapper${PARAMS_PASSING});\n' +
-        '    }\n\n')
+    match_obj = re.search(
+        r'ValueCallback<([A-Za-z]+)Internal> ([a-zA-Z0-9_$]+)(,|$)', 
+        self._bridge_params_declare)
+    if match_obj :
+      callback_type = match_obj.group(1)
+      callback = match_obj.group(2)
+
+      template = Template(
+          '    public ${RETURN_TYPE} ${NAME}(${PARAMS}) {\n' +
+          '        final ValueCallback<' + callback_type + 'Internal> ' + 
+          callback + '2 = ' +  callback + ';\n' +
+          '        ${RETURN}ReflectionHelper.invokeMethod(\n' +
+          '            ${METHOD_DECLARE_NAME}, wrapper${PARAMS_PASSING});\n' +
+          '    }\n\n')
+
+      params_passing = re.sub(
+          str(callback),
+          '\n            new ValueCallback<Object>() {\n' +
+          '                @Override\n' +
+          '                public void onReceiveValue(Object value) {\n' +
+          '                    ' + callback + '2.onReceiveValue((' + 
+          callback_type + 
+          'Bridge) ReflectionHelper.getBridgeOrWrapper(value));\n' +
+          '                }\n' +
+          '            }',
+          self._bridge_params_pass_to_wrapper)
+    elif return_is_internal:
+      template = Template(
+          '    public ${RETURN_TYPE} ${NAME}(${PARAMS}) {\n' +
+          '        ${RETURN}ReflectionHelper.getBridgeOrWrapper(' + 
+          'ReflectionHelper.invokeMethod(\n' +
+          '            ${METHOD_DECLARE_NAME}, wrapper${PARAMS_PASSING}));\n' +
+          '    }\n\n')
+      params_passing = self._bridge_params_pass_to_wrapper
+    else :
+      template = Template(
+          '    public ${RETURN_TYPE} ${NAME}(${PARAMS}) {\n' +
+          '        ${RETURN}ReflectionHelper.invokeMethod(\n' +
+          '            ${METHOD_DECLARE_NAME}, wrapper${PARAMS_PASSING});\n' +
+          '    }\n\n')
+      params_passing = self._bridge_params_pass_to_wrapper
+
     if no_return_value:
       return_statement = ''
     elif return_is_internal:
@@ -435,7 +480,7 @@ class Method(object):
              'METHOD_DECLARE_NAME': self._method_declare_name,
              'PARAMS': self._bridge_params_declare,
              'RETURN': return_statement,
-             'PARAMS_PASSING': self._bridge_params_pass_to_wrapper}
+             'PARAMS_PASSING': params_passing}
     return template.substitute(value)
 
   def GenerateBridgeSuperMethod(self):
@@ -599,9 +644,11 @@ class Method(object):
              'RETURN': return_state,
              'DOC': self.GenerateDoc(self.method_doc),
              'NAME': self.method_name,
-             'PARAMS': self._wrapper_params_declare,
+             'PARAMS': re.sub(r'ValueCallback<([A-Za-z]+)Internal>', 
+                  r'ValueCallback<\1>',self._wrapper_params_declare),
              'METHOD_DECLARE_NAME': self._method_declare_name,
              'PARAMS_PASSING': self._wrapper_params_pass_to_bridge}
+
     return template.substitute(value)
 
   def GenerateWrapperInterface(self):