| 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 "content/shell/shell_browser_main.h" | 5 #include "content/shell/shell_browser_main.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| 10 #include "content/public/browser/browser_main_runner.h" | 11 #include "content/public/browser/browser_main_runner.h" |
| 11 #include "content/shell/shell.h" | 12 #include "content/shell/shell.h" |
| 12 #include "content/shell/shell_browser_context.h" | 13 #include "content/shell/shell_browser_context.h" |
| 13 #include "content/shell/shell_content_browser_client.h" | 14 #include "content/shell/shell_content_browser_client.h" |
| 14 #include "content/shell/shell_switches.h" | 15 #include "content/shell/shell_switches.h" |
| 15 #include "webkit/support/webkit_support.h" | 16 #include "webkit/support/webkit_support.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 GURL GetURLForLayoutTest(const char* test_name) { | 20 GURL GetURLForLayoutTest(const char* test_name) { |
| 21 #if defined(OS_ANDROID) |
| 22 // DumpRenderTree is not currently supported for Android using the content |
| 23 // shell. |
| 24 NOTIMPLEMENTED(); |
| 25 return GURL::EmptyGURL(); |
| 26 #else |
| 20 std::string path_or_url = test_name; | 27 std::string path_or_url = test_name; |
| 21 std::string pixel_hash; | 28 std::string pixel_hash; |
| 22 std::string timeout; | 29 std::string timeout; |
| 23 std::string::size_type separator_position = path_or_url.find(' '); | 30 std::string::size_type separator_position = path_or_url.find(' '); |
| 24 if (separator_position != std::string::npos) { | 31 if (separator_position != std::string::npos) { |
| 25 timeout = path_or_url.substr(separator_position + 1); | 32 timeout = path_or_url.substr(separator_position + 1); |
| 26 path_or_url.erase(separator_position); | 33 path_or_url.erase(separator_position); |
| 27 separator_position = path_or_url.find(' '); | 34 separator_position = path_or_url.find(' '); |
| 28 if (separator_position != std::string::npos) { | 35 if (separator_position != std::string::npos) { |
| 29 pixel_hash = timeout.substr(separator_position + 1); | 36 pixel_hash = timeout.substr(separator_position + 1); |
| 30 timeout.erase(separator_position); | 37 timeout.erase(separator_position); |
| 31 } | 38 } |
| 32 } | 39 } |
| 33 // TODO(jochen): use pixel_hash and timeout. | 40 // TODO(jochen): use pixel_hash and timeout. |
| 34 GURL test_url = webkit_support::CreateURLForPathOrURL(path_or_url); | 41 GURL test_url = webkit_support::CreateURLForPathOrURL(path_or_url); |
| 35 { | 42 { |
| 36 // We're outside of the message loop here, and this is a test. | 43 // We're outside of the message loop here, and this is a test. |
| 37 base::ThreadRestrictions::ScopedAllowIO allow_io; | 44 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 38 webkit_support::SetCurrentDirectoryForFileURL(test_url); | 45 webkit_support::SetCurrentDirectoryForFileURL(test_url); |
| 39 } | 46 } |
| 40 return test_url; | 47 return test_url; |
| 48 #endif |
| 41 } | 49 } |
| 42 | 50 |
| 43 } // namespace | 51 } // namespace |
| 44 | 52 |
| 45 // Main routine for running as the Browser process. | 53 // Main routine for running as the Browser process. |
| 46 int ShellBrowserMain(const content::MainFunctionParams& parameters) { | 54 int ShellBrowserMain(const content::MainFunctionParams& parameters) { |
| 47 scoped_ptr<content::BrowserMainRunner> main_runner_( | 55 scoped_ptr<content::BrowserMainRunner> main_runner_( |
| 48 content::BrowserMainRunner::Create()); | 56 content::BrowserMainRunner::Create()); |
| 49 | 57 |
| 50 int exit_code = main_runner_->Initialize(parameters); | 58 int exit_code = main_runner_->Initialize(parameters); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 79 } | 87 } |
| 80 exit_code = 0; | 88 exit_code = 0; |
| 81 } else { | 89 } else { |
| 82 exit_code = main_runner_->Run(); | 90 exit_code = main_runner_->Run(); |
| 83 } | 91 } |
| 84 | 92 |
| 85 main_runner_->Shutdown(); | 93 main_runner_->Shutdown(); |
| 86 | 94 |
| 87 return exit_code; | 95 return exit_code; |
| 88 } | 96 } |
| OLD | NEW |