Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Make all the readonly attributes in Device Capabilities valid.
Browse files Browse the repository at this point in the history
Bug = XWALK-2162
  • Loading branch information
scuxiayiqian committed Aug 20, 2014
2 parents 009d1de + e42d0aa commit c8a9a68
Show file tree
Hide file tree
Showing 18 changed files with 360 additions and 136 deletions.
8 changes: 4 additions & 4 deletions DEPS.xwalk
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
# Edit these when rolling DEPS.xwalk.
# -----------------------------------

chromium_crosswalk_rev = 'b93afe0192aa9888d1246e8933d31272afecb7f0'
blink_crosswalk_rev = 'b656b39cc2eb71a9f4b70f8439c2d0a1ca54d619'
v8_crosswalk_rev = '402ca0b81254dd9d7b376485d4582c6b6eac2185'
ozone_wayland_rev = '0a8caf9bc740d767464b2d1d16fec08ff2f91d1f'
chromium_crosswalk_rev = 'f506465773c4515957798e38250a3a7becb2bea6'
blink_crosswalk_rev = 'db2fa6ff036de0611105c872817b487f0a88dd94'
v8_crosswalk_rev = '8ddfc6f1a103ddbe20e38afeb12c3e0666c8a361'
ozone_wayland_rev = '3372a0e23d925d5402eb16abbbe58dd82b583a5a'

crosswalk_git = 'https://github.com/crosswalk-project'
ozone_wayland_git = 'https://github.com/01org'
Expand Down
35 changes: 34 additions & 1 deletion application/browser/application_tizen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ ApplicationTizen::ApplicationTizen(
scoped_refptr<ApplicationData> data,
RuntimeContext* runtime_context,
Application::Observer* observer)
: Application(data, runtime_context, observer) {
: Application(data, runtime_context, observer),
is_suspended_(false) {
#if defined(USE_OZONE)
ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
#endif
Expand Down Expand Up @@ -111,6 +112,38 @@ base::FilePath ApplicationTizen::GetSplashScreenPath() {
return base::FilePath();
}

void ApplicationTizen::Suspend() {
if (is_suspended_)
return;

DCHECK(render_process_host_);
render_process_host_->Send(new ViewMsg_SuspendJSEngine(true));

DCHECK(!runtimes_.empty());
std::set<Runtime*>::iterator it = runtimes_.begin();
for (; it != runtimes_.end(); ++it) {
if ((*it)->web_contents())
(*it)->web_contents()->WasHidden();
}
is_suspended_ = true;
}

void ApplicationTizen::Resume() {
if (!is_suspended_)
return;

DCHECK(render_process_host_);
render_process_host_->Send(new ViewMsg_SuspendJSEngine(false));

DCHECK(!runtimes_.empty());
std::set<Runtime*>::iterator it = runtimes_.begin();
for (; it != runtimes_.end(); ++it) {
if ((*it)->web_contents())
(*it)->web_contents()->WasShown();
}
is_suspended_ = false;
}

#if defined(USE_OZONE)
void ApplicationTizen::WillProcessEvent(const ui::PlatformEvent& event) {}

Expand Down
4 changes: 4 additions & 0 deletions application/browser/application_tizen.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class ApplicationTizen : // NOLINT
public:
virtual ~ApplicationTizen();
void Hide();
void Suspend();
void Resume();

private:
// We enforce ApplicationService ownership.
Expand All @@ -38,6 +40,8 @@ class ApplicationTizen : // NOLINT
virtual void WillProcessEvent(const ui::PlatformEvent& event) OVERRIDE;
virtual void DidProcessEvent(const ui::PlatformEvent& event) OVERRIDE;
#endif

bool is_suspended_;
};

inline ApplicationTizen* ToApplicationTizen(Application* app) {
Expand Down
52 changes: 52 additions & 0 deletions application/browser/linux/running_application_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ RunningApplicationObject::RunningApplicationObject(
base::Unretained(this)),
base::Bind(&RunningApplicationObject::OnExported,
base::Unretained(this)));

dbus_object()->ExportMethod(
kRunningApplicationDBusInterface, "Suspend",
base::Bind(&RunningApplicationObject::OnSuspend,
base::Unretained(this)),
base::Bind(&RunningApplicationObject::OnExported,
base::Unretained(this)));

dbus_object()->ExportMethod(
kRunningApplicationDBusInterface, "Resume",
base::Bind(&RunningApplicationObject::OnResume,
base::Unretained(this)),
base::Bind(&RunningApplicationObject::OnExported,
base::Unretained(this)));
#endif
}

Expand Down Expand Up @@ -148,6 +162,44 @@ void RunningApplicationObject::OnHide(
dbus::Response::FromMethodCall(method_call);
response_sender.Run(response.Pass());
}

void RunningApplicationObject::OnSuspend(
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_)->Suspend();

scoped_ptr<dbus::Response> response =
dbus::Response::FromMethodCall(method_call);
response_sender.Run(response.Pass());
}

void RunningApplicationObject::OnResume(
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_)->Resume();

scoped_ptr<dbus::Response> response =
dbus::Response::FromMethodCall(method_call);
response_sender.Run(response.Pass());
}
#endif

void RunningApplicationObject::ListenForOwnerChange() {
Expand Down
7 changes: 6 additions & 1 deletion application/browser/linux/running_application_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ class RunningApplicationObject : public dbus::ManagedObject {
#if defined(OS_TIZEN)
void OnHide(dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender);

void OnSuspend(dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender);

void OnResume(dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender);
#endif

void ListenForOwnerChange();
Expand All @@ -76,4 +82,3 @@ class RunningApplicationObject : public dbus::ManagedObject {
} // namespace xwalk

#endif // XWALK_APPLICATION_BROWSER_LINUX_RUNNING_APPLICATION_OBJECT_H_

2 changes: 1 addition & 1 deletion application/tools/linux/xwalk_launcher_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static void launch_application(const char* appid_or_url,
char name[128];
snprintf(name, sizeof(name), "xwalk-%s", appid_or_url);

if (xwalk_appcore_init(g_argc, g_argv, name)) {
if (xwalk_appcore_init(g_argc, g_argv, name, app_proxy)) {
fprintf(stderr, "Failed to initialize appcore");
exit(1);
}
Expand Down
36 changes: 32 additions & 4 deletions application/tools/linux/xwalk_launcher_tizen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include <glib.h>
#include <gio/gio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
Expand Down Expand Up @@ -60,15 +61,42 @@ static const char* event2str(enum app_event event) {

static void application_event_cb(enum app_event event, void* data, bundle* b) {
fprintf(stderr, "event '%s'\n", event2str(event));
GDBusProxy* app_proxy = reinterpret_cast<GDBusProxy*>(data);

if (event == AE_TERMINATE) {
exit(0);
if (!app_proxy) {
fprintf(stderr, "Invalid DBus proxy.");
return;
}

switch (event) {
case AE_UNKNOWN:
case AE_CREATE:
break;
case AE_TERMINATE:
exit(0);
break;
case AE_PAUSE:
g_dbus_proxy_call(
app_proxy, "Suspend", NULL,
G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
break;
case AE_RESUME:
g_dbus_proxy_call(
app_proxy, "Resume", NULL,
G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
break;
case AE_RESET:
case AE_LOWMEM_POST:
case AE_MEM_FLUSH:
case AE_MAX:
break;
}
}

int xwalk_appcore_init(int argc, char** argv, const char* name) {
int xwalk_appcore_init(
int argc, char** argv, const char* name, GDBusProxy* app_proxy) {
appcore_ops.cb_app = application_event_cb;
appcore_ops.data = NULL;
appcore_ops.data = app_proxy;

return appcore_init(name, &appcore_ops, argc, argv);
}
Expand Down
3 changes: 2 additions & 1 deletion application/tools/linux/xwalk_launcher_tizen.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#ifndef XWALK_APPLICATION_TOOLS_LINUX_XWALK_LAUNCHER_TIZEN_H_
#define XWALK_APPLICATION_TOOLS_LINUX_XWALK_LAUNCHER_TIZEN_H_

int xwalk_appcore_init(int argc, char** argv, const char* name);
int xwalk_appcore_init(int argc, char** argv,
const char* name, GDBusProxy* app_proxy);

int xwalk_change_cmdline(int argc, char** argv, const char* app_id);

Expand Down
33 changes: 33 additions & 0 deletions extensions/renderer/xwalk_extension_renderer_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include "xwalk/extensions/renderer/xwalk_module_system.h"
#include "xwalk/extensions/renderer/xwalk_v8tools_module.h"

#if defined(OS_TIZEN)
#include "xwalk/application/common/constants.h"
#endif

namespace xwalk {
namespace extensions {

Expand Down Expand Up @@ -70,6 +74,24 @@ void CreateExtensionModules(XWalkExtensionClient* client,
}
}

#if defined(OS_TIZEN)
void CreateExtensionModulesWithoutDeviceAPI(XWalkExtensionClient* client,
XWalkModuleSystem* module_system) {
const XWalkExtensionClient::ExtensionAPIMap& extensions =
client->extension_apis();
XWalkExtensionClient::ExtensionAPIMap::const_iterator it = extensions.begin();
for (; it != extensions.end(); ++it) {
XWalkExtensionClient::ExtensionCodePoints* codepoint = it->second;
if (codepoint->api.empty() || it->first.find("tizen") == 0)
continue;
scoped_ptr<XWalkExtensionModule> module(
new XWalkExtensionModule(client, module_system,
it->first, codepoint->api));
module_system->RegisterExtensionModule(module.Pass(),
codepoint->entry_points);
}
}
#endif
} // namespace

void XWalkExtensionRendererController::DidCreateScriptContext(
Expand All @@ -90,8 +112,19 @@ void XWalkExtensionRendererController::DidCreateScriptContext(
module_system);

if (external_extensions_client_) {
#if defined(OS_TIZEN)
// On Tizen platform, only local pages can access to device APIs.
GURL url = static_cast<GURL>(frame->document().url());
if (!url.SchemeIs(xwalk::application::kApplicationScheme) &&
!url.SchemeIsFile())
CreateExtensionModulesWithoutDeviceAPI(external_extensions_client_.get(),
module_system);
else
CreateExtensionModules(external_extensions_client_.get(), module_system);
#else
CreateExtensionModules(external_extensions_client_.get(),
module_system);
#endif
}

module_system->Initialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@ public XWalkContent(Context context, AttributeSet attrs, XWalkViewInternal xwVie
boolean animated = XWalkPreferencesInternal.getValue(XWalkPreferencesInternal.ANIMATABLE_XWALK_VIEW);
CompositingSurfaceType surfaceType =
animated ? CompositingSurfaceType.TEXTURE_VIEW : CompositingSurfaceType.SURFACE_VIEW;
mContentViewRenderView = new ContentViewRenderView(context, mWindow, surfaceType) {
mContentViewRenderView = new ContentViewRenderView(context, surfaceType) {
protected void onReadyToRender() {
// Anything depending on the underlying Surface readiness should
// be placed here.
}
};
mContentViewRenderView.onNativeLibraryLoaded(mWindow);
mLaunchScreenManager = new XWalkLaunchScreenManager(context, mXWalkView);
mContentViewRenderView.registerFirstRenderedFrameListener(mLaunchScreenManager);
addView(mContentViewRenderView,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ private void showNotification(String title, String message, String replaceId,
// FIXME(wang16): use replaceId to replace exist notification. It happens when
// a notification with same name and tag fires.
mNotificationService.showNotification(
title, message, notificationId, delegate);
title, message, replaceId, notificationId, delegate);
}

@CalledByNative
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
interface XWalkNotificationService {
public void setBridge(XWalkContentsClientBridge bridge);
public void showNotification(
String title, String message, int notificationId, long delegate);
String title, String message, String replaceId, int notificationId, long delegate);
public void updateNotificationIcon(int notificationId, Bitmap icon);
public void cancelNotification(int notificationId, long delegate);
public void shutdown();
Expand Down
Loading

0 comments on commit c8a9a68

Please sign in to comment.