summaryrefslogtreecommitdiff
path: root/Tizen.WebView
diff options
context:
space:
mode:
Diffstat (limited to 'Tizen.WebView')
-rw-r--r--Tizen.WebView/Interop/Interop.ChromiumEwk.Context.cs41
-rw-r--r--Tizen.WebView/Interop/Interop.ChromiumEwk.CookieManager.cs46
-rw-r--r--Tizen.WebView/Interop/Interop.ChromiumEwk.Error.cs49
-rw-r--r--Tizen.WebView/Interop/Interop.ChromiumEwk.Settings.cs60
-rw-r--r--Tizen.WebView/Interop/Interop.ChromiumEwk.View.cs127
-rw-r--r--Tizen.WebView/Interop/Interop.ChromiumEwk.cs29
-rw-r--r--Tizen.WebView/Interop/Interop.Elementary.cs37
-rw-r--r--Tizen.WebView/Interop/Interop.Evas.cs27
-rw-r--r--Tizen.WebView/Interop/Interop.Libraries.cs24
-rw-r--r--Tizen.WebView/Properties/AssemblyInfo.cs36
-rwxr-xr-xTizen.WebView/Tizen.WebView.csproj99
-rw-r--r--Tizen.WebView/Tizen.WebView.nuspec19
-rw-r--r--Tizen.WebView/Tizen.WebView.project.json9
-rw-r--r--Tizen.WebView/Tizen.WebView.snkbin0 -> 596 bytes
-rw-r--r--Tizen.WebView/Tizen.WebView/Chromium.cs39
-rw-r--r--Tizen.WebView/Tizen.WebView/Context.cs78
-rw-r--r--Tizen.WebView/Tizen.WebView/CookieManager.cs82
-rw-r--r--Tizen.WebView/Tizen.WebView/JavaScriptMessage.cs104
-rw-r--r--Tizen.WebView/Tizen.WebView/Settings.cs94
-rw-r--r--Tizen.WebView/Tizen.WebView/SmartCallbackArgs.cs93
-rw-r--r--Tizen.WebView/Tizen.WebView/SmartCallbackLoadErrorArgs.cs150
-rw-r--r--Tizen.WebView/Tizen.WebView/WebView.cs342
22 files changed, 1585 insertions, 0 deletions
diff --git a/Tizen.WebView/Interop/Interop.ChromiumEwk.Context.cs b/Tizen.WebView/Interop/Interop.ChromiumEwk.Context.cs
new file mode 100644
index 0000000..e073823
--- /dev/null
+++ b/Tizen.WebView/Interop/Interop.ChromiumEwk.Context.cs
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class ChromiumEwk
+ {
+ public enum CacheModel
+ {
+ DocumentViewer,
+ DocumentBrowser,
+ PrimaryWebBrowser
+ }
+
+ [DllImport(Libraries.ChromiumEwk)]
+ internal static extern IntPtr ewk_context_cookie_manager_get(IntPtr context);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_context_cache_model_set(IntPtr context, CacheModel model);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ internal static extern CacheModel ewk_context_cache_model_get(IntPtr context);
+ }
+}
diff --git a/Tizen.WebView/Interop/Interop.ChromiumEwk.CookieManager.cs b/Tizen.WebView/Interop/Interop.ChromiumEwk.CookieManager.cs
new file mode 100644
index 0000000..2c90553
--- /dev/null
+++ b/Tizen.WebView/Interop/Interop.ChromiumEwk.CookieManager.cs
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class ChromiumEwk
+ {
+ public enum CookieAcceptPolicy
+ {
+ Always,
+ Never,
+ NoThirdParty
+ }
+
+ public enum CookiePersistentStorage
+ {
+ Text,
+ SqlLite
+ }
+
+ [DllImport(Libraries.ChromiumEwk)]
+ internal static extern void ewk_cookie_manager_accept_policy_set(IntPtr manager, CookieAcceptPolicy policy);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ internal static extern void ewk_cookie_manager_cookies_clear(IntPtr manager);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ internal static extern void ewk_cookie_manager_persistent_storage_set(IntPtr manager, string path, CookiePersistentStorage storage);
+ }
+}
diff --git a/Tizen.WebView/Interop/Interop.ChromiumEwk.Error.cs b/Tizen.WebView/Interop/Interop.ChromiumEwk.Error.cs
new file mode 100644
index 0000000..9234dc6
--- /dev/null
+++ b/Tizen.WebView/Interop/Interop.ChromiumEwk.Error.cs
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class ChromiumEwk
+ {
+ [DllImport(Libraries.ChromiumEwk, EntryPoint = "ewk_error_url_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, CharSet = CharSet.Ansi)]
+ internal static extern IntPtr _ewk_error_url_get(IntPtr error);
+
+ internal static string ewk_error_url_get(IntPtr error)
+ {
+ IntPtr ptr = _ewk_error_url_get(error);
+ return Marshal.PtrToStringAnsi(ptr);
+ }
+
+ [DllImport(Libraries.ChromiumEwk)]
+ internal static extern int ewk_error_code_get(IntPtr error);
+
+ [DllImport(Libraries.ChromiumEwk, EntryPoint = "ewk_error_description_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, CharSet = CharSet.Ansi)]
+ internal static extern IntPtr _ewk_error_description_get(IntPtr error);
+
+ internal static string ewk_error_description_get(IntPtr error)
+ {
+ IntPtr ptr = _ewk_error_description_get(error);
+ return Marshal.PtrToStringAnsi(ptr);
+ }
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_error_cancellation_get(IntPtr error);
+ }
+}
diff --git a/Tizen.WebView/Interop/Interop.ChromiumEwk.Settings.cs b/Tizen.WebView/Interop/Interop.ChromiumEwk.Settings.cs
new file mode 100644
index 0000000..2acd268
--- /dev/null
+++ b/Tizen.WebView/Interop/Interop.ChromiumEwk.Settings.cs
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class ChromiumEwk
+ {
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_settings_javascript_enabled_set(IntPtr settings, bool enable);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_settings_javascript_enabled_get(IntPtr settings);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_settings_loads_images_automatically_set(IntPtr settings, bool enable);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_settings_loads_images_automatically_get(IntPtr settings);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_settings_default_text_encoding_name_set(IntPtr settings, string encoding);
+
+ [DllImport(Libraries.ChromiumEwk, EntryPoint = "ewk_settings_default_text_encoding_name_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, CharSet = CharSet.Ansi)]
+ internal static extern IntPtr _ewk_settings_default_text_encoding_name_get(IntPtr settings);
+
+ internal static string ewk_settings_default_text_encoding_name_get(IntPtr settings)
+ {
+ IntPtr ptr = _ewk_settings_default_text_encoding_name_get(settings);
+ return Marshal.PtrToStringAnsi(ptr);
+ }
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_settings_default_font_size_set(IntPtr settings, int size);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ internal static extern int ewk_settings_default_font_size_get(IntPtr settings);
+ }
+}
diff --git a/Tizen.WebView/Interop/Interop.ChromiumEwk.View.cs b/Tizen.WebView/Interop/Interop.ChromiumEwk.View.cs
new file mode 100644
index 0000000..e507ca8
--- /dev/null
+++ b/Tizen.WebView/Interop/Interop.ChromiumEwk.View.cs
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class ChromiumEwk
+ {
+ [DllImport(Libraries.ChromiumEwk)]
+ internal static extern IntPtr ewk_view_add(IntPtr evas);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ internal static extern IntPtr ewk_view_context_get(IntPtr obj);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ internal static extern IntPtr ewk_view_settings_get(IntPtr obj);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_view_url_set(IntPtr obj, string url);
+
+ [DllImport(Libraries.ChromiumEwk, EntryPoint = "ewk_view_url_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, CharSet = CharSet.Ansi)]
+ internal static extern IntPtr _ewk_view_url_get(IntPtr obj);
+
+ internal static string ewk_view_url_get(IntPtr obj)
+ {
+ IntPtr ptr = _ewk_view_url_get(obj);
+ return Marshal.PtrToStringAnsi(ptr);
+ }
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_view_html_string_load(IntPtr obj, string html, string baseUrl, string unreachableUrl);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_view_reload(IntPtr obj);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_view_stop(IntPtr obj);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_view_back(IntPtr obj);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_view_forward(IntPtr obj);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_view_back_possible(IntPtr obj);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_view_forward_possible(IntPtr obj);
+
+ internal delegate void ScriptExcuteCallback(IntPtr obj, IntPtr resultValue, IntPtr userData);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_view_script_execute(IntPtr obj, string script, ScriptExcuteCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.ChromiumEwk, EntryPoint = "ewk_view_title_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, CharSet = CharSet.Ansi)]
+ internal static extern IntPtr _ewk_view_title_get(IntPtr obj);
+
+ internal static string ewk_view_title_get(IntPtr obj)
+ {
+ IntPtr ptr = _ewk_view_url_get(obj);
+ return Marshal.PtrToStringAnsi(ptr);
+ }
+
+ [DllImport(Libraries.ChromiumEwk, EntryPoint = "ewk_view_user_agent_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, CharSet = CharSet.Ansi)]
+ internal static extern IntPtr _ewk_view_user_agent_get(IntPtr obj);
+
+ internal static string ewk_view_user_agent_get(IntPtr obj)
+ {
+ IntPtr ptr = _ewk_view_user_agent_get(obj);
+ return Marshal.PtrToStringAnsi(ptr);
+ }
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_view_user_agent_set(IntPtr obj, string userAgent);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_view_focus_set(IntPtr obj, bool focused);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_view_focus_get(IntPtr obj);
+
+ [StructLayout(LayoutKind.Sequential, CharSet =CharSet.Ansi)]
+ internal struct ScriptMessage
+ {
+ public IntPtr name;
+ public IntPtr body;
+ }
+
+ internal delegate void ScriptMessageCallback(IntPtr obj, ScriptMessage message);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_view_javascript_message_handler_add(IntPtr obj, ScriptMessageCallback callback, string name);
+
+ [DllImport(Libraries.ChromiumEwk)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool ewk_view_evaluate_javascript(IntPtr obj, string name, string result);
+ }
+}
diff --git a/Tizen.WebView/Interop/Interop.ChromiumEwk.cs b/Tizen.WebView/Interop/Interop.ChromiumEwk.cs
new file mode 100644
index 0000000..47ca039
--- /dev/null
+++ b/Tizen.WebView/Interop/Interop.ChromiumEwk.cs
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class ChromiumEwk
+ {
+ [DllImport(Libraries.ChromiumEwk)]
+ internal static extern int ewk_init();
+
+ [DllImport(Libraries.ChromiumEwk)]
+ internal static extern int ewk_shutdown();
+ }
+}
diff --git a/Tizen.WebView/Interop/Interop.Elementary.cs b/Tizen.WebView/Interop/Interop.Elementary.cs
new file mode 100644
index 0000000..09b9bc4
--- /dev/null
+++ b/Tizen.WebView/Interop/Interop.Elementary.cs
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class Elementary
+ {
+ [DllImport(Libraries.Elementary)]
+ internal static extern IntPtr elm_layout_add(IntPtr obj);
+
+ [DllImport(Libraries.Elementary)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ internal static extern bool elm_layout_theme_set(IntPtr obj, string klass, string group, string style);
+
+ [DllImport(Libraries.Elementary)]
+ internal static extern void elm_object_part_content_set(IntPtr obj, string part, IntPtr content);
+
+ [DllImport(Libraries.Elementary)]
+ internal static extern void elm_object_focus_allow_set(IntPtr obj, bool enable);
+ }
+} \ No newline at end of file
diff --git a/Tizen.WebView/Interop/Interop.Evas.cs b/Tizen.WebView/Interop/Interop.Evas.cs
new file mode 100644
index 0000000..a9e6d58
--- /dev/null
+++ b/Tizen.WebView/Interop/Interop.Evas.cs
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class Evas
+ {
+ [DllImport(Libraries.Evas)]
+ internal static extern IntPtr evas_object_evas_get(IntPtr obj);
+ }
+}
diff --git a/Tizen.WebView/Interop/Interop.Libraries.cs b/Tizen.WebView/Interop/Interop.Libraries.cs
new file mode 100644
index 0000000..0d91a26
--- /dev/null
+++ b/Tizen.WebView/Interop/Interop.Libraries.cs
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+internal static partial class Interop
+{
+ private static class Libraries
+ {
+ internal const string ChromiumEwk = "libchromium-ewk.so";
+ internal const string Elementary = "libelementary.so.1";
+ internal const string Evas = "libevas.so.1";
+ }
+}
diff --git a/Tizen.WebView/Properties/AssemblyInfo.cs b/Tizen.WebView/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..75cc36c
--- /dev/null
+++ b/Tizen.WebView/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tizen.WebView")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Samsung Electronics")]
+[assembly: AssemblyProduct("Tizen.WebView")]
+[assembly: AssemblyCopyright("Copyright © Samsung Electronics 2017")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("8405e84f-b920-4aac-9ad5-001b9debc9ca")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Tizen.WebView/Tizen.WebView.csproj b/Tizen.WebView/Tizen.WebView.csproj
new file mode 100755
index 0000000..29df008
--- /dev/null
+++ b/Tizen.WebView/Tizen.WebView.csproj
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{8405E84F-B920-4AAC-9AD5-001B9DEBC9CA}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Tizen.WebView</RootNamespace>
+ <AssemblyName>Tizen.WebView</AssemblyName>
+ <FileAlignment>512</FileAlignment>
+ <DefaultLanguage>en-US</DefaultLanguage>
+ </PropertyGroup>
+ <PropertyGroup>
+ <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>
+ <TargetFrameworkVersion>v1.3</TargetFrameworkVersion>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker>
+ <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
+ <NoStdLib>true</NoStdLib>
+ <NoWarn>$(NoWarn);1701</NoWarn>
+ <UseVSHostingProcess>false</UseVSHostingProcess>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <NoWarn>;1701;1702</NoWarn>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <NoWarn>;1701;1702</NoWarn>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <DebugSymbols>true</DebugSymbols>
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Tizen.WebView.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <None Include="Tizen.WebView.nuspec" />
+ <None Include="Tizen.WebView.project.json" />
+ <None Include="Tizen.WebView.snk" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Interop\Interop.ChromiumEwk.Context.cs" />
+ <Compile Include="Interop\Interop.ChromiumEwk.CookieManager.cs" />
+ <Compile Include="Interop\Interop.ChromiumEwk.cs" />
+ <Compile Include="Interop\Interop.ChromiumEwk.Error.cs" />
+ <Compile Include="Interop\Interop.ChromiumEwk.Settings.cs" />
+ <Compile Include="Interop\Interop.ChromiumEwk.View.cs" />
+ <Compile Include="Interop\Interop.Elementary.cs" />
+ <Compile Include="Interop\Interop.Evas.cs" />
+ <Compile Include="Interop\Interop.Libraries.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Tizen.WebView\Chromium.cs" />
+ <Compile Include="Tizen.WebView\Context.cs" />
+ <Compile Include="Tizen.WebView\CookieManager.cs" />
+ <Compile Include="Tizen.WebView\JavaScriptMessage.cs" />
+ <Compile Include="Tizen.WebView\Settings.cs" />
+ <Compile Include="Tizen.WebView\SmartCallbackLoadErrorArgs.cs" />
+ <Compile Include="Tizen.WebView\SmartCallbackArgs.cs" />
+ <Compile Include="Tizen.WebView\WebView.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+ <PropertyGroup>
+ <!-- https://github.com/dotnet/corefxlab/tree/master/samples/NetCoreSample and
+ https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/target-dotnetcore-with-msbuild
+ -->
+ <!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two
+ properties to any folder that exists to skip the GetReferenceAssemblyPaths task (not target) and
+ to prevent it from outputting a warning (MSB3644).
+ -->
+ <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories>
+ <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>
+ <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
+ </PropertyGroup>
+</Project>
diff --git a/Tizen.WebView/Tizen.WebView.nuspec b/Tizen.WebView/Tizen.WebView.nuspec
new file mode 100644
index 0000000..a0bfe59
--- /dev/null
+++ b/Tizen.WebView/Tizen.WebView.nuspec
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<package >
+ <metadata>
+ <id>Tizen.WebView</id>
+ <version>$version$</version>
+ <authors>Samsung Electronics</authors>
+ <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
+ <iconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</iconUrl>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <description>Tizen WebView API for C#</description>
+ <copyright>© Samsung Electronics Co., Ltd All Rights Reserved</copyright>
+ <dependencies>
+ <dependency id="ElmSharp" version="1.1.0" />
+ </dependencies>
+ </metadata>
+ <files>
+ <file src="bin/$Configuration$/Tizen.WebView.dll" target="lib/netstandard1.3" />
+ </files>
+</package>
diff --git a/Tizen.WebView/Tizen.WebView.project.json b/Tizen.WebView/Tizen.WebView.project.json
new file mode 100644
index 0000000..389f3bf
--- /dev/null
+++ b/Tizen.WebView/Tizen.WebView.project.json
@@ -0,0 +1,9 @@
+{
+ "dependencies": {
+ "ElmSharp": "1.1.0-*",
+ "NETStandard.Library": "1.6.0"
+ },
+ "frameworks": {
+ "netstandard1.3": {}
+ }
+}
diff --git a/Tizen.WebView/Tizen.WebView.snk b/Tizen.WebView/Tizen.WebView.snk
new file mode 100644
index 0000000..b540543
--- /dev/null
+++ b/Tizen.WebView/Tizen.WebView.snk
Binary files differ
diff --git a/Tizen.WebView/Tizen.WebView/Chromium.cs b/Tizen.WebView/Tizen.WebView/Chromium.cs
new file mode 100644
index 0000000..ab63379
--- /dev/null
+++ b/Tizen.WebView/Tizen.WebView/Chromium.cs
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.WebView
+{
+ public static class Chromium
+ {
+ /// <summary>
+ /// Initializes Chromium's instance
+ /// </summary>
+ /// <returns>A reference count of Chromium's instance</returns>
+ public static int Initialize()
+ {
+ return Interop.ChromiumEwk.ewk_init();
+ }
+
+ /// <summary>
+ /// Decreases a reference count of WebKit's instance, possibly destroying it
+ /// </summary>
+ /// <returns>A reference count of Chromium's instance</returns>
+ public static int Shutdown()
+ {
+ return Interop.ChromiumEwk.ewk_shutdown();
+ }
+ }
+}
diff --git a/Tizen.WebView/Tizen.WebView/Context.cs b/Tizen.WebView/Tizen.WebView/Context.cs
new file mode 100644
index 0000000..0e1b5cc
--- /dev/null
+++ b/Tizen.WebView/Tizen.WebView/Context.cs
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.WebView
+{
+ /// <summary>
+ /// Enumeration that contains option for cache model.
+ /// </summary>
+ public enum CacheModel
+ {
+ DocumentViewer, /* Use the smallest cache capacity */
+ DocumentBrowser, /* Use bigger cache capacity than DocumentBrowser */
+ PrimaryWebBrowser /* Use the biggest cache capacity. */
+ }
+
+ public class Context
+ {
+ private IntPtr _handle;
+ private CookieManager _cookieManager;
+
+ internal Context(IntPtr handle)
+ {
+ _handle = handle;
+ }
+
+ /// <summary>
+ /// The cache model.
+ /// </summary>
+ /// <remarks>
+ /// The default cache model is DocumentViewer.
+ /// </remarks>
+ public CacheModel CacheModel
+ {
+ get
+ {
+ return (CacheModel)Interop.ChromiumEwk.ewk_context_cache_model_get(_handle);
+ }
+
+ set
+ {
+ Interop.ChromiumEwk.ewk_context_cache_model_set(_handle, (Interop.ChromiumEwk.CacheModel)value);
+ }
+ }
+
+ /// <summary>
+ /// Gets the CookieManager object for this context.
+ /// </summary>
+ /// <returns>The CookieManager object</returns>
+ public CookieManager GetCookieManager()
+ {
+ if (_cookieManager == null)
+ {
+ IntPtr cookieManagerHandle = Interop.ChromiumEwk.ewk_context_cookie_manager_get(_handle);
+ if (cookieManagerHandle == IntPtr.Zero)
+ {
+ return null;
+ }
+ _cookieManager = new CookieManager(cookieManagerHandle);
+ }
+ return _cookieManager;
+ }
+ }
+}
diff --git a/Tizen.WebView/Tizen.WebView/CookieManager.cs b/Tizen.WebView/Tizen.WebView/CookieManager.cs
new file mode 100644
index 0000000..3728201
--- /dev/null
+++ b/Tizen.WebView/Tizen.WebView/CookieManager.cs
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+
+namespace Tizen.WebView
+{
+ /// <summary>
+ /// Enumeration that contains accept policies for the cookies.
+ /// </summary>
+ public enum CookieAcceptPolicy
+ {
+ Always, /* Accepts every cookie sent from any page */
+ Never, /* Rejects all cookies */
+ NoThirdParty /* Accepts only cookies set by the main document loaded */
+ }
+
+ /// <summary>
+ /// Enumeration that creates a type name for the storage of persistent cookies.
+ /// </summary>
+ public enum CookiePersistentStorage
+ {
+ Text, /* Cookies are stored in a text file in the Mozilla "cookies.txt" format */
+ SqlLite /* Cookies are stored in a SQLite file in the current Mozilla format. */
+ }
+
+ public class CookieManager
+ {
+ private IntPtr _handle;
+
+ internal CookieManager(IntPtr handle)
+ {
+ _handle = handle;
+ }
+
+ /// <summary>
+ /// Sets the cookie acceptance policy.
+ /// </summary>
+ /// <remarks>
+ /// By default, only cookies set by the main document loaded are accepted.
+ /// </remarks>
+ /// <param name="policy">The cookie acceptance policy</param>
+ public void SetCookieAcceptPolicy(CookieAcceptPolicy policy)
+ {
+ Interop.ChromiumEwk.ewk_cookie_manager_accept_policy_set(_handle, (Interop.ChromiumEwk.CookieAcceptPolicy)policy);
+ }
+
+ /// <summary>
+ /// Deletes all the cookies.
+ /// </summary>
+ public void ClearCookies()
+ {
+ Interop.ChromiumEwk.ewk_cookie_manager_cookies_clear(_handle);
+ }
+
+ /// <summary>
+ /// Sets the storage where non-session cookies are stored persistently to read/write the cookies.
+ /// </summary>
+ ///<privilege>
+ /// http://tizen.org/privilege/mediastorage
+ /// http://tizen.org/privilege/externalstorage
+ /// </privilege>
+ /// <param name="path">The path where to read/write Cookies</param>
+ /// <param name="storage">The type of storage</param>
+ public void SetPersistentStorage(string path, CookiePersistentStorage storage)
+ {
+ Interop.ChromiumEwk.ewk_cookie_manager_persistent_storage_set(_handle, path, (Interop.ChromiumEwk.CookiePersistentStorage)storage);
+ }
+ }
+}
diff --git a/Tizen.WebView/Tizen.WebView/JavaScriptMessage.cs b/Tizen.WebView/Tizen.WebView/JavaScriptMessage.cs
new file mode 100644
index 0000000..3b9c555
--- /dev/null
+++ b/Tizen.WebView/Tizen.WebView/JavaScriptMessage.cs
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace Tizen.WebView
+{
+ public delegate void JavaScriptMessageHandler(JavaScriptMessage message);
+
+ /// <summary>
+ /// A Script message contains information that sent from JavaScript runtime.
+ /// </summary>
+ public class JavaScriptMessage
+ {
+ private string _name;
+ private IntPtr _body;
+
+ internal JavaScriptMessage(Interop.ChromiumEwk.ScriptMessage message)
+ {
+ _name = Marshal.PtrToStringAnsi(message.name);
+ _body = message.body;
+ }
+
+ /// <summary>
+ /// Obect name in JavaScript.
+ /// </summary>
+ public string Name
+ {
+ get
+ {
+ return _name;
+ }
+ }
+
+ /// <summary>
+ /// Gets the value of body as integer type.
+ /// </summary>
+ /// <returns>The value of body as integer type</returns>
+ public int GetBodyAsInteger()
+ {
+ if (_body == IntPtr.Zero)
+ {
+ return 0;
+ }
+ return Marshal.ReadInt32(_body, 0);
+ }
+
+ /// <summary>
+ /// Gets the value of body as double type.
+ /// </summary>
+ /// <returns>The value of body as double type</returns>
+ public double GetBodyAsDouble()
+ {
+ if (_body == IntPtr.Zero)
+ {
+ return 0d;
+ }
+ double[] ret = new double[1] ;
+ Marshal.Copy(_body, ret, 0, 1);
+ return ret[0];
+ }
+
+ /// <summary>
+ /// Gets the value of body as boolean type.
+ /// </summary>
+ /// <returns>The value of body as boolean type</returns>
+ public bool GetBodyAsBoolean()
+ {
+ if (_body == IntPtr.Zero)
+ {
+ return false;
+ }
+ return Marshal.ReadByte(_body) != (byte)0;
+ }
+
+ /// <summary>
+ /// Gets the value of body as string type.
+ /// </summary>
+ /// <returns>The value of body as string type</returns>
+ public string GetBodyAsString()
+ {
+ if (_body == IntPtr.Zero)
+ {
+ return string.Empty;
+ }
+ return Marshal.PtrToStringAnsi(_body);
+ }
+ }
+}
diff --git a/Tizen.WebView/Tizen.WebView/Settings.cs b/Tizen.WebView/Tizen.WebView/Settings.cs
new file mode 100644
index 0000000..083e773
--- /dev/null
+++ b/Tizen.WebView/Tizen.WebView/Settings.cs
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.WebView
+{
+ public class Settings
+ {
+ private IntPtr _handle;
+
+ internal Settings(IntPtr handle)
+ {
+ _handle = handle;
+ }
+
+ /// <summary>
+ /// Whether JavaScript can be executable.
+ /// </summary>
+ public bool JavaScriptEnabled
+ {
+ get
+ {
+ return Interop.ChromiumEwk.ewk_settings_javascript_enabled_get(_handle);
+ }
+
+ set
+ {
+ Interop.ChromiumEwk.ewk_settings_javascript_enabled_set(_handle, value);
+ }
+ }
+
+ /// <summary>
+ /// Whether images can be loaded automatically.
+ /// </summary>
+ public bool LoadImageAutomatically
+ {
+ get
+ {
+ return Interop.ChromiumEwk.ewk_settings_loads_images_automatically_get(_handle);
+ }
+
+ set
+ {
+ Interop.ChromiumEwk.ewk_settings_loads_images_automatically_set(_handle, value);
+ }
+ }
+
+ /// <summary>
+ /// The default text encoding name.
+ /// </summary>
+ public string DefaultTextEncodingName
+ {
+ get
+ {
+ return Interop.ChromiumEwk.ewk_settings_default_text_encoding_name_get(_handle);
+ }
+
+ set
+ {
+ Interop.ChromiumEwk.ewk_settings_default_text_encoding_name_set(_handle, value);
+ }
+ }
+
+ /// <summary>
+ /// The default font size of a pixel.
+ /// </summary>
+ public int DefaultFontSize
+ {
+ get
+ {
+ return Interop.ChromiumEwk.ewk_settings_default_font_size_get(_handle);
+ }
+
+ set
+ {
+ Interop.ChromiumEwk.ewk_settings_default_font_size_set(_handle, value);
+ }
+ }
+ }
+}
diff --git a/Tizen.WebView/Tizen.WebView/SmartCallbackArgs.cs b/Tizen.WebView/Tizen.WebView/SmartCallbackArgs.cs
new file mode 100644
index 0000000..9da498f
--- /dev/null
+++ b/Tizen.WebView/Tizen.WebView/SmartCallbackArgs.cs
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Tizen.WebView
+{
+ /// <summary>
+ /// Argument from the SmartCallback.
+ /// </summary>
+ public class SmartCallbackArgs : EventArgs
+ {
+ private IntPtr _arg;
+
+ internal SmartCallbackArgs(IntPtr arg)
+ {
+ _arg = arg;
+ }
+
+ /// <summary>
+ /// Gets argument as integer type.
+ /// </summary>
+ /// <returns>Argument as integer type</returns>
+ public int GetAsInteger()
+ {
+ if (_arg == IntPtr.Zero)
+ {
+ return 0;
+ }
+ return Marshal.ReadInt32(_arg, 0);
+ }
+
+ /// <summary>
+ /// Gets argument as double type.
+ /// </summary>
+ /// <returns>Argument as double type</returns>
+ public double GetAsDouble()
+ {
+ if (_arg == IntPtr.Zero)
+ {
+ return 0d;
+ }
+ double[] ret = new double[1];
+ Marshal.Copy(_arg, ret, 0, 1);
+ return ret[0];
+ }
+
+ /// <summary>
+ /// Gets argument as boolean type.
+ /// </summary>
+ /// <returns>Argument as boolean type</returns>
+ public bool GetAsBoolean()
+ {
+ if (_arg == IntPtr.Zero)
+ {
+ return false;
+ }
+ return Marshal.ReadByte(_arg) != (byte)0;
+ }
+
+ /// <summary>
+ /// Gets argument as string type.
+ /// </summary>
+ /// <returns>Argument as string type</returns>
+ public string GetAsString()
+ {
+ if (_arg == IntPtr.Zero)
+ {
+ return string.Empty;
+ }
+ return Marshal.PtrToStringAnsi(_arg);
+ }
+
+ internal static SmartCallbackArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)
+ {
+ return new SmartCallbackArgs(info);
+ }
+ }
+}
diff --git a/Tizen.WebView/Tizen.WebView/SmartCallbackLoadErrorArgs.cs b/Tizen.WebView/Tizen.WebView/SmartCallbackLoadErrorArgs.cs
new file mode 100644
index 0000000..8ade295
--- /dev/null
+++ b/Tizen.WebView/Tizen.WebView/SmartCallbackLoadErrorArgs.cs
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Tizen.WebView
+{
+ /// <summary>
+ /// Enumeration that provides an option to error codes.
+ /// </summary>
+ public enum LoadErrorCode
+ {
+ /// <summary>
+ /// Unknown
+ /// </summary>
+ Unknown = 0,
+ /// <summary>
+ /// User canceled
+ /// </summary>
+ Canceled,
+ /// <summary>
+ /// Can't show page for this MIME Type
+ /// </summary>
+ CantSupportMimetype,
+ /// <summary>
+ /// File IO error
+ /// </summary>
+ FailedFileIo,
+ /// <summary>
+ /// Cannot connect to network
+ /// </summary>
+ CantConnect,
+ /// <summary>
+ /// Fail to look up host from DNS
+ /// </summary>
+ CantLookupHost,
+ /// <summary>
+ /// Fail to SSL/TLS handshake
+ /// </summary>
+ FailedTlsHandshake,
+ /// <summary>
+ /// Received certificate is invalid
+ /// </summary>
+ InvalidCertificate,
+ /// <summary>
+ /// Connection timeout
+ /// </summary>
+ RequestTimeout,
+ /// <summary>
+ /// Too many redirects
+ /// </summary>
+ TooManyRedirects,
+ /// <summary>
+ /// Too many requests during this load
+ /// </summary>
+ TooManyRequests,
+ /// <summary>
+ /// Malformed url
+ /// </summary>
+ BadUrl,
+ /// <summary>
+ /// Unsupported scheme
+ /// </summary>
+ UnsupportedScheme,
+ /// <summary>
+ /// User authentication failed on server
+ /// </summary>
+ Authentication,
+ /// <summary>
+ /// Web server has internal server error
+ /// </summary>
+ InternalServer,
+ }
+
+ /// <summary>
+ /// Argument from the LoadError SmartCallback.
+ /// </summary>
+ public class SmartCallbackLoadErrorArgs : EventArgs
+ {
+ IntPtr _handle;
+
+ internal SmartCallbackLoadErrorArgs(IntPtr handle)
+ {
+ _handle = handle;
+ }
+
+ /// <summary>
+ /// Failing URL for the error.
+ /// </summary>
+ public string Url
+ {
+ get
+ {
+ return Interop.ChromiumEwk.ewk_error_url_get(_handle);
+ }
+ }
+
+ /// <summary>
+ /// The error code.
+ /// </summary>
+ public LoadErrorCode Code
+ {
+ get
+ {
+ return (LoadErrorCode)Interop.ChromiumEwk.ewk_error_code_get(_handle);
+ }
+ }
+
+ /// <summary>
+ /// The description for the error.
+ /// </summary>
+ public string Description
+ {
+ get
+ {
+ return Interop.ChromiumEwk.ewk_error_description_get(_handle);
+ }
+ }
+
+ /// <summary>
+ /// Whether the error should be treated as a cancellation.
+ /// </summary>
+ public bool Cancellation
+ {
+ get
+ {
+ return Interop.ChromiumEwk.ewk_error_cancellation_get(_handle);
+ }
+ }
+
+ internal static SmartCallbackLoadErrorArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)
+ {
+ return new SmartCallbackLoadErrorArgs(info);
+ }
+ }
+}
diff --git a/Tizen.WebView/Tizen.WebView/WebView.cs b/Tizen.WebView/Tizen.WebView/WebView.cs
new file mode 100644
index 0000000..6b9e751
--- /dev/null
+++ b/Tizen.WebView/Tizen.WebView/WebView.cs
@@ -0,0 +1,342 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using ElmSharp;
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace Tizen.WebView
+{
+ /// <summary>
+ /// A view used to render web contents.
+ /// </summary>
+ public class WebView: EvasObject
+ {
+ private static IDictionary<string, JavaScriptMessageHandler> _javaScriptMessageHandlerMap = new Dictionary<string, JavaScriptMessageHandler>();
+
+ private IntPtr _handle;
+ private IntPtr _realHandle;
+ private Context _context;
+ private Settings _settings;
+
+ // focus dummy
+ private SmartEvent _focusIn;
+ private SmartEvent _focusOut;
+
+ // Smart events
+ private SmartEvent _loadStarted;
+ private SmartEvent _loadFinished;
+ private SmartEvent<SmartCallbackLoadErrorArgs> _loadError;
+ private SmartEvent<SmartCallbackArgs> _titleChanged;
+ private SmartEvent<SmartCallbackArgs> _urlChanged;
+
+
+
+ /// <summary>
+ /// Event that occurs when load started.
+ /// </summary>
+ public event EventHandler LoadStarted;
+
+ /// <summary>
+ /// Event that occurs when load finished.
+ /// </summary>
+ public event EventHandler LoadFinished;
+
+ /// <summary>
+ /// Event that occurs when load error.
+ /// </summary>
+ public event EventHandler<SmartCallbackLoadErrorArgs> LoadError;
+
+ /// <summary>
+ /// Event that occurs when title of main frame was changed.
+ /// </summary>
+ public event EventHandler<SmartCallbackArgs> TitleChanged;
+
+ /// <summary>
+ /// Event that occurs when URL of main frame was changed.
+ /// </summary>
+ public event EventHandler<SmartCallbackArgs> UrlChanged;
+
+ /// <summary>
+ /// Current URL of the main frame.
+ /// </summary>
+ public string Url
+ {
+ get
+ {
+ return Interop.ChromiumEwk.ewk_view_url_get(_realHandle);
+ }
+ }
+
+ /// <summary>
+ /// Current title of the main frame.
+ /// </summary>
+ public string Title
+ {
+ get
+ {
+ return Interop.ChromiumEwk.ewk_view_title_get(_realHandle);
+ }
+ }
+
+ /// <summary>
+ /// Current user agent string of this view.
+ /// </summary>
+ public string UserAgent
+ {
+ get
+ {
+ return Interop.ChromiumEwk.ewk_view_user_agent_get(_realHandle);
+ }
+
+ set
+ {
+ Interop.ChromiumEwk.ewk_view_user_agent_set(_realHandle, value);
+ }
+ }
+
+ /// <summary>
+ /// Whether a view has the focus.
+ /// </summary>
+ public bool HasFocus
+ {
+ get
+ {
+ return Interop.ChromiumEwk.ewk_view_focus_get(_realHandle);
+ }
+ }
+
+ /// <summary>
+ /// Create a WebView object.
+ /// </summary>
+ /// <param name="parent">Parent object of WebView</param>
+ public WebView(EvasObject parent) : base(parent)
+ {
+ InitializeSmartEvent();
+ }
+
+ /// <summary>
+ /// Gets the Context object of this view.
+ /// </summary>
+ /// <returns>The Context object of this view</returns>
+ public Context GetContext()
+ {
+ if (_context == null)
+ {
+ IntPtr contextHandle = Interop.ChromiumEwk.ewk_view_context_get(_realHandle);
+ if (contextHandle == IntPtr.Zero)
+ {
+ return null;
+ }
+ _context = new Context(contextHandle);
+ }
+ return _context;
+ }
+
+ /// <summary>
+ /// Gets the Settings object of this view.
+ /// </summary>
+ /// <returns>The Settings object of this view</returns>
+ public Settings GetSettings()
+ {
+ if (_settings == null)
+ {
+ IntPtr settingsHandle = Interop.ChromiumEwk.ewk_view_settings_get(_realHandle);
+ if (settingsHandle == IntPtr.Zero)
+ {
+ return null;
+ }
+ _settings = new Settings(settingsHandle);
+ }
+ return _settings;
+ }
+
+ /// <summary>
+ /// Asks the object to load the given URL.
+ /// </summary>
+ /// <remarks>
+ /// You can only be sure that url changed after UrlChanged event.
+ /// </remarks>
+ /// <param name="url">The uniform resource identifier to load</param>
+ public void LoadUrl(string url)
+ {
+ Interop.ChromiumEwk.ewk_view_url_set(_realHandle, url);
+ }
+
+ /// <summary>
+ /// Loads the specified html string as the content of the view.
+ /// </summary>
+ /// <param name="html">HTML data to load</param>
+ /// <param name="baseUrl">Base URL used for relative paths to external objects</param>
+ public void LoadHtml(string html, string baseUrl)
+ {
+ Interop.ChromiumEwk.ewk_view_html_string_load(_realHandle, html, baseUrl, null);
+ }
+
+ /// <summary>
+ /// Asks the main frame to stop loading.
+ /// </summary>
+ public void StopLoading()
+ {
+ Interop.ChromiumEwk.ewk_view_stop(_realHandle);
+ }
+
+ /// <summary>
+ /// Asks the main frame to reload the current document.
+ /// </summary>
+ public void Reload()
+ {
+ Interop.ChromiumEwk.ewk_view_reload(_realHandle);
+ }
+
+ /// <summary>
+ /// Asks the main frame to navigate back in history.
+ /// </summary>
+ public void GoBack()
+ {
+ Interop.ChromiumEwk.ewk_view_back(_realHandle);
+ }
+
+ /// <summary>
+ /// Asks the main frame to navigate forward in history.
+ /// </summary>
+ public void GoForward()
+ {
+ Interop.ChromiumEwk.ewk_view_forward(_realHandle);
+ }
+
+ /// <summary>
+ /// Checks whether it is possible to navigate backwards one item in history.
+ /// </summary>
+ /// <returns>Whether it is possible to navigate backwards one item in history</returns>
+ public bool CanGoBack()
+ {
+ return Interop.ChromiumEwk.ewk_view_back_possible(_realHandle);
+ }
+
+ /// <summary>
+ /// Checks whether it is possible to navigate forwards one item in history.
+ /// </summary>
+ /// <returns>Whether it is possible to navigate forwards one item in history</returns>
+ public bool CanGoForward()
+ {
+ return Interop.ChromiumEwk.ewk_view_forward_possible(_realHandle);
+ }
+
+ /// <summary>
+ /// Injects the supplied javascript message handler into the view.
+ /// </summary>
+ /// <param name="name"> The message callback</param>
+ /// <param name="handler">The name used to expose the object in JavaScript</param>
+ /// <returns>'true' on success, otherwise 'false'</returns>
+ public bool AddJavaScriptMessageHandler(string name, JavaScriptMessageHandler handler)
+ {
+ lock (_javaScriptMessageHandlerMap)
+ {
+ if (_javaScriptMessageHandlerMap.ContainsKey(name))
+ {
+ return false;
+ }
+ _javaScriptMessageHandlerMap[name] = handler;
+ }
+ Interop.ChromiumEwk.ScriptMessageCallback callback = (handle, message) =>
+ {
+ JavaScriptMessage convertedMessage = new JavaScriptMessage(message);
+ lock (_javaScriptMessageHandlerMap)
+ {
+ if (_javaScriptMessageHandlerMap.ContainsKey(convertedMessage.Name))
+ {
+ _javaScriptMessageHandlerMap[convertedMessage.Name](convertedMessage);
+ }
+ }
+ };
+ if (!Interop.ChromiumEwk.ewk_view_javascript_message_handler_add(_realHandle, callback, name))
+ {
+ lock (_javaScriptMessageHandlerMap)
+ {
+ _javaScriptMessageHandlerMap.Remove(name);
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /// <summary>
+ /// Requests the execution of given name and result to the JavaScript runtime.
+ /// </summary>
+ /// <param name="name">The name used to expose the object in JavaScript</param>
+ /// <param name="result">The result to the JavaScript runtime</param>
+ public void EvalWithResult(string name, string result)
+ {
+ Interop.ChromiumEwk.ewk_view_evaluate_javascript(_realHandle, name, result);
+ }
+
+ /// <summary>
+ /// Requests the execution of the given script.
+ /// </summary>
+ /// <param name="script">The JavaScript code string to execute</param>
+ public void Eval(string script)
+ {
+ Interop.ChromiumEwk.ewk_view_script_execute(_realHandle, script, null, IntPtr.Zero);
+ }
+
+ /// <summary>
+ /// Requests to set or unset a view as the currently focused one.
+ /// </summary>
+ /// <param name="focused">'true' to set the focus on the view, 'false' to remove the focus from the view</param>
+ public void SetFocus(bool focused)
+ {
+ Interop.ChromiumEwk.ewk_view_focus_set(_realHandle, focused);
+ }
+
+ protected override IntPtr CreateHandle(EvasObject parent)
+ {
+ // focus dummy
+ _handle = Interop.Elementary.elm_layout_add((IntPtr)parent);
+ Interop.Elementary.elm_layout_theme_set(_handle, "layout", "elm_widget", "default");
+ Interop.Elementary.elm_object_focus_allow_set(_handle, true);
+
+ IntPtr evas = Interop.Evas.evas_object_evas_get(parent);
+ _realHandle = Interop.ChromiumEwk.ewk_view_add(evas);
+ Interop.Elementary.elm_object_part_content_set(_handle, "elm.swallow.content", _realHandle);
+
+ return _handle;
+ }
+
+ private void InitializeSmartEvent()
+ {
+ // focus dummy
+ _focusIn = new SmartEvent(this, "focused");
+ _focusOut = new SmartEvent(this, "unfocused");
+
+ _focusIn.On += (s, e) => { ((WebView)s).SetFocus(true); };
+ _focusOut.On += (s, e) => { ((WebView)s).SetFocus(false); };
+
+ _loadStarted = new SmartEvent(this, _realHandle, "load,started");
+ _loadFinished = new SmartEvent(this, _realHandle, "load,finished");
+ _loadError = new SmartEvent<SmartCallbackLoadErrorArgs>(this, _realHandle, "load,error", SmartCallbackLoadErrorArgs.CreateFromSmartEvent);
+ _titleChanged = new SmartEvent<SmartCallbackArgs>(this, _realHandle, "title,changed", SmartCallbackArgs.CreateFromSmartEvent);
+ _urlChanged = new SmartEvent<SmartCallbackArgs>(this, _realHandle, "url,changed", SmartCallbackArgs.CreateFromSmartEvent);
+
+ _loadStarted.On += (s, e) => { LoadStarted?.Invoke(this, EventArgs.Empty); };
+ _loadFinished.On += (s, e) => { LoadFinished?.Invoke(this, EventArgs.Empty); };
+ _loadError.On += (s, e) => { LoadError?.Invoke(this, e); };
+ _titleChanged.On += (s, e) => { TitleChanged?.Invoke(this, e); };
+ _urlChanged.On += (s, e) => { UrlChanged?.Invoke(this, e); };
+ }
+ }
+}