Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: webkit/support/webkit_support.cc

Issue 13196006: Move path functions from file_util to FilePath object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git try Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "webkit/support/webkit_support.h" 5 #include "webkit/support/webkit_support.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/base64.h" 8 #include "base/base64.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 basePath = basePath.Append(FILE_PATH_LITERAL("third_party/WebKit")); 248 basePath = basePath.Append(FILE_PATH_LITERAL("third_party/WebKit"));
249 } else if (file_util::PathExists( 249 } else if (file_util::PathExists(
250 basePath.Append(FILE_PATH_LITERAL("chromium")))) { 250 basePath.Append(FILE_PATH_LITERAL("chromium")))) {
251 // We're in a WebKit-only checkout on Windows. 251 // We're in a WebKit-only checkout on Windows.
252 basePath = basePath.Append(FILE_PATH_LITERAL("../..")); 252 basePath = basePath.Append(FILE_PATH_LITERAL("../.."));
253 } else if (file_util::PathExists( 253 } else if (file_util::PathExists(
254 basePath.Append(FILE_PATH_LITERAL("webkit/support")))) { 254 basePath.Append(FILE_PATH_LITERAL("webkit/support")))) {
255 // We're in a WebKit-only/xcodebuild checkout on Mac 255 // We're in a WebKit-only/xcodebuild checkout on Mac
256 basePath = basePath.Append(FILE_PATH_LITERAL("../../..")); 256 basePath = basePath.Append(FILE_PATH_LITERAL("../../.."));
257 } 257 }
258 CHECK(file_util::AbsolutePath(&basePath)); 258 basePath = base::MakeAbsoluteFilePath(basePath);
259 CHECK(!basePath.empty());
259 // We're in a WebKit-only, make-build, so the DIR_SOURCE_ROOT is already the 260 // We're in a WebKit-only, make-build, so the DIR_SOURCE_ROOT is already the
260 // WebKit root. That, or we have no idea where we are. 261 // WebKit root. That, or we have no idea where we are.
261 return basePath; 262 return basePath;
262 } 263 }
263 264
264 class WebKitClientMessageLoopImpl 265 class WebKitClientMessageLoopImpl
265 : public WebDevToolsAgentClient::WebKitClientMessageLoop { 266 : public WebDevToolsAgentClient::WebKitClientMessageLoop {
266 public: 267 public:
267 WebKitClientMessageLoopImpl() : message_loop_(MessageLoop::current()) {} 268 WebKitClientMessageLoopImpl() : message_loop_(MessageLoop::current()) {}
268 virtual ~WebKitClientMessageLoopImpl() { 269 virtual ~WebKitClientMessageLoopImpl() {
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 FROM_HERE, 567 FROM_HERE,
567 base::Bind(&TaskAdaptor::Run, base::Owned(task)), 568 base::Bind(&TaskAdaptor::Run, base::Owned(task)),
568 base::TimeDelta::FromMilliseconds(delay_ms)); 569 base::TimeDelta::FromMilliseconds(delay_ms));
569 } 570 }
570 571
571 // Wrappers for FilePath and file_util 572 // Wrappers for FilePath and file_util
572 573
573 WebString GetAbsoluteWebStringFromUTF8Path(const std::string& utf8_path) { 574 WebString GetAbsoluteWebStringFromUTF8Path(const std::string& utf8_path) {
574 #if defined(OS_WIN) 575 #if defined(OS_WIN)
575 base::FilePath path(UTF8ToWide(utf8_path)); 576 base::FilePath path(UTF8ToWide(utf8_path));
576 file_util::AbsolutePath(&path); 577 return WebString(base::MakeAbsoluteFilePath(path).value());
577 return WebString(path.value());
578 #else 578 #else
579 base::FilePath path(base::SysWideToNativeMB(base::SysUTF8ToWide(utf8_path))); 579 base::FilePath path(base::SysWideToNativeMB(base::SysUTF8ToWide(utf8_path)));
580 #if defined(OS_ANDROID) 580 #if defined(OS_ANDROID)
581 if (WebKit::layoutTestMode()) { 581 if (WebKit::layoutTestMode()) {
582 // See comment of TestEnvironment::set_mock_current_directory(). 582 // See comment of TestEnvironment::set_mock_current_directory().
583 if (!path.IsAbsolute()) { 583 if (!path.IsAbsolute()) {
584 // Not using FilePath::Append() because it can't handle '..' in path. 584 // Not using FilePath::Append() because it can't handle '..' in path.
585 DCHECK(test_environment); 585 DCHECK(test_environment);
586 GURL base_url = net::FilePathToFileURL( 586 GURL base_url = net::FilePathToFileURL(
587 test_environment->mock_current_directory() 587 test_environment->mock_current_directory()
588 .Append(FILE_PATH_LITERAL("foo"))); 588 .Append(FILE_PATH_LITERAL("foo")));
589 net::FileURLToFilePath(base_url.Resolve(path.value()), &path); 589 net::FileURLToFilePath(base_url.Resolve(path.value()), &path);
590 } 590 }
591 } else { 591 } else {
592 file_util::AbsolutePath(&path); 592 path = base::MakeAbsoluteFilePath(path);
593 } 593 }
594 #else 594 #else
595 file_util::AbsolutePath(&path); 595 path = base::MakeAbsoluteFilePath(path);
596 #endif // else defined(OS_ANDROID) 596 #endif // else defined(OS_ANDROID)
597 return WideToUTF16(base::SysNativeMBToWide(path.value())); 597 return WideToUTF16(base::SysNativeMBToWide(path.value()));
598 #endif // else defined(OS_WIN) 598 #endif // else defined(OS_WIN)
599 } 599 }
600 600
601 WebURL CreateURLForPathOrURL(const std::string& path_or_url_in_nativemb) { 601 WebURL CreateURLForPathOrURL(const std::string& path_or_url_in_nativemb) {
602 // NativeMB to UTF-8 602 // NativeMB to UTF-8
603 std::wstring wide_path_or_url 603 std::wstring wide_path_or_url
604 = base::SysNativeMBToWide(path_or_url_in_nativemb); 604 = base::SysNativeMBToWide(path_or_url_in_nativemb);
605 std::string path_or_url_in_utf8 = WideToUTF8(wide_path_or_url); 605 std::string path_or_url_in_utf8 = WideToUTF8(wide_path_or_url);
606 606
607 GURL url(path_or_url_in_utf8); 607 GURL url(path_or_url_in_utf8);
608 if (url.is_valid() && url.has_scheme()) 608 if (url.is_valid() && url.has_scheme())
609 return WebURL(url); 609 return WebURL(url);
610 #if defined(OS_WIN) 610 #if defined(OS_WIN)
611 base::FilePath path(wide_path_or_url); 611 base::FilePath path(wide_path_or_url);
612 #else 612 #else
613 base::FilePath path(path_or_url_in_nativemb); 613 base::FilePath path(path_or_url_in_nativemb);
614 #endif 614 #endif
615 file_util::AbsolutePath(&path); 615 return net::FilePathToFileURL(base::MakeAbsoluteFilePath(path));
616 return net::FilePathToFileURL(path);
617 } 616 }
618 617
619 WebURL RewriteLayoutTestsURL(const std::string& utf8_url) { 618 WebURL RewriteLayoutTestsURL(const std::string& utf8_url) {
620 const char kPrefix[] = "file:///tmp/LayoutTests/"; 619 const char kPrefix[] = "file:///tmp/LayoutTests/";
621 const int kPrefixLen = arraysize(kPrefix) - 1; 620 const int kPrefixLen = arraysize(kPrefix) - 1;
622 621
623 if (utf8_url.compare(0, kPrefixLen, kPrefix, kPrefixLen)) 622 if (utf8_url.compare(0, kPrefixLen, kPrefix, kPrefixLen))
624 return WebURL(GURL(utf8_url)); 623 return WebURL(GURL(utf8_url));
625 624
626 base::FilePath replacePath = 625 base::FilePath replacePath =
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 // Logging 845 // Logging
847 void EnableWebCoreLogChannels(const std::string& channels) { 846 void EnableWebCoreLogChannels(const std::string& channels) {
848 webkit_glue::EnableWebCoreLogChannels(channels); 847 webkit_glue::EnableWebCoreLogChannels(channels);
849 } 848 }
850 849
851 void SetGamepadData(const WebKit::WebGamepads& pads) { 850 void SetGamepadData(const WebKit::WebGamepads& pads) {
852 test_environment->webkit_platform_support()->setGamepadData(pads); 851 test_environment->webkit_platform_support()->setGamepadData(pads);
853 } 852 }
854 853
855 } // namespace webkit_support 854 } // namespace webkit_support
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698