atom_browser_context.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright (c) 2013 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ATOM_BROWSER_ATOM_BROWSER_CONTEXT_H_
  5. #define ATOM_BROWSER_ATOM_BROWSER_CONTEXT_H_
  6. #include <string>
  7. #include <vector>
  8. #include "brightray/browser/browser_context.h"
  9. namespace atom {
  10. class AtomBlobReader;
  11. class AtomDownloadManagerDelegate;
  12. class AtomPermissionManager;
  13. class RequestContextDelegate;
  14. class WebViewManager;
  15. class AtomBrowserContext : public brightray::BrowserContext {
  16. public:
  17. // Get or create the BrowserContext according to its |partition| and
  18. // |in_memory|. The |options| will be passed to constructor when there is no
  19. // existing BrowserContext.
  20. static scoped_refptr<AtomBrowserContext> From(
  21. const std::string& partition,
  22. bool in_memory,
  23. const base::DictionaryValue& options = base::DictionaryValue());
  24. void SetUserAgent(const std::string& user_agent);
  25. AtomBlobReader* GetBlobReader();
  26. // content::BrowserContext:
  27. content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
  28. content::BrowserPluginGuestManager* GetGuestManager() override;
  29. content::PermissionManager* GetPermissionManager() override;
  30. // brightray::BrowserContext:
  31. void RegisterPrefs(PrefRegistrySimple* pref_registry) override;
  32. std::string GetUserAgent() const override;
  33. void OnMainRequestContextCreated(
  34. brightray::URLRequestContextGetter* getter) override;
  35. RequestContextDelegate* GetRequestContextDelegate() const {
  36. return request_context_delegate_.get();
  37. }
  38. protected:
  39. AtomBrowserContext(const std::string& partition,
  40. bool in_memory,
  41. const base::DictionaryValue& options);
  42. ~AtomBrowserContext() override;
  43. private:
  44. brightray::URLRequestContextGetter* url_request_context_getter_;
  45. std::unique_ptr<AtomDownloadManagerDelegate> download_manager_delegate_;
  46. std::unique_ptr<WebViewManager> guest_manager_;
  47. std::unique_ptr<AtomPermissionManager> permission_manager_;
  48. std::unique_ptr<AtomBlobReader> blob_reader_;
  49. std::unique_ptr<RequestContextDelegate> request_context_delegate_;
  50. std::string user_agent_;
  51. DISALLOW_COPY_AND_ASSIGN(AtomBrowserContext);
  52. };
  53. } // namespace atom
  54. #endif // ATOM_BROWSER_ATOM_BROWSER_CONTEXT_H_