mock_resource_context.h revision 3240926e260ce088908e02ac07a6cf7b0c0cbf44
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_MOCK_RESOURCE_CONTEXT_H_
6#define CONTENT_PUBLIC_TEST_MOCK_RESOURCE_CONTEXT_H_
7
8#include "base/basictypes.h"
9#include "base/compiler_specific.h"
10#include "base/memory/scoped_ptr.h"
11#include "content/public/browser/resource_context.h"
12
13namespace net {
14class URLRequestContext;
15}
16
17namespace content {
18
19class MockResourceContext : public ResourceContext {
20 public:
21  MockResourceContext();
22
23  // Does not take ownership of |test_request_context|.
24  explicit MockResourceContext(net::URLRequestContext* test_request_context);
25
26  virtual ~MockResourceContext();
27
28  // ResourceContext implementation:
29  virtual net::HostResolver* GetHostResolver() OVERRIDE;
30  virtual net::URLRequestContext* GetRequestContext() OVERRIDE;
31  virtual bool AllowMicAccess(const GURL& origin) OVERRIDE;
32  virtual bool AllowCameraAccess(const GURL& origin) OVERRIDE;
33
34  //////////////////////////////////////////////////////////////////////////
35  // The following functions are used by tests.
36  void set_mic_access(bool mic_allowed) {
37    mic_allowed_ = mic_allowed;
38  }
39
40  void set_camera_access(bool camera_allowed) {
41    camera_allowed_ = camera_allowed;
42  }
43
44 private:
45  net::URLRequestContext* test_request_context_;
46
47  bool mic_allowed_;
48  bool camera_allowed_;
49
50  DISALLOW_COPY_AND_ASSIGN(MockResourceContext);
51};
52
53}  // namespace content
54
55#endif  // CONTENT_PUBLIC_TEST_MOCK_RESOURCE_CONTEXT_H_
56