1 // Copyright (c) 2012 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.
5 #ifndef CONTENT_PUBLIC_TEST_TEST_BROWSER_CONTEXT_H_
6 #define CONTENT_PUBLIC_TEST_TEST_BROWSER_CONTEXT_H_
8 #include "base/compiler_specific.h"
9 #include "base/files/file_path.h"
10 #include "base/files/scoped_temp_dir.h"
11 #include "base/gtest_prod_util.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "content/public/browser/browser_context.h"
17 class MockResourceContext
;
18 class ZoomLevelDelegate
;
20 class TestBrowserContext
: public BrowserContext
{
23 ~TestBrowserContext() override
;
25 // Takes ownership of the temporary directory so that it's not deleted when
26 // this object is destructed.
27 base::FilePath
TakePath();
29 void SetSpecialStoragePolicy(storage::SpecialStoragePolicy
* policy
);
31 base::FilePath
GetPath() const override
;
32 scoped_ptr
<ZoomLevelDelegate
> CreateZoomLevelDelegate(
33 const base::FilePath
& partition_path
) override
;
34 bool IsOffTheRecord() const override
;
35 DownloadManagerDelegate
* GetDownloadManagerDelegate() override
;
36 net::URLRequestContextGetter
* GetRequestContext() override
;
37 net::URLRequestContextGetter
* GetRequestContextForRenderProcess(
38 int renderer_child_id
) override
;
39 net::URLRequestContextGetter
* GetMediaRequestContext() override
;
40 net::URLRequestContextGetter
* GetMediaRequestContextForRenderProcess(
41 int renderer_child_id
) override
;
42 net::URLRequestContextGetter
* GetMediaRequestContextForStoragePartition(
43 const base::FilePath
& partition_path
,
44 bool in_memory
) override
;
45 ResourceContext
* GetResourceContext() override
;
46 BrowserPluginGuestManager
* GetGuestManager() override
;
47 storage::SpecialStoragePolicy
* GetSpecialStoragePolicy() override
;
48 PushMessagingService
* GetPushMessagingService() override
;
49 SSLHostStateDelegate
* GetSSLHostStateDelegate() override
;
50 PermissionManager
* GetPermissionManager() override
;
53 FRIEND_TEST_ALL_PREFIXES(DOMStorageTest
, SessionOnly
);
54 FRIEND_TEST_ALL_PREFIXES(DOMStorageTest
, SaveSessionState
);
56 scoped_refptr
<net::URLRequestContextGetter
> request_context_
;
57 scoped_ptr
<MockResourceContext
> resource_context_
;
58 base::ScopedTempDir browser_context_dir_
;
59 scoped_refptr
<storage::SpecialStoragePolicy
> special_storage_policy_
;
61 DISALLOW_COPY_AND_ASSIGN(TestBrowserContext
);
64 } // namespace content
66 #endif // CONTENT_PUBLIC_TEST_TEST_BROWSER_CONTEXT_H_