| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/test/testing_browser_process.h" | 5 #include "chrome/test/testing_browser_process.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "chrome/browser/google/google_url_tracker.h" | 8 #include "chrome/browser/google/google_url_tracker.h" |
| 9 #include "chrome/browser/notifications/notification_ui_manager.h" | 9 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 10 #include "chrome/browser/policy/browser_policy_connector.h" | 10 #include "chrome/browser/policy/browser_policy_connector.h" |
| 11 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
| 12 #include "chrome/browser/prerender/prerender_tracker.h" | 12 #include "chrome/browser/prerender/prerender_tracker.h" |
| 13 #include "chrome/browser/printing/background_printing_manager.h" | 13 #include "chrome/browser/printing/background_printing_manager.h" |
| 14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
| 15 #include "net/url_request/url_request_context_getter.h" | 15 #include "net/url_request/url_request_context_getter.h" |
| 16 #include "ui/base/clipboard/clipboard.h" | 16 #include "ui/base/clipboard/clipboard.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 TestingBrowserProcess::TestingBrowserProcess() | 19 TestingBrowserProcess::TestingBrowserProcess() |
| 20 : module_ref_count_(0), | 20 : module_ref_count_(0), |
| 21 app_locale_("en"), | 21 app_locale_("en"), |
| 22 local_state_(NULL) { | 22 local_state_(NULL), |
| 23 io_thread_(NULL) { |
| 23 } | 24 } |
| 24 | 25 |
| 25 TestingBrowserProcess::~TestingBrowserProcess() { | 26 TestingBrowserProcess::~TestingBrowserProcess() { |
| 26 EXPECT_FALSE(local_state_); | 27 EXPECT_FALSE(local_state_); |
| 27 } | 28 } |
| 28 | 29 |
| 29 void TestingBrowserProcess::EndSession() { | 30 void TestingBrowserProcess::EndSession() { |
| 30 } | 31 } |
| 31 | 32 |
| 32 ResourceDispatcherHost* TestingBrowserProcess::resource_dispatcher_host() { | 33 ResourceDispatcherHost* TestingBrowserProcess::resource_dispatcher_host() { |
| 33 return NULL; | 34 return NULL; |
| 34 } | 35 } |
| 35 | 36 |
| 36 MetricsService* TestingBrowserProcess::metrics_service() { | 37 MetricsService* TestingBrowserProcess::metrics_service() { |
| 37 return NULL; | 38 return NULL; |
| 38 } | 39 } |
| 39 | 40 |
| 40 IOThread* TestingBrowserProcess::io_thread() { | 41 IOThread* TestingBrowserProcess::io_thread() { |
| 41 return NULL; | 42 return io_thread_; |
| 42 } | 43 } |
| 43 | 44 |
| 44 base::Thread* TestingBrowserProcess::file_thread() { | 45 base::Thread* TestingBrowserProcess::file_thread() { |
| 45 return NULL; | 46 return NULL; |
| 46 } | 47 } |
| 47 | 48 |
| 48 base::Thread* TestingBrowserProcess::db_thread() { | 49 base::Thread* TestingBrowserProcess::db_thread() { |
| 49 return NULL; | 50 return NULL; |
| 50 } | 51 } |
| 51 | 52 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 if (!local_state && notification_ui_manager_.get()) | 242 if (!local_state && notification_ui_manager_.get()) |
| 242 notification_ui_manager_.reset(); // Used local_state_. | 243 notification_ui_manager_.reset(); // Used local_state_. |
| 243 local_state_ = local_state; | 244 local_state_ = local_state; |
| 244 } | 245 } |
| 245 | 246 |
| 246 void TestingBrowserProcess::SetGoogleURLTracker( | 247 void TestingBrowserProcess::SetGoogleURLTracker( |
| 247 GoogleURLTracker* google_url_tracker) { | 248 GoogleURLTracker* google_url_tracker) { |
| 248 google_url_tracker_.reset(google_url_tracker); | 249 google_url_tracker_.reset(google_url_tracker); |
| 249 } | 250 } |
| 250 | 251 |
| 252 void TestingBrowserProcess::SetIOThread(IOThread* io_thread) { |
| 253 io_thread_ = io_thread; |
| 254 } |
| 255 |
| 251 ScopedTestingBrowserProcess::ScopedTestingBrowserProcess() { | 256 ScopedTestingBrowserProcess::ScopedTestingBrowserProcess() { |
| 252 // TODO(phajdan.jr): Temporary, for http://crbug.com/61062. | 257 // TODO(phajdan.jr): Temporary, for http://crbug.com/61062. |
| 253 // ChromeTestSuite sets up a global TestingBrowserProcess | 258 // ChromeTestSuite sets up a global TestingBrowserProcess |
| 254 // for all tests. We need to get rid of it, because it contains | 259 // for all tests. We need to get rid of it, because it contains |
| 255 // a NotificationService, and there can be only one NotificationService | 260 // a NotificationService, and there can be only one NotificationService |
| 256 // per thread. | 261 // per thread. |
| 257 DCHECK(g_browser_process); | 262 DCHECK(g_browser_process); |
| 258 delete g_browser_process; | 263 delete g_browser_process; |
| 259 | 264 |
| 260 browser_process_.reset(new TestingBrowserProcess); | 265 browser_process_.reset(new TestingBrowserProcess); |
| 261 g_browser_process = browser_process_.get(); | 266 g_browser_process = browser_process_.get(); |
| 262 } | 267 } |
| 263 | 268 |
| 264 ScopedTestingBrowserProcess::~ScopedTestingBrowserProcess() { | 269 ScopedTestingBrowserProcess::~ScopedTestingBrowserProcess() { |
| 265 DCHECK_EQ(browser_process_.get(), g_browser_process); | 270 DCHECK_EQ(browser_process_.get(), g_browser_process); |
| 266 | 271 |
| 267 // TODO(phajdan.jr): Temporary, for http://crbug.com/61062. | 272 // TODO(phajdan.jr): Temporary, for http://crbug.com/61062. |
| 268 // After the transition is over, we should just | 273 // After the transition is over, we should just |
| 269 // reset |g_browser_process| to NULL. | 274 // reset |g_browser_process| to NULL. |
| 270 browser_process_.reset(); | 275 browser_process_.reset(); |
| 271 g_browser_process = new TestingBrowserProcess(); | 276 g_browser_process = new TestingBrowserProcess(); |
| 272 } | 277 } |
| OLD | NEW |