Content settings: remove some plugin-related code/resources when... there are no...
[chromium-blink-merge.git] / content / public / test / test_web_contents_factory.h
blob92cdcae72721ae779b93a9cec5a409b0b7ade376
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.
5 #ifndef CONTENT_PUBLIC_TEST_TEST_WEB_CONTENTS_FACTORY_H_
6 #define CONTENT_PUBLIC_TEST_TEST_WEB_CONTENTS_FACTORY_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_vector.h"
11 namespace content {
12 class BrowserContext;
13 class RenderViewHostTestEnabler;
14 class WebContents;
16 // A helper class to create test web contents (tabs) for unit tests, without
17 // inheriting from RenderViewTestHarness. Can create web contents, and will
18 // clean up after itself upon destruction. Owns all created web contents.
19 // A few notes:
20 // - Works well allocated on the stack, because it should be destroyed before
21 // associated browser context.
22 // - Doesn't play nice with web contents created any other way (because of
23 // the implementation of RenderViewHostTestEnabler). But if you are creating
24 // web contents already, what do you need this for? ;)
25 // TODO(devlin): The API is currently a bit sparse; there may need to be methods
26 // to, e.g., delete/close a web contents, access existing web contents, etc.
27 // These can be added as-needed.
28 class TestWebContentsFactory {
29 public:
30 TestWebContentsFactory();
31 ~TestWebContentsFactory();
33 // Creates a new WebContents with the given |context|, and returns it.
34 // Ownership remains with the TestWebContentsFactory.
35 WebContents* CreateWebContents(BrowserContext* context);
37 private:
38 // The test factory (and friends) for creating test web contents.
39 scoped_ptr<RenderViewHostTestEnabler> rvh_enabler_;
41 // The vector of web contents that this class created.
42 ScopedVector<WebContents> web_contents_;
44 DISALLOW_COPY_AND_ASSIGN(TestWebContentsFactory);
47 } // namespace content
49 #endif // CONTENT_PUBLIC_TEST_TEST_WEB_CONTENTS_FACTORY_H_