/*
* 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
{
///
/// Enumeration that contains accept policies for the cookies.
///
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 */
}
///
/// Enumeration that creates a type name for the storage of persistent cookies.
///
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;
}
///
/// Sets the cookie acceptance policy.
///
///
/// By default, only cookies set by the main document loaded are accepted.
///
/// The cookie acceptance policy
public void SetCookieAcceptPolicy(CookieAcceptPolicy policy)
{
Interop.ChromiumEwk.ewk_cookie_manager_accept_policy_set(_handle, (Interop.ChromiumEwk.CookieAcceptPolicy)policy);
}
///
/// Deletes all the cookies.
///
public void ClearCookies()
{
Interop.ChromiumEwk.ewk_cookie_manager_cookies_clear(_handle);
}
///
/// Sets the storage where non-session cookies are stored persistently to read/write the cookies.
///
///
/// http://tizen.org/privilege/mediastorage
/// http://tizen.org/privilege/externalstorage
///
/// The path where to read/write Cookies
/// The type of storage
public void SetPersistentStorage(string path, CookiePersistentStorage storage)
{
Interop.ChromiumEwk.ewk_cookie_manager_persistent_storage_set(_handle, path, (Interop.ChromiumEwk.CookiePersistentStorage)storage);
}
}
}