Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / extensions / browser / test_extensions_browser_client.h
blob84a4ed361350667ac61452aa9bb3025242e6452c
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"
10 #include "extensions/browser/updater/extension_cache.h"
12 namespace extensions {
14 // A simplified ExtensionsBrowserClient for a single normal browser context and
15 // an optional incognito browser context associated with it. A test that uses
16 // this class should call ExtensionsBrowserClient::Set() with its instance.
17 class TestExtensionsBrowserClient : public ExtensionsBrowserClient {
18 public:
19 // |main_context| is required and must not be an incognito context.
20 explicit TestExtensionsBrowserClient(content::BrowserContext* main_context);
21 ~TestExtensionsBrowserClient() override;
23 void set_process_manager_delegate(ProcessManagerDelegate* delegate) {
24 process_manager_delegate_ = delegate;
26 void set_extension_system_factory(ExtensionSystemProvider* factory) {
27 extension_system_factory_ = factory;
29 void set_extension_cache(scoped_ptr<ExtensionCache> extension_cache) {
30 extension_cache_ = extension_cache.Pass();
33 // Associates an incognito context with |main_context_|.
34 void SetIncognitoContext(content::BrowserContext* incognito_context);
36 // ExtensionsBrowserClient overrides:
37 bool IsShuttingDown() override;
38 bool AreExtensionsDisabled(const base::CommandLine& command_line,
39 content::BrowserContext* context) override;
40 bool IsValidContext(content::BrowserContext* context) override;
41 bool IsSameContext(content::BrowserContext* first,
42 content::BrowserContext* second) override;
43 bool HasOffTheRecordContext(content::BrowserContext* context) override;
44 content::BrowserContext* GetOffTheRecordContext(
45 content::BrowserContext* context) override;
46 content::BrowserContext* GetOriginalContext(
47 content::BrowserContext* context) override;
48 #if defined(OS_CHROMEOS)
49 std::string GetUserIdHashFromContext(
50 content::BrowserContext* context) override;
51 #endif
52 bool IsGuestSession(content::BrowserContext* context) const override;
53 bool IsExtensionIncognitoEnabled(
54 const std::string& extension_id,
55 content::BrowserContext* context) const override;
56 bool CanExtensionCrossIncognito(
57 const extensions::Extension* extension,
58 content::BrowserContext* context) const override;
59 net::URLRequestJob* MaybeCreateResourceBundleRequestJob(
60 net::URLRequest* request,
61 net::NetworkDelegate* network_delegate,
62 const base::FilePath& directory_path,
63 const std::string& content_security_policy,
64 bool send_cors_header) override;
65 bool AllowCrossRendererResourceLoad(net::URLRequest* request,
66 bool is_incognito,
67 const Extension* extension,
68 InfoMap* extension_info_map) override;
69 PrefService* GetPrefServiceForContext(
70 content::BrowserContext* context) override;
71 void GetEarlyExtensionPrefsObservers(
72 content::BrowserContext* context,
73 std::vector<ExtensionPrefsObserver*>* observers) const override;
74 ProcessManagerDelegate* GetProcessManagerDelegate() const override;
75 scoped_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() override;
76 bool DidVersionUpdate(content::BrowserContext* context) override;
77 void PermitExternalProtocolHandler() override;
78 scoped_ptr<AppSorting> CreateAppSorting() override;
79 bool IsRunningInForcedAppMode() override;
80 ApiActivityMonitor* GetApiActivityMonitor(
81 content::BrowserContext* context) override;
82 ExtensionSystemProvider* GetExtensionSystemFactory() override;
83 void RegisterExtensionFunctions(
84 ExtensionFunctionRegistry* registry) const override;
85 void RegisterMojoServices(content::RenderFrameHost* render_frame_host,
86 const Extension* extension) const override;
87 scoped_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate(
88 content::BrowserContext* context) const override;
89 const ComponentExtensionResourceManager*
90 GetComponentExtensionResourceManager() override;
91 void BroadcastEventToRenderers(const std::string& event_name,
92 scoped_ptr<base::ListValue> args) override;
93 net::NetLog* GetNetLog() override;
94 ExtensionCache* GetExtensionCache() override;
95 bool IsBackgroundUpdateAllowed() override;
96 bool IsMinBrowserVersionSupported(const std::string& min_version) override;
98 private:
99 content::BrowserContext* main_context_; // Not owned.
100 content::BrowserContext* incognito_context_; // Not owned, defaults to NULL.
102 // Not owned, defaults to NULL.
103 ProcessManagerDelegate* process_manager_delegate_;
105 // Not owned, defaults to NULL.
106 ExtensionSystemProvider* extension_system_factory_;
108 scoped_ptr<ExtensionCache> extension_cache_;
110 DISALLOW_COPY_AND_ASSIGN(TestExtensionsBrowserClient);
113 } // namespace extensions
115 #endif // EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_