| 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_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 base::FilePath autostart_file = | 40 base::FilePath autostart_file = |
| 41 autostart_directory.Append(autostart_filename); | 41 autostart_directory.Append(autostart_filename); |
| 42 std::string terminal = is_terminal_app ? "true" : "false"; | 42 std::string terminal = is_terminal_app ? "true" : "false"; |
| 43 std::string autostart_file_contents = | 43 std::string autostart_file_contents = |
| 44 "[Desktop Entry]\n" | 44 "[Desktop Entry]\n" |
| 45 "Type=Application\n" | 45 "Type=Application\n" |
| 46 "Terminal=" + terminal + "\n" | 46 "Terminal=" + terminal + "\n" |
| 47 "Exec=" + command_line + "\n" | 47 "Exec=" + command_line + "\n" |
| 48 "Name=" + application_name + "\n"; | 48 "Name=" + application_name + "\n"; |
| 49 std::string::size_type content_length = autostart_file_contents.length(); | 49 std::string::size_type content_length = autostart_file_contents.length(); |
| 50 if (file_util::WriteFile(autostart_file, autostart_file_contents.c_str(), | 50 if (base::WriteFile(autostart_file, autostart_file_contents.c_str(), |
| 51 content_length) != | 51 content_length) != |
| 52 static_cast<int>(content_length)) { | 52 static_cast<int>(content_length)) { |
| 53 base::DeleteFile(autostart_file, false); | 53 base::DeleteFile(autostart_file, false); |
| 54 return false; | 54 return false; |
| 55 } | 55 } |
| 56 return true; | 56 return true; |
| 57 } | 57 } |
| 58 | 58 |
| 59 bool AutoStart::Remove(const std::string& autostart_filename) { | 59 bool AutoStart::Remove(const std::string& autostart_filename) { |
| 60 scoped_ptr<base::Environment> environment(base::Environment::Create()); | 60 scoped_ptr<base::Environment> environment(base::Environment::Create()); |
| 61 base::FilePath autostart_directory = GetAutostartDirectory(environment.get()); | 61 base::FilePath autostart_directory = GetAutostartDirectory(environment.get()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 82 base::StringTokenizer tokenizer(contents, "\n"); | 82 base::StringTokenizer tokenizer(contents, "\n"); |
| 83 std::string token = value_name + "="; | 83 std::string token = value_name + "="; |
| 84 while (tokenizer.GetNext()) { | 84 while (tokenizer.GetNext()) { |
| 85 if (tokenizer.token().substr(0, token.length()) == token) { | 85 if (tokenizer.token().substr(0, token.length()) == token) { |
| 86 *value = tokenizer.token().substr(token.length()); | 86 *value = tokenizer.token().substr(token.length()); |
| 87 return true; | 87 return true; |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 return false; | 90 return false; |
| 91 } | 91 } |
| OLD | NEW |