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/common/auto_start_linux.h" | 5 #include "chrome/common/auto_start_linux.h" |
6 | 6 |
7 #include "base/environment.h" | 7 #include "base/environment.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/nix/xdg_util.h" | 11 #include "base/nix/xdg_util.h" |
12 #include "base/string_tokenizer.h" | 12 #include "base/strings/string_tokenizer.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 const FilePath::CharType kAutostart[] = "autostart"; | 16 const FilePath::CharType kAutostart[] = "autostart"; |
17 | 17 |
18 FilePath GetAutostartDirectory(base::Environment* environment) { | 18 FilePath GetAutostartDirectory(base::Environment* environment) { |
19 FilePath result = base::nix::GetXDGDirectory(environment, | 19 FilePath result = base::nix::GetXDGDirectory(environment, |
20 base::nix::kXdgConfigHomeEnvVar, | 20 base::nix::kXdgConfigHomeEnvVar, |
21 base::nix::kDotConfigDir); | 21 base::nix::kDotConfigDir); |
22 result = result.Append(kAutostart); | 22 result = result.Append(kAutostart); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 FilePath autostart_file = autostart_directory.Append(autostart_filename); | 68 FilePath autostart_file = autostart_directory.Append(autostart_filename); |
69 return file_util::ReadFileToString(autostart_file, contents); | 69 return file_util::ReadFileToString(autostart_file, contents); |
70 } | 70 } |
71 | 71 |
72 bool AutoStart::GetAutostartFileValue(const std::string& autostart_filename, | 72 bool AutoStart::GetAutostartFileValue(const std::string& autostart_filename, |
73 const std::string& value_name, | 73 const std::string& value_name, |
74 std::string* value) { | 74 std::string* value) { |
75 std::string contents; | 75 std::string contents; |
76 if (!GetAutostartFileContents(autostart_filename, &contents)) | 76 if (!GetAutostartFileContents(autostart_filename, &contents)) |
77 return false; | 77 return false; |
78 StringTokenizer tokenizer(contents, "\n"); | 78 base::StringTokenizer tokenizer(contents, "\n"); |
79 std::string token = value_name + "="; | 79 std::string token = value_name + "="; |
80 while (tokenizer.GetNext()) { | 80 while (tokenizer.GetNext()) { |
81 if (tokenizer.token().substr(0, token.length()) == token) { | 81 if (tokenizer.token().substr(0, token.length()) == token) { |
82 *value = tokenizer.token().substr(token.length()); | 82 *value = tokenizer.token().substr(token.length()); |
83 return true; | 83 return true; |
84 } | 84 } |
85 } | 85 } |
86 return false; | 86 return false; |
87 } | 87 } |
OLD | NEW |