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 "chrome/test/chromedriver/chrome_launcher_impl.h" | 5 #include "chrome/test/chromedriver/chrome_launcher_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/process.h" | 11 #include "base/process.h" |
12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
13 #include "base/string_number_conversions.h" | |
13 #include "chrome/test/chromedriver/chrome.h" | 14 #include "chrome/test/chromedriver/chrome.h" |
14 #include "chrome/test/chromedriver/chrome_finder.h" | 15 #include "chrome/test/chromedriver/chrome_finder.h" |
15 #include "chrome/test/chromedriver/chrome_impl.h" | 16 #include "chrome/test/chromedriver/chrome_impl.h" |
17 #include "chrome/test/chromedriver/net/url_request_context_getter.h" | |
16 #include "chrome/test/chromedriver/status.h" | 18 #include "chrome/test/chromedriver/status.h" |
17 | 19 |
18 ChromeLauncherImpl::ChromeLauncherImpl() {} | 20 ChromeLauncherImpl::ChromeLauncherImpl(URLRequestContextGetter* context_getter) |
21 : context_getter_(context_getter) {} | |
19 | 22 |
20 ChromeLauncherImpl::~ChromeLauncherImpl() {} | 23 ChromeLauncherImpl::~ChromeLauncherImpl() {} |
21 | 24 |
22 Status ChromeLauncherImpl::Launch( | 25 Status ChromeLauncherImpl::Launch( |
23 const FilePath& chrome_exe, | 26 const FilePath& chrome_exe, |
24 scoped_ptr<Chrome>* chrome) { | 27 scoped_ptr<Chrome>* chrome) { |
25 FilePath program = chrome_exe; | 28 FilePath program = chrome_exe; |
26 if (program.empty()) { | 29 if (program.empty()) { |
27 if (!FindChrome(&program)) | 30 if (!FindChrome(&program)) |
28 return Status(kUnknownError, "cannot find Chrome binary"); | 31 return Status(kUnknownError, "cannot find Chrome binary"); |
29 } | 32 } |
30 | 33 |
34 int port = 33081; | |
31 CommandLine command(program); | 35 CommandLine command(program); |
36 command.AppendSwitchASCII("remote-debugging-port", base::IntToString(port)); | |
37 command.AppendSwitch("no-first-run"); | |
38 command.AppendSwitch("disable-extensions"); | |
craigdh
2012/12/04 01:41:27
In Chrome OS we will certainly need to have extens
kkania
2013/02/28 21:51:58
I removed this flag. I accidentally put it in ther
| |
32 command.AppendSwitch("enable-logging"); | 39 command.AppendSwitch("enable-logging"); |
33 command.AppendSwitchASCII("logging-level", "1"); | 40 command.AppendSwitchASCII("logging-level", "1"); |
34 base::ScopedTempDir user_data_dir; | 41 base::ScopedTempDir user_data_dir; |
35 if (!user_data_dir.CreateUniqueTempDir()) | 42 if (!user_data_dir.CreateUniqueTempDir()) |
36 return Status(kUnknownError, "cannot create temp dir for user data dir"); | 43 return Status(kUnknownError, "cannot create temp dir for user data dir"); |
37 command.AppendSwitchPath("user-data-dir", user_data_dir.path()); | 44 command.AppendSwitchPath("user-data-dir", user_data_dir.path()); |
38 command.AppendArg("about:blank"); | 45 command.AppendArg("about:blank"); |
39 | 46 |
40 base::LaunchOptions options; | 47 base::LaunchOptions options; |
41 base::ProcessHandle process; | 48 base::ProcessHandle process; |
42 if (!base::LaunchProcess(command, options, &process)) | 49 if (!base::LaunchProcess(command, options, &process)) |
43 return Status(kUnknownError, "chrome failed to start"); | 50 return Status(kUnknownError, "chrome failed to start"); |
44 chrome->reset(new ChromeImpl(process, &user_data_dir)); | 51 scoped_ptr<ChromeImpl> chrome_impl(new ChromeImpl( |
45 | 52 process, context_getter_, &user_data_dir, port)); |
53 Status status = chrome_impl->Init(); | |
54 if (status.IsError()) | |
55 return status; | |
56 chrome->reset(chrome_impl.release()); | |
46 return Status(kOk); | 57 return Status(kOk); |
47 } | 58 } |
OLD | NEW |