OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <exdisp.h> | 7 #include <exdisp.h> |
8 | 8 |
9 #include "app/app_paths.h" | 9 #include "app/app_paths.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "app/win_util.h" | 11 #include "app/win_util.h" |
12 | 12 |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
15 #include "base/i18n/icu_util.h" | 15 #include "base/i18n/icu_util.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "base/scoped_bstr_win.h" | 17 #include "base/scoped_bstr_win.h" |
18 #include "base/scoped_comptr_win.h" | 18 #include "base/scoped_comptr_win.h" |
19 #include "base/scoped_variant_win.h" | 19 #include "base/scoped_variant_win.h" |
20 | 20 |
21 #include "chrome/browser/browser_prefs.h" | 21 #include "chrome/browser/browser_prefs.h" |
22 #include "chrome/browser/chrome_thread.h" | 22 #include "chrome/browser/chrome_thread.h" |
23 #include "chrome/browser/process_singleton.h" | 23 #include "chrome/browser/process_singleton.h" |
24 #include "chrome/browser/profile_manager.h" | 24 #include "chrome/browser/profile_manager.h" |
| 25 #include "chrome/browser/renderer_host/render_process_host.h" |
25 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
26 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
| 28 #include "chrome/common/chrome_paths_internal.h" |
27 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
29 #include "chrome/browser/renderer_host/render_process_host.h" | |
30 | 31 |
31 #include "chrome_frame/utils.h" | 32 #include "chrome_frame/utils.h" |
32 #include "chrome_frame/test/chrome_frame_test_utils.h" | 33 #include "chrome_frame/test/chrome_frame_test_utils.h" |
33 #include "chrome_frame/test/net/dialog_watchdog.h" | 34 #include "chrome_frame/test/net/dialog_watchdog.h" |
34 #include "chrome_frame/test/net/test_automation_resource_message_filter.h" | 35 #include "chrome_frame/test/net/test_automation_resource_message_filter.h" |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
38 // A special command line switch to allow developers to manually launch the | 39 // A special command line switch to allow developers to manually launch the |
39 // browser and debug CF inside the browser. | 40 // browser and debug CF inside the browser. |
(...skipping 22 matching lines...) Expand all Loading... |
62 } | 63 } |
63 | 64 |
64 bool PromptAfterSetup() { | 65 bool PromptAfterSetup() { |
65 return CommandLine::ForCurrentProcess()->HasSwitch(kPromptAfterSetup); | 66 return CommandLine::ForCurrentProcess()->HasSwitch(kPromptAfterSetup); |
66 } | 67 } |
67 | 68 |
68 } // end namespace | 69 } // end namespace |
69 | 70 |
70 FakeExternalTab::FakeExternalTab() { | 71 FakeExternalTab::FakeExternalTab() { |
71 PathService::Get(chrome::DIR_USER_DATA, &overridden_user_dir_); | 72 PathService::Get(chrome::DIR_USER_DATA, &overridden_user_dir_); |
72 user_data_dir_ = FilePath::FromWStringHack(GetProfilePath()); | 73 GetProfilePath(&user_data_dir_); |
73 PathService::Override(chrome::DIR_USER_DATA, user_data_dir_); | 74 PathService::Override(chrome::DIR_USER_DATA, user_data_dir_); |
74 process_singleton_.reset(new ProcessSingleton(user_data_dir_)); | 75 process_singleton_.reset(new ProcessSingleton(user_data_dir_)); |
75 } | 76 } |
76 | 77 |
77 FakeExternalTab::~FakeExternalTab() { | 78 FakeExternalTab::~FakeExternalTab() { |
78 if (!overridden_user_dir_.empty()) { | 79 if (!overridden_user_dir_.empty()) { |
79 PathService::Override(chrome::DIR_USER_DATA, overridden_user_dir_); | 80 PathService::Override(chrome::DIR_USER_DATA, overridden_user_dir_); |
80 } | 81 } |
81 } | 82 } |
82 | 83 |
83 std::wstring FakeExternalTab::GetProfileName() { | 84 std::wstring FakeExternalTab::GetProfileName() { |
84 return L"iexplore"; | 85 return L"iexplore"; |
85 } | 86 } |
86 | 87 |
87 std::wstring FakeExternalTab::GetProfilePath() { | 88 bool FakeExternalTab::GetProfilePath(FilePath* path) { |
88 std::wstring path; | 89 if (!chrome::GetChromeFrameUserDataDirectory(path)) |
89 GetUserProfileBaseDirectory(&path); | 90 return false; |
90 file_util::AppendToPath(&path, GetProfileName()); | 91 *path = path->Append(GetProfileName()); |
91 return path; | 92 return true; |
92 } | 93 } |
93 | 94 |
94 void FakeExternalTab::Initialize() { | 95 void FakeExternalTab::Initialize() { |
95 DCHECK(g_browser_process == NULL); | 96 DCHECK(g_browser_process == NULL); |
96 | 97 |
97 // The gears plugin causes the PluginRequestInterceptor to kick in and it | 98 // The gears plugin causes the PluginRequestInterceptor to kick in and it |
98 // will cause problems when it tries to intercept URL requests. | 99 // will cause problems when it tries to intercept URL requests. |
99 PathService::Override(chrome::FILE_GEARS_PLUGIN, FilePath()); | 100 PathService::Override(chrome::FILE_GEARS_PLUGIN, FilePath()); |
100 | 101 |
101 icu_util::Initialize(); | 102 icu_util::Initialize(); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 DialogWatchdog watchdog; | 383 DialogWatchdog watchdog; |
383 // See url_request_unittest.cc for these credentials. | 384 // See url_request_unittest.cc for these credentials. |
384 SupplyProxyCredentials credentials("user", "secret"); | 385 SupplyProxyCredentials credentials("user", "secret"); |
385 watchdog.AddObserver(&credentials); | 386 watchdog.AddObserver(&credentials); |
386 testing::InitGoogleTest(&argc, argv); | 387 testing::InitGoogleTest(&argc, argv); |
387 FilterDisabledTests(); | 388 FilterDisabledTests(); |
388 CFUrlRequestUnittestRunner test_suite(argc, argv); | 389 CFUrlRequestUnittestRunner test_suite(argc, argv); |
389 test_suite.RunMainUIThread(); | 390 test_suite.RunMainUIThread(); |
390 return 0; | 391 return 0; |
391 } | 392 } |
OLD | NEW |