--- /dev/null
+{
+ 'includes':[
+ '../common/common.gypi',
+ ],
+ 'targets': [
+ {
+ 'target_name': 'tizen_bookmark',
+ 'type': 'loadable_module',
+ 'includes': [
+ '../common/pkg-config.gypi',
+ ],
+ 'sources': [
+ 'bookmark_api.js',
+ 'bookmark_extension.cc',
+ 'bookmark_extension.h',
+ 'bookmark_instance.cc',
+ 'bookmark_instance.h',
+ ],
+ 'conditions': [
+ [ 'tizen == 1', {
+ 'variables': { },
+ }],
+ ],
+ },
+ ],
+}
--- /dev/null
+// Copyright 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.
+
+function throwException_(err) {
+ throw new tizen.WebAPIException(err.code, err.name, err.message);
+}
+
+function _sendSyncMessage(msg) {
+ var data = null;
+ data = JSON.stringify(msg);
+
+ return JSON.parse(extension.internal.sendSyncMessage(data));
+}
+
+function BookmarkManager() {
+}
+
+BookmarkManager.prototype.get = function() {
+ return new BookmarkManager();
+};
+
+BookmarkManager.prototype.add = function(parent_folder, recursive) {
+ var msg = {
+ cmd: 'add',
+ arg: ''
+ };
+
+ return _sendSyncMessage(msg).value;
+};
+
+
+BookmarkManager.prototype.remove = function(bookmark) {
+ var msg = {
+ cmd: 'remove',
+ arg: ''
+ };
+
+ return _sendSyncMessage(msg).value;
+};
+
+tizen.BookmarkItem = function(title, url) {
+ var parent;
+ var title_;
+ var url_;
+};
+
+tizen.BookmarkFolder = function(title) {
+ var parent;
+ var title_;
+};
+
+exports = new BookmarkManager();
--- /dev/null
+// Copyright 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 "bookmark/bookmark_extension.h"
+#include "bookmark/bookmark_instance.h"
+
+namespace {
+ const char* kBookmark = "tizen.bookmark";
+ const char* kBookmarkItem = "tizen.BookmarkItem";
+ const char* kBookmarkFolder = "tizen.BookmarkFolder";
+}
+
+// This will be generated from bookmark_api.js.
+extern const char kSource_bookmark_api[];
+
+common::Extension* CreateExtension() {
+ return new BookmarkExtension;
+}
+
+BookmarkExtension::BookmarkExtension() {
+ SetExtensionName(kBookmark);
+ SetJavaScriptAPI(kSource_bookmark_api);
+
+ const char* entry_points[] = {
+ kBookmarkItem,
+ kBookmarkFolder,
+ NULL
+ };
+ SetExtraJSEntryPoints(entry_points);
+}
+
+BookmarkExtension::~BookmarkExtension() {}
+
+common::Instance* BookmarkExtension::CreateInstance() {
+ return new extension::bookmark::BookmarkInstance;
+}
--- /dev/null
+// Copyright 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 BOOKMARK_BOOKMARK_EXTENSION_H_
+#define BOOKMARK_BOOKMARK_EXTENSION_H_
+
+#include "common/extension.h"
+
+class BookmarkExtension : public common::Extension {
+ public:
+ BookmarkExtension();
+ virtual ~BookmarkExtension();
+
+ private:
+ virtual common::Instance* CreateInstance();
+};
+
+#endif // BOOKMARK_BOOKMARK_EXTENSION_H_
--- /dev/null
+// Copyright 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 "bookmark/bookmark_instance.h"
+
+#include <string>
+
+namespace extension {
+namespace bookmark {
+
+namespace {
+ const char* kGet = "get";
+ const char* kAdd = "add";
+ const char* kRemove = "remove";
+ const char* kCmd = "cmd";
+ const char* kArg = "arg";
+ const char* kError = "error";
+ const char* kValue = "value";
+ const char* kNotImplemented = "Not implemented";
+}
+
+BookmarkInstance::BookmarkInstance() {}
+
+BookmarkInstance::~BookmarkInstance() {}
+
+void BookmarkInstance::HandleMessage(const char* msg) {}
+
+void BookmarkInstance::HandleSyncMessage(const char* msg) {
+ picojson::value v;
+ std::string err;
+
+ picojson::parse(v, msg, msg + strlen(msg), &err);
+ if (!err.empty()) {
+ return;
+ }
+
+ std::string cmd = v.get(kCmd).to_str();
+ picojson::value arg = v.get(kArg);
+ picojson::value::object o;
+
+ if (cmd == kGet) {
+ HandleGet(arg, o);
+ } else if (cmd == kAdd) {
+ HandleAdd(arg, o);
+ } else if (cmd == kRemove) {
+ HandleRemove(arg, o);
+ }
+
+ if (o.empty())
+ o[kError] = picojson::value(true);
+
+ SendSyncReply(picojson::value(o).serialize().c_str());
+}
+
+void BookmarkInstance::HandleGet(const picojson::value& arg, picojson::object& o) {
+ o[kValue] = picojson::value(kNotImplemented);
+}
+
+void BookmarkInstance::HandleAdd(const picojson::value& arg, picojson::object& o) {
+ o[kValue] = picojson::value(kNotImplemented);
+}
+
+void BookmarkInstance::HandleRemove(const picojson::value& arg, picojson::object& o) {
+ o[kValue] = picojson::value(kNotImplemented);
+}
+
+} //namespace bookmark
+} //namespace extension
--- /dev/null
+// Copyright 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 BOOKMARK_BOOKMARK_INSTANCE_H_
+#define BOOKMARK_BOOKMARK_INSTANCE_H_
+
+#include "common/extension.h"
+#include "common/picojson.h"
+
+namespace extension {
+namespace bookmark {
+
+class BookmarkInstance : public common::Instance {
+ public:
+ BookmarkInstance();
+ virtual ~BookmarkInstance();
+
+ private:
+ virtual void HandleMessage(const char* msg);
+ virtual void HandleSyncMessage(const char* msg);
+
+ void HandleGet(const picojson::value& arg, picojson::value::object& o);
+ void HandleAdd(const picojson::value& arg, picojson::value::object& o);
+ void HandleRemove(const picojson::value& arg, picojson::value::object& o);
+};
+
+} // namespace bookmark
+} // namespace extension
+
+#endif // BOOKMARK_BOOKMARK_INSTANCE_H_
'power/power.gyp:*',
'messageport/messageport.gyp:*',
#'calendar/calendar.gyp:*',
+ 'bookmark/bookmark.gyp:*',
],
},
],