1c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// found in the LICENSE file. 4c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 5c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#ifndef CONTENT_PUBLIC_BROWSER_COOKIE_STORE_FACTORY_H_ 6c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#define CONTENT_PUBLIC_BROWSER_COOKIE_STORE_FACTORY_H_ 7c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/files/file_path.h" 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/memory/ref_counted.h" 10c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "content/common/content_export.h" 11c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 12c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)namespace base { 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class SequencedTaskRunner; 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace net { 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class CookieMonsterDelegate; 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class CookieStore; 19c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 20c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 2103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)namespace storage { 22c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class SpecialStoragePolicy; 23c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 24c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 25c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)namespace content { 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class CookieCryptoDelegate; 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)struct CONTENT_EXPORT CookieStoreConfig { 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Specifies how session cookies are persisted in the backing data store. 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // EPHEMERAL_SESSION_COOKIES specifies session cookies will not be written 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // out in a manner that allows for restoration. 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // PERSISTANT_SESSION_COOKIES specifies that session cookies are not restored 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // when the cookie store is opened, however they will be written in a manner 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // that allows for them to be restored if the cookie store is opened again 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // using RESTORED_SESSION_COOKIES. 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // RESTORED_SESSION_COOKIES is the: same as PERSISTANT_SESSION_COOKIES 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // except when the cookie store is opened, the previously written session 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // cookies are loaded first. 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) enum SessionCookieMode { 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EPHEMERAL_SESSION_COOKIES, 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) PERSISTANT_SESSION_COOKIES, 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) RESTORED_SESSION_COOKIES 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) }; 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Convenience constructor for an in-memory cookie store with no delegate. 495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CookieStoreConfig(); 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // If |path| is empty, then this specifies an in-memory cookie store. 525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // With in-memory cookie stores, |session_cookie_mode| must be 535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // EPHEMERAL_SESSION_COOKIES. 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // 555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Note: If |crypto_delegate| is non-NULL, it must outlive any CookieStores 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // created using this config. 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CookieStoreConfig(const base::FilePath& path, 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SessionCookieMode session_cookie_mode, 5903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) storage::SpecialStoragePolicy* storage_policy, 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) net::CookieMonsterDelegate* cookie_delegate); 615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ~CookieStoreConfig(); 625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const base::FilePath path; 645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const SessionCookieMode session_cookie_mode; 6503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const scoped_refptr<storage::SpecialStoragePolicy> storage_policy; 665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const scoped_refptr<net::CookieMonsterDelegate> cookie_delegate; 675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The following are infrequently used cookie store parameters. 695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Rather than clutter the constructor API, these are assigned a default 705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // value on CookieStoreConfig construction. Clients should then override 715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // them as necessary. 725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Used to provide encryption hooks for the cookie store. The 745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // CookieCryptoDelegate must outlive any cookie store created with this 755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // config. 765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::CookieCryptoDelegate* crypto_delegate; 775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Callbacks for data load events will be performed on |client_task_runner|. 795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // If NULL, uses the task runner for BrowserThread::IO. 805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // 815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Only used for persistent cookie stores. 825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_refptr<base::SequencedTaskRunner> client_task_runner; 835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // All blocking database accesses will be performed on 855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // |background_task_runner|. If NULL, uses a SequencedTaskRunner from the 865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // BrowserThread blocking pool. 875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // 885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Only used for persistent cookie stores. 895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_refptr<base::SequencedTaskRunner> background_task_runner; 905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 91c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)CONTENT_EXPORT net::CookieStore* CreateCookieStore( 935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const CookieStoreConfig& config); 940f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 95c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} // namespace content 96c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 97c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif // CONTENT_PUBLIC_BROWSER_COOKIE_STORE_FACTORY_H_ 98