OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // An implementation of BrowserProcess for unit tests that fails for most | 5 // An implementation of BrowserProcess for unit tests that fails for most |
6 // services. By preventing creation of services, we reduce dependencies and | 6 // services. By preventing creation of services, we reduce dependencies and |
7 // keep the profile clean. Clients of this class must handle the NULL return | 7 // keep the profile clean. Clients of this class must handle the NULL return |
8 // value, however. | 8 // value, however. |
9 | 9 |
10 #ifndef CHROME_TEST_TESTING_BROWSER_PROCESS_H_ | 10 #ifndef CHROME_TEST_TESTING_BROWSER_PROCESS_H_ |
11 #define CHROME_TEST_TESTING_BROWSER_PROCESS_H_ | 11 #define CHROME_TEST_TESTING_BROWSER_PROCESS_H_ |
12 #pragma once | 12 #pragma once |
13 | 13 |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 | 15 |
16 #include <string> | 16 #include <string> |
17 | 17 |
18 #include "app/clipboard/clipboard.h" | 18 #include "app/clipboard/clipboard.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "base/waitable_event.h" | 20 #include "base/waitable_event.h" |
21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/google_url_tracker.h" |
| 23 #include "chrome/browser/pref_service.h" |
22 #include "chrome/common/notification_service.h" | 24 #include "chrome/common/notification_service.h" |
23 | 25 |
24 class IOThread; | 26 class IOThread; |
25 | 27 |
26 class TestingBrowserProcess : public BrowserProcess { | 28 class TestingBrowserProcess : public BrowserProcess { |
27 public: | 29 public: |
28 TestingBrowserProcess() | 30 TestingBrowserProcess() |
29 : shutdown_event_(new base::WaitableEvent(true, false)), | 31 : shutdown_event_(new base::WaitableEvent(true, false)), |
30 module_ref_count_(0), | 32 module_ref_count_(0), |
31 app_locale_("en") { | 33 app_locale_("en"), |
| 34 pref_service_(NULL) { |
32 } | 35 } |
33 | 36 |
34 virtual ~TestingBrowserProcess() { | 37 virtual ~TestingBrowserProcess() { |
35 } | 38 } |
36 | 39 |
37 virtual void EndSession() { | 40 virtual void EndSession() { |
38 } | 41 } |
39 | 42 |
40 virtual ResourceDispatcherHost* resource_dispatcher_host() { | 43 virtual ResourceDispatcherHost* resource_dispatcher_host() { |
41 return NULL; | 44 return NULL; |
(...skipping 23 matching lines...) Expand all Loading... |
65 | 68 |
66 virtual base::Thread* cache_thread() { | 69 virtual base::Thread* cache_thread() { |
67 return NULL; | 70 return NULL; |
68 } | 71 } |
69 | 72 |
70 virtual ProfileManager* profile_manager() { | 73 virtual ProfileManager* profile_manager() { |
71 return NULL; | 74 return NULL; |
72 } | 75 } |
73 | 76 |
74 virtual PrefService* local_state() { | 77 virtual PrefService* local_state() { |
75 return NULL; | 78 return pref_service_; |
76 } | 79 } |
77 | 80 |
78 virtual IconManager* icon_manager() { | 81 virtual IconManager* icon_manager() { |
79 return NULL; | 82 return NULL; |
80 } | 83 } |
81 | 84 |
82 virtual ThumbnailGenerator* GetThumbnailGenerator() { | 85 virtual ThumbnailGenerator* GetThumbnailGenerator() { |
83 return NULL; | 86 return NULL; |
84 } | 87 } |
85 | 88 |
(...skipping 11 matching lines...) Expand all Loading... |
97 clipboard_.reset(new Clipboard); | 100 clipboard_.reset(new Clipboard); |
98 } | 101 } |
99 return clipboard_.get(); | 102 return clipboard_.get(); |
100 } | 103 } |
101 | 104 |
102 virtual NotificationUIManager* notification_ui_manager() { | 105 virtual NotificationUIManager* notification_ui_manager() { |
103 return NULL; | 106 return NULL; |
104 } | 107 } |
105 | 108 |
106 virtual GoogleURLTracker* google_url_tracker() { | 109 virtual GoogleURLTracker* google_url_tracker() { |
107 return NULL; | 110 return google_url_tracker_.get(); |
108 } | 111 } |
109 | 112 |
110 virtual IntranetRedirectDetector* intranet_redirect_detector() { | 113 virtual IntranetRedirectDetector* intranet_redirect_detector() { |
111 return NULL; | 114 return NULL; |
112 } | 115 } |
113 | 116 |
114 virtual AutomationProviderList* InitAutomationProviderList() { | 117 virtual AutomationProviderList* InitAutomationProviderList() { |
115 return NULL; | 118 return NULL; |
116 } | 119 } |
117 | 120 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 153 |
151 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 154 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
152 virtual void StartAutoupdateTimer() {} | 155 virtual void StartAutoupdateTimer() {} |
153 #endif | 156 #endif |
154 | 157 |
155 virtual bool have_inspector_files() const { return true; } | 158 virtual bool have_inspector_files() const { return true; } |
156 #if defined(IPC_MESSAGE_LOG_ENABLED) | 159 #if defined(IPC_MESSAGE_LOG_ENABLED) |
157 virtual void SetIPCLoggingEnabled(bool enable) {} | 160 virtual void SetIPCLoggingEnabled(bool enable) {} |
158 #endif | 161 #endif |
159 | 162 |
| 163 void SetPrefService(PrefService* pref_service) { |
| 164 pref_service_ = pref_service; |
| 165 } |
| 166 void SetGoogleURLTracker(GoogleURLTracker* google_url_tracker) { |
| 167 google_url_tracker_.reset(google_url_tracker); |
| 168 } |
| 169 |
160 private: | 170 private: |
161 NotificationService notification_service_; | 171 NotificationService notification_service_; |
162 scoped_ptr<base::WaitableEvent> shutdown_event_; | 172 scoped_ptr<base::WaitableEvent> shutdown_event_; |
163 unsigned int module_ref_count_; | 173 unsigned int module_ref_count_; |
164 scoped_ptr<Clipboard> clipboard_; | 174 scoped_ptr<Clipboard> clipboard_; |
165 std::string app_locale_; | 175 std::string app_locale_; |
166 | 176 |
| 177 PrefService* pref_service_; |
| 178 scoped_ptr<GoogleURLTracker> google_url_tracker_; |
| 179 |
167 DISALLOW_COPY_AND_ASSIGN(TestingBrowserProcess); | 180 DISALLOW_COPY_AND_ASSIGN(TestingBrowserProcess); |
168 }; | 181 }; |
169 | 182 |
170 #endif // CHROME_TEST_TESTING_BROWSER_PROCESS_H_ | 183 #endif // CHROME_TEST_TESTING_BROWSER_PROCESS_H_ |
OLD | NEW |