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_finder.h" | 5 #include "chrome/test/chromedriver/chrome_finder.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #endif | 22 #endif |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
27 void GetApplicationDirs(std::vector<base::FilePath>* locations) { | 27 void GetApplicationDirs(std::vector<base::FilePath>* locations) { |
28 // Add user-level location. | 28 // Add user-level location. |
29 scoped_ptr<base::Environment> env(base::Environment::Create()); | 29 scoped_ptr<base::Environment> env(base::Environment::Create()); |
30 std::string home_dir; | 30 std::string home_dir; |
31 if (env->GetVar("userprofile", &home_dir)) { | 31 if (env->GetVar("userprofile", &home_dir)) { |
32 base::FilePath default_location(UTF8ToWide(home_dir)); | 32 base::FilePath default_location(base::UTF8ToWide(home_dir)); |
33 if (base::win::GetVersion() < base::win::VERSION_VISTA) { | 33 if (base::win::GetVersion() < base::win::VERSION_VISTA) { |
34 default_location = default_location.Append( | 34 default_location = default_location.Append( |
35 L"Local Settings\\Application Data"); | 35 L"Local Settings\\Application Data"); |
36 } else { | 36 } else { |
37 default_location = default_location.Append(L"AppData\\Local"); | 37 default_location = default_location.Append(L"AppData\\Local"); |
38 } | 38 } |
39 locations->push_back(default_location); | 39 locations->push_back(default_location); |
40 } | 40 } |
41 | 41 |
42 // Add the system-level location. | 42 // Add the system-level location. |
43 std::string program_dir; | 43 std::string program_dir; |
44 if (env->GetVar("ProgramFiles", &program_dir)) | 44 if (env->GetVar("ProgramFiles", &program_dir)) |
45 locations->push_back(base::FilePath(UTF8ToWide(program_dir))); | 45 locations->push_back(base::FilePath(base::UTF8ToWide(program_dir))); |
46 if (env->GetVar("ProgramFiles(x86)", &program_dir)) | 46 if (env->GetVar("ProgramFiles(x86)", &program_dir)) |
47 locations->push_back(base::FilePath(UTF8ToWide(program_dir))); | 47 locations->push_back(base::FilePath(base::UTF8ToWide(program_dir))); |
48 } | 48 } |
49 #elif defined(OS_LINUX) | 49 #elif defined(OS_LINUX) |
50 void GetApplicationDirs(std::vector<base::FilePath>* locations) { | 50 void GetApplicationDirs(std::vector<base::FilePath>* locations) { |
51 locations->push_back(base::FilePath("/opt/google/chrome")); | 51 locations->push_back(base::FilePath("/opt/google/chrome")); |
52 locations->push_back(base::FilePath("/usr/local/bin")); | 52 locations->push_back(base::FilePath("/usr/local/bin")); |
53 locations->push_back(base::FilePath("/usr/local/sbin")); | 53 locations->push_back(base::FilePath("/usr/local/sbin")); |
54 locations->push_back(base::FilePath("/usr/bin")); | 54 locations->push_back(base::FilePath("/usr/bin")); |
55 locations->push_back(base::FilePath("/usr/sbin")); | 55 locations->push_back(base::FilePath("/usr/sbin")); |
56 locations->push_back(base::FilePath("/bin")); | 56 locations->push_back(base::FilePath("/bin")); |
57 locations->push_back(base::FilePath("/sbin")); | 57 locations->push_back(base::FilePath("/sbin")); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 std::vector<base::FilePath> browser_exes( | 107 std::vector<base::FilePath> browser_exes( |
108 browser_exes_array, browser_exes_array + arraysize(browser_exes_array)); | 108 browser_exes_array, browser_exes_array + arraysize(browser_exes_array)); |
109 std::vector<base::FilePath> locations; | 109 std::vector<base::FilePath> locations; |
110 GetApplicationDirs(&locations); | 110 GetApplicationDirs(&locations); |
111 return internal::FindExe( | 111 return internal::FindExe( |
112 base::Bind(&file_util::PathExists), | 112 base::Bind(&file_util::PathExists), |
113 browser_exes, | 113 browser_exes, |
114 locations, | 114 locations, |
115 browser_exe); | 115 browser_exe); |
116 } | 116 } |
OLD | NEW |