test_browser_context.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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.
4
5#ifndef CONTENT_PUBLIC_TEST_TEST_BROWSER_CONTEXT_H_
6#define CONTENT_PUBLIC_TEST_TEST_BROWSER_CONTEXT_H_
7
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"
15
16namespace content {
17class MockResourceContext;
18
19class TestBrowserContext : public BrowserContext {
20 public:
21  TestBrowserContext();
22  virtual ~TestBrowserContext();
23
24  // Takes ownership of the temporary directory so that it's not deleted when
25  // this object is destructed.
26  base::FilePath TakePath();
27
28  void SetSpecialStoragePolicy(quota::SpecialStoragePolicy* policy);
29
30  virtual base::FilePath GetPath() const OVERRIDE;
31  virtual bool IsOffTheRecord() const OVERRIDE;
32  virtual DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE;
33  virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
34  virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
35      int renderer_child_id) OVERRIDE;
36  virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
37  virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
38      int renderer_child_id) OVERRIDE;
39  virtual net::URLRequestContextGetter*
40      GetMediaRequestContextForStoragePartition(
41          const base::FilePath& partition_path,
42          bool in_memory) OVERRIDE;
43  virtual void RequestMidiSysExPermission(
44      int render_process_id,
45      int render_view_id,
46      int bridge_id,
47      const GURL& requesting_frame,
48      const MidiSysExPermissionCallback& callback) OVERRIDE;
49  virtual void CancelMidiSysExPermissionRequest(
50        int render_process_id,
51        int render_view_id,
52        int bridge_id,
53        const GURL& requesting_frame) OVERRIDE;
54  virtual void RequestProtectedMediaIdentifierPermission(
55      int render_process_id,
56      int render_view_id,
57      int bridge_id,
58      int group_id,
59      const GURL& requesting_frame,
60      const ProtectedMediaIdentifierPermissionCallback& callback) OVERRIDE;
61  virtual void CancelProtectedMediaIdentifierPermissionRequests(
62      int group_id) OVERRIDE;
63  virtual ResourceContext* GetResourceContext() OVERRIDE;
64  virtual GeolocationPermissionContext*
65      GetGeolocationPermissionContext() OVERRIDE;
66  virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
67
68 private:
69  FRIEND_TEST_ALL_PREFIXES(DOMStorageTest, SessionOnly);
70  FRIEND_TEST_ALL_PREFIXES(DOMStorageTest, SaveSessionState);
71
72  scoped_refptr<net::URLRequestContextGetter> request_context_;
73  scoped_ptr<MockResourceContext> resource_context_;
74  base::ScopedTempDir browser_context_dir_;
75  scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
76
77  DISALLOW_COPY_AND_ASSIGN(TestBrowserContext);
78};
79
80}  // namespace content
81
82#endif  // CONTENT_PUBLIC_TEST_TEST_BROWSER_CONTEXT_H_
83