| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_frame/test/net/fake_external_tab.h" | 5 #include "chrome_frame/test/net/fake_external_tab.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlcom.h> | 8 #include <atlcom.h> |
| 9 #include <exdisp.h> | 9 #include <exdisp.h> |
| 10 #include <Winsock2.h> | 10 #include <Winsock2.h> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/debug/debugger.h" | 14 #include "base/debug/debugger.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/file_version_info.h" | 16 #include "base/file_version_info.h" |
| 17 #include "base/i18n/icu_util.h" | 17 #include "base/i18n/icu_util.h" |
| 18 #include "base/lazy_instance.h" | 18 #include "base/lazy_instance.h" |
| 19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| 21 #include "base/prefs/json_pref_store.h" |
| 21 #include "base/scoped_temp_dir.h" | 22 #include "base/scoped_temp_dir.h" |
| 22 #include "base/string_piece.h" | 23 #include "base/string_piece.h" |
| 23 #include "base/string_util.h" | 24 #include "base/string_util.h" |
| 24 #include "base/stringprintf.h" | 25 #include "base/stringprintf.h" |
| 25 #include "base/system_monitor/system_monitor.h" | 26 #include "base/system_monitor/system_monitor.h" |
| 26 #include "base/test/test_timeouts.h" | 27 #include "base/test/test_timeouts.h" |
| 27 #include "base/threading/platform_thread.h" | 28 #include "base/threading/platform_thread.h" |
| 28 #include "base/threading/thread.h" | 29 #include "base/threading/thread.h" |
| 29 #include "base/win/scoped_comptr.h" | 30 #include "base/win/scoped_comptr.h" |
| 30 #include "base/win/scoped_handle.h" | 31 #include "base/win/scoped_handle.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 } | 347 } |
| 347 | 348 |
| 348 ::testing::FLAGS_gtest_filter = filter; | 349 ::testing::FLAGS_gtest_filter = filter; |
| 349 } | 350 } |
| 350 | 351 |
| 351 } // namespace | 352 } // namespace |
| 352 | 353 |
| 353 // Same as BrowserProcessImpl, but uses custom profile manager. | 354 // Same as BrowserProcessImpl, but uses custom profile manager. |
| 354 class FakeBrowserProcessImpl : public BrowserProcessImpl { | 355 class FakeBrowserProcessImpl : public BrowserProcessImpl { |
| 355 public: | 356 public: |
| 356 explicit FakeBrowserProcessImpl(const CommandLine& command_line) | 357 FakeBrowserProcessImpl(base::SequencedTaskRunner* local_state_task_runner, |
| 357 : BrowserProcessImpl(command_line) { | 358 const CommandLine& command_line) |
| 359 : BrowserProcessImpl(local_state_task_runner, command_line) { |
| 358 profiles_dir_.CreateUniqueTempDir(); | 360 profiles_dir_.CreateUniqueTempDir(); |
| 359 } | 361 } |
| 360 | 362 |
| 361 virtual ~FakeBrowserProcessImpl() {} | 363 virtual ~FakeBrowserProcessImpl() {} |
| 362 | 364 |
| 363 virtual ProfileManager* profile_manager() OVERRIDE { | 365 virtual ProfileManager* profile_manager() OVERRIDE { |
| 364 if (!profile_manager_.get()) { | 366 if (!profile_manager_.get()) { |
| 365 profile_manager_.reset( | 367 profile_manager_.reset( |
| 366 new ProfileManagerWithoutInit(profiles_dir_.path())); | 368 new ProfileManagerWithoutInit(profiles_dir_.path())); |
| 367 } | 369 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 | 490 |
| 489 // Point the ResourceBundle at chrome.dll. | 491 // Point the ResourceBundle at chrome.dll. |
| 490 ui::SetResourcesDataDLL(_AtlBaseModule.GetResourceInstance()); | 492 ui::SetResourcesDataDLL(_AtlBaseModule.GetResourceInstance()); |
| 491 | 493 |
| 492 ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); | 494 ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); |
| 493 | 495 |
| 494 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 496 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| 495 cmd->AppendSwitch(switches::kDisableWebResources); | 497 cmd->AppendSwitch(switches::kDisableWebResources); |
| 496 cmd->AppendSwitch(switches::kSingleProcess); | 498 cmd->AppendSwitch(switches::kSingleProcess); |
| 497 | 499 |
| 498 browser_process_.reset(new FakeBrowserProcessImpl(*cmd)); | 500 FilePath local_state_path; |
| 501 CHECK(PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path)); |
| 502 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner = |
| 503 JsonPrefStore::GetTaskRunnerForFile(local_state_path, |
| 504 BrowserThread::GetBlockingPool()); |
| 505 browser_process_.reset(new FakeBrowserProcessImpl(local_state_task_runner, |
| 506 *cmd)); |
| 499 // BrowserProcessImpl's constructor should set g_browser_process. | 507 // BrowserProcessImpl's constructor should set g_browser_process. |
| 500 DCHECK(g_browser_process); | 508 DCHECK(g_browser_process); |
| 501 g_browser_process->SetApplicationLocale("en-US"); | 509 g_browser_process->SetApplicationLocale("en-US"); |
| 502 | 510 |
| 503 content::RenderProcessHost::SetRunRendererInProcess(true); | 511 content::RenderProcessHost::SetRunRendererInProcess(true); |
| 504 | 512 |
| 505 browser_process_->local_state()->RegisterBooleanPref( | 513 browser_process_->local_state()->RegisterBooleanPref( |
| 506 prefs::kMetricsReportingEnabled, false); | 514 prefs::kMetricsReportingEnabled, false); |
| 507 } | 515 } |
| 508 | 516 |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 // content::InitializeSandboxInfo(&sandbox_info); | 950 // content::InitializeSandboxInfo(&sandbox_info); |
| 943 FakeMainDelegate delegate; | 951 FakeMainDelegate delegate; |
| 944 content::ContentMain( | 952 content::ContentMain( |
| 945 reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL)), | 953 reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL)), |
| 946 &sandbox_info, | 954 &sandbox_info, |
| 947 &delegate); | 955 &delegate); |
| 948 | 956 |
| 949 // Note: In debug builds, we ExitProcess during PostDestroyThreads. | 957 // Note: In debug builds, we ExitProcess during PostDestroyThreads. |
| 950 return g_test_suite->test_result(); | 958 return g_test_suite->test_result(); |
| 951 } | 959 } |
| OLD | NEW |