summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorgspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-01 18:29:53 +0000
committergspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-01 18:29:53 +0000
commit1e3850fb95964792b477f5033e608c58a06038e5 (patch)
tree429703989f269657597f31aca76dbb80aee8e6c5 /chrome/common
parent363680faae60b8ec1f6a57d3c701935a6f046fb6 (diff)
downloadchromium_src-1e3850fb95964792b477f5033e608c58a06038e5.zip
chromium_src-1e3850fb95964792b477f5033e608c58a06038e5.tar.gz
chromium_src-1e3850fb95964792b477f5033e608c58a06038e5.tar.bz2
This moves log output for ChromeOS to safer locations.
For BWSI (incognito) mode, we want to make sure that we don't leak private information between sessions, so we need to have chrome write log output to the tmpfs created for that mode. Also, the chrome log in "logged in" mode should reside in the "log" subdir instead of in the user data dir. BUG=http://crosbug.com/6908 TEST=Ran on device in incognito and regular modes, and watched where log output ended up. Review URL: http://codereview.chromium.org/4194005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64638 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/env_vars.cc3
-rw-r--r--chrome/common/env_vars.h1
-rw-r--r--chrome/common/logging_chrome.cc32
-rw-r--r--chrome/common/logging_chrome.h4
4 files changed, 34 insertions, 6 deletions
diff --git a/chrome/common/env_vars.cc b/chrome/common/env_vars.cc
index dc2648c..f63d3e4 100644
--- a/chrome/common/env_vars.cc
+++ b/chrome/common/env_vars.cc
@@ -14,6 +14,9 @@ const char kHeadless[] = "CHROME_HEADLESS";
// The name of the log file.
const char kLogFileName[] = "CHROME_LOG_FILE";
+// The name of the session log directory when logged in to ChromeOS.
+const char kSessionLogDir[] = "CHROMEOS_SESSION_LOG_DIR";
+
// If this environment variable is set, Chrome on Windows will log
// to Event Tracing for Windows.
const char kEtwLogging[] = "CHROME_ETW_LOGGING";
diff --git a/chrome/common/env_vars.h b/chrome/common/env_vars.h
index e9984d2a..320a0b4 100644
--- a/chrome/common/env_vars.h
+++ b/chrome/common/env_vars.h
@@ -12,6 +12,7 @@ namespace env_vars {
extern const char kHeadless[];
extern const char kLogFileName[];
+extern const char kSessionLogDir[];
extern const char kEtwLogging[];
extern const char kShowRestart[];
extern const char kRestartInfo[];
diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc
index 6106e43..0b2a620 100644
--- a/chrome/common/logging_chrome.cc
+++ b/chrome/common/logging_chrome.cc
@@ -150,6 +150,23 @@ FilePath GenerateTimestampedName(const FilePath& base_path,
return base_path.InsertBeforeExtension(suffix);
}
+FilePath GetSessionLogFile(const CommandLine& command_line) {
+ FilePath log_dir;
+ std::string log_dir_str;
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+ if (env->GetVar(env_vars::kSessionLogDir, &log_dir_str) &&
+ !log_dir_str.empty()) {
+ log_dir = FilePath(log_dir_str);
+ } else {
+ PathService::Get(chrome::DIR_USER_DATA, &log_dir);
+ FilePath login_profile =
+ command_line.GetSwitchValuePath(switches::kLoginProfile);
+ log_dir = log_dir.Append(login_profile);
+ }
+ DCHECK(file_util::PathExists(log_dir));
+ return log_dir.Append(GetLogFileName().BaseName());
+}
+
FilePath SetUpSymlinkIfNeeded(const FilePath& symlink_path, bool new_log) {
DCHECK(!symlink_path.empty());
@@ -193,12 +210,13 @@ void RemoveSymlinkAndLog(const FilePath& link_path,
} // anonymous namespace
-void RedirectChromeLogging(const FilePath& new_log_dir,
- const CommandLine& command_line) {
+void RedirectChromeLogging(const CommandLine& command_line) {
DCHECK(!chrome_logging_redirected_) <<
"Attempted to redirect logging when it was already initialized.";
- FilePath orig_log_path = GetLogFileName();
- FilePath log_path = new_log_dir.Append(orig_log_path.BaseName());
+
+ // Redirect logs to the session log directory, if set. Otherwise
+ // defaults to the profile dir.
+ FilePath log_path = GetSessionLogFile(command_line);
// Always force a new symlink when redirecting.
FilePath target_path = SetUpSymlinkIfNeeded(log_path, true);
@@ -229,6 +247,12 @@ void InitChromeLogging(const CommandLine& command_line,
FilePath log_path = GetLogFileName();
#if defined(OS_CHROMEOS)
+ // For BWSI (Incognito) logins, we want to put the logs in the user
+ // profile directory that is created for the temporary session instead
+ // of in the system log directory, for privacy reasons.
+ if (command_line.HasSwitch(switches::kGuestSession))
+ log_path = GetSessionLogFile(command_line);
+
// On ChromeOS we log to the symlink. We force creation of a new
// symlink if we've been asked to delete the old log, since that
// indicates the start of a new session.
diff --git a/chrome/common/logging_chrome.h b/chrome/common/logging_chrome.h
index c8dac42..2812721 100644
--- a/chrome/common/logging_chrome.h
+++ b/chrome/common/logging_chrome.h
@@ -37,8 +37,8 @@ void InitChromeLogging(const CommandLine& command_line,
OldFileDeletionState delete_old_log_file);
#if defined(OS_CHROMEOS)
-void RedirectChromeLogging(const FilePath& new_log_dir,
- const CommandLine& command_line);
+// Redirects chrome logging to the appropriate session log dir.
+void RedirectChromeLogging(const CommandLine& command_line);
#endif
// Call when done using logging for Chrome.