| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BLIMP_ENGINE_COMMON_BLIMP_BROWSER_CONTEXT_H_ | |
| 6 #define BLIMP_ENGINE_COMMON_BLIMP_BROWSER_CONTEXT_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/files/file_path.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "blimp/engine/app/blimp_metrics_service_client.h" | |
| 13 #include "blimp/engine/app/blimp_system_url_request_context_getter.h" | |
| 14 #include "blimp/engine/app/blimp_url_request_context_getter.h" | |
| 15 #include "content/public/browser/browser_context.h" | |
| 16 #include "content/public/browser/content_browser_client.h" | |
| 17 #include "content/public/browser/resource_context.h" | |
| 18 #include "net/url_request/url_request_job_factory.h" | |
| 19 | |
| 20 namespace net { | |
| 21 class NetLog; | |
| 22 } | |
| 23 | |
| 24 namespace blimp { | |
| 25 namespace engine { | |
| 26 | |
| 27 class BlimpResourceContext; | |
| 28 class PermissionManager; | |
| 29 | |
| 30 class BlimpBrowserContext : public content::BrowserContext { | |
| 31 public: | |
| 32 // Caller owns |net_log| and ensures it out-lives this browser context. | |
| 33 BlimpBrowserContext(bool off_the_record, net::NetLog* net_log); | |
| 34 ~BlimpBrowserContext() override; | |
| 35 | |
| 36 // content::BrowserContext implementation. | |
| 37 std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate( | |
| 38 const base::FilePath& partition_path) override; | |
| 39 base::FilePath GetPath() const override; | |
| 40 bool IsOffTheRecord() const override; | |
| 41 content::ResourceContext* GetResourceContext() override; | |
| 42 content::DownloadManagerDelegate* GetDownloadManagerDelegate() override; | |
| 43 content::BrowserPluginGuestManager* GetGuestManager() override; | |
| 44 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; | |
| 45 content::PushMessagingService* GetPushMessagingService() override; | |
| 46 content::SSLHostStateDelegate* GetSSLHostStateDelegate() override; | |
| 47 content::PermissionManager* GetPermissionManager() override; | |
| 48 content::BackgroundSyncController* GetBackgroundSyncController() override; | |
| 49 net::URLRequestContextGetter* CreateRequestContext( | |
| 50 content::ProtocolHandlerMap* protocol_handlers, | |
| 51 content::URLRequestInterceptorScopedVector request_interceptors) override; | |
| 52 net::URLRequestContextGetter* CreateRequestContextForStoragePartition( | |
| 53 const base::FilePath& partition_path, | |
| 54 bool in_memory, | |
| 55 content::ProtocolHandlerMap* protocol_handlers, | |
| 56 content::URLRequestInterceptorScopedVector request_interceptors) override; | |
| 57 net::URLRequestContextGetter* CreateMediaRequestContext() override; | |
| 58 net::URLRequestContextGetter* CreateMediaRequestContextForStoragePartition( | |
| 59 const base::FilePath& partition_path, | |
| 60 bool in_memory) override; | |
| 61 | |
| 62 // Provides a URLRequestContextGetter for system requests (e.g. metrics | |
| 63 // uploads). | |
| 64 net::URLRequestContextGetter* GetSystemRequestContextGetter(); | |
| 65 | |
| 66 PrefService* GetPrefService() { return pref_service_.get(); } | |
| 67 | |
| 68 private: | |
| 69 // Performs initialization of the BlimpBrowserContext while IO is still | |
| 70 // allowed on the current thread. | |
| 71 void InitWhileIOAllowed(); | |
| 72 | |
| 73 // Helper function for PrefService initialization. | |
| 74 void InitPrefService(); | |
| 75 | |
| 76 // Used in metrics initialization to get a PrefService to store logs | |
| 77 // temporarily. Must stay alive for lifetime of metrics_service_client_. | |
| 78 std::unique_ptr<PrefService> pref_service_; | |
| 79 | |
| 80 // Used for metrics recording and reporting. | |
| 81 std::unique_ptr<BlimpMetricsServiceClient> metrics_service_client_; | |
| 82 | |
| 83 std::unique_ptr<BlimpResourceContext> resource_context_; | |
| 84 scoped_refptr<BlimpSystemURLRequestContextGetter> system_context_getter_; | |
| 85 bool ignore_certificate_errors_; | |
| 86 std::unique_ptr<content::PermissionManager> permission_manager_; | |
| 87 bool off_the_record_; | |
| 88 net::NetLog* net_log_; | |
| 89 base::FilePath path_; | |
| 90 | |
| 91 DISALLOW_COPY_AND_ASSIGN(BlimpBrowserContext); | |
| 92 }; | |
| 93 | |
| 94 } // namespace engine | |
| 95 } // namespace blimp | |
| 96 | |
| 97 #endif // BLIMP_ENGINE_COMMON_BLIMP_BROWSER_CONTEXT_H_ | |
| OLD | NEW |