// Copyright (c) 2013 GitHub, Inc. // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. #ifndef ATOM_BROWSER_ATOM_BROWSER_CONTEXT_H_ #define ATOM_BROWSER_ATOM_BROWSER_CONTEXT_H_ #include #include #include "atom/browser/net/atom_cookie_delegate.h" #include "brightray/browser/browser_context.h" #include "net/cookies/cookie_monster.h" namespace atom { class AtomBlobReader; class AtomDownloadManagerDelegate; class AtomNetworkDelegate; class AtomPermissionManager; class WebViewManager; class AtomBrowserContext : public brightray::BrowserContext { public: // Get or create the BrowserContext according to its |partition| and // |in_memory|. The |options| will be passed to constructor when there is no // existing BrowserContext. static scoped_refptr From( const std::string& partition, bool in_memory, const base::DictionaryValue& options = base::DictionaryValue()); void SetUserAgent(const std::string& user_agent); // brightray::URLRequestContextGetter::Delegate: net::NetworkDelegate* CreateNetworkDelegate() override; net::CookieMonsterDelegate* CreateCookieDelegate() override; std::string GetUserAgent() override; std::unique_ptr CreateURLRequestJobFactory( content::ProtocolHandlerMap* protocol_handlers) override; net::HttpCache::BackendFactory* CreateHttpCacheBackendFactory( const base::FilePath& base_path) override; std::unique_ptr CreateCertVerifier( brightray::RequireCTDelegate* ct_delegate) override; std::vector GetCookieableSchemes() override; // content::BrowserContext: content::DownloadManagerDelegate* GetDownloadManagerDelegate() override; content::BrowserPluginGuestManager* GetGuestManager() override; content::PermissionManager* GetPermissionManager() override; // brightray::BrowserContext: void RegisterPrefs(PrefRegistrySimple* pref_registry) override; AtomBlobReader* GetBlobReader(); AtomNetworkDelegate* network_delegate() const { return network_delegate_; } AtomCookieDelegate* cookie_delegate() const { return cookie_delegate_.get(); } protected: AtomBrowserContext(const std::string& partition, bool in_memory, const base::DictionaryValue& options); ~AtomBrowserContext() override; private: std::unique_ptr download_manager_delegate_; std::unique_ptr guest_manager_; std::unique_ptr permission_manager_; std::unique_ptr blob_reader_; std::string user_agent_; bool use_cache_; // Managed by brightray::BrowserContext. AtomNetworkDelegate* network_delegate_; scoped_refptr cookie_delegate_; DISALLOW_COPY_AND_ASSIGN(AtomBrowserContext); }; } // namespace atom #endif // ATOM_BROWSER_ATOM_BROWSER_CONTEXT_H_