Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(793)

Side by Side Diff: extensions/browser/test_extensions_browser_client.h

Issue 1362043005: Add extensions code to use common updater in components/update_client/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use ConfiguratorImpl, change TestExtensionService, etc Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "base/callback.h"
8 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "components/update_client/update_client.h"
9 #include "extensions/browser/extensions_browser_client.h" 15 #include "extensions/browser/extensions_browser_client.h"
10 #include "extensions/browser/updater/extension_cache.h" 16 #include "extensions/browser/updater/extension_cache.h"
11 17
12 namespace extensions { 18 namespace extensions {
13 19
14 // A simplified ExtensionsBrowserClient for a single normal browser context and 20 // A simplified ExtensionsBrowserClient for a single normal browser context and
15 // an optional incognito browser context associated with it. A test that uses 21 // an optional incognito browser context associated with it. A test that uses
16 // this class should call ExtensionsBrowserClient::Set() with its instance. 22 // this class should call ExtensionsBrowserClient::Set() with its instance.
17 class TestExtensionsBrowserClient : public ExtensionsBrowserClient { 23 class TestExtensionsBrowserClient : public ExtensionsBrowserClient {
18 public: 24 public:
19 // |main_context| is required and must not be an incognito context. 25 // |main_context| is required and must not be an incognito context.
20 explicit TestExtensionsBrowserClient(content::BrowserContext* main_context); 26 explicit TestExtensionsBrowserClient(content::BrowserContext* main_context);
21 ~TestExtensionsBrowserClient() override; 27 ~TestExtensionsBrowserClient() override;
22 28
23 void set_process_manager_delegate(ProcessManagerDelegate* delegate) { 29 void set_process_manager_delegate(ProcessManagerDelegate* delegate) {
24 process_manager_delegate_ = delegate; 30 process_manager_delegate_ = delegate;
25 } 31 }
26 void set_extension_system_factory(ExtensionSystemProvider* factory) { 32 void set_extension_system_factory(ExtensionSystemProvider* factory) {
27 extension_system_factory_ = factory; 33 extension_system_factory_ = factory;
28 } 34 }
29 void set_extension_cache(scoped_ptr<ExtensionCache> extension_cache) { 35 void set_extension_cache(scoped_ptr<ExtensionCache> extension_cache) {
30 extension_cache_ = extension_cache.Pass(); 36 extension_cache_ = extension_cache.Pass();
31 } 37 }
32 38
39 // Sets a factory to respond to calls of the CreateUpdateClient method.
40 void SetUpdateClientFactory(
41 const base::Callback<update_client::UpdateClient*(void)>& factory);
42
33 // Associates an incognito context with |main_context_|. 43 // Associates an incognito context with |main_context_|.
34 void SetIncognitoContext(content::BrowserContext* incognito_context); 44 void SetIncognitoContext(content::BrowserContext* incognito_context);
35 45
36 // ExtensionsBrowserClient overrides: 46 // ExtensionsBrowserClient overrides:
37 bool IsShuttingDown() override; 47 bool IsShuttingDown() override;
38 bool AreExtensionsDisabled(const base::CommandLine& command_line, 48 bool AreExtensionsDisabled(const base::CommandLine& command_line,
39 content::BrowserContext* context) override; 49 content::BrowserContext* context) override;
40 bool IsValidContext(content::BrowserContext* context) override; 50 bool IsValidContext(content::BrowserContext* context) override;
41 bool IsSameContext(content::BrowserContext* first, 51 bool IsSameContext(content::BrowserContext* first,
42 content::BrowserContext* second) override; 52 content::BrowserContext* second) override;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 GetComponentExtensionResourceManager() override; 99 GetComponentExtensionResourceManager() override;
90 void BroadcastEventToRenderers(events::HistogramValue histogram_value, 100 void BroadcastEventToRenderers(events::HistogramValue histogram_value,
91 const std::string& event_name, 101 const std::string& event_name,
92 scoped_ptr<base::ListValue> args) override; 102 scoped_ptr<base::ListValue> args) override;
93 net::NetLog* GetNetLog() override; 103 net::NetLog* GetNetLog() override;
94 ExtensionCache* GetExtensionCache() override; 104 ExtensionCache* GetExtensionCache() override;
95 bool IsBackgroundUpdateAllowed() override; 105 bool IsBackgroundUpdateAllowed() override;
96 bool IsMinBrowserVersionSupported(const std::string& min_version) override; 106 bool IsMinBrowserVersionSupported(const std::string& min_version) override;
97 ExtensionWebContentsObserver* GetExtensionWebContentsObserver( 107 ExtensionWebContentsObserver* GetExtensionWebContentsObserver(
98 content::WebContents* web_contents) override; 108 content::WebContents* web_contents) override;
109 scoped_refptr<update_client::UpdateClient> CreateUpdateClient(
110 content::BrowserContext* context) override;
99 111
100 private: 112 private:
101 content::BrowserContext* main_context_; // Not owned. 113 content::BrowserContext* main_context_; // Not owned.
102 content::BrowserContext* incognito_context_; // Not owned, defaults to NULL. 114 content::BrowserContext* incognito_context_; // Not owned, defaults to NULL.
103 115
104 // Not owned, defaults to NULL. 116 // Not owned, defaults to NULL.
105 ProcessManagerDelegate* process_manager_delegate_; 117 ProcessManagerDelegate* process_manager_delegate_;
106 118
107 // Not owned, defaults to NULL. 119 // Not owned, defaults to NULL.
108 ExtensionSystemProvider* extension_system_factory_; 120 ExtensionSystemProvider* extension_system_factory_;
109 121
110 scoped_ptr<ExtensionCache> extension_cache_; 122 scoped_ptr<ExtensionCache> extension_cache_;
111 123
124 base::Callback<update_client::UpdateClient*(void)> update_client_factory_;
125
112 DISALLOW_COPY_AND_ASSIGN(TestExtensionsBrowserClient); 126 DISALLOW_COPY_AND_ASSIGN(TestExtensionsBrowserClient);
113 }; 127 };
114 128
115 } // namespace extensions 129 } // namespace extensions
116 130
117 #endif // EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_ 131 #endif // EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698