blob: 7e77050abc224c8edf46728844dbd733d7b4dae5 [file] [log] [blame]
[email protected]b9f6ba32014-03-10 18:34:081// Copyright 2014 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 EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_
6#define EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_
7
8#include "base/compiler_specific.h"
9#include "extensions/browser/extensions_browser_client.h"
10
11namespace extensions {
12
13// A simplified ExtensionsBrowserClient for a single normal browser context and
14// an optional incognito browser context associated with it. A test that uses
15// this class should call ExtensionsBrowserClient::Set() with its instance.
16class TestExtensionsBrowserClient : public ExtensionsBrowserClient {
17 public:
[email protected]6b54fda2014-07-22 02:13:4718 // |main_context| is required and must not be an incognito context.
[email protected]883346042014-06-03 12:04:3319 explicit TestExtensionsBrowserClient(content::BrowserContext* main_context);
[email protected]b9f6ba32014-03-10 18:34:0820 virtual ~TestExtensionsBrowserClient();
21
[email protected]6b54fda2014-07-22 02:13:4722 void set_process_manager_delegate(ProcessManagerDelegate* delegate) {
23 process_manager_delegate_ = delegate;
24 }
[email protected]9fc5bdc82014-08-03 23:49:2625 void set_extension_system_factory(ExtensionSystemProvider* factory) {
26 extension_system_factory_ = factory;
27 }
[email protected]6b54fda2014-07-22 02:13:4728
[email protected]b9f6ba32014-03-10 18:34:0829 // Associates an incognito context with |main_context_|.
30 void SetIncognitoContext(content::BrowserContext* incognito_context);
31
32 // ExtensionsBrowserClient overrides:
33 virtual bool IsShuttingDown() OVERRIDE;
[email protected]2f3b1cc2014-03-17 23:07:1534 virtual bool AreExtensionsDisabled(const base::CommandLine& command_line,
[email protected]b9f6ba32014-03-10 18:34:0835 content::BrowserContext* context) OVERRIDE;
36 virtual bool IsValidContext(content::BrowserContext* context) OVERRIDE;
37 virtual bool IsSameContext(content::BrowserContext* first,
38 content::BrowserContext* second) OVERRIDE;
39 virtual bool HasOffTheRecordContext(content::BrowserContext* context)
40 OVERRIDE;
41 virtual content::BrowserContext* GetOffTheRecordContext(
42 content::BrowserContext* context) OVERRIDE;
43 virtual content::BrowserContext* GetOriginalContext(
44 content::BrowserContext* context) OVERRIDE;
45 virtual bool IsGuestSession(content::BrowserContext* context) const OVERRIDE;
46 virtual bool IsExtensionIncognitoEnabled(
47 const std::string& extension_id,
48 content::BrowserContext* context) const OVERRIDE;
49 virtual bool CanExtensionCrossIncognito(
50 const extensions::Extension* extension,
51 content::BrowserContext* context) const OVERRIDE;
[email protected]b32f21732014-04-16 18:25:1652 virtual bool IsWebViewRequest(net::URLRequest* request) const OVERRIDE;
[email protected]1791e6c92014-04-11 08:29:0153 virtual net::URLRequestJob* MaybeCreateResourceBundleRequestJob(
54 net::URLRequest* request,
55 net::NetworkDelegate* network_delegate,
56 const base::FilePath& directory_path,
57 const std::string& content_security_policy,
58 bool send_cors_header) OVERRIDE;
59 virtual bool AllowCrossRendererResourceLoad(net::URLRequest* request,
60 bool is_incognito,
61 const Extension* extension,
62 InfoMap* extension_info_map)
63 OVERRIDE;
[email protected]b9f6ba32014-03-10 18:34:0864 virtual PrefService* GetPrefServiceForContext(
65 content::BrowserContext* context) OVERRIDE;
[email protected]d31e2482014-04-02 22:52:2066 virtual void GetEarlyExtensionPrefsObservers(
67 content::BrowserContext* context,
68 std::vector<ExtensionPrefsObserver*>* observers) const OVERRIDE;
[email protected]6b54fda2014-07-22 02:13:4769 virtual ProcessManagerDelegate* GetProcessManagerDelegate() const OVERRIDE;
[email protected]6c0f179f2014-03-19 11:04:4170 virtual scoped_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate()
[email protected]b9f6ba32014-03-10 18:34:0871 OVERRIDE;
72 virtual bool DidVersionUpdate(content::BrowserContext* context) OVERRIDE;
[email protected]86fad30d2014-07-29 21:39:2773 virtual void PermitExternalProtocolHandler() OVERRIDE;
[email protected]b9f6ba32014-03-10 18:34:0874 virtual scoped_ptr<AppSorting> CreateAppSorting() OVERRIDE;
75 virtual bool IsRunningInForcedAppMode() OVERRIDE;
[email protected]b9f6ba32014-03-10 18:34:0876 virtual ApiActivityMonitor* GetApiActivityMonitor(
77 content::BrowserContext* context) OVERRIDE;
78 virtual ExtensionSystemProvider* GetExtensionSystemFactory() OVERRIDE;
79 virtual void RegisterExtensionFunctions(
80 ExtensionFunctionRegistry* registry) const OVERRIDE;
[email protected]f0e9ac552014-05-07 14:26:5081 virtual scoped_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate(
82 content::BrowserContext* context) const OVERRIDE;
[email protected]326e6f02014-06-20 04:53:3783 virtual ComponentExtensionResourceManager*
84 GetComponentExtensionResourceManager() OVERRIDE;
[email protected]4d1663782014-07-25 21:44:3685 virtual net::NetLog* GetNetLog() OVERRIDE;
[email protected]b9f6ba32014-03-10 18:34:0886
87 private:
88 content::BrowserContext* main_context_; // Not owned.
89 content::BrowserContext* incognito_context_; // Not owned, defaults to NULL.
90
[email protected]6b54fda2014-07-22 02:13:4791 // Not owned, defaults to NULL.
92 ProcessManagerDelegate* process_manager_delegate_;
93
[email protected]9fc5bdc82014-08-03 23:49:2694 // Not owned, defaults to NULL.
95 ExtensionSystemProvider* extension_system_factory_;
96
[email protected]b9f6ba32014-03-10 18:34:0897 DISALLOW_COPY_AND_ASSIGN(TestExtensionsBrowserClient);
98};
99
100} // namespace extensions
101
102#endif // EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_