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