%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+)
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
MAJOR=10
MINOR=38
-BUILD=208
+BUILD=210
PATCH=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.
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_;
void NotifyTermination();
- RuntimeContext* runtime_context_;
Observer* observer_;
std::map<std::string, std::string> name_perm_map_;
#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"
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();
// 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 "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"
#if defined(USE_OZONE)
ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
#endif
+ cookie_manager_ = scoped_ptr<CookieManager>(
+ new CookieManager(id(), runtime_context_));
}
ApplicationTizen::~ApplicationTizen() {
}
#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
// 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"
void Suspend();
void Resume();
+ void RemoveAllCookies();
+ void SetUserAgentString(const std::string& user_agent_string);
+
private:
friend class Application;
ApplicationTizen(scoped_refptr<ApplicationData> data,
virtual void DidProcessEvent(const ui::PlatformEvent& event) OVERRIDE;
#endif
+ scoped_ptr<CookieManager> cookie_manager_;
bool is_suspended_;
};
// 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.
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,
}
}
+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) {
// 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.
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);
}
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();
--- /dev/null
+// 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
--- /dev/null
+// 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_
'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',
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}
#include <errno.h>
#include <pwd.h>
#include <grp.h>
+#include <tzplatform_config.h>
int xwalk_tizen_check_user_app(void) {
char* buffer = NULL;
} 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, ¤t_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");
// 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_
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");
'type': 'none',
'variables': {
'packages': [
+ 'libtzplatform-config',
'ail',
'dlog',
'pkgmgr-parser',
%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+)
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
private XWalkGeolocationPermissions mGeolocationPermissions;
private XWalkLaunchScreenManager mLaunchScreenManager;
- long mXWalkContent;
+ long mNativeContent;
long mWebContents;
static void setJavascriptInterfaceClass(Class<? extends Annotation> clazz) {
}
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;
// 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);
// 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) {
}
public void clearCache(boolean includeDiskFiles) {
- if (mXWalkContent == 0) return;
- nativeClearCache(mXWalkContent, includeDiskFiles);
+ if (mNativeContent == 0) return;
+ nativeClearCache(mNativeContent, includeDiskFiles);
}
public void clearHistory() {
}
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.
}
public String devToolsAgentId() {
- if (mXWalkContent == 0) return "";
- return nativeDevToolsAgentId(mXWalkContent);
+ if (mNativeContent == 0) return "";
+ return nativeDevToolsAgentId(mNativeContent);
}
public XWalkSettings getSettings() {
}
public void loadAppFromManifest(String url, String data) {
- if (mXWalkContent == 0 ||
+ if (mNativeContent == 0 ||
((url == null || url.isEmpty()) &&
(data == null || data.isEmpty()))) {
return;
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);
}
}
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);
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
}
public void destroy() {
- if (mXWalkContent == 0) return;
+ if (mNativeContent == 0) return;
XWalkPreferencesInternal.unload(this);
// Reset existing notification service in order to destruct it.
mCleanupReference.cleanupNow();
mCleanupReference = null;
- mXWalkContent = 0;
+ mNativeContent = 0;
}
public int getRoutingID() {
- return nativeGetRoutingID(mXWalkContent);
+ return nativeGetRoutingID(mNativeContent);
}
//--------------------------------------------------------------------------------------------
mGeolocationPermissions.deny(origin);
}
}
- nativeInvokeGeolocationCallback(mXWalkContent, allow, origin);
+ nativeInvokeGeolocationCallback(mNativeContent, allow, origin);
}
});
}
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;
}
}
- 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);
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;
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;
private PageLoadListener mPageLoadListener;
private XWalkNavigationHandler mNavigationHandler;
private XWalkNotificationService mNotificationService;
+ private Handler mUiThreadHandler;
/** State recording variables */
// For fullscreen state.
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) {
@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
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
}
/**
+ * 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
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.
@Override
public boolean addNewContents(boolean isDialog, boolean isUserGesture) {
- // TODO: implement.
- return false;
+ return mXWalkContentsClient.onCreateWindow(isDialog, isUserGesture);
}
@Override
} // 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) {
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(
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) {
}
}
}
+
} // namespace xwalk
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);
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
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
// 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>
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) {
// 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.
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) {
// 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.
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);
// 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"
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.
// 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";
}
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();
}
// 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.
}
}
+std::string XWalkContentRendererClientTizen::GetOverridenUserAgent() const {
+ if (!xwalk_render_process_observer_)
+ return "";
+ return xwalk_render_process_observer_->GetOverridenUserAgent();
+}
+
} // namespace xwalk
// 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.
const blink::WebURLError& error,
std::string* error_html,
base::string16* error_description) OVERRIDE;
+ std::string GetOverridenUserAgent() const;
private:
DISALLOW_COPY_AND_ASSIGN(XWalkContentRendererClientTizen);
// 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.
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(
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
// 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.
#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 {
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;
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
// 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.
}
const GURL& app_url() const { return app_url_; }
+#if defined(OS_TIZEN)
+ std::string GetOverridenUserAgent() const;
+#endif
private:
void OnSetAccessWhiteList(
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_;
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):
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
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
# 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())
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:
'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):
'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):