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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 } | 346 } |
346 | 347 |
347 ::testing::FLAGS_gtest_filter = filter; | 348 ::testing::FLAGS_gtest_filter = filter; |
348 } | 349 } |
349 | 350 |
350 } // namespace | 351 } // namespace |
351 | 352 |
352 // Same as BrowserProcessImpl, but uses custom profile manager. | 353 // Same as BrowserProcessImpl, but uses custom profile manager. |
353 class FakeBrowserProcessImpl : public BrowserProcessImpl { | 354 class FakeBrowserProcessImpl : public BrowserProcessImpl { |
354 public: | 355 public: |
355 explicit FakeBrowserProcessImpl(const CommandLine& command_line) | 356 FakeBrowserProcessImpl(base::SequencedTaskRunner* local_state_task_runner, |
356 : BrowserProcessImpl(command_line) { | 357 const CommandLine& command_line) |
| 358 : BrowserProcessImpl(local_state_task_runner, command_line) { |
357 profiles_dir_.CreateUniqueTempDir(); | 359 profiles_dir_.CreateUniqueTempDir(); |
358 } | 360 } |
359 | 361 |
360 virtual ~FakeBrowserProcessImpl() {} | 362 virtual ~FakeBrowserProcessImpl() {} |
361 | 363 |
362 virtual ProfileManager* profile_manager() OVERRIDE { | 364 virtual ProfileManager* profile_manager() OVERRIDE { |
363 if (!profile_manager_.get()) { | 365 if (!profile_manager_.get()) { |
364 profile_manager_.reset( | 366 profile_manager_.reset( |
365 new ProfileManagerWithoutInit(profiles_dir_.path())); | 367 new ProfileManagerWithoutInit(profiles_dir_.path())); |
366 } | 368 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 | 489 |
488 // Point the ResourceBundle at chrome.dll. | 490 // Point the ResourceBundle at chrome.dll. |
489 ui::SetResourcesDataDLL(_AtlBaseModule.GetResourceInstance()); | 491 ui::SetResourcesDataDLL(_AtlBaseModule.GetResourceInstance()); |
490 | 492 |
491 ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); | 493 ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); |
492 | 494 |
493 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 495 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
494 cmd->AppendSwitch(switches::kDisableWebResources); | 496 cmd->AppendSwitch(switches::kDisableWebResources); |
495 cmd->AppendSwitch(switches::kSingleProcess); | 497 cmd->AppendSwitch(switches::kSingleProcess); |
496 | 498 |
497 browser_process_.reset(new FakeBrowserProcessImpl(*cmd)); | 499 FilePath local_state_path; |
| 500 CHECK(PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path)); |
| 501 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner = |
| 502 JsonPrefStore::GetTaskRunnerForFile(local_state_path, |
| 503 BrowserThread::GetBlockingPool()); |
| 504 browser_process_.reset(new FakeBrowserProcessImpl(local_state_task_runner, |
| 505 *cmd)); |
498 // BrowserProcessImpl's constructor should set g_browser_process. | 506 // BrowserProcessImpl's constructor should set g_browser_process. |
499 DCHECK(g_browser_process); | 507 DCHECK(g_browser_process); |
500 g_browser_process->SetApplicationLocale("en-US"); | 508 g_browser_process->SetApplicationLocale("en-US"); |
501 | 509 |
502 content::RenderProcessHost::SetRunRendererInProcess(true); | 510 content::RenderProcessHost::SetRunRendererInProcess(true); |
503 | 511 |
504 browser_process_->local_state()->RegisterBooleanPref( | 512 browser_process_->local_state()->RegisterBooleanPref( |
505 prefs::kMetricsReportingEnabled, false); | 513 prefs::kMetricsReportingEnabled, false); |
506 } | 514 } |
507 | 515 |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 // content::InitializeSandboxInfo(&sandbox_info); | 949 // content::InitializeSandboxInfo(&sandbox_info); |
942 FakeMainDelegate delegate; | 950 FakeMainDelegate delegate; |
943 content::ContentMain( | 951 content::ContentMain( |
944 reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL)), | 952 reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL)), |
945 &sandbox_info, | 953 &sandbox_info, |
946 &delegate); | 954 &delegate); |
947 | 955 |
948 // Note: In debug builds, we ExitProcess during PostDestroyThreads. | 956 // Note: In debug builds, we ExitProcess during PostDestroyThreads. |
949 return g_test_suite->test_result(); | 957 return g_test_suite->test_result(); |
950 } | 958 } |
OLD | NEW |