1 // 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.
5 #ifndef EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_
6 #define EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_
8 #include "base/compiler_specific.h"
9 #include "extensions/browser/extensions_browser_client.h"
11 namespace extensions
{
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.
16 class TestExtensionsBrowserClient
: public ExtensionsBrowserClient
{
18 // |main_context| is required and must not be an incognito context.
19 explicit TestExtensionsBrowserClient(content::BrowserContext
* main_context
);
20 virtual ~TestExtensionsBrowserClient();
22 void set_process_manager_delegate(ProcessManagerDelegate
* delegate
) {
23 process_manager_delegate_
= delegate
;
25 void set_extension_system_factory(ExtensionSystemProvider
* factory
) {
26 extension_system_factory_
= factory
;
29 // Associates an incognito context with |main_context_|.
30 void SetIncognitoContext(content::BrowserContext
* incognito_context
);
32 // ExtensionsBrowserClient overrides:
33 virtual bool IsShuttingDown() OVERRIDE
;
34 virtual bool AreExtensionsDisabled(const base::CommandLine
& command_line
,
35 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
)
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
;
52 virtual bool IsWebViewRequest(net::URLRequest
* request
) const OVERRIDE
;
53 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
,
61 const Extension
* extension
,
62 InfoMap
* extension_info_map
)
64 virtual PrefService
* GetPrefServiceForContext(
65 content::BrowserContext
* context
) OVERRIDE
;
66 virtual void GetEarlyExtensionPrefsObservers(
67 content::BrowserContext
* context
,
68 std::vector
<ExtensionPrefsObserver
*>* observers
) const OVERRIDE
;
69 virtual ProcessManagerDelegate
* GetProcessManagerDelegate() const OVERRIDE
;
70 virtual scoped_ptr
<ExtensionHostDelegate
> CreateExtensionHostDelegate()
72 virtual bool DidVersionUpdate(content::BrowserContext
* context
) OVERRIDE
;
73 virtual void PermitExternalProtocolHandler() OVERRIDE
;
74 virtual scoped_ptr
<AppSorting
> CreateAppSorting() OVERRIDE
;
75 virtual bool IsRunningInForcedAppMode() OVERRIDE
;
76 virtual ApiActivityMonitor
* GetApiActivityMonitor(
77 content::BrowserContext
* context
) OVERRIDE
;
78 virtual ExtensionSystemProvider
* GetExtensionSystemFactory() OVERRIDE
;
79 virtual void RegisterExtensionFunctions(
80 ExtensionFunctionRegistry
* registry
) const OVERRIDE
;
81 virtual scoped_ptr
<RuntimeAPIDelegate
> CreateRuntimeAPIDelegate(
82 content::BrowserContext
* context
) const OVERRIDE
;
83 virtual ComponentExtensionResourceManager
*
84 GetComponentExtensionResourceManager() OVERRIDE
;
85 virtual net::NetLog
* GetNetLog() OVERRIDE
;
88 content::BrowserContext
* main_context_
; // Not owned.
89 content::BrowserContext
* incognito_context_
; // Not owned, defaults to NULL.
91 // Not owned, defaults to NULL.
92 ProcessManagerDelegate
* process_manager_delegate_
;
94 // Not owned, defaults to NULL.
95 ExtensionSystemProvider
* extension_system_factory_
;
97 DISALLOW_COPY_AND_ASSIGN(TestExtensionsBrowserClient
);
100 } // namespace extensions
102 #endif // EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_