[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; |
| 45 | virtual PrefService* GetPrefServiceForContext( |
| 46 | content::BrowserContext* context) OVERRIDE; |
[email protected] | d31e248 | 2014-04-02 22:52:20 | [diff] [blame^] | 47 | virtual void GetEarlyExtensionPrefsObservers( |
| 48 | content::BrowserContext* context, |
| 49 | std::vector<ExtensionPrefsObserver*>* observers) const OVERRIDE; |
[email protected] | b9f6ba3 | 2014-03-10 18:34:08 | [diff] [blame] | 50 | virtual bool DeferLoadingBackgroundHosts( |
| 51 | content::BrowserContext* context) const OVERRIDE; |
| 52 | virtual bool IsBackgroundPageAllowed(content::BrowserContext* context) const |
| 53 | OVERRIDE; |
[email protected] | 6c0f179f | 2014-03-19 11:04:41 | [diff] [blame] | 54 | virtual scoped_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() |
[email protected] | b9f6ba3 | 2014-03-10 18:34:08 | [diff] [blame] | 55 | OVERRIDE; |
| 56 | virtual bool DidVersionUpdate(content::BrowserContext* context) OVERRIDE; |
[email protected] | 54aa17b | 2014-04-02 01:35:22 | [diff] [blame] | 57 | virtual void PermitExternalProtocolHandler() OVERRIDE; |
[email protected] | b9f6ba3 | 2014-03-10 18:34:08 | [diff] [blame] | 58 | virtual scoped_ptr<AppSorting> CreateAppSorting() OVERRIDE; |
| 59 | virtual bool IsRunningInForcedAppMode() OVERRIDE; |
[email protected] | b9f6ba3 | 2014-03-10 18:34:08 | [diff] [blame] | 60 | virtual ApiActivityMonitor* GetApiActivityMonitor( |
| 61 | content::BrowserContext* context) OVERRIDE; |
| 62 | virtual ExtensionSystemProvider* GetExtensionSystemFactory() OVERRIDE; |
| 63 | virtual void RegisterExtensionFunctions( |
| 64 | ExtensionFunctionRegistry* registry) const OVERRIDE; |
| 65 | |
| 66 | private: |
| 67 | content::BrowserContext* main_context_; // Not owned. |
| 68 | content::BrowserContext* incognito_context_; // Not owned, defaults to NULL. |
| 69 | |
| 70 | DISALLOW_COPY_AND_ASSIGN(TestExtensionsBrowserClient); |
| 71 | }; |
| 72 | |
| 73 | } // namespace extensions |
| 74 | |
| 75 | #endif // EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_ |