diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-07 10:17:12 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-07 10:17:12 +0000 |
commit | 72cbd32707a2ede460bcc1b3cb199e653282a8ed (patch) | |
tree | d212d36fbd064fd4b8c5783a9002f235c98d7a2d /chrome | |
parent | 2fe25aac3d317086338a761e3b040cbcffc3a873 (diff) | |
download | chromium_src-72cbd32707a2ede460bcc1b3cb199e653282a8ed.zip chromium_src-72cbd32707a2ede460bcc1b3cb199e653282a8ed.tar.gz chromium_src-72cbd32707a2ede460bcc1b3cb199e653282a8ed.tar.bz2 |
Switching things to FilePath:
Remove following deprecated wstring-using functions:
net/net_util: FilePathToFileURL
net/net_util: FileURLToFilePath
Switch net/base/upload_data to FilePath.
Switch upload-related parts of net/url_request/url_request to FilePath.
Made necessary adjustments in rest of code (a lot).
Review URL: http://codereview.chromium.org/63011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13242 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
31 files changed, 135 insertions, 121 deletions
diff --git a/chrome/browser/automation/url_request_mock_http_job.cc b/chrome/browser/automation/url_request_mock_http_job.cc index 26a5cc7..4bb191a 100644 --- a/chrome/browser/automation/url_request_mock_http_job.cc +++ b/chrome/browser/automation/url_request_mock_http_job.cc @@ -32,10 +32,9 @@ URLRequestJob* URLRequestMockHTTPJob::Factory(URLRequest* request, } // Convert the file:/// URL to a path on disk. - std::wstring file_path; + FilePath file_path; net::FileURLToFilePath(GURL(WideToUTF8(file_url)), &file_path); - return new URLRequestMockHTTPJob(request, - FilePath::FromWStringHack(file_path)); + return new URLRequestMockHTTPJob(request, file_path); } /* static */ diff --git a/chrome/browser/automation/url_request_mock_net_error_job.cc b/chrome/browser/automation/url_request_mock_net_error_job.cc index e6ab51f..0b9a20a 100644 --- a/chrome/browser/automation/url_request_mock_net_error_job.cc +++ b/chrome/browser/automation/url_request_mock_net_error_job.cc @@ -54,11 +54,11 @@ URLRequestJob* URLRequestMockNetErrorJob::Factory(URLRequest* request, file_url.append(mock_info.base); file_url.append(UTF8ToWide(url.path())); // Convert the file:/// URL to a path on disk. - std::wstring file_path; + FilePath file_path; net::FileURLToFilePath(GURL(WideToUTF8(file_url)), &file_path); return new URLRequestMockNetErrorJob(request, mock_info.errors, mock_info.ssl_cert, - FilePath::FromWStringHack(file_path)); + file_path); } URLRequestMockNetErrorJob::URLRequestMockNetErrorJob(URLRequest* request, diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 727d128..ab5037a 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1949,7 +1949,7 @@ void Browser::RenderWidgetShowing() { // Browser, SelectFileDialog::Listener implementation: void Browser::FileSelected(const FilePath& path, int index, void* params) { - GURL file_url = net::FilePathToFileURL(path.ToWStringHack()); + GURL file_url = net::FilePathToFileURL(path); if (!file_url.is_empty()) OpenURL(file_url, GURL(), CURRENT_TAB, PageTransition::TYPED); } diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc index a30016a..3a05636 100644 --- a/chrome/browser/browser_uitest.cc +++ b/chrome/browser/browser_uitest.cc @@ -61,8 +61,8 @@ class VisibleBrowserTest : public UITest { // Launch the app on a page with no title, check that the app title was set // correctly. TEST_F(BrowserTest, NoTitle) { - std::wstring test_file = test_data_directory_; - file_util::AppendToPath(&test_file, L"title1.html"); + FilePath test_file(FilePath::FromWStringHack(test_data_directory_)); + test_file = test_file.AppendASCII("title1.html"); NavigateToURL(net::FilePathToFileURL(test_file)); Sleep(sleep_timeout_ms()); // The browser lazily updates the title. @@ -74,8 +74,8 @@ TEST_F(BrowserTest, NoTitle) { // Launch the app, navigate to a page with a title, check that the app title // was set correctly. TEST_F(BrowserTest, Title) { - std::wstring test_file = test_data_directory_; - file_util::AppendToPath(&test_file, L"title2.html"); + FilePath test_file(FilePath::FromWStringHack(test_data_directory_)); + test_file = test_file.AppendASCII("title2.html"); NavigateToURL(net::FilePathToFileURL(test_file)); Sleep(sleep_timeout_ms()); // The browser lazily updates the title. @@ -90,8 +90,8 @@ TEST_F(BrowserTest, Title) { // had a hard limit of 31 processes and this test is mainly directed at // verifying that we don't crash when we pass this limit. TEST_F(BrowserTest, ThirtyFourTabs) { - std::wstring test_file = test_data_directory_; - file_util::AppendToPath(&test_file, L"title2.html"); + FilePath test_file(FilePath::FromWStringHack(test_data_directory_)); + test_file = test_file.AppendASCII("title2.html"); GURL url(net::FilePathToFileURL(test_file)); scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); // There is one initial tab. @@ -116,8 +116,8 @@ TEST_F(BrowserTest, ThirtyFourTabs) { // The browser should quit quickly if it receives a WM_ENDSESSION message. TEST_F(BrowserTest, WindowsSessionEnd) { - std::wstring test_file = test_data_directory_; - file_util::AppendToPath(&test_file, L"title1.html"); + FilePath test_file(FilePath::FromWStringHack(test_data_directory_)); + test_file = test_file.AppendASCII("title1.html"); NavigateToURL(net::FilePathToFileURL(test_file)); Sleep(action_timeout_ms()); @@ -186,12 +186,12 @@ TEST_F(BrowserTest, NullOpenerRedirectForksProcess) { scoped_refptr<HTTPTestServer> server = HTTPTestServer::CreateServer(kDocRoot, NULL); ASSERT_TRUE(NULL != server.get()); - std::wstring test_file(test_data_directory_); + FilePath test_file(FilePath::FromWStringHack(test_data_directory_)); scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); scoped_ptr<TabProxy> tab(window->GetActiveTab()); // Start with a file:// url - file_util::AppendToPath(&test_file, L"title2.html"); + test_file = test_file.AppendASCII("title2.html"); tab->NavigateToURL(net::FilePathToFileURL(test_file)); int orig_tab_count = -1; ASSERT_TRUE(window->GetTabCount(&orig_tab_count)); @@ -226,12 +226,12 @@ TEST_F(BrowserTest, OtherRedirectsDontForkProcess) { scoped_refptr<HTTPTestServer> server = HTTPTestServer::CreateServer(kDocRoot, NULL); ASSERT_TRUE(NULL != server.get()); - std::wstring test_file(test_data_directory_); + FilePath test_file(FilePath::FromWStringHack(test_data_directory_)); scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); scoped_ptr<TabProxy> tab(window->GetActiveTab()); // Start with a file:// url - file_util::AppendToPath(&test_file, L"title2.html"); + test_file = test_file.AppendASCII("title2.html"); tab->NavigateToURL(net::FilePathToFileURL(test_file)); int orig_tab_count = -1; ASSERT_TRUE(window->GetTabCount(&orig_tab_count)); @@ -263,8 +263,8 @@ TEST_F(BrowserTest, OtherRedirectsDontForkProcess) { } TEST_F(VisibleBrowserTest, WindowOpenClose) { - std::wstring test_file(test_data_directory_); - file_util::AppendToPath(&test_file, L"window.close.html"); + FilePath test_file(FilePath::FromWStringHack(test_data_directory_)); + test_file = test_file.AppendASCII("window.close.html"); NavigateToURL(net::FilePathToFileURL(test_file)); diff --git a/chrome/browser/chrome_plugin_host.cc b/chrome/browser/chrome_plugin_host.cc index 373bee1..4548a48 100644 --- a/chrome/browser/chrome_plugin_host.cc +++ b/chrome/browser/chrome_plugin_host.cc @@ -8,6 +8,7 @@ #include "base/basictypes.h" #include "base/command_line.h" +#include "base/file_path.h" #include "base/file_util.h" #include "base/gfx/png_encoder.h" #include "base/histogram.h" @@ -637,8 +638,8 @@ CPError STDCALL CPR_AppendFileToUpload(CPRequest* request, const char* filepath, CHECK(handler); if (!length) length = kuint64max; - std::wstring wfilepath(UTF8ToWide(filepath)); - handler->request()->AppendFileRangeToUpload(wfilepath, offset, length); + FilePath path(FilePath::FromWStringHack(UTF8ToWide(filepath))); + handler->request()->AppendFileRangeToUpload(path, offset, length); return CPERR_SUCCESS; } diff --git a/chrome/browser/crash_recovery_uitest.cc b/chrome/browser/crash_recovery_uitest.cc index 2ee7a98..bbd577a 100644 --- a/chrome/browser/crash_recovery_uitest.cc +++ b/chrome/browser/crash_recovery_uitest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/file_path.h" #include "base/file_util.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" @@ -50,8 +51,8 @@ TEST_F(CrashRecoveryUITest, LoadInNewTab) { return; // The title of the active tab should change each time this URL is loaded. - std::wstring test_file = test_data_directory_; - file_util::AppendToPath(&test_file, L"title2.html"); + FilePath test_file(FilePath::FromWStringHack(test_data_directory_)); + test_file = test_file.AppendASCII("title2.html"); GURL url(net::FilePathToFileURL(test_file)); NavigateToURL(url); diff --git a/chrome/browser/download/download_manager.h b/chrome/browser/download/download_manager.h index 37906d3..c013f0c 100644 --- a/chrome/browser/download/download_manager.h +++ b/chrome/browser/download/download_manager.h @@ -410,7 +410,6 @@ class DownloadManager : public base::RefCountedThreadSafe<DownloadManager>, bool HasAutoOpenFileTypesRegistered() const; // Overridden from SelectFileDialog::Listener: - // TODO(port): convert this to FilePath when SelectFileDialog gets converted. virtual void FileSelected(const FilePath& path, int index, void* params); virtual void FileSelectionCanceled(void* params); diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc index b54f060..23bb704 100644 --- a/chrome/browser/download/save_package.cc +++ b/chrome/browser/download/save_package.cc @@ -1041,7 +1041,7 @@ void SavePackage::GetSaveInfo() { } else #endif // defined(OS_LINUX) || defined(OS_WIN) { - // Just use 'suggested_name' instead of opening the dialog prompt. + // Just use 'suggested_path' instead of opening the dialog prompt. ContinueSave(save_params, suggested_path, filter_index); delete save_params; } diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc index 03b54b9..723b1f3 100644 --- a/chrome/browser/extensions/user_script_master.cc +++ b/chrome/browser/extensions/user_script_master.cc @@ -155,7 +155,7 @@ void UserScriptMaster::ScriptReloader::LoadScriptsFromDirectory( UserScript& user_script = result->back(); // Push single js file in this UserScript. GURL url(std::string(chrome::kUserScriptScheme) + ":/" + - net::FilePathToFileURL(file.ToWStringHack()).ExtractFileName()); + net::FilePathToFileURL(file).ExtractFileName()); user_script.js_scripts().push_back(UserScript::File(file, url)); UserScript::File& script_file = user_script.js_scripts().back(); LoadScriptContent(&script_file); diff --git a/chrome/browser/history/redirect_uitest.cc b/chrome/browser/history/redirect_uitest.cc index af80496..1d27804 100644 --- a/chrome/browser/history/redirect_uitest.cc +++ b/chrome/browser/history/redirect_uitest.cc @@ -7,6 +7,7 @@ // here might indicate that WebKit changed the calls our glue layer gets in // the case of redirects. It may also mean problems with the history system. +#include "base/file_path.h" #include "base/file_util.h" #include "base/platform_thread.h" #include "base/scoped_ptr.h" @@ -81,8 +82,8 @@ TEST_F(RedirectTest, ClientEmptyReferer) { ASSERT_TRUE(NULL != server.get()); GURL final_url = server->TestServerPageW(std::wstring()); - std::wstring test_file = test_data_directory_; - file_util::AppendToPath(&test_file, L"file_client_redirect.html"); + FilePath test_file(FilePath::FromWStringHack(test_data_directory_)); + test_file = test_file.AppendASCII("file_client_redirect.html"); GURL first_url = net::FilePathToFileURL(test_file); NavigateToURL(first_url); @@ -107,8 +108,8 @@ TEST_F(RedirectTest, ClientEmptyReferer) { // Tests to make sure a location change when a pending redirect exists isn't // flagged as a redirect. TEST_F(RedirectTest, ClientCancelled) { - std::wstring first_path = test_data_directory_; - file_util::AppendToPath(&first_path, L"cancelled_redirect_test.html"); + FilePath first_path(FilePath::FromWStringHack(test_data_directory_)); + first_path = first_path.AppendASCII("cancelled_redirect_test.html"); ASSERT_TRUE(file_util::AbsolutePath(&first_path)); GURL first_url = net::FilePathToFileURL(first_path); @@ -132,11 +133,12 @@ TEST_F(RedirectTest, ClientCancelled) { // containing an anchor using FilePathToFileURL will escape the anchor as // %23, but in current_url the anchor will be '#'. std::string final_ref = "myanchor"; - std::wstring current_path; + FilePath current_path; ASSERT_TRUE(net::FileURLToFilePath(current_url, ¤t_path)); ASSERT_TRUE(file_util::AbsolutePath(¤t_path)); // Path should remain unchanged. - EXPECT_EQ(StringToLowerASCII(first_path), StringToLowerASCII(current_path)); + EXPECT_EQ(StringToLowerASCII(first_path.value()), + StringToLowerASCII(current_path.value())); EXPECT_EQ(final_ref, current_url.ref()); } @@ -202,8 +204,8 @@ TEST_F(RedirectTest, NoHttpToFile) { scoped_refptr<HTTPTestServer> server = HTTPTestServer::CreateServer(kDocRoot, NULL); ASSERT_TRUE(NULL != server.get()); - std::wstring test_file = test_data_directory_; - file_util::AppendToPath(&test_file, L"http_to_file.html"); + FilePath test_file(FilePath::FromWStringHack(test_data_directory_)); + test_file = test_file.AppendASCII("http_to_file.html"); GURL file_url = net::FilePathToFileURL(test_file); GURL initial_url = server->TestServerPageW( @@ -226,8 +228,8 @@ TEST_F(RedirectTest, ClientFragments) { HTTPTestServer::CreateServer(kDocRoot, NULL); ASSERT_TRUE(NULL != server.get()); - std::wstring test_file = test_data_directory_; - file_util::AppendToPath(&test_file, L"ref_redirect.html"); + FilePath test_file(FilePath::FromWStringHack(test_data_directory_)); + test_file = test_file.AppendASCII("ref_redirect.html"); GURL first_url = net::FilePathToFileURL(test_file); std::vector<GURL> redirects; diff --git a/chrome/browser/iframe_uitest.cc b/chrome/browser/iframe_uitest.cc index 7e2e617..2f3a7f7 100644 --- a/chrome/browser/iframe_uitest.cc +++ b/chrome/browser/iframe_uitest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/basictypes.h" +#include "base/file_path.h" #include "base/file_util.h" #include "base/platform_thread.h" #include "chrome/test/ui/ui_test.h" @@ -10,9 +11,9 @@ class IFrameTest : public UITest { protected: - void NavigateAndVerifyTitle(const wchar_t* url, const wchar_t* page_title) { - std::wstring test_file = test_data_directory_; - file_util::AppendToPath(&test_file, url); + void NavigateAndVerifyTitle(const char* url, const wchar_t* page_title) { + FilePath test_file(FilePath::FromWStringHack(test_data_directory_)); + test_file = test_file.AppendASCII(url); NavigateToURL(net::FilePathToFileURL(test_file)); // The browser lazily updates the title. @@ -27,9 +28,9 @@ class IFrameTest : public UITest { }; TEST_F(IFrameTest, Crash) { - NavigateAndVerifyTitle(L"iframe.html", L"iframe test"); + NavigateAndVerifyTitle("iframe.html", L"iframe test"); } TEST_F(IFrameTest, InEmptyFrame) { - NavigateAndVerifyTitle(L"iframe_in_empty_frame.html", L"iframe test"); + NavigateAndVerifyTitle("iframe_in_empty_frame.html", L"iframe test"); } diff --git a/chrome/browser/metrics/metrics_service_uitest.cc b/chrome/browser/metrics/metrics_service_uitest.cc index 9e6940ed..a994767 100644 --- a/chrome/browser/metrics/metrics_service_uitest.cc +++ b/chrome/browser/metrics/metrics_service_uitest.cc @@ -7,6 +7,7 @@ #include <string> +#include "base/file_path.h" #include "base/file_util.h" #include "base/path_service.h" #include "base/platform_thread.h" @@ -33,14 +34,14 @@ class MetricsServiceTest : public UITest { window_ = automation()->GetBrowserWindow(0); ASSERT_TRUE(window_); - std::wstring page1_path; + FilePath page1_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &page1_path)); - file_util::AppendToPath(&page1_path, L"title2.html"); + page1_path = page1_path.AppendASCII("title2.html"); ASSERT_TRUE(window_->AppendTab(net::FilePathToFileURL(page1_path))); - std::wstring page2_path; + FilePath page2_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &page2_path)); - file_util::AppendToPath(&page2_path, L"iframe.html"); + page2_path = page2_path.AppendASCII("iframe.html"); ASSERT_TRUE(window_->AppendTab(net::FilePathToFileURL(page2_path))); } diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 0f80652..e049523 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -398,8 +398,9 @@ void RenderViewHost::DragTargetDragEnter(const WebDropData& drop_data, for (std::vector<std::wstring>::const_iterator iter(drop_data.filenames.begin()); iter != drop_data.filenames.end(); ++iter) { - policy->GrantRequestURL(process()->pid(), net::FilePathToFileURL(*iter)); - policy->GrantUploadFile(process()->pid(), FilePath::FromWStringHack(*iter)); + FilePath path = FilePath::FromWStringHack(*iter); + policy->GrantRequestURL(process()->pid(), net::FilePathToFileURL(path)); + policy->GrantUploadFile(process()->pid(), path); } Send(new ViewMsg_DragTargetDragEnter(routing_id(), drop_data, client_pt, screen_pt)); diff --git a/chrome/browser/renderer_host/renderer_security_policy.h b/chrome/browser/renderer_host/renderer_security_policy.h index 2064700..84fd32c 100644 --- a/chrome/browser/renderer_host/renderer_security_policy.h +++ b/chrome/browser/renderer_host/renderer_security_policy.h @@ -10,6 +10,7 @@ #include <set> #include "base/basictypes.h" +#include "base/file_path.h" #include "base/lock.h" #include "base/singleton.h" diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc index b2b2c73..1a73ca5 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc @@ -122,9 +122,9 @@ bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type, std::vector<net::UploadData::Element>::const_iterator iter; for (iter = uploads.begin(); iter != uploads.end(); ++iter) { if (iter->type() == net::UploadData::TYPE_FILE && - !policy->CanUploadFile(process_id, - FilePath::FromWStringHack(iter->file_path()))) { - NOTREACHED() << "Denied unauthorized upload of " << iter->file_path(); + !policy->CanUploadFile(process_id, iter->file_path())) { + NOTREACHED() << "Denied unauthorized upload of " + << iter->file_path().value(); return false; } } diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc index d44080f..682336a 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc @@ -231,8 +231,8 @@ TEST_F(ResourceDispatcherTest, CrossSiteNavigationNonBuffered) { // Now load a file:// page, which does not use the BufferedEventHandler. // Make sure that the page loads and displays a title, and doesn't get stuck. - std::wstring test_file = test_data_directory_; - file_util::AppendToPath(&test_file, L"title2.html"); + FilePath test_file(FilePath::FromWStringHack(test_data_directory_)); + test_file = test_file.AppendASCII("title2.html"); bool timed_out = false; tab->NavigateToURLWithTimeout(net::FilePathToFileURL(test_file), action_max_timeout_ms(), diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc index 7c389d5..bfd2d2c 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc @@ -4,6 +4,7 @@ #include <vector> +#include "base/file_path.h" #include "base/message_loop.h" #include "base/process_util.h" #include "chrome/browser/renderer_host/renderer_security_policy.h" @@ -532,7 +533,7 @@ TEST_F(ResourceDispatcherHostTest, CalculateApproximateMemoryCost) { EXPECT_EQ(4434, ResourceDispatcherHost::CalculateApproximateMemoryCost(&req)); // Add a file upload -- should have no effect. - req.AppendFileToUpload(L"does-not-exist.png"); + req.AppendFileToUpload(FilePath(FILE_PATH_LITERAL("does-not-exist.png"))); EXPECT_EQ(4434, ResourceDispatcherHost::CalculateApproximateMemoryCost(&req)); } diff --git a/chrome/browser/tab_restore_uitest.cc b/chrome/browser/tab_restore_uitest.cc index 34922e6..b72e6dc 100644 --- a/chrome/browser/tab_restore_uitest.cc +++ b/chrome/browser/tab_restore_uitest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/command_line.h" +#include "base/file_path.h" #include "base/file_util.h" #include "base/win_util.h" #include "chrome/app/chrome_dll_resource.h" @@ -19,11 +20,10 @@ class TabRestoreUITest : public UITest { public: TabRestoreUITest() : UITest() { - std::wstring path_prefix = test_data_directory_; - file_util::AppendToPath(&path_prefix, L"session_history"); - path_prefix += FilePath::kSeparators[0]; - url1_ = net::FilePathToFileURL(path_prefix + L"bot1.html"); - url2_ = net::FilePathToFileURL(path_prefix + L"bot2.html"); + FilePath path_prefix(FilePath::FromWStringHack(test_data_directory_)); + path_prefix = path_prefix.AppendASCII("session_history"); + url1_ = net::FilePathToFileURL(path_prefix.AppendASCII("bot1.html")); + url2_ = net::FilePathToFileURL(path_prefix.AppendASCII("bot2.html")); } protected: diff --git a/chrome/browser/views/constrained_window_impl_interactive_uitest.cc b/chrome/browser/views/constrained_window_impl_interactive_uitest.cc index a114168..1ccb80f 100644 --- a/chrome/browser/views/constrained_window_impl_interactive_uitest.cc +++ b/chrome/browser/views/constrained_window_impl_interactive_uitest.cc @@ -4,6 +4,7 @@ #include <string> +#include "base/file_path.h" #include "base/file_util.h" #include "chrome/browser/view_ids.h" #include "chrome/common/chrome_constants.h" @@ -38,9 +39,9 @@ class InteractiveConstrainedWindowTest : public UITest { } void NavigateMainTabTo(const std::wstring& file_name) { - std::wstring filename(test_data_directory_); - file_util::AppendToPath(&filename, L"constrained_files"); - file_util::AppendToPath(&filename, file_name); + FilePath filename(FilePath::FromWStringHack(test_data_directory_)); + filename = filename.AppendASCII("constrained_files"); + filename = filename.Append(FilePath::FromWStringHack(file_name)); ASSERT_TRUE(tab_->NavigateToURL(net::FilePathToFileURL(filename))); } diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 1c983d0..0d5404a 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -1105,7 +1105,7 @@ struct ParamTraits<net::UploadData::Element> { r->SetToBytes(data, len); } else { DCHECK(type == net::UploadData::TYPE_FILE); - std::wstring file_path; + FilePath file_path; uint64 offset, length; if (!ReadParam(m, iter, &file_path)) return false; diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 4b36a35..a39dca8 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -12,6 +12,7 @@ #include "build/build_config.h" #include "base/clipboard.h" +#include "base/file_path.h" #include "base/gfx/rect.h" #include "base/gfx/native_widget_types.h" #include "base/shared_memory.h" diff --git a/chrome/common/resource_dispatcher.cc b/chrome/common/resource_dispatcher.cc index 08ace17..c507510 100644 --- a/chrome/common/resource_dispatcher.cc +++ b/chrome/common/resource_dispatcher.cc @@ -8,6 +8,7 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" +#include "base/file_path.h" #include "base/message_loop.h" #include "base/shared_memory.h" #include "base/string_util.h" @@ -60,7 +61,7 @@ class IPCResourceLoaderBridge : public ResourceLoaderBridge { // ResourceLoaderBridge virtual void AppendDataToUpload(const char* data, int data_len); - virtual void AppendFileRangeToUpload(const std::wstring& path, + virtual void AppendFileRangeToUpload(const FilePath& path, uint64 offset, uint64 length); virtual void SetUploadIdentifier(int64 identifier); virtual bool Start(Peer* peer); @@ -157,7 +158,7 @@ void IPCResourceLoaderBridge::AppendDataToUpload(const char* data, } void IPCResourceLoaderBridge::AppendFileRangeToUpload( - const std::wstring& path, uint64 offset, uint64 length) { + const FilePath& path, uint64 offset, uint64 length) { DCHECK(request_id_ == -1) << "request already started"; if (!request_.upload_data) diff --git a/chrome/plugin/chrome_plugin_host.cc b/chrome/plugin/chrome_plugin_host.cc index adf1860..0f0e240 100644 --- a/chrome/plugin/chrome_plugin_host.cc +++ b/chrome/plugin/chrome_plugin_host.cc @@ -5,6 +5,7 @@ #include "chrome/plugin/chrome_plugin_host.h" #include "base/command_line.h" +#include "base/file_path.h" #include "base/file_util.h" #include "base/message_loop.h" #include "chrome/common/child_process.h" @@ -127,11 +128,11 @@ class PluginRequestHandlerProxy upload_content_.back().SetToBytes(bytes, bytes_len); } - void AppendFileToUpload(const std::wstring &filepath) { + void AppendFileToUpload(const FilePath &filepath) { AppendFileRangeToUpload(filepath, 0, kuint64max); } - void AppendFileRangeToUpload(const std::wstring &filepath, + void AppendFileRangeToUpload(const FilePath &filepath, uint64 offset, uint64 length) { upload_content_.push_back(net::UploadData::Element()); upload_content_.back().SetToFilePathRange(filepath, offset, length); @@ -475,7 +476,8 @@ CPError STDCALL CPR_AppendFileToUpload(CPRequest* request, const char* filepath, if (!length) length = kuint64max; std::wstring wfilepath(UTF8ToWide(filepath)); - handler->AppendFileRangeToUpload(wfilepath, offset, length); + handler->AppendFileRangeToUpload(FilePath::FromWStringHack(wfilepath), offset, + length); return CPERR_SUCCESS; } diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 7f19567..3fe9dbb 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -9,6 +9,7 @@ #include <vector> #include "base/basictypes.h" +#include "base/file_path.h" #include "base/gfx/point.h" #include "base/gfx/rect.h" #include "base/id_map.h" diff --git a/chrome/test/accessibility/accessibility_tests.cc b/chrome/test/accessibility/accessibility_tests.cc index bc42dbc..542ba7f 100644 --- a/chrome/test/accessibility/accessibility_tests.cc +++ b/chrome/test/accessibility/accessibility_tests.cc @@ -140,8 +140,8 @@ TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) { // Set URL and check button status. scoped_ptr<TabProxy> tab1(window->GetTab(0)); ASSERT_TRUE(tab1.get()); - std::wstring test_file1 = test_data_directory_; - file_util::AppendToPath(&test_file1, L"title1.html"); + FilePath test_file1(FilePath::FromWStringHack(test_data_directory_)); + test_file1 = test_file1.AppendASCII("title1.html"); tab1->NavigateToURL(net::FilePathToFileURL(test_file1)); Sleep(sleep_timeout_ms()); EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE, @@ -167,8 +167,8 @@ TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) { // Add new tab with URL and check status. ASSERT_TRUE(window->GetTabCount(&tab_count)); - std::wstring test_file2 = test_data_directory_; - file_util::AppendToPath(&test_file2, L"title1.html"); + FilePath test_file2(FilePath::FromWStringHack(test_data_directory_)); + test_file2 = test_file2.AppendASCII("title1.html"); ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(test_file2))); ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1, action_max_timeout_ms())); @@ -242,8 +242,8 @@ TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) { // Set URL and check button status. scoped_ptr<TabProxy> tab1(window->GetTab(0)); ASSERT_TRUE(tab1.get()); - std::wstring test_file1 = test_data_directory_; - file_util::AppendToPath(&test_file1, L"title1.html"); + FilePath test_file1(FilePath::FromWStringHack(test_data_directory_)); + test_file1 = test_file1.AppendASCII("title1.html"); tab1->NavigateToURL(net::FilePathToFileURL(test_file1)); Sleep(sleep_timeout_ms()); EXPECT_EQ(STATE_SYSTEM_HASPOPUP | @@ -275,8 +275,8 @@ TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) { // Add new tab with URL and check status. ASSERT_TRUE(window->GetTabCount(&tab_count)); - std::wstring test_file2 = test_data_directory_; - file_util::AppendToPath(&test_file2, L"title1.html"); + FilePath test_file2(FilePath::FromWStringHack(test_data_directory_)); + test_file2 = test_file2.AppendASCII("title1.html"); ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(test_file2))); ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1, action_max_timeout_ms())); @@ -328,8 +328,8 @@ TEST_F(AccessibilityTest, DISABLED_TestStarBtnStatusOnNewTab) { // Set URL and check button status. scoped_ptr<TabProxy> tab1(window->GetTab(0)); ASSERT_TRUE(tab1.get()); - std::wstring test_file1 = test_data_directory_; - file_util::AppendToPath(&test_file1, L"title1.html"); + FilePath test_file1(FilePath::FromWStringHack(test_data_directory_)); + test_file1 = test_file1.AppendASCII("title1.html"); tab1->NavigateToURL(net::FilePathToFileURL(test_file1)); Sleep(sleep_timeout_ms()); EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj)); @@ -346,8 +346,8 @@ TEST_F(AccessibilityTest, DISABLED_TestStarBtnStatusOnNewTab) { // Add new tab with URL and check status. ASSERT_TRUE(window->GetTabCount(&tab_count)); - std::wstring test_file2 = test_data_directory_; - file_util::AppendToPath(&test_file2, L"title1.html"); + FilePath test_file2(FilePath::FromWStringHack(test_data_directory_)); + test_file2 = test_file2.AppendASCII("title1.html"); ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(test_file2))); ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1, action_max_timeout_ms())); diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index d2d6ac7..464fa81 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -194,8 +194,8 @@ TEST_F(AutomationProxyVisibleTest, AppendTab) { ASSERT_EQ(tab_count - 1, active_tab_index); ASSERT_NE(original_active_tab_index, active_tab_index); - std::wstring filename(test_data_directory_); - file_util::AppendToPath(&filename, L"title2.html"); + FilePath filename(FilePath::FromWStringHack(test_data_directory_)); + filename = filename.AppendASCII("title2.html"); ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(filename))); int appended_tab_index; @@ -262,8 +262,8 @@ TEST_F(AutomationProxyTest, NavigateToURL) { // BUG [634097] : expected title should be "about:blank" ASSERT_STREQ(L"", title.c_str()); - std::wstring filename(test_data_directory_); - file_util::AppendToPath(&filename, L"title2.html"); + FilePath filename(FilePath::FromWStringHack(test_data_directory_)); + filename = filename.AppendASCII("title2.html"); tab->NavigateToURL(net::FilePathToFileURL(filename)); ASSERT_TRUE(tab->GetTabTitle(&title)); @@ -279,8 +279,8 @@ TEST_F(AutomationProxyTest, DISABLED_NavigateToURLWithTimeout1) { scoped_ptr<TabProxy> tab(window->GetTab(0)); ASSERT_TRUE(tab.get()); - std::wstring filename(test_data_directory_); - file_util::AppendToPath(&filename, L"title2.html"); + FilePath filename(FilePath::FromWStringHack(test_data_directory_)); + filename = filename.AppendASCII("title2.html"); bool is_timeout; tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename), @@ -306,16 +306,16 @@ TEST_F(AutomationProxyTest, DISABLED_NavigateToURLWithTimeout2) { tab.reset(window->GetTab(0)); ASSERT_TRUE(tab.get()); - std::wstring filename1(test_data_directory_); - file_util::AppendToPath(&filename1, L"title1.html"); + FilePath filename1(FilePath::FromWStringHack(test_data_directory_)); + filename1 = filename1.AppendASCII("title1.html"); bool is_timeout; tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename1), 1, &is_timeout); ASSERT_TRUE(is_timeout); - std::wstring filename2(test_data_directory_); - file_util::AppendToPath(&filename2, L"title2.html"); + FilePath filename2(FilePath::FromWStringHack(test_data_directory_)); + filename2 = filename2.AppendASCII("title1.html"); tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename2), 10000, &is_timeout); ASSERT_FALSE(is_timeout); @@ -338,8 +338,8 @@ TEST_F(AutomationProxyTest, GoBackForward) { ASSERT_TRUE(tab->GetTabTitle(&title)); ASSERT_STREQ(L"", title.c_str()); - std::wstring filename(test_data_directory_); - file_util::AppendToPath(&filename, L"title2.html"); + FilePath filename(FilePath::FromWStringHack(test_data_directory_)); + filename = filename.AppendASCII("title2.html"); ASSERT_TRUE(tab->NavigateToURL(net::FilePathToFileURL(filename))); ASSERT_TRUE(tab->GetTabTitle(&title)); ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); @@ -367,8 +367,8 @@ TEST_F(AutomationProxyTest, GetCurrentURL) { ASSERT_TRUE(tab->GetCurrentURL(&url)); ASSERT_STREQ("about:blank", url.spec().c_str()); - std::wstring filename(test_data_directory_); - file_util::AppendToPath(&filename, L"cookie1.html"); + FilePath filename(FilePath::FromWStringHack(test_data_directory_)); + filename = filename.AppendASCII("cookie1.html"); GURL newurl = net::FilePathToFileURL(filename); ASSERT_TRUE(tab->NavigateToURL(newurl)); ASSERT_TRUE(tab->GetCurrentURL(&url)); @@ -474,8 +474,8 @@ TEST_F(AutomationProxyTest, NavigateToURLAsync) { scoped_ptr<TabProxy> tab(window->GetTab(0)); ASSERT_TRUE(tab.get()); - std::wstring filename(test_data_directory_); - file_util::AppendToPath(&filename, L"cookie1.html"); + FilePath filename(FilePath::FromWStringHack(test_data_directory_)); + filename = filename.AppendASCII("cookie1.html"); GURL newurl = net::FilePathToFileURL(filename); ASSERT_TRUE(tab->NavigateToURLAsync(newurl)); @@ -657,9 +657,9 @@ TEST_F(AutomationProxyTest, DISABLED_ConstrainedWindowTest) { tab.reset(window->GetTab(0)); ASSERT_TRUE(tab.get()); - std::wstring filename(test_data_directory_); - file_util::AppendToPath(&filename, L"constrained_files"); - file_util::AppendToPath(&filename, L"constrained_window.html"); + FilePath filename(FilePath::FromWStringHack(test_data_directory_)); + filename = filename.AppendASCII("constrained_files"); + filename = filename.AppendASCII("constrained_window.html"); ASSERT_TRUE(tab->NavigateToURL(net::FilePathToFileURL(filename))); @@ -698,9 +698,9 @@ TEST_F(AutomationProxyTest, CantEscapeByOnloadMoveto) { tab.reset(window->GetTab(0)); ASSERT_TRUE(tab.get()); - std::wstring filename(test_data_directory_); - file_util::AppendToPath(&filename, L"constrained_files"); - file_util::AppendToPath(&filename, L"constrained_window_onload_moveto.html"); + FilePath filename(FilePath::FromWStringHack(test_data_directory_)); + filename = filename.AppendASCII("constrained_files"); + filename = filename.AppendASCII("constrained_window_onload_moveto.html"); ASSERT_TRUE(tab->NavigateToURL(net::FilePathToFileURL(filename))); @@ -1101,8 +1101,8 @@ TEST_F(AutomationProxyTest5, TestLifetimeOfDomAutomationController) { scoped_ptr<TabProxy> tab(window->GetTab(0)); ASSERT_TRUE(tab.get()); - std::wstring filename(test_data_directory_); - file_util::AppendToPath(&filename, L"dom_automation_test_with_popup.html"); + FilePath filename(FilePath::FromWStringHack(test_data_directory_)); + filename = filename.AppendASCII("dom_automation_test_with_popup.html"); tab->NavigateToURL(net::FilePathToFileURL(filename)); diff --git a/chrome/test/plugin/plugin_test.cpp b/chrome/test/plugin/plugin_test.cpp index 4907a9a..77bc77d 100644 --- a/chrome/test/plugin/plugin_test.cpp +++ b/chrome/test/plugin/plugin_test.cpp @@ -47,6 +47,7 @@ #include <string.h> #include <memory.h> +#include "base/file_path.h" #include "base/file_util.h" #include "base/registry.h" #include "chrome/common/chrome_switches.h" @@ -102,10 +103,10 @@ class PluginTest : public UITest { // Generate the URL for testing a particular test. // HTML for the tests is all located in test_directory\plugin\<testcase> GURL GetTestUrl(const std::wstring &test_case) { - std::wstring path; + FilePath path; PathService::Get(chrome::DIR_TEST_DATA, &path); - file_util::AppendToPath(&path, L"plugin"); - file_util::AppendToPath(&path, test_case); + path = path.AppendASCII("plugin"); + path = path.Append(FilePath::FromWStringHack(test_case)); return net::FilePathToFileURL(path); } diff --git a/chrome/test/selenium/selenium_test.cc b/chrome/test/selenium/selenium_test.cc index be66b0d..590d996 100644 --- a/chrome/test/selenium/selenium_test.cc +++ b/chrome/test/selenium/selenium_test.cc @@ -12,6 +12,7 @@ #include <list> #include <set> +#include "base/file_path.h" #include "base/file_util.h" #include "base/path_service.h" #include "base/rand_util.h" @@ -101,7 +102,7 @@ class SeleniumTest : public UITest { file_util::AppendToPath(&test_path, L"core"); file_util::AppendToPath(&test_path, L"TestRunner.html"); - GURL test_url(net::FilePathToFileURL(test_path)); + GURL test_url(net::FilePathToFileURL(FilePath::FromWStringHack(test_path))); scoped_ptr<TabProxy> tab(GetActiveTab()); tab->NavigateToURL(test_url); diff --git a/chrome/test/tab_switching/tab_switching_test.cc b/chrome/test/tab_switching/tab_switching_test.cc index 3cbbfa6..d56be38 100644 --- a/chrome/test/tab_switching/tab_switching_test.cc +++ b/chrome/test/tab_switching/tab_switching_test.cc @@ -108,18 +108,17 @@ class TabSwitchingUITest : public UITest { // Opens new tabs. Returns the number of tabs opened. int OpenTabs() { // Add tabs. - static const wchar_t* files[] = { L"espn.go.com", L"bugzilla.mozilla.org", - L"news.cnet.com", L"www.amazon.com", - L"kannada.chakradeo.net", L"allegro.pl", - L"ml.wikipedia.org", L"www.bbc.co.uk", - L"126.com", L"www.altavista.com"}; + static const char* files[] = { "espn.go.com", "bugzilla.mozilla.org", + "news.cnet.com", "www.amazon.com", + "kannada.chakradeo.net", "allegro.pl", + "ml.wikipedia.org", "www.bbc.co.uk", + "126.com", "www.altavista.com"}; int number_of_new_tabs_opened = 0; - std::wstring file_name; + FilePath file_name; for (int i = 0; i < arraysize(files); ++i) { - file_name = path_prefix_; - file_name += files[i]; - file_name += FilePath::kSeparators[0]; - file_name += L"index.html"; + file_name = FilePath::FromWStringHack(path_prefix_); + file_name = file_name.AppendASCII(files[i]); + file_name = file_name.AppendASCII("index.html"); browser_proxy_->AppendTab(net::FilePathToFileURL(file_name)); number_of_new_tabs_opened++; } diff --git a/chrome/test/ui/layout_plugin_uitest.cc b/chrome/test/ui/layout_plugin_uitest.cc index fa46e2a..f0778ab 100644 --- a/chrome/test/ui/layout_plugin_uitest.cc +++ b/chrome/test/ui/layout_plugin_uitest.cc @@ -57,9 +57,9 @@ TEST_F(LayoutPluginTester, UnloadNoCrash) { CreateDirectory(plugins_directory.c_str(), NULL); CopyFile(plugin_src.c_str(), plugin_dest.c_str(), true /* overwrite */); - std::wstring path; + FilePath path; PathService::Get(chrome::DIR_TEST_DATA, &path); - file_util::AppendToPath(&path, L"npapi/layout_test_plugin.html"); + path = path.AppendASCII("npapi").AppendASCII("layout_test_plugin.html"); NavigateToURL(net::FilePathToFileURL(path)); std::wstring title; diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 6b43ae0..5cd8e2a 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -774,7 +774,7 @@ GURL UITest::GetTestUrl(const std::wstring& test_directory, PathService::Get(chrome::DIR_TEST_DATA, &path); file_util::AppendToPath(&path, test_directory); file_util::AppendToPath(&path, test_case); - return net::FilePathToFileURL(path); + return net::FilePathToFileURL(FilePath::FromWStringHack(path)); } void UITest::WaitForFinish(const std::string &name, |