[email protected] | b9f6ba3 | 2014-03-10 18:34:08 | [diff] [blame] | 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. |
| 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 | |
| 11 | namespace 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. |
| 16 | class TestExtensionsBrowserClient : public ExtensionsBrowserClient { |
| 17 | public: |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame^] | 18 | // |main_context| is required and must not be an incognito context. |
[email protected] | 88334604 | 2014-06-03 12:04:33 | [diff] [blame] | 19 | explicit TestExtensionsBrowserClient(content::BrowserContext* main_context); |
[email protected] | b9f6ba3 | 2014-03-10 18:34:08 | [diff] [blame] | 20 | virtual ~TestExtensionsBrowserClient(); |
| 21 | |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame^] | 22 | void set_process_manager_delegate(ProcessManagerDelegate* delegate) { |
| 23 | process_manager_delegate_ = delegate; |
| 24 | } |
| 25 | |
[email protected] | b9f6ba3 | 2014-03-10 18:34:08 | [diff] [blame] | 26 | // Associates an incognito context with |main_context_|. |
| 27 | void SetIncognitoContext(content::BrowserContext* incognito_context); |
| 28 | |
| 29 | // ExtensionsBrowserClient overrides: |
| 30 | virtual bool IsShuttingDown() OVERRIDE; |
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 31 | virtual bool AreExtensionsDisabled(const base::CommandLine& command_line, |
[email protected] | b9f6ba3 | 2014-03-10 18:34:08 | [diff] [blame] | 32 | content::BrowserContext* context) OVERRIDE; |
| 33 | virtual bool IsValidContext(content::BrowserContext* context) OVERRIDE; |
| 34 | virtual bool IsSameContext(content::BrowserContext* first, |
| 35 | content::BrowserContext* second) OVERRIDE; |
| 36 | virtual bool HasOffTheRecordContext(content::BrowserContext* context) |
| 37 | OVERRIDE; |
| 38 | virtual content::BrowserContext* GetOffTheRecordContext( |
| 39 | content::BrowserContext* context) OVERRIDE; |
| 40 | virtual content::BrowserContext* GetOriginalContext( |
| 41 | content::BrowserContext* context) OVERRIDE; |
| 42 | virtual bool IsGuestSession(content::BrowserContext* context) const OVERRIDE; |
| 43 | virtual bool IsExtensionIncognitoEnabled( |
| 44 | const std::string& extension_id, |
| 45 | content::BrowserContext* context) const OVERRIDE; |
| 46 | virtual bool CanExtensionCrossIncognito( |
| 47 | const extensions::Extension* extension, |
| 48 | content::BrowserContext* context) const OVERRIDE; |
[email protected] | b32f2173 | 2014-04-16 18:25:16 | [diff] [blame] | 49 | virtual bool IsWebViewRequest(net::URLRequest* request) const OVERRIDE; |
[email protected] | 1791e6c9 | 2014-04-11 08:29:01 | [diff] [blame] | 50 | virtual net::URLRequestJob* MaybeCreateResourceBundleRequestJob( |
| 51 | net::URLRequest* request, |
| 52 | net::NetworkDelegate* network_delegate, |
| 53 | const base::FilePath& directory_path, |
| 54 | const std::string& content_security_policy, |
| 55 | bool send_cors_header) OVERRIDE; |
| 56 | virtual bool AllowCrossRendererResourceLoad(net::URLRequest* request, |
| 57 | bool is_incognito, |
| 58 | const Extension* extension, |
| 59 | InfoMap* extension_info_map) |
| 60 | OVERRIDE; |
[email protected] | b9f6ba3 | 2014-03-10 18:34:08 | [diff] [blame] | 61 | virtual PrefService* GetPrefServiceForContext( |
| 62 | content::BrowserContext* context) OVERRIDE; |
[email protected] | d31e248 | 2014-04-02 22:52:20 | [diff] [blame] | 63 | virtual void GetEarlyExtensionPrefsObservers( |
| 64 | content::BrowserContext* context, |
| 65 | std::vector<ExtensionPrefsObserver*>* observers) const OVERRIDE; |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame^] | 66 | virtual ProcessManagerDelegate* GetProcessManagerDelegate() const OVERRIDE; |
[email protected] | 6c0f179f | 2014-03-19 11:04:41 | [diff] [blame] | 67 | virtual scoped_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() |
[email protected] | b9f6ba3 | 2014-03-10 18:34:08 | [diff] [blame] | 68 | OVERRIDE; |
| 69 | virtual bool DidVersionUpdate(content::BrowserContext* context) OVERRIDE; |
[email protected] | b9f6ba3 | 2014-03-10 18:34:08 | [diff] [blame] | 70 | virtual scoped_ptr<AppSorting> CreateAppSorting() OVERRIDE; |
| 71 | virtual bool IsRunningInForcedAppMode() OVERRIDE; |
[email protected] | b9f6ba3 | 2014-03-10 18:34:08 | [diff] [blame] | 72 | virtual ApiActivityMonitor* GetApiActivityMonitor( |
| 73 | content::BrowserContext* context) OVERRIDE; |
| 74 | virtual ExtensionSystemProvider* GetExtensionSystemFactory() OVERRIDE; |
| 75 | virtual void RegisterExtensionFunctions( |
| 76 | ExtensionFunctionRegistry* registry) const OVERRIDE; |
[email protected] | f0e9ac55 | 2014-05-07 14:26:50 | [diff] [blame] | 77 | virtual scoped_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate( |
| 78 | content::BrowserContext* context) const OVERRIDE; |
[email protected] | 326e6f0 | 2014-06-20 04:53:37 | [diff] [blame] | 79 | virtual ComponentExtensionResourceManager* |
| 80 | GetComponentExtensionResourceManager() OVERRIDE; |
[email protected] | b9f6ba3 | 2014-03-10 18:34:08 | [diff] [blame] | 81 | |
| 82 | private: |
| 83 | content::BrowserContext* main_context_; // Not owned. |
| 84 | content::BrowserContext* incognito_context_; // Not owned, defaults to NULL. |
| 85 | |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame^] | 86 | // Not owned, defaults to NULL. |
| 87 | ProcessManagerDelegate* process_manager_delegate_; |
| 88 | |
[email protected] | b9f6ba3 | 2014-03-10 18:34:08 | [diff] [blame] | 89 | DISALLOW_COPY_AND_ASSIGN(TestExtensionsBrowserClient); |
| 90 | }; |
| 91 | |
| 92 | } // namespace extensions |
| 93 | |
| 94 | #endif // EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_ |