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

Side by Side Diff: webkit/tools/test_shell/test_shell_mac.mm

Issue 2850042: Deprecate more old filepath functions. (Closed)
Patch Set: rebase Created 10 years, 5 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <ApplicationServices/ApplicationServices.h> 5 #include <ApplicationServices/ApplicationServices.h>
6 #import <Cocoa/Cocoa.h> 6 #import <Cocoa/Cocoa.h>
7 #import <objc/objc-runtime.h> 7 #import <objc/objc-runtime.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 9
10 #include "webkit/tools/test_shell/test_shell.h" 10 #include "webkit/tools/test_shell/test_shell.h"
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 // only resize back to the default when running tests 586 // only resize back to the default when running tests
587 if (layout_test_mode()) 587 if (layout_test_mode())
588 SizeToDefault(); 588 SizeToDefault();
589 } 589 }
590 590
591 navigation_controller_->LoadEntry( 591 navigation_controller_->LoadEntry(
592 new TestNavigationEntry(-1, url, std::wstring(), frame_name)); 592 new TestNavigationEntry(-1, url, std::wstring(), frame_name));
593 } 593 }
594 594
595 bool TestShell::PromptForSaveFile(const wchar_t* prompt_title, 595 bool TestShell::PromptForSaveFile(const wchar_t* prompt_title,
596 std::wstring* result) 596 FilePath* result)
597 { 597 {
598 NSSavePanel* save_panel = [NSSavePanel savePanel]; 598 NSSavePanel* save_panel = [NSSavePanel savePanel];
599 599
600 /* set up new attributes */ 600 /* set up new attributes */
601 [save_panel setRequiredFileType:@"txt"]; 601 [save_panel setRequiredFileType:@"txt"];
602 [save_panel setMessage: 602 [save_panel setMessage:
603 [NSString stringWithUTF8String:WideToUTF8(prompt_title).c_str()]]; 603 [NSString stringWithUTF8String:WideToUTF8(prompt_title).c_str()]];
604 604
605 /* display the NSSavePanel */ 605 /* display the NSSavePanel */
606 if ([save_panel runModalForDirectory:NSHomeDirectory() file:@""] == 606 if ([save_panel runModalForDirectory:NSHomeDirectory() file:@""] ==
607 NSOKButton) { 607 NSOKButton) {
608 result->assign(UTF8ToWide([[save_panel filename] UTF8String])); 608 *result = FilePath([[save_panel filename] fileSystemRepresentation]);
609 return true; 609 return true;
610 } 610 }
611 return false; 611 return false;
612 } 612 }
613 613
614 // static 614 // static
615 std::string TestShell::RewriteLocalUrl(const std::string& url) { 615 std::string TestShell::RewriteLocalUrl(const std::string& url) {
616 // Convert file:///tmp/LayoutTests urls to the actual location on disk. 616 // Convert file:///tmp/LayoutTests urls to the actual location on disk.
617 const char kPrefix[] = "file:///tmp/LayoutTests/"; 617 const char kPrefix[] = "file:///tmp/LayoutTests/";
618 const int kPrefixLen = arraysize(kPrefix) - 1; 618 const int kPrefixLen = arraysize(kPrefix) - 1;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 switch (resource_id) { 665 switch (resource_id) {
666 case IDR_BROKENIMAGE: { 666 case IDR_BROKENIMAGE: {
667 // Use webkit's broken image icon (16x16) 667 // Use webkit's broken image icon (16x16)
668 static std::string broken_image_data; 668 static std::string broken_image_data;
669 if (broken_image_data.empty()) { 669 if (broken_image_data.empty()) {
670 FilePath path = GetResourcesFilePath(); 670 FilePath path = GetResourcesFilePath();
671 // In order to match WebKit's colors for the missing image, we have to 671 // In order to match WebKit's colors for the missing image, we have to
672 // use a PNG. The GIF doesn't have the color range needed to correctly 672 // use a PNG. The GIF doesn't have the color range needed to correctly
673 // match the TIFF they use in Safari. 673 // match the TIFF they use in Safari.
674 path = path.AppendASCII("missingImage.png"); 674 path = path.AppendASCII("missingImage.png");
675 bool success = file_util::ReadFileToString(path.ToWStringHack(), 675 bool success = file_util::ReadFileToString(path, &broken_image_data);
676 &broken_image_data);
677 if (!success) { 676 if (!success) {
678 LOG(FATAL) << "Failed reading: " << path.value(); 677 LOG(FATAL) << "Failed reading: " << path.value();
679 } 678 }
680 } 679 }
681 return broken_image_data; 680 return broken_image_data;
682 } 681 }
683 case IDR_TEXTAREA_RESIZER: { 682 case IDR_TEXTAREA_RESIZER: {
684 // Use webkit's text area resizer image. 683 // Use webkit's text area resizer image.
685 static std::string resize_corner_data; 684 static std::string resize_corner_data;
686 if (resize_corner_data.empty()) { 685 if (resize_corner_data.empty()) {
687 FilePath path = GetResourcesFilePath(); 686 FilePath path = GetResourcesFilePath();
688 path = path.AppendASCII("textAreaResizeCorner.png"); 687 path = path.AppendASCII("textAreaResizeCorner.png");
689 bool success = file_util::ReadFileToString(path.ToWStringHack(), 688 bool success = file_util::ReadFileToString(path, &resize_corner_data);
690 &resize_corner_data);
691 if (!success) { 689 if (!success) {
692 LOG(FATAL) << "Failed reading: " << path.value(); 690 LOG(FATAL) << "Failed reading: " << path.value();
693 } 691 }
694 } 692 }
695 return resize_corner_data; 693 return resize_corner_data;
696 } 694 }
697 695
698 case IDR_SEARCH_CANCEL: 696 case IDR_SEARCH_CANCEL:
699 case IDR_SEARCH_CANCEL_PRESSED: 697 case IDR_SEARCH_CANCEL_PRESSED:
700 case IDR_SEARCH_MAGNIFIER: 698 case IDR_SEARCH_MAGNIFIER:
(...skipping 23 matching lines...) Expand all
724 return false; 722 return false;
725 } 723 }
726 724
727 void DidLoadPlugin(const std::string& filename) { 725 void DidLoadPlugin(const std::string& filename) {
728 } 726 }
729 727
730 void DidUnloadPlugin(const std::string& filename) { 728 void DidUnloadPlugin(const std::string& filename) {
731 } 729 }
732 730
733 } // namespace webkit_glue 731 } // namespace webkit_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698