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 <string> | |
9 #include <vector> | |
10 | |
8 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "components/update_client/update_client.h" | |
9 #include "extensions/browser/extensions_browser_client.h" | 13 #include "extensions/browser/extensions_browser_client.h" |
10 #include "extensions/browser/updater/extension_cache.h" | 14 #include "extensions/browser/updater/extension_cache.h" |
11 | 15 |
12 namespace extensions { | 16 namespace extensions { |
13 | 17 |
14 // A simplified ExtensionsBrowserClient for a single normal browser context and | 18 // A simplified ExtensionsBrowserClient for a single normal browser context and |
15 // an optional incognito browser context associated with it. A test that uses | 19 // an optional incognito browser context associated with it. A test that uses |
16 // this class should call ExtensionsBrowserClient::Set() with its instance. | 20 // this class should call ExtensionsBrowserClient::Set() with its instance. |
17 class TestExtensionsBrowserClient : public ExtensionsBrowserClient { | 21 class TestExtensionsBrowserClient : public ExtensionsBrowserClient { |
18 public: | 22 public: |
19 // |main_context| is required and must not be an incognito context. | 23 // |main_context| is required and must not be an incognito context. |
20 explicit TestExtensionsBrowserClient(content::BrowserContext* main_context); | 24 explicit TestExtensionsBrowserClient(content::BrowserContext* main_context); |
21 ~TestExtensionsBrowserClient() override; | 25 ~TestExtensionsBrowserClient() override; |
22 | 26 |
23 void set_process_manager_delegate(ProcessManagerDelegate* delegate) { | 27 void set_process_manager_delegate(ProcessManagerDelegate* delegate) { |
24 process_manager_delegate_ = delegate; | 28 process_manager_delegate_ = delegate; |
25 } | 29 } |
26 void set_extension_system_factory(ExtensionSystemProvider* factory) { | 30 void set_extension_system_factory(ExtensionSystemProvider* factory) { |
27 extension_system_factory_ = factory; | 31 extension_system_factory_ = factory; |
28 } | 32 } |
29 void set_extension_cache(scoped_ptr<ExtensionCache> extension_cache) { | 33 void set_extension_cache(scoped_ptr<ExtensionCache> extension_cache) { |
30 extension_cache_ = extension_cache.Pass(); | 34 extension_cache_ = extension_cache.Pass(); |
31 } | 35 } |
36 void set_update_client( | |
37 scoped_refptr<update_client::UpdateClient> update_client) { | |
Sorin Jianu
2015/10/02 00:05:10
include ref_counted.h ?
asargent_no_longer_on_chrome
2015/10/06 21:31:17
Done.
| |
38 update_client_ = update_client; | |
39 } | |
32 | 40 |
33 // Associates an incognito context with |main_context_|. | 41 // Associates an incognito context with |main_context_|. |
34 void SetIncognitoContext(content::BrowserContext* incognito_context); | 42 void SetIncognitoContext(content::BrowserContext* incognito_context); |
35 | 43 |
36 // ExtensionsBrowserClient overrides: | 44 // ExtensionsBrowserClient overrides: |
37 bool IsShuttingDown() override; | 45 bool IsShuttingDown() override; |
38 bool AreExtensionsDisabled(const base::CommandLine& command_line, | 46 bool AreExtensionsDisabled(const base::CommandLine& command_line, |
39 content::BrowserContext* context) override; | 47 content::BrowserContext* context) override; |
40 bool IsValidContext(content::BrowserContext* context) override; | 48 bool IsValidContext(content::BrowserContext* context) override; |
41 bool IsSameContext(content::BrowserContext* first, | 49 bool IsSameContext(content::BrowserContext* first, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 GetComponentExtensionResourceManager() override; | 97 GetComponentExtensionResourceManager() override; |
90 void BroadcastEventToRenderers(events::HistogramValue histogram_value, | 98 void BroadcastEventToRenderers(events::HistogramValue histogram_value, |
91 const std::string& event_name, | 99 const std::string& event_name, |
92 scoped_ptr<base::ListValue> args) override; | 100 scoped_ptr<base::ListValue> args) override; |
93 net::NetLog* GetNetLog() override; | 101 net::NetLog* GetNetLog() override; |
94 ExtensionCache* GetExtensionCache() override; | 102 ExtensionCache* GetExtensionCache() override; |
95 bool IsBackgroundUpdateAllowed() override; | 103 bool IsBackgroundUpdateAllowed() override; |
96 bool IsMinBrowserVersionSupported(const std::string& min_version) override; | 104 bool IsMinBrowserVersionSupported(const std::string& min_version) override; |
97 ExtensionWebContentsObserver* GetExtensionWebContentsObserver( | 105 ExtensionWebContentsObserver* GetExtensionWebContentsObserver( |
98 content::WebContents* web_contents) override; | 106 content::WebContents* web_contents) override; |
107 scoped_refptr<update_client::UpdateClient> CreateUpdateClient( | |
108 content::BrowserContext* context) override; | |
99 | 109 |
100 private: | 110 private: |
101 content::BrowserContext* main_context_; // Not owned. | 111 content::BrowserContext* main_context_; // Not owned. |
102 content::BrowserContext* incognito_context_; // Not owned, defaults to NULL. | 112 content::BrowserContext* incognito_context_; // Not owned, defaults to NULL. |
103 | 113 |
104 // Not owned, defaults to NULL. | 114 // Not owned, defaults to NULL. |
105 ProcessManagerDelegate* process_manager_delegate_; | 115 ProcessManagerDelegate* process_manager_delegate_; |
106 | 116 |
107 // Not owned, defaults to NULL. | 117 // Not owned, defaults to NULL. |
108 ExtensionSystemProvider* extension_system_factory_; | 118 ExtensionSystemProvider* extension_system_factory_; |
109 | 119 |
110 scoped_ptr<ExtensionCache> extension_cache_; | 120 scoped_ptr<ExtensionCache> extension_cache_; |
111 | 121 |
122 scoped_refptr<update_client::UpdateClient> update_client_; | |
123 | |
112 DISALLOW_COPY_AND_ASSIGN(TestExtensionsBrowserClient); | 124 DISALLOW_COPY_AND_ASSIGN(TestExtensionsBrowserClient); |
113 }; | 125 }; |
114 | 126 |
115 } // namespace extensions | 127 } // namespace extensions |
116 | 128 |
117 #endif // EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_ | 129 #endif // EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_ |
OLD | NEW |