OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_ | 5 #ifndef EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_ |
6 #define EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_ | 6 #define EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "extensions/browser/extensions_browser_client.h" | 9 #include "extensions/browser/extensions_browser_client.h" |
10 #include "extensions/browser/updater/extension_cache.h" | |
11 | 10 |
12 namespace extensions { | 11 namespace extensions { |
13 | 12 |
14 // A simplified ExtensionsBrowserClient for a single normal browser context and | 13 // A simplified ExtensionsBrowserClient for a single normal browser context and |
15 // an optional incognito browser context associated with it. A test that uses | 14 // an optional incognito browser context associated with it. A test that uses |
16 // this class should call ExtensionsBrowserClient::Set() with its instance. | 15 // this class should call ExtensionsBrowserClient::Set() with its instance. |
17 class TestExtensionsBrowserClient : public ExtensionsBrowserClient { | 16 class TestExtensionsBrowserClient : public ExtensionsBrowserClient { |
18 public: | 17 public: |
19 // |main_context| is required and must not be an incognito context. | 18 // |main_context| is required and must not be an incognito context. |
20 explicit TestExtensionsBrowserClient(content::BrowserContext* main_context); | 19 explicit TestExtensionsBrowserClient(content::BrowserContext* main_context); |
21 virtual ~TestExtensionsBrowserClient(); | 20 virtual ~TestExtensionsBrowserClient(); |
22 | 21 |
23 void set_process_manager_delegate(ProcessManagerDelegate* delegate) { | 22 void set_process_manager_delegate(ProcessManagerDelegate* delegate) { |
24 process_manager_delegate_ = delegate; | 23 process_manager_delegate_ = delegate; |
25 } | 24 } |
26 void set_extension_system_factory(ExtensionSystemProvider* factory) { | 25 void set_extension_system_factory(ExtensionSystemProvider* factory) { |
27 extension_system_factory_ = factory; | 26 extension_system_factory_ = factory; |
28 } | 27 } |
29 void set_extension_cache(scoped_ptr<ExtensionCache> extension_cache) { | |
30 extension_cache_ = extension_cache.Pass(); | |
31 } | |
32 | 28 |
33 // Associates an incognito context with |main_context_|. | 29 // Associates an incognito context with |main_context_|. |
34 void SetIncognitoContext(content::BrowserContext* incognito_context); | 30 void SetIncognitoContext(content::BrowserContext* incognito_context); |
35 | 31 |
36 // ExtensionsBrowserClient overrides: | 32 // ExtensionsBrowserClient overrides: |
37 virtual bool IsShuttingDown() override; | 33 virtual bool IsShuttingDown() override; |
38 virtual bool AreExtensionsDisabled(const base::CommandLine& command_line, | 34 virtual bool AreExtensionsDisabled(const base::CommandLine& command_line, |
39 content::BrowserContext* context) override; | 35 content::BrowserContext* context) override; |
40 virtual bool IsValidContext(content::BrowserContext* context) override; | 36 virtual bool IsValidContext(content::BrowserContext* context) override; |
41 virtual bool IsSameContext(content::BrowserContext* first, | 37 virtual bool IsSameContext(content::BrowserContext* first, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 virtual void RegisterExtensionFunctions( | 78 virtual void RegisterExtensionFunctions( |
83 ExtensionFunctionRegistry* registry) const override; | 79 ExtensionFunctionRegistry* registry) const override; |
84 virtual scoped_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate( | 80 virtual scoped_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate( |
85 content::BrowserContext* context) const override; | 81 content::BrowserContext* context) const override; |
86 virtual ComponentExtensionResourceManager* | 82 virtual ComponentExtensionResourceManager* |
87 GetComponentExtensionResourceManager() override; | 83 GetComponentExtensionResourceManager() override; |
88 virtual void BroadcastEventToRenderers( | 84 virtual void BroadcastEventToRenderers( |
89 const std::string& event_name, | 85 const std::string& event_name, |
90 scoped_ptr<base::ListValue> args) override; | 86 scoped_ptr<base::ListValue> args) override; |
91 virtual net::NetLog* GetNetLog() override; | 87 virtual net::NetLog* GetNetLog() override; |
92 virtual ExtensionCache* GetExtensionCache() override; | |
93 | 88 |
94 private: | 89 private: |
95 content::BrowserContext* main_context_; // Not owned. | 90 content::BrowserContext* main_context_; // Not owned. |
96 content::BrowserContext* incognito_context_; // Not owned, defaults to NULL. | 91 content::BrowserContext* incognito_context_; // Not owned, defaults to NULL. |
97 | 92 |
98 // Not owned, defaults to NULL. | 93 // Not owned, defaults to NULL. |
99 ProcessManagerDelegate* process_manager_delegate_; | 94 ProcessManagerDelegate* process_manager_delegate_; |
100 | 95 |
101 // Not owned, defaults to NULL. | 96 // Not owned, defaults to NULL. |
102 ExtensionSystemProvider* extension_system_factory_; | 97 ExtensionSystemProvider* extension_system_factory_; |
103 | 98 |
104 scoped_ptr<ExtensionCache> extension_cache_; | |
105 | |
106 DISALLOW_COPY_AND_ASSIGN(TestExtensionsBrowserClient); | 99 DISALLOW_COPY_AND_ASSIGN(TestExtensionsBrowserClient); |
107 }; | 100 }; |
108 | 101 |
109 } // namespace extensions | 102 } // namespace extensions |
110 | 103 |
111 #endif // EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_ | 104 #endif // EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_ |
OLD | NEW |