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 "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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 basePath = basePath.Append(FILE_PATH_LITERAL("third_party/WebKit")); | 251 basePath = basePath.Append(FILE_PATH_LITERAL("third_party/WebKit")); |
252 } else if (file_util::PathExists( | 252 } else if (file_util::PathExists( |
253 basePath.Append(FILE_PATH_LITERAL("chromium")))) { | 253 basePath.Append(FILE_PATH_LITERAL("chromium")))) { |
254 // We're in a WebKit-only checkout on Windows. | 254 // We're in a WebKit-only checkout on Windows. |
255 basePath = basePath.Append(FILE_PATH_LITERAL("../..")); | 255 basePath = basePath.Append(FILE_PATH_LITERAL("../..")); |
256 } else if (file_util::PathExists( | 256 } else if (file_util::PathExists( |
257 basePath.Append(FILE_PATH_LITERAL("webkit/support")))) { | 257 basePath.Append(FILE_PATH_LITERAL("webkit/support")))) { |
258 // We're in a WebKit-only/xcodebuild checkout on Mac | 258 // We're in a WebKit-only/xcodebuild checkout on Mac |
259 basePath = basePath.Append(FILE_PATH_LITERAL("../../..")); | 259 basePath = basePath.Append(FILE_PATH_LITERAL("../../..")); |
260 } | 260 } |
261 CHECK(file_util::AbsolutePath(&basePath)); | 261 basePath = basePath.AsAbsolute(); |
262 CHECK(!basePath.empty()); | |
262 // We're in a WebKit-only, make-build, so the DIR_SOURCE_ROOT is already the | 263 // We're in a WebKit-only, make-build, so the DIR_SOURCE_ROOT is already the |
263 // WebKit root. That, or we have no idea where we are. | 264 // WebKit root. That, or we have no idea where we are. |
264 return basePath; | 265 return basePath; |
265 } | 266 } |
266 | 267 |
267 class WebKitClientMessageLoopImpl | 268 class WebKitClientMessageLoopImpl |
268 : public WebDevToolsAgentClient::WebKitClientMessageLoop { | 269 : public WebDevToolsAgentClient::WebKitClientMessageLoop { |
269 public: | 270 public: |
270 WebKitClientMessageLoopImpl() : message_loop_(MessageLoop::current()) {} | 271 WebKitClientMessageLoopImpl() : message_loop_(MessageLoop::current()) {} |
271 virtual ~WebKitClientMessageLoopImpl() { | 272 virtual ~WebKitClientMessageLoopImpl() { |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
568 MessageLoop::current()->PostDelayedTask( | 569 MessageLoop::current()->PostDelayedTask( |
569 FROM_HERE, | 570 FROM_HERE, |
570 base::Bind(&TaskAdaptor::Run, base::Owned(task)), | 571 base::Bind(&TaskAdaptor::Run, base::Owned(task)), |
571 base::TimeDelta::FromMilliseconds(delay_ms)); | 572 base::TimeDelta::FromMilliseconds(delay_ms)); |
572 } | 573 } |
573 | 574 |
574 // Wrappers for FilePath and file_util | 575 // Wrappers for FilePath and file_util |
575 | 576 |
576 WebString GetAbsoluteWebStringFromUTF8Path(const std::string& utf8_path) { | 577 WebString GetAbsoluteWebStringFromUTF8Path(const std::string& utf8_path) { |
577 #if defined(OS_WIN) | 578 #if defined(OS_WIN) |
578 base::FilePath path(UTF8ToWide(utf8_path)); | 579 base::FilePath path(UTF8ToWide(utf8_path)).AsAbsolute(); |
brettw
2013/03/30 04:19:38
Fixme
| |
579 file_util::AbsolutePath(&path); | |
580 return WebString(path.value()); | 580 return WebString(path.value()); |
581 #else | 581 #else |
582 base::FilePath path(base::SysWideToNativeMB(base::SysUTF8ToWide(utf8_path))); | 582 base::FilePath path(base::SysWideToNativeMB(base::SysUTF8ToWide(utf8_path))); |
583 #if defined(OS_ANDROID) | 583 #if defined(OS_ANDROID) |
584 if (WebKit::layoutTestMode()) { | 584 if (WebKit::layoutTestMode()) { |
585 // See comment of TestEnvironment::set_mock_current_directory(). | 585 // See comment of TestEnvironment::set_mock_current_directory(). |
586 if (!path.IsAbsolute()) { | 586 if (!path.IsAbsolute()) { |
587 // Not using FilePath::Append() because it can't handle '..' in path. | 587 // Not using FilePath::Append() because it can't handle '..' in path. |
588 DCHECK(test_environment); | 588 DCHECK(test_environment); |
589 GURL base_url = net::FilePathToFileURL( | 589 GURL base_url = net::FilePathToFileURL( |
590 test_environment->mock_current_directory() | 590 test_environment->mock_current_directory() |
591 .Append(FILE_PATH_LITERAL("foo"))); | 591 .Append(FILE_PATH_LITERAL("foo"))); |
592 net::FileURLToFilePath(base_url.Resolve(path.value()), &path); | 592 net::FileURLToFilePath(base_url.Resolve(path.value()), &path); |
593 } | 593 } |
594 } else { | 594 } else { |
595 file_util::AbsolutePath(&path); | 595 path = path.AsAbsolute(); |
596 } | 596 } |
597 #else | 597 #else |
598 file_util::AbsolutePath(&path); | 598 path = path.AsAbsolute(); |
599 #endif // else defined(OS_ANDROID) | 599 #endif // else defined(OS_ANDROID) |
600 return WideToUTF16(base::SysNativeMBToWide(path.value())); | 600 return WideToUTF16(base::SysNativeMBToWide(path.value())); |
601 #endif // else defined(OS_WIN) | 601 #endif // else defined(OS_WIN) |
602 } | 602 } |
603 | 603 |
604 WebURL CreateURLForPathOrURL(const std::string& path_or_url_in_nativemb) { | 604 WebURL CreateURLForPathOrURL(const std::string& path_or_url_in_nativemb) { |
605 // NativeMB to UTF-8 | 605 // NativeMB to UTF-8 |
606 std::wstring wide_path_or_url | 606 std::wstring wide_path_or_url |
607 = base::SysNativeMBToWide(path_or_url_in_nativemb); | 607 = base::SysNativeMBToWide(path_or_url_in_nativemb); |
608 std::string path_or_url_in_utf8 = WideToUTF8(wide_path_or_url); | 608 std::string path_or_url_in_utf8 = WideToUTF8(wide_path_or_url); |
609 | 609 |
610 GURL url(path_or_url_in_utf8); | 610 GURL url(path_or_url_in_utf8); |
611 if (url.is_valid() && url.has_scheme()) | 611 if (url.is_valid() && url.has_scheme()) |
612 return WebURL(url); | 612 return WebURL(url); |
613 #if defined(OS_WIN) | 613 #if defined(OS_WIN) |
614 base::FilePath path(wide_path_or_url); | 614 base::FilePath path(wide_path_or_url); |
615 #else | 615 #else |
616 base::FilePath path(path_or_url_in_nativemb); | 616 base::FilePath path(path_or_url_in_nativemb); |
617 #endif | 617 #endif |
618 file_util::AbsolutePath(&path); | 618 return net::FilePathToFileURL(path.AsAbsolute()); |
619 return net::FilePathToFileURL(path); | |
620 } | 619 } |
621 | 620 |
622 WebURL RewriteLayoutTestsURL(const std::string& utf8_url) { | 621 WebURL RewriteLayoutTestsURL(const std::string& utf8_url) { |
623 const char kPrefix[] = "file:///tmp/LayoutTests/"; | 622 const char kPrefix[] = "file:///tmp/LayoutTests/"; |
624 const int kPrefixLen = arraysize(kPrefix) - 1; | 623 const int kPrefixLen = arraysize(kPrefix) - 1; |
625 | 624 |
626 if (utf8_url.compare(0, kPrefixLen, kPrefix, kPrefixLen)) | 625 if (utf8_url.compare(0, kPrefixLen, kPrefix, kPrefixLen)) |
627 return WebURL(GURL(utf8_url)); | 626 return WebURL(GURL(utf8_url)); |
628 | 627 |
629 base::FilePath replacePath = | 628 base::FilePath replacePath = |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
849 // Logging | 848 // Logging |
850 void EnableWebCoreLogChannels(const std::string& channels) { | 849 void EnableWebCoreLogChannels(const std::string& channels) { |
851 webkit_glue::EnableWebCoreLogChannels(channels); | 850 webkit_glue::EnableWebCoreLogChannels(channels); |
852 } | 851 } |
853 | 852 |
854 void SetGamepadData(const WebKit::WebGamepads& pads) { | 853 void SetGamepadData(const WebKit::WebGamepads& pads) { |
855 test_environment->webkit_platform_support()->setGamepadData(pads); | 854 test_environment->webkit_platform_support()->setGamepadData(pads); |
856 } | 855 } |
857 | 856 |
858 } // namespace webkit_support | 857 } // namespace webkit_support |
OLD | NEW |