Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: chrome/common/auto_start_linux.cc

Issue 6591002: Removed the command line from ServiceProcessState::AddToAutoRun() and had the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 13
13 namespace { 14 namespace {
14 15
15 const FilePath::CharType kAutostart[] = "autostart"; 16 const FilePath::CharType kAutostart[] = "autostart";
16 const FilePath::CharType kConfig[] = ".config"; 17 const FilePath::CharType kConfig[] = ".config";
17 const char kXdgConfigHome[] = "XDG_CONFIG_HOME"; 18 const char kXdgConfigHome[] = "XDG_CONFIG_HOME";
18 19
19 FilePath GetAutostartDirectory(base::Environment* environment) { 20 FilePath GetAutostartDirectory(base::Environment* environment) {
20 FilePath result = 21 FilePath result =
21 base::nix::GetXDGDirectory(environment, kXdgConfigHome, kConfig); 22 base::nix::GetXDGDirectory(environment, kXdgConfigHome, kConfig);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 54 }
54 return true; 55 return true;
55 } 56 }
56 57
57 bool AutoStart::Remove(const std::string& autostart_filename) { 58 bool AutoStart::Remove(const std::string& autostart_filename) {
58 scoped_ptr<base::Environment> environment(base::Environment::Create()); 59 scoped_ptr<base::Environment> environment(base::Environment::Create());
59 FilePath autostart_directory = GetAutostartDirectory(environment.get()); 60 FilePath autostart_directory = GetAutostartDirectory(environment.get());
60 FilePath autostart_file = autostart_directory.Append(autostart_filename); 61 FilePath autostart_file = autostart_directory.Append(autostart_filename);
61 return file_util::Delete(autostart_file, false); 62 return file_util::Delete(autostart_file, false);
62 } 63 }
64
65 bool AutoStart::GetAutostartFileContents(
66 const std::string& autostart_filename, std::string* contents) {
67 scoped_ptr<base::Environment> environment(base::Environment::Create());
68 FilePath autostart_directory = GetAutostartDirectory(environment.get());
69 FilePath autostart_file = autostart_directory.Append(autostart_filename);
70 return file_util::ReadFileToString(autostart_file, contents);
71 }
72
73 bool AutoStart::GetAutostartFileValue(const std::string& autostart_filename,
74 const std::string& value_name,
75 std::string* value) {
76 std::string contents;
77 if (!GetAutostartFileContents(autostart_filename, &contents))
78 return false;
79 StringTokenizer tokenizer(contents, "\n");
80 std::string token = value_name + "=";
81 while (tokenizer.GetNext()) {
82 if (tokenizer.token().substr(0, token.length()) == token) {
83 *value = tokenizer.token().substr(token.length());
84 return true;
85 }
86 }
87 return false;
88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698