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

Side by Side Diff: content/shell/shell_browser_main.cc

Issue 11151007: [content shell] don't use webkit_support functions to manipulate URLs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/shell/shell_browser_main.h" 5 #include "content/shell/shell_browser_main.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h"
11 #include "base/file_util.h"
10 #include "base/logging.h" 12 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/thread_restrictions.h" 14 #include "base/threading/thread_restrictions.h"
13 #include "content/public/browser/browser_main_runner.h" 15 #include "content/public/browser/browser_main_runner.h"
14 #include "content/shell/shell_switches.h" 16 #include "content/shell/shell_switches.h"
15 #include "content/shell/webkit_test_runner_host.h" 17 #include "content/shell/webkit_test_runner_host.h"
18 #include "net/base/net_util.h"
16 #include "webkit/support/webkit_support.h" 19 #include "webkit/support/webkit_support.h"
17 20
18 namespace { 21 namespace {
19 22
20 GURL GetURLForLayoutTest(const char* test_name, 23 GURL GetURLForLayoutTest(const char* test_name,
21 bool* enable_pixel_dumping, 24 bool* enable_pixel_dumping,
22 std::string* expected_pixel_hash) { 25 std::string* expected_pixel_hash) {
23 // A test name is formated like file:///path/to/test'--pixel-test'pixelhash 26 // A test name is formated like file:///path/to/test'--pixel-test'pixelhash
24 std::string path_or_url = test_name; 27 std::string path_or_url = test_name;
25 std::string pixel_switch; 28 std::string pixel_switch;
26 std::string pixel_hash; 29 std::string pixel_hash;
27 std::string::size_type separator_position = path_or_url.find('\''); 30 std::string::size_type separator_position = path_or_url.find('\'');
28 if (separator_position != std::string::npos) { 31 if (separator_position != std::string::npos) {
29 pixel_switch = path_or_url.substr(separator_position + 1); 32 pixel_switch = path_or_url.substr(separator_position + 1);
30 path_or_url.erase(separator_position); 33 path_or_url.erase(separator_position);
31 } 34 }
32 separator_position = pixel_switch.find('\''); 35 separator_position = pixel_switch.find('\'');
33 if (separator_position != std::string::npos) { 36 if (separator_position != std::string::npos) {
34 pixel_hash = pixel_switch.substr(separator_position + 1); 37 pixel_hash = pixel_switch.substr(separator_position + 1);
35 pixel_switch.erase(separator_position); 38 pixel_switch.erase(separator_position);
36 } 39 }
37 if (enable_pixel_dumping) { 40 if (enable_pixel_dumping) {
38 *enable_pixel_dumping = 41 *enable_pixel_dumping =
39 (pixel_switch == "--pixel-test" || pixel_switch == "-p"); 42 (pixel_switch == "--pixel-test" || pixel_switch == "-p");
40 } 43 }
41 if (expected_pixel_hash) 44 if (expected_pixel_hash)
42 *expected_pixel_hash = pixel_hash; 45 *expected_pixel_hash = pixel_hash;
43 GURL test_url = webkit_support::CreateURLForPathOrURL(path_or_url); 46 GURL test_url(path_or_url);
44 { 47 if (!(test_url.is_valid() && test_url.has_scheme()))
48 test_url = net::FilePathToFileURL(FilePath(path_or_url));
49 FilePath local_path;
50 if (net::FileURLToFilePath(test_url, &local_path)) {
45 // We're outside of the message loop here, and this is a test. 51 // We're outside of the message loop here, and this is a test.
46 base::ThreadRestrictions::ScopedAllowIO allow_io; 52 base::ThreadRestrictions::ScopedAllowIO allow_io;
47 webkit_support::SetCurrentDirectoryForFileURL(test_url); 53 file_util::SetCurrentDirectory(local_path.DirName());
48 } 54 }
49 return test_url; 55 return test_url;
50 } 56 }
51 57
52 } // namespace 58 } // namespace
53 59
54 // Main routine for running as the Browser process. 60 // Main routine for running as the Browser process.
55 int ShellBrowserMain(const content::MainFunctionParams& parameters) { 61 int ShellBrowserMain(const content::MainFunctionParams& parameters) {
56 scoped_ptr<content::BrowserMainRunner> main_runner_( 62 scoped_ptr<content::BrowserMainRunner> main_runner_(
57 content::BrowserMainRunner::Create()); 63 content::BrowserMainRunner::Create());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 109 }
104 exit_code = 0; 110 exit_code = 0;
105 } else { 111 } else {
106 exit_code = main_runner_->Run(); 112 exit_code = main_runner_->Run();
107 } 113 }
108 114
109 main_runner_->Shutdown(); 115 main_runner_->Shutdown();
110 116
111 return exit_code; 117 return exit_code;
112 } 118 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698