const char kRuntimeServiceName[] = "org.crosswalkproject.Runtime1";
const char kRuntimeRunningManagerPath[] = "/running1";
-const char kRuntimeRunningAppInterface[] = "org.crosswalkproject.Running.Application1";
+const char kRuntimeRunningAppInterface[] =
+ "org.crosswalkproject.Running.Application1";
// The runtime process exports object for each running app on the session bus.
GDBusProxy* CreateRunningAppProxy(const std::string& app_id) {
GError* error = NULL;
- GDBusConnection* connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
+ GDBusConnection* connection =
+ g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
if (!connection) {
- std::cerr << "Couldn't get the session bus connection: " << error->message << std::endl;
+ std::cerr << "Couldn't get the session bus connection: " << error->message
+ << std::endl;
g_error_free(error);
return NULL;
}
// The d-bus proxy doesn't accept '.' character in object path
// And that is why the substantiation is needed here.
std::replace(path.begin(), path.end(), '.', '_');
- GDBusProxy* proxy =
- g_dbus_proxy_new_sync(connection, G_DBUS_PROXY_FLAGS_NONE, NULL, kRuntimeServiceName,
- path.c_str(), kRuntimeRunningAppInterface, NULL, &error);
+ GDBusProxy* proxy = g_dbus_proxy_new_sync(
+ connection, G_DBUS_PROXY_FLAGS_NONE, NULL, kRuntimeServiceName,
+ path.c_str(), kRuntimeRunningAppInterface, NULL, &error);
if (!proxy) {
- std::cerr << "Couldn't create proxy for " << kRuntimeRunningAppInterface << ": "
- << error->message << std::endl;
+ std::cerr << "Couldn't create proxy for " << kRuntimeRunningAppInterface
+ << ": " << error->message << std::endl;
g_error_free(error);
return NULL;
}
} // namespace
-WebSetting::WebSetting(const std::string& app_id) : app_id_(app_id), running_app_proxy_(NULL) {}
+WebSetting::WebSetting(const std::string& app_id)
+ : app_id_(app_id), running_app_proxy_(NULL) {}
WebSetting::~WebSetting() {
if (running_app_proxy_) g_object_unref(running_app_proxy_);
return CreateResultMessage(ErrorCode::UNKNOWN_ERR);
}
GError* error = NULL;
- GVariant* result = g_dbus_proxy_call_sync(running_app_proxy_, "RemoveAllCookies", NULL,
- G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ GVariant* result =
+ g_dbus_proxy_call_sync(running_app_proxy_, "RemoveAllCookies", NULL,
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
if (!result) {
- std::cerr << "Fail to call 'RemoveuserAgentAllCookies':" << error->message << std::endl;
+ std::cerr << "Fail to call 'RemoveuserAgentAllCookies':" << error->message
+ << std::endl;
g_error_free(error);
return CreateResultMessage(ErrorCode::UNKNOWN_ERR);
}
return CreateResultMessage();
}
-std::unique_ptr<picojson::value> WebSetting::SetUserAgentString(const std::string& user_agent) {
+std::unique_ptr<picojson::value> WebSetting::SetUserAgentString(
+ const std::string& user_agent) {
if (!running_app_proxy_) {
if (!(running_app_proxy_ = CreateRunningAppProxy(app_id_)))
return CreateResultMessage(ErrorCode::UNKNOWN_ERR);
}
GError* error = NULL;
- GVariant* result = g_dbus_proxy_call_sync(running_app_proxy_, "SetUserAgentString",
- g_variant_new("(s)", user_agent.c_str()),
- G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ GVariant* result =
+ g_dbus_proxy_call_sync(running_app_proxy_, "SetUserAgentString",
+ g_variant_new("(s)", user_agent.c_str()),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
if (!result) {
- std::cerr << "Fail to call 'SetUserAgentString':" << error->message << std::endl;
+ std::cerr << "Fail to call 'SetUserAgentString':" << error->message
+ << std::endl;
g_error_free(error);
return CreateResultMessage(ErrorCode::UNKNOWN_ERR);
}
return std::unique_ptr<picojson::value>(new picojson::value(obj));
}
-std::unique_ptr<picojson::value> CreateResultMessage(const common::ErrorCode& error) {
+std::unique_ptr<picojson::value> CreateResultMessage(
+ const common::ErrorCode& error) {
picojson::object obj;
obj["error"] = picojson::value(static_cast<double>(error));
return std::unique_ptr<picojson::value>(new picojson::value(obj));
}
-std::unique_ptr<picojson::value> CreateResultMessage(const picojson::object& data) {
+std::unique_ptr<picojson::value> CreateResultMessage(
+ const picojson::object& data) {
picojson::object obj;
obj["data"] = picojson::value(data);
return std::unique_ptr<picojson::value>(new picojson::value(obj));
}
-std::unique_ptr<picojson::value> CreateResultMessage(const picojson::array& data) {
+std::unique_ptr<picojson::value> CreateResultMessage(
+ const picojson::array& data) {
picojson::object obj;
obj["data"] = picojson::value(data);
return std::unique_ptr<picojson::value>(new picojson::value(obj));
}
-std::unique_ptr<picojson::value> CreateResultMessage(const picojson::value& data) {
+std::unique_ptr<picojson::value> CreateResultMessage(
+ const picojson::value& data) {
picojson::object obj;
obj["data"] = data;
return std::unique_ptr<picojson::value>(new picojson::value(obj));
namespace {
// The privileges that required in Websetting API
-const std::string kPrivilegeWebsetting = "http://tizen.org/privilege/websetting";
+const std::string kPrivilegeWebsetting =
+ "http://tizen.org/privilege/websetting";
const char kWrtServiceName[] = "wrt-service";
} // namespace
typedef picojson::array JsonArray;
typedef std::string JsonString;
-WebSettingInstance::WebSettingInstance(WebSettingExtension* extension) : extension_(extension) {
+WebSettingInstance::WebSettingInstance(WebSettingExtension* extension)
+ : extension_(extension) {
using namespace std::placeholders;
-#define REGISTER_ASYNC(c, x) RegisterHandler(c, std::bind(&WebSettingInstance::x, this, _1, _2));
- REGISTER_ASYNC("WebSettingManager_setUserAgentString", WebSettingManagerSetUserAgentString);
- REGISTER_ASYNC("WebSettingManager_removeAllCookies", WebSettingManagerRemoveAllCookies);
+#define REGISTER_ASYNC(c, x) \
+ RegisterHandler(c, std::bind(&WebSettingInstance::x, this, _1, _2));
+ REGISTER_ASYNC("WebSettingManager_setUserAgentString",
+ WebSettingManagerSetUserAgentString);
+ REGISTER_ASYNC("WebSettingManager_removeAllCookies",
+ WebSettingManagerRemoveAllCookies);
#undef REGISTER_ASYNC
}