This patch introduces Tizen.WebView project.
Plus, Tizen.WebView.Test project is included in order to test basic
functionality of Tizen.WebView.
Change-Id: I79b01c2c18817f399f83a3e56cc5cd8ceae3322f
Signed-off-by: yh106.jung <yh106.jung@samsung.com>
--- /dev/null
+bin/
+obj/
+*.exe
+*.dll
+*.csproj.user
+*.lock.json
+.vs/
+*sln
--- /dev/null
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+Name: csapi-webview
+Summary: Tizen WebView API for C#
+Version: 1.0.0
+Release: 1
+Group: Development/Libraries
+License: Apache-2.0
+URL: https://www.tizen.org
+Source0: %{name}-%{version}.tar.gz
+Source1: %{name}.manifest
+
+AutoReqProv: no
+ExcludeArch: aarch64
+
+BuildRequires: dotnet-build-tools
+
+# C# API Requires
+BuildRequires: elm-sharp-nuget
+
+%define Assemblies Tizen.WebView
+
+%description
+%{summary}
+
+%dotnet_import_sub_packages
+
+%prep
+%setup -q
+cp %{SOURCE1} .
+
+%build
+for ASM in %{Assemblies}; do
+%dotnet_build $ASM
+%dotnet_pack $ASM/$ASM.nuspec %{version}
+done
+
+%install
+for ASM in %{Assemblies}; do
+%dotnet_install $ASM
+done
+
+%files
+%manifest %{name}.manifest
+%license LICENSE
+%attr(644,root,root) %{dotnet_assembly_files}
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+internal static partial class Interop\r
+{\r
+ internal static partial class ChromiumEwk\r
+ {\r
+ public enum CacheModel\r
+ {\r
+ DocumentViewer,\r
+ DocumentBrowser,\r
+ PrimaryWebBrowser\r
+ }\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ internal static extern IntPtr ewk_context_cookie_manager_get(IntPtr context);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_context_cache_model_set(IntPtr context, CacheModel model);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ internal static extern CacheModel ewk_context_cache_model_get(IntPtr context);\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+internal static partial class Interop\r
+{\r
+ internal static partial class ChromiumEwk\r
+ {\r
+ public enum CookieAcceptPolicy\r
+ {\r
+ Always,\r
+ Never,\r
+ NoThirdParty\r
+ }\r
+\r
+ public enum CookiePersistentStorage\r
+ {\r
+ Text,\r
+ SqlLite\r
+ }\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ internal static extern void ewk_cookie_manager_accept_policy_set(IntPtr manager, CookieAcceptPolicy policy);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ internal static extern void ewk_cookie_manager_cookies_clear(IntPtr manager);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ internal static extern void ewk_cookie_manager_persistent_storage_set(IntPtr manager, string path, CookiePersistentStorage storage);\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+internal static partial class Interop\r
+{\r
+ internal static partial class ChromiumEwk\r
+ {\r
+ [DllImport(Libraries.ChromiumEwk, EntryPoint = "ewk_error_url_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, CharSet = CharSet.Ansi)]\r
+ internal static extern IntPtr _ewk_error_url_get(IntPtr error);\r
+\r
+ internal static string ewk_error_url_get(IntPtr error)\r
+ {\r
+ IntPtr ptr = _ewk_error_url_get(error);\r
+ return Marshal.PtrToStringAnsi(ptr);\r
+ }\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ internal static extern int ewk_error_code_get(IntPtr error);\r
+\r
+ [DllImport(Libraries.ChromiumEwk, EntryPoint = "ewk_error_description_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, CharSet = CharSet.Ansi)]\r
+ internal static extern IntPtr _ewk_error_description_get(IntPtr error);\r
+\r
+ internal static string ewk_error_description_get(IntPtr error)\r
+ {\r
+ IntPtr ptr = _ewk_error_description_get(error);\r
+ return Marshal.PtrToStringAnsi(ptr);\r
+ }\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_error_cancellation_get(IntPtr error);\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+internal static partial class Interop\r
+{\r
+ internal static partial class ChromiumEwk\r
+ {\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_settings_javascript_enabled_set(IntPtr settings, bool enable);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_settings_javascript_enabled_get(IntPtr settings);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_settings_loads_images_automatically_set(IntPtr settings, bool enable);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_settings_loads_images_automatically_get(IntPtr settings);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_settings_default_text_encoding_name_set(IntPtr settings, string encoding);\r
+\r
+ [DllImport(Libraries.ChromiumEwk, EntryPoint = "ewk_settings_default_text_encoding_name_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, CharSet = CharSet.Ansi)]\r
+ internal static extern IntPtr _ewk_settings_default_text_encoding_name_get(IntPtr settings);\r
+\r
+ internal static string ewk_settings_default_text_encoding_name_get(IntPtr settings)\r
+ {\r
+ IntPtr ptr = _ewk_settings_default_text_encoding_name_get(settings);\r
+ return Marshal.PtrToStringAnsi(ptr);\r
+ }\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_settings_default_font_size_set(IntPtr settings, int size);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ internal static extern int ewk_settings_default_font_size_get(IntPtr settings);\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+internal static partial class Interop\r
+{\r
+ internal static partial class ChromiumEwk\r
+ {\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ internal static extern IntPtr ewk_view_add(IntPtr evas);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ internal static extern IntPtr ewk_view_context_get(IntPtr obj);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ internal static extern IntPtr ewk_view_settings_get(IntPtr obj);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_view_url_set(IntPtr obj, string url);\r
+\r
+ [DllImport(Libraries.ChromiumEwk, EntryPoint = "ewk_view_url_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, CharSet = CharSet.Ansi)]\r
+ internal static extern IntPtr _ewk_view_url_get(IntPtr obj);\r
+\r
+ internal static string ewk_view_url_get(IntPtr obj)\r
+ {\r
+ IntPtr ptr = _ewk_view_url_get(obj);\r
+ return Marshal.PtrToStringAnsi(ptr);\r
+ }\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_view_html_string_load(IntPtr obj, string html, string baseUrl, string unreachableUrl);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_view_reload(IntPtr obj);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_view_stop(IntPtr obj);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_view_back(IntPtr obj);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_view_forward(IntPtr obj);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_view_back_possible(IntPtr obj);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_view_forward_possible(IntPtr obj);\r
+\r
+ internal delegate void ScriptExcuteCallback(IntPtr obj, IntPtr resultValue, IntPtr userData);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_view_script_execute(IntPtr obj, string script, ScriptExcuteCallback callback, IntPtr userData);\r
+\r
+ [DllImport(Libraries.ChromiumEwk, EntryPoint = "ewk_view_title_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, CharSet = CharSet.Ansi)]\r
+ internal static extern IntPtr _ewk_view_title_get(IntPtr obj);\r
+\r
+ internal static string ewk_view_title_get(IntPtr obj)\r
+ {\r
+ IntPtr ptr = _ewk_view_url_get(obj);\r
+ return Marshal.PtrToStringAnsi(ptr);\r
+ }\r
+\r
+ [DllImport(Libraries.ChromiumEwk, EntryPoint = "ewk_view_user_agent_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, CharSet = CharSet.Ansi)]\r
+ internal static extern IntPtr _ewk_view_user_agent_get(IntPtr obj);\r
+\r
+ internal static string ewk_view_user_agent_get(IntPtr obj)\r
+ {\r
+ IntPtr ptr = _ewk_view_user_agent_get(obj);\r
+ return Marshal.PtrToStringAnsi(ptr);\r
+ }\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_view_user_agent_set(IntPtr obj, string userAgent);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_view_focus_set(IntPtr obj, bool focused);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_view_focus_get(IntPtr obj);\r
+\r
+ [StructLayout(LayoutKind.Sequential, CharSet =CharSet.Ansi)]\r
+ internal struct ScriptMessage\r
+ {\r
+ public IntPtr name;\r
+ public IntPtr body;\r
+ }\r
+\r
+ internal delegate void ScriptMessageCallback(IntPtr obj, ScriptMessage message);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_view_javascript_message_handler_add(IntPtr obj, ScriptMessageCallback callback, string name);\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool ewk_view_evaluate_javascript(IntPtr obj, string name, string result);\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+internal static partial class Interop\r
+{\r
+ internal static partial class ChromiumEwk\r
+ {\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ internal static extern int ewk_init();\r
+\r
+ [DllImport(Libraries.ChromiumEwk)]\r
+ internal static extern int ewk_shutdown();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+internal static partial class Interop\r
+{\r
+ internal static partial class Elementary\r
+ {\r
+ [DllImport(Libraries.Elementary)]\r
+ internal static extern IntPtr elm_layout_add(IntPtr obj);\r
+\r
+ [DllImport(Libraries.Elementary)]\r
+ [return: MarshalAs(UnmanagedType.U1)]\r
+ internal static extern bool elm_layout_theme_set(IntPtr obj, string klass, string group, string style);\r
+\r
+ [DllImport(Libraries.Elementary)]\r
+ internal static extern void elm_object_part_content_set(IntPtr obj, string part, IntPtr content);\r
+\r
+ [DllImport(Libraries.Elementary)]\r
+ internal static extern void elm_object_focus_allow_set(IntPtr obj, bool enable);\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+internal static partial class Interop\r
+{\r
+ internal static partial class Evas\r
+ {\r
+ [DllImport(Libraries.Evas)]\r
+ internal static extern IntPtr evas_object_evas_get(IntPtr obj);\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+internal static partial class Interop\r
+{\r
+ private static class Libraries\r
+ {\r
+ internal const string ChromiumEwk = "libchromium-ewk.so";\r
+ internal const string Elementary = "libelementary.so.1";\r
+ internal const string Evas = "libevas.so.1";\r
+ }\r
+}\r
--- /dev/null
+using System.Reflection;\r
+using System.Runtime.CompilerServices;\r
+using System.Runtime.InteropServices;\r
+\r
+// General Information about an assembly is controlled through the following\r
+// set of attributes. Change these attribute values to modify the information\r
+// associated with an assembly.\r
+[assembly: AssemblyTitle("Tizen.WebView")]\r
+[assembly: AssemblyDescription("")]\r
+[assembly: AssemblyConfiguration("")]\r
+[assembly: AssemblyCompany("Samsung Electronics")]\r
+[assembly: AssemblyProduct("Tizen.WebView")]\r
+[assembly: AssemblyCopyright("Copyright © Samsung Electronics 2017")]\r
+[assembly: AssemblyTrademark("")]\r
+[assembly: AssemblyCulture("")]\r
+\r
+// Setting ComVisible to false makes the types in this assembly not visible\r
+// to COM components. If you need to access a type in this assembly from\r
+// COM, set the ComVisible attribute to true on that type.\r
+[assembly: ComVisible(false)]\r
+\r
+// The following GUID is for the ID of the typelib if this project is exposed to COM\r
+[assembly: Guid("8405e84f-b920-4aac-9ad5-001b9debc9ca")]\r
+\r
+// Version information for an assembly consists of the following four values:\r
+//\r
+// Major Version\r
+// Minor Version\r
+// Build Number\r
+// Revision\r
+//\r
+// You can specify all the values or you can default the Build and Revision Numbers\r
+// by using the '*' as shown below:\r
+// [assembly: AssemblyVersion("1.0.*")]\r
+[assembly: AssemblyVersion("1.0.0.0")]\r
+[assembly: AssemblyFileVersion("1.0.0.0")]\r
--- /dev/null
+<?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>
--- /dev/null
+<?xml version="1.0"?>\r
+<package >\r
+ <metadata>\r
+ <id>Tizen.WebView</id>\r
+ <version>$version$</version>\r
+ <authors>Samsung Electronics</authors>\r
+ <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>\r
+ <iconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</iconUrl>\r
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>\r
+ <description>Tizen WebView API for C#</description>\r
+ <copyright>© Samsung Electronics Co., Ltd All Rights Reserved</copyright>\r
+ <dependencies>\r
+ <dependency id="ElmSharp" version="1.1.0" />\r
+ </dependencies>\r
+ </metadata>\r
+ <files>\r
+ <file src="bin/$Configuration$/Tizen.WebView.dll" target="lib/netstandard1.3" />\r
+ </files>\r
+</package>\r
--- /dev/null
+{
+ "dependencies": {
+ "ElmSharp": "1.1.0-*",
+ "NETStandard.Library": "1.6.0"
+ },
+ "frameworks": {
+ "netstandard1.3": {}
+ }
+}
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+namespace Tizen.WebView\r
+{\r
+ public static class Chromium\r
+ {\r
+ /// <summary>\r
+ /// Initializes Chromium's instance\r
+ /// </summary>\r
+ /// <returns>A reference count of Chromium's instance</returns>\r
+ public static int Initialize()\r
+ {\r
+ return Interop.ChromiumEwk.ewk_init();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Decreases a reference count of WebKit's instance, possibly destroying it\r
+ /// </summary>\r
+ /// <returns>A reference count of Chromium's instance</returns>\r
+ public static int Shutdown()\r
+ {\r
+ return Interop.ChromiumEwk.ewk_shutdown();\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+using System;\r
+\r
+namespace Tizen.WebView\r
+{\r
+ /// <summary>\r
+ /// Enumeration that contains option for cache model.\r
+ /// </summary>\r
+ public enum CacheModel\r
+ {\r
+ DocumentViewer, /* Use the smallest cache capacity */\r
+ DocumentBrowser, /* Use bigger cache capacity than DocumentBrowser */\r
+ PrimaryWebBrowser /* Use the biggest cache capacity. */\r
+ }\r
+\r
+ public class Context\r
+ {\r
+ private IntPtr _handle;\r
+ private CookieManager _cookieManager;\r
+\r
+ internal Context(IntPtr handle)\r
+ {\r
+ _handle = handle;\r
+ }\r
+\r
+ /// <summary>\r
+ /// The cache model.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// The default cache model is DocumentViewer.\r
+ /// </remarks>\r
+ public CacheModel CacheModel\r
+ {\r
+ get\r
+ {\r
+ return (CacheModel)Interop.ChromiumEwk.ewk_context_cache_model_get(_handle);\r
+ }\r
+\r
+ set\r
+ {\r
+ Interop.ChromiumEwk.ewk_context_cache_model_set(_handle, (Interop.ChromiumEwk.CacheModel)value);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the CookieManager object for this context.\r
+ /// </summary>\r
+ /// <returns>The CookieManager object</returns>\r
+ public CookieManager GetCookieManager()\r
+ {\r
+ if (_cookieManager == null)\r
+ {\r
+ IntPtr cookieManagerHandle = Interop.ChromiumEwk.ewk_context_cookie_manager_get(_handle);\r
+ if (cookieManagerHandle == IntPtr.Zero)\r
+ {\r
+ return null;\r
+ }\r
+ _cookieManager = new CookieManager(cookieManagerHandle);\r
+ }\r
+ return _cookieManager;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+using System;\r
+\r
+namespace Tizen.WebView\r
+{\r
+ /// <summary>\r
+ /// Enumeration that contains accept policies for the cookies.\r
+ /// </summary>\r
+ public enum CookieAcceptPolicy\r
+ {\r
+ Always, /* Accepts every cookie sent from any page */\r
+ Never, /* Rejects all cookies */\r
+ NoThirdParty /* Accepts only cookies set by the main document loaded */\r
+ }\r
+\r
+ /// <summary>\r
+ /// Enumeration that creates a type name for the storage of persistent cookies.\r
+ /// </summary>\r
+ public enum CookiePersistentStorage\r
+ {\r
+ Text, /* Cookies are stored in a text file in the Mozilla "cookies.txt" format */\r
+ SqlLite /* Cookies are stored in a SQLite file in the current Mozilla format. */\r
+ }\r
+\r
+ public class CookieManager\r
+ {\r
+ private IntPtr _handle;\r
+\r
+ internal CookieManager(IntPtr handle)\r
+ {\r
+ _handle = handle;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Sets the cookie acceptance policy.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// By default, only cookies set by the main document loaded are accepted.\r
+ /// </remarks>\r
+ /// <param name="policy">The cookie acceptance policy</param>\r
+ public void SetCookieAcceptPolicy(CookieAcceptPolicy policy)\r
+ {\r
+ Interop.ChromiumEwk.ewk_cookie_manager_accept_policy_set(_handle, (Interop.ChromiumEwk.CookieAcceptPolicy)policy);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Deletes all the cookies.\r
+ /// </summary>\r
+ public void ClearCookies()\r
+ {\r
+ Interop.ChromiumEwk.ewk_cookie_manager_cookies_clear(_handle);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Sets the storage where non-session cookies are stored persistently to read/write the cookies.\r
+ /// </summary>\r
+ ///<privilege>\r
+ /// http://tizen.org/privilege/mediastorage\r
+ /// http://tizen.org/privilege/externalstorage\r
+ /// </privilege>\r
+ /// <param name="path">The path where to read/write Cookies</param>\r
+ /// <param name="storage">The type of storage</param>\r
+ public void SetPersistentStorage(string path, CookiePersistentStorage storage)\r
+ {\r
+ Interop.ChromiumEwk.ewk_cookie_manager_persistent_storage_set(_handle, path, (Interop.ChromiumEwk.CookiePersistentStorage)storage);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+using System.Text;\r
+\r
+namespace Tizen.WebView\r
+{\r
+ public delegate void JavaScriptMessageHandler(JavaScriptMessage message);\r
+\r
+ /// <summary>\r
+ /// A Script message contains information that sent from JavaScript runtime.\r
+ /// </summary>\r
+ public class JavaScriptMessage\r
+ {\r
+ private string _name;\r
+ private IntPtr _body;\r
+\r
+ internal JavaScriptMessage(Interop.ChromiumEwk.ScriptMessage message)\r
+ {\r
+ _name = Marshal.PtrToStringAnsi(message.name);\r
+ _body = message.body;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Obect name in JavaScript.\r
+ /// </summary>\r
+ public string Name\r
+ {\r
+ get\r
+ {\r
+ return _name;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the value of body as integer type.\r
+ /// </summary>\r
+ /// <returns>The value of body as integer type</returns>\r
+ public int GetBodyAsInteger()\r
+ {\r
+ if (_body == IntPtr.Zero)\r
+ {\r
+ return 0;\r
+ }\r
+ return Marshal.ReadInt32(_body, 0);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the value of body as double type.\r
+ /// </summary>\r
+ /// <returns>The value of body as double type</returns>\r
+ public double GetBodyAsDouble()\r
+ {\r
+ if (_body == IntPtr.Zero)\r
+ {\r
+ return 0d;\r
+ }\r
+ double[] ret = new double[1] ;\r
+ Marshal.Copy(_body, ret, 0, 1);\r
+ return ret[0];\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the value of body as boolean type.\r
+ /// </summary>\r
+ /// <returns>The value of body as boolean type</returns>\r
+ public bool GetBodyAsBoolean()\r
+ {\r
+ if (_body == IntPtr.Zero)\r
+ {\r
+ return false;\r
+ }\r
+ return Marshal.ReadByte(_body) != (byte)0;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the value of body as string type.\r
+ /// </summary>\r
+ /// <returns>The value of body as string type</returns>\r
+ public string GetBodyAsString()\r
+ {\r
+ if (_body == IntPtr.Zero)\r
+ {\r
+ return string.Empty;\r
+ }\r
+ return Marshal.PtrToStringAnsi(_body);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+using System;\r
+\r
+namespace Tizen.WebView\r
+{\r
+ public class Settings\r
+ {\r
+ private IntPtr _handle;\r
+\r
+ internal Settings(IntPtr handle)\r
+ {\r
+ _handle = handle;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Whether JavaScript can be executable.\r
+ /// </summary>\r
+ public bool JavaScriptEnabled\r
+ {\r
+ get\r
+ {\r
+ return Interop.ChromiumEwk.ewk_settings_javascript_enabled_get(_handle);\r
+ }\r
+\r
+ set\r
+ {\r
+ Interop.ChromiumEwk.ewk_settings_javascript_enabled_set(_handle, value);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Whether images can be loaded automatically.\r
+ /// </summary>\r
+ public bool LoadImageAutomatically\r
+ {\r
+ get\r
+ {\r
+ return Interop.ChromiumEwk.ewk_settings_loads_images_automatically_get(_handle);\r
+ }\r
+\r
+ set\r
+ {\r
+ Interop.ChromiumEwk.ewk_settings_loads_images_automatically_set(_handle, value);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// The default text encoding name.\r
+ /// </summary>\r
+ public string DefaultTextEncodingName\r
+ {\r
+ get\r
+ {\r
+ return Interop.ChromiumEwk.ewk_settings_default_text_encoding_name_get(_handle);\r
+ }\r
+\r
+ set\r
+ {\r
+ Interop.ChromiumEwk.ewk_settings_default_text_encoding_name_set(_handle, value);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// The default font size of a pixel.\r
+ /// </summary>\r
+ public int DefaultFontSize\r
+ {\r
+ get\r
+ {\r
+ return Interop.ChromiumEwk.ewk_settings_default_font_size_get(_handle);\r
+ }\r
+\r
+ set\r
+ {\r
+ Interop.ChromiumEwk.ewk_settings_default_font_size_set(_handle, value);\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace Tizen.WebView\r
+{\r
+ /// <summary>\r
+ /// Argument from the SmartCallback.\r
+ /// </summary>\r
+ public class SmartCallbackArgs : EventArgs\r
+ {\r
+ private IntPtr _arg;\r
+\r
+ internal SmartCallbackArgs(IntPtr arg)\r
+ {\r
+ _arg = arg;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets argument as integer type.\r
+ /// </summary>\r
+ /// <returns>Argument as integer type</returns>\r
+ public int GetAsInteger()\r
+ {\r
+ if (_arg == IntPtr.Zero)\r
+ {\r
+ return 0;\r
+ }\r
+ return Marshal.ReadInt32(_arg, 0);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets argument as double type.\r
+ /// </summary>\r
+ /// <returns>Argument as double type</returns>\r
+ public double GetAsDouble()\r
+ {\r
+ if (_arg == IntPtr.Zero)\r
+ {\r
+ return 0d;\r
+ }\r
+ double[] ret = new double[1];\r
+ Marshal.Copy(_arg, ret, 0, 1);\r
+ return ret[0];\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets argument as boolean type.\r
+ /// </summary>\r
+ /// <returns>Argument as boolean type</returns>\r
+ public bool GetAsBoolean()\r
+ {\r
+ if (_arg == IntPtr.Zero)\r
+ {\r
+ return false;\r
+ }\r
+ return Marshal.ReadByte(_arg) != (byte)0;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets argument as string type.\r
+ /// </summary>\r
+ /// <returns>Argument as string type</returns>\r
+ public string GetAsString()\r
+ {\r
+ if (_arg == IntPtr.Zero)\r
+ {\r
+ return string.Empty;\r
+ }\r
+ return Marshal.PtrToStringAnsi(_arg);\r
+ }\r
+\r
+ internal static SmartCallbackArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)\r
+ {\r
+ return new SmartCallbackArgs(info);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace Tizen.WebView\r
+{\r
+ /// <summary>\r
+ /// Enumeration that provides an option to error codes.\r
+ /// </summary>\r
+ public enum LoadErrorCode\r
+ {\r
+ /// <summary>\r
+ /// Unknown\r
+ /// </summary>\r
+ Unknown = 0,\r
+ /// <summary>\r
+ /// User canceled\r
+ /// </summary>\r
+ Canceled,\r
+ /// <summary>\r
+ /// Can't show page for this MIME Type\r
+ /// </summary>\r
+ CantSupportMimetype,\r
+ /// <summary>\r
+ /// File IO error\r
+ /// </summary>\r
+ FailedFileIo,\r
+ /// <summary>\r
+ /// Cannot connect to network\r
+ /// </summary>\r
+ CantConnect,\r
+ /// <summary>\r
+ /// Fail to look up host from DNS\r
+ /// </summary>\r
+ CantLookupHost,\r
+ /// <summary>\r
+ /// Fail to SSL/TLS handshake\r
+ /// </summary>\r
+ FailedTlsHandshake,\r
+ /// <summary>\r
+ /// Received certificate is invalid\r
+ /// </summary>\r
+ InvalidCertificate,\r
+ /// <summary>\r
+ /// Connection timeout\r
+ /// </summary>\r
+ RequestTimeout,\r
+ /// <summary>\r
+ /// Too many redirects\r
+ /// </summary>\r
+ TooManyRedirects,\r
+ /// <summary>\r
+ /// Too many requests during this load\r
+ /// </summary>\r
+ TooManyRequests,\r
+ /// <summary>\r
+ /// Malformed url\r
+ /// </summary>\r
+ BadUrl,\r
+ /// <summary>\r
+ /// Unsupported scheme\r
+ /// </summary>\r
+ UnsupportedScheme,\r
+ /// <summary>\r
+ /// User authentication failed on server\r
+ /// </summary>\r
+ Authentication,\r
+ /// <summary>\r
+ /// Web server has internal server error\r
+ /// </summary>\r
+ InternalServer,\r
+ }\r
+\r
+ /// <summary>\r
+ /// Argument from the LoadError SmartCallback.\r
+ /// </summary>\r
+ public class SmartCallbackLoadErrorArgs : EventArgs\r
+ {\r
+ IntPtr _handle;\r
+\r
+ internal SmartCallbackLoadErrorArgs(IntPtr handle)\r
+ {\r
+ _handle = handle;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Failing URL for the error.\r
+ /// </summary>\r
+ public string Url\r
+ {\r
+ get\r
+ {\r
+ return Interop.ChromiumEwk.ewk_error_url_get(_handle);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// The error code.\r
+ /// </summary>\r
+ public LoadErrorCode Code\r
+ {\r
+ get\r
+ {\r
+ return (LoadErrorCode)Interop.ChromiumEwk.ewk_error_code_get(_handle);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// The description for the error.\r
+ /// </summary>\r
+ public string Description\r
+ {\r
+ get\r
+ {\r
+ return Interop.ChromiumEwk.ewk_error_description_get(_handle);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Whether the error should be treated as a cancellation.\r
+ /// </summary>\r
+ public bool Cancellation\r
+ {\r
+ get\r
+ {\r
+ return Interop.ChromiumEwk.ewk_error_cancellation_get(_handle);\r
+ }\r
+ }\r
+\r
+ internal static SmartCallbackLoadErrorArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)\r
+ {\r
+ return new SmartCallbackLoadErrorArgs(info);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+using ElmSharp;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace Tizen.WebView\r
+{\r
+ /// <summary>\r
+ /// A view used to render web contents.\r
+ /// </summary>\r
+ public class WebView: EvasObject\r
+ {\r
+ private static IDictionary<string, JavaScriptMessageHandler> _javaScriptMessageHandlerMap = new Dictionary<string, JavaScriptMessageHandler>();\r
+\r
+ private IntPtr _handle;\r
+ private IntPtr _realHandle;\r
+ private Context _context;\r
+ private Settings _settings;\r
+\r
+ // focus dummy\r
+ private SmartEvent _focusIn;\r
+ private SmartEvent _focusOut;\r
+\r
+ // Smart events\r
+ private SmartEvent _loadStarted;\r
+ private SmartEvent _loadFinished;\r
+ private SmartEvent<SmartCallbackLoadErrorArgs> _loadError;\r
+ private SmartEvent<SmartCallbackArgs> _titleChanged;\r
+ private SmartEvent<SmartCallbackArgs> _urlChanged;\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Event that occurs when load started.\r
+ /// </summary>\r
+ public event EventHandler LoadStarted;\r
+\r
+ /// <summary>\r
+ /// Event that occurs when load finished.\r
+ /// </summary>\r
+ public event EventHandler LoadFinished;\r
+\r
+ /// <summary>\r
+ /// Event that occurs when load error.\r
+ /// </summary>\r
+ public event EventHandler<SmartCallbackLoadErrorArgs> LoadError;\r
+\r
+ /// <summary>\r
+ /// Event that occurs when title of main frame was changed.\r
+ /// </summary>\r
+ public event EventHandler<SmartCallbackArgs> TitleChanged;\r
+\r
+ /// <summary>\r
+ /// Event that occurs when URL of main frame was changed.\r
+ /// </summary>\r
+ public event EventHandler<SmartCallbackArgs> UrlChanged;\r
+\r
+ /// <summary>\r
+ /// Current URL of the main frame.\r
+ /// </summary>\r
+ public string Url\r
+ {\r
+ get\r
+ {\r
+ return Interop.ChromiumEwk.ewk_view_url_get(_realHandle);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Current title of the main frame.\r
+ /// </summary>\r
+ public string Title\r
+ {\r
+ get\r
+ {\r
+ return Interop.ChromiumEwk.ewk_view_title_get(_realHandle);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Current user agent string of this view.\r
+ /// </summary>\r
+ public string UserAgent\r
+ {\r
+ get\r
+ {\r
+ return Interop.ChromiumEwk.ewk_view_user_agent_get(_realHandle);\r
+ }\r
+\r
+ set\r
+ {\r
+ Interop.ChromiumEwk.ewk_view_user_agent_set(_realHandle, value);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Whether a view has the focus.\r
+ /// </summary>\r
+ public bool HasFocus\r
+ {\r
+ get\r
+ {\r
+ return Interop.ChromiumEwk.ewk_view_focus_get(_realHandle);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Create a WebView object.\r
+ /// </summary>\r
+ /// <param name="parent">Parent object of WebView</param>\r
+ public WebView(EvasObject parent) : base(parent)\r
+ {\r
+ InitializeSmartEvent();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the Context object of this view.\r
+ /// </summary>\r
+ /// <returns>The Context object of this view</returns>\r
+ public Context GetContext()\r
+ {\r
+ if (_context == null)\r
+ {\r
+ IntPtr contextHandle = Interop.ChromiumEwk.ewk_view_context_get(_realHandle);\r
+ if (contextHandle == IntPtr.Zero)\r
+ {\r
+ return null;\r
+ }\r
+ _context = new Context(contextHandle);\r
+ }\r
+ return _context;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the Settings object of this view.\r
+ /// </summary>\r
+ /// <returns>The Settings object of this view</returns>\r
+ public Settings GetSettings()\r
+ {\r
+ if (_settings == null)\r
+ {\r
+ IntPtr settingsHandle = Interop.ChromiumEwk.ewk_view_settings_get(_realHandle);\r
+ if (settingsHandle == IntPtr.Zero)\r
+ {\r
+ return null;\r
+ }\r
+ _settings = new Settings(settingsHandle);\r
+ }\r
+ return _settings;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Asks the object to load the given URL.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// You can only be sure that url changed after UrlChanged event.\r
+ /// </remarks>\r
+ /// <param name="url">The uniform resource identifier to load</param>\r
+ public void LoadUrl(string url)\r
+ {\r
+ Interop.ChromiumEwk.ewk_view_url_set(_realHandle, url);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Loads the specified html string as the content of the view.\r
+ /// </summary>\r
+ /// <param name="html">HTML data to load</param>\r
+ /// <param name="baseUrl">Base URL used for relative paths to external objects</param>\r
+ public void LoadHtml(string html, string baseUrl)\r
+ {\r
+ Interop.ChromiumEwk.ewk_view_html_string_load(_realHandle, html, baseUrl, null);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Asks the main frame to stop loading.\r
+ /// </summary>\r
+ public void StopLoading()\r
+ {\r
+ Interop.ChromiumEwk.ewk_view_stop(_realHandle);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Asks the main frame to reload the current document.\r
+ /// </summary>\r
+ public void Reload()\r
+ {\r
+ Interop.ChromiumEwk.ewk_view_reload(_realHandle);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Asks the main frame to navigate back in history.\r
+ /// </summary>\r
+ public void GoBack()\r
+ {\r
+ Interop.ChromiumEwk.ewk_view_back(_realHandle);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Asks the main frame to navigate forward in history.\r
+ /// </summary>\r
+ public void GoForward()\r
+ {\r
+ Interop.ChromiumEwk.ewk_view_forward(_realHandle);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Checks whether it is possible to navigate backwards one item in history.\r
+ /// </summary>\r
+ /// <returns>Whether it is possible to navigate backwards one item in history</returns>\r
+ public bool CanGoBack()\r
+ {\r
+ return Interop.ChromiumEwk.ewk_view_back_possible(_realHandle);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Checks whether it is possible to navigate forwards one item in history.\r
+ /// </summary>\r
+ /// <returns>Whether it is possible to navigate forwards one item in history</returns>\r
+ public bool CanGoForward()\r
+ {\r
+ return Interop.ChromiumEwk.ewk_view_forward_possible(_realHandle);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Injects the supplied javascript message handler into the view.\r
+ /// </summary>\r
+ /// <param name="name"> The message callback</param>\r
+ /// <param name="handler">The name used to expose the object in JavaScript</param>\r
+ /// <returns>'true' on success, otherwise 'false'</returns>\r
+ public bool AddJavaScriptMessageHandler(string name, JavaScriptMessageHandler handler)\r
+ {\r
+ lock (_javaScriptMessageHandlerMap)\r
+ {\r
+ if (_javaScriptMessageHandlerMap.ContainsKey(name))\r
+ {\r
+ return false;\r
+ }\r
+ _javaScriptMessageHandlerMap[name] = handler;\r
+ }\r
+ Interop.ChromiumEwk.ScriptMessageCallback callback = (handle, message) =>\r
+ {\r
+ JavaScriptMessage convertedMessage = new JavaScriptMessage(message);\r
+ lock (_javaScriptMessageHandlerMap)\r
+ {\r
+ if (_javaScriptMessageHandlerMap.ContainsKey(convertedMessage.Name))\r
+ {\r
+ _javaScriptMessageHandlerMap[convertedMessage.Name](convertedMessage);\r
+ }\r
+ }\r
+ };\r
+ if (!Interop.ChromiumEwk.ewk_view_javascript_message_handler_add(_realHandle, callback, name))\r
+ {\r
+ lock (_javaScriptMessageHandlerMap)\r
+ {\r
+ _javaScriptMessageHandlerMap.Remove(name);\r
+ return false;\r
+ }\r
+ }\r
+ return true;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Requests the execution of given name and result to the JavaScript runtime.\r
+ /// </summary>\r
+ /// <param name="name">The name used to expose the object in JavaScript</param>\r
+ /// <param name="result">The result to the JavaScript runtime</param>\r
+ public void EvalWithResult(string name, string result)\r
+ {\r
+ Interop.ChromiumEwk.ewk_view_evaluate_javascript(_realHandle, name, result);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Requests the execution of the given script.\r
+ /// </summary>\r
+ /// <param name="script">The JavaScript code string to execute</param>\r
+ public void Eval(string script)\r
+ {\r
+ Interop.ChromiumEwk.ewk_view_script_execute(_realHandle, script, null, IntPtr.Zero);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Requests to set or unset a view as the currently focused one.\r
+ /// </summary>\r
+ /// <param name="focused">'true' to set the focus on the view, 'false' to remove the focus from the view</param>\r
+ public void SetFocus(bool focused)\r
+ {\r
+ Interop.ChromiumEwk.ewk_view_focus_set(_realHandle, focused);\r
+ }\r
+\r
+ protected override IntPtr CreateHandle(EvasObject parent)\r
+ {\r
+ // focus dummy\r
+ _handle = Interop.Elementary.elm_layout_add((IntPtr)parent);\r
+ Interop.Elementary.elm_layout_theme_set(_handle, "layout", "elm_widget", "default");\r
+ Interop.Elementary.elm_object_focus_allow_set(_handle, true);\r
+\r
+ IntPtr evas = Interop.Evas.evas_object_evas_get(parent);\r
+ _realHandle = Interop.ChromiumEwk.ewk_view_add(evas);\r
+ Interop.Elementary.elm_object_part_content_set(_handle, "elm.swallow.content", _realHandle);\r
+\r
+ return _handle;\r
+ }\r
+\r
+ private void InitializeSmartEvent()\r
+ {\r
+ // focus dummy\r
+ _focusIn = new SmartEvent(this, "focused");\r
+ _focusOut = new SmartEvent(this, "unfocused");\r
+\r
+ _focusIn.On += (s, e) => { ((WebView)s).SetFocus(true); };\r
+ _focusOut.On += (s, e) => { ((WebView)s).SetFocus(false); };\r
+\r
+ _loadStarted = new SmartEvent(this, _realHandle, "load,started");\r
+ _loadFinished = new SmartEvent(this, _realHandle, "load,finished");\r
+ _loadError = new SmartEvent<SmartCallbackLoadErrorArgs>(this, _realHandle, "load,error", SmartCallbackLoadErrorArgs.CreateFromSmartEvent);\r
+ _titleChanged = new SmartEvent<SmartCallbackArgs>(this, _realHandle, "title,changed", SmartCallbackArgs.CreateFromSmartEvent);\r
+ _urlChanged = new SmartEvent<SmartCallbackArgs>(this, _realHandle, "url,changed", SmartCallbackArgs.CreateFromSmartEvent);\r
+\r
+ _loadStarted.On += (s, e) => { LoadStarted?.Invoke(this, EventArgs.Empty); };\r
+ _loadFinished.On += (s, e) => { LoadFinished?.Invoke(this, EventArgs.Empty); };\r
+ _loadError.On += (s, e) => { LoadError?.Invoke(this, e); };\r
+ _titleChanged.On += (s, e) => { TitleChanged?.Invoke(this, e); };\r
+ _urlChanged.On += (s, e) => { UrlChanged?.Invoke(this, e); };\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using System.Reflection;\r
+using System.Runtime.CompilerServices;\r
+using System.Runtime.InteropServices;\r
+\r
+// General Information about an assembly is controlled through the following\r
+// set of attributes. Change these attribute values to modify the information\r
+// associated with an assembly.\r
+[assembly: AssemblyTitle("Tizen.WebView.Test")]\r
+[assembly: AssemblyDescription("")]\r
+[assembly: AssemblyConfiguration("")]\r
+[assembly: AssemblyCompany("Samsung Electronics")]\r
+[assembly: AssemblyProduct("Tizen.WebView.Test")]\r
+[assembly: AssemblyCopyright("Copyright © Samsung Electronics 2017")]\r
+[assembly: AssemblyTrademark("")]\r
+[assembly: AssemblyCulture("")]\r
+\r
+// Setting ComVisible to false makes the types in this assembly not visible\r
+// to COM components. If you need to access a type in this assembly from\r
+// COM, set the ComVisible attribute to true on that type.\r
+[assembly: ComVisible(false)]\r
+\r
+// The following GUID is for the ID of the typelib if this project is exposed to COM\r
+[assembly: Guid("b57dafa3-b566-4ebf-a6f0-ecd2224a748d")]\r
+\r
+// Version information for an assembly consists of the following four values:\r
+//\r
+// Major Version\r
+// Minor Version\r
+// Build Number\r
+// Revision\r
+//\r
+// You can specify all the values or you can default the Build and Revision Numbers\r
+// by using the '*' as shown below:\r
+// [assembly: AssemblyVersion("1.0.*")]\r
+[assembly: AssemblyVersion("1.0.0.0")]\r
+[assembly: AssemblyFileVersion("1.0.0.0")]\r
--- /dev/null
+/*
+ * 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.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using ElmSharp;
+using Tizen.Applications;
+using Tizen.WebView;
+
+
+namespace Tizen.WebView.Test
+{
+ public class SimpleWebviewApp : CoreUIApplication
+ {
+ private const string LogTag = "WebViewApp";
+
+ private const string _windowName = "Simple WebView App";
+ private const string _defaultUrl = "http://www.google.com";
+ private WebView _webview;
+ private Entry _addressEntry;
+ private Button _reloadButton;
+
+ public SimpleWebviewApp()
+ {
+
+ }
+
+ protected override void OnCreate()
+ {
+ base.OnCreate();
+ Chromium.Initialize();
+ // Create webview and toolbox
+ CreateUI();
+ }
+
+ protected override void OnTerminate()
+ {
+ Chromium.Shutdown();
+ base.OnTerminate();
+ }
+
+ private void CreateUI()
+ {
+ // Create Window
+ Window window = new Window(_windowName);
+ window.Show();
+
+ // Create Box for main window
+ Box mainBox = CreateBaseUI(window);
+
+ // Create top bar
+ Box topBar = CreateTopBar(window);
+
+ // Create Webview
+ _webview = new WebView(window)
+ {
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ _webview.Show();
+
+ // Create bottom bar
+ Box bottomBar = CreateBottomBar(window);
+
+ mainBox.PackEnd(topBar);
+ mainBox.PackEnd(_webview);
+ mainBox.PackEnd(bottomBar);
+
+ InitializeWebView();
+
+ // Load default URL
+ _webview.LoadUrl(_defaultUrl);
+ }
+
+ private Box CreateBaseUI(Window window)
+ {
+ // Create Background
+ Background background = new Background(window)
+ {
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1,
+ Color = Color.White
+ };
+ background.Show();
+ window.AddResizeObject(background);
+
+ // Create Conformant
+ Conformant conformant = new Conformant(window);
+ conformant.Show();
+
+ // Create Box for all contents
+ Box box = new Box(window)
+ {
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ box.Show();
+ conformant.SetContent(box);
+
+ return box;
+ }
+
+ private Box CreateTopBar(Window window)
+ {
+ // Create Box for address bar
+ Box topBar = new Box(window)
+ {
+ AlignmentX = -1,
+ AlignmentY = 0,
+ WeightX = 1,
+ WeightY = 0,
+ IsHorizontal = true
+ };
+ topBar.Show();
+
+ // Create address entry
+ _addressEntry = new Entry(window)
+ {
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1,
+ IsSingleLine = true,
+ Scrollable = true,
+ Text = _defaultUrl
+ };
+ _addressEntry.SetInputPanelLayout(InputPanelLayout.Url);
+ _addressEntry.Activated += (s, e) =>
+ {
+ _webview.LoadUrl(((Entry)s).Text);
+ };
+ _addressEntry.Show();
+
+ // Create reload button
+ _reloadButton = new Button(window)
+ {
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 0.3,
+ WeightY = 1,
+ Text = "Reload"
+ };
+ _reloadButton.Clicked += (s, e) =>
+ {
+ if (_reloadButton.Text.Equals("Reload"))
+ {
+ _webview.Reload();
+ }
+ else if (_reloadButton.Text.Equals("Stop"))
+ {
+ _webview.StopLoading();
+ }
+ };
+ _reloadButton.Show();
+
+ topBar.PackEnd(_addressEntry);
+ topBar.PackEnd(_reloadButton);
+
+ return topBar;
+ }
+
+ private Box CreateBottomBar(Window window)
+ {
+ // Create Box for bottom bar
+ Box bottomBar = new Box(window)
+ {
+ AlignmentX = -1,
+ AlignmentY = 1,
+ WeightX = 1,
+ WeightY = 0,
+ IsHorizontal = true
+ };
+ bottomBar.Show();
+
+ // Create back/forward buttons
+ Button backButton = new Button(window)
+ {
+ AlignmentX = -1,
+ AlignmentY = 0.5,
+ WeightX = 1,
+ WeightY = 1,
+ Text = "Back"
+
+ };
+ backButton.Clicked += (s, e) =>
+ {
+ if (_webview.CanGoBack())
+ _webview.GoBack();
+ };
+ backButton.Show();
+
+ Button forwardButton = new Button(window)
+ {
+ AlignmentX = -1,
+ AlignmentY = 0.5,
+ WeightX = 1,
+ WeightY = 1,
+ Text = "Forward"
+
+ };
+ forwardButton.Clicked += (s, e) =>
+ {
+ if (_webview.CanGoForward())
+ _webview.GoForward();
+ };
+ forwardButton.Show();
+
+ bottomBar.PackEnd(backButton);
+ bottomBar.PackEnd(forwardButton);
+
+ return bottomBar;
+ }
+
+ private void InitializeWebView()
+ {
+ _webview.LoadStarted += (s, e) =>
+ {
+ Log.Info(LogTag, "Load started");
+ _reloadButton.Text = "Stop";
+ };
+
+ _webview.LoadFinished += (s, e) =>
+ {
+ Log.Info(LogTag, "Load finished");
+ _reloadButton.Text = "Reload";
+ };
+
+ _webview.LoadError += (s, e) =>
+ {
+ Log.Info(LogTag, "Load error(" + e.Code + "): " + e.Description);
+ };
+
+ _webview.UrlChanged += (s, e) =>
+ {
+ Log.Info(LogTag, "Url changed: " + e.GetAsString());
+ _addressEntry.Text = e.GetAsString();
+ };
+
+ CookieManager cookieManager = _webview.GetContext().GetCookieManager();
+ if (cookieManager != null)
+ {
+ cookieManager.SetCookieAcceptPolicy(CookieAcceptPolicy.Always);
+ cookieManager.SetPersistentStorage(DirectoryInfo.Data, CookiePersistentStorage.SqlLite);
+ }
+ }
+
+ static void Main(string[] args)
+ {
+ Elementary.Initialize();
+ Elementary.ThemeOverlay();
+
+ SimpleWebviewApp app = new Test.SimpleWebviewApp();
+ app.Run(args);
+ }
+ }
+}
--- /dev/null
+<?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>
+ <ProjectTypeGuids>{2F98DAC9-6F16-457B-AED7-D43CAC379341};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ProjectGuid>{B57DAFA3-B566-4EBF-A6F0-ECD2224A748D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Tizen.WebView.Test</RootNamespace>
+ <AssemblyName>Tizen.WebView.Test</AssemblyName>
+ <FileAlignment>512</FileAlignment>
+ <DefaultLanguage>en-US</DefaultLanguage>
+ </PropertyGroup>
+ <PropertyGroup>
+ <TargetFrameworkIdentifier>DNXCore</TargetFrameworkIdentifier>
+ <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
+ <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
+ <NuGetTargetMoniker>.NETCoreApp,Version=v1.0</NuGetTargetMoniker>
+ <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>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <NoWarn>;1701;1702</NoWarn>
+ <DebugSymbols>true</DebugSymbols>
+ </PropertyGroup>
+ <ItemGroup>
+ <None Include="Tizen.WebView.Test.project.json" />
+ <None Include="tizen-manifest.xml" />
+ <None Include="shared\res\Tizen.WebView.Test.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="SimpleWebviewApp.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="lib\" />
+ <Folder Include="res\" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Tizen.WebView\Tizen.WebView.csproj">
+ <Project>{8405e84f-b920-4aac-9ad5-001b9debc9ca}</Project>
+ <Name>Tizen.WebView</Name>
+ </ProjectReference>
+ </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>
+ <ProjectExtensions>
+ <VisualStudio>
+ <FlavorProperties GUID="{2F98DAC9-6F16-457B-AED7-D43CAC379341}" Configuration="Debug|Any CPU">
+ <ProjectCorporateFlavorCfg />
+ </FlavorProperties>
+ <FlavorProperties GUID="{2F98DAC9-6F16-457B-AED7-D43CAC379341}" Configuration="Release|Any CPU">
+ <ProjectCorporateFlavorCfg />
+ </FlavorProperties>
+ </VisualStudio>
+ </ProjectExtensions>
+</Project>
--- /dev/null
+{
+ "dependencies": {
+ "ElmSharp": "1.1.0-*",
+ "Microsoft.NETCore.App": "1.0.0",
+ "Tizen": "1.0.2",
+ "Tizen.Applications": "1.2.0"
+ },
+ "frameworks": {
+ "netcoreapp1.0": {}
+ },
+ "runtimes": {
+ "win": {}
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="Tizen.WebView.Test" version="1.0.0">
+ <profile name="common" />
+ <ui-application appid="org.tizen.Tizen.WebView.Test"
+ exec="Tizen.WebView.Test.exe"
+ type="dotnet"
+ multiple="false"
+ taskmanage="true"
+ launch_mode="single">
+ <icon>Tizen.WebView.Test.png</icon>
+ <label>Tizen.WebView.Test</label>
+ </ui-application>
+ <privileges>
+ <privilege>http://tizen.org/privilege/mediastorage</privilege>
+ <privilege>http://tizen.org/privilege/externalstorage</privilege>
+ <privilege>http://tizen.org/privilege/network.get</privilege>
+ <privilege>http://tizen.org/privilege/internet</privilege>
+ </privileges>
+</manifest>