summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-24 18:32:14 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-24 18:32:14 +0000
commitba3d54f0c867fb3ed038d36520ef22d62e82862a (patch)
tree3924762457300874d1b104ef110696acb9e4033d /chrome/common
parent19284663cc52278fc44d9da1a200e4b0bcba6768 (diff)
downloadchromium_src-ba3d54f0c867fb3ed038d36520ef22d62e82862a.zip
chromium_src-ba3d54f0c867fb3ed038d36520ef22d62e82862a.tar.gz
chromium_src-ba3d54f0c867fb3ed038d36520ef22d62e82862a.tar.bz2
Port:
- chrome/common/chrome_paths.cc - chrome/common/logging_chrome.cc Add these to libcommon along with: - chrome/common/notification_registrar.cc Patch by Paweł Hajdan jr <phajdan.jr@gmail.com> http://codereview.chromium.org/8059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3932 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/SConscript6
-rw-r--r--chrome/common/chrome_paths.cc74
-rw-r--r--chrome/common/logging_chrome.cc29
3 files changed, 76 insertions, 33 deletions
diff --git a/chrome/common/SConscript b/chrome/common/SConscript
index 52c9e0e..edbbfbb 100644
--- a/chrome/common/SConscript
+++ b/chrome/common/SConscript
@@ -54,6 +54,7 @@ if env['PLATFORM'] in ('posix', 'win32'):
'animation.cc',
'chrome_constants.cc',
'chrome_counters.cc',
+ 'chrome_paths.cc',
'chrome_switches.cc',
'debug_flags.cc',
'env_vars.cc',
@@ -62,7 +63,9 @@ if env['PLATFORM'] in ('posix', 'win32'):
'jpeg_codec.cc',
'json_value_serializer.cc',
'libxml_utils.cc',
+ 'logging_chrome.cc',
'net/cookie_monster_sqlite.cc',
+ 'notification_registrar.cc',
'notification_service.cc',
'pref_member.cc',
'pref_names.cc',
@@ -79,7 +82,6 @@ if env['PLATFORM'] == 'win32':
# TODO(port): Port these.
input_files.extend([
'child_process.cc',
- 'chrome_paths.cc',
'chrome_plugin_lib.cc',
'chrome_plugin_util.cc',
'chrome_process_filter.cc',
@@ -101,10 +103,8 @@ if env['PLATFORM'] == 'win32':
'ipc_sync_message.cc',
'jstemplate_builder.cc',
'l10n_util.cc',
- 'logging_chrome.cc',
'message_router.cc',
'net/url_request_intercept_job.cc',
- 'notification_registrar.cc',
'os_exchange_data.cc',
'plugin_messages.cc',
'pref_service.cc',
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc
index 9d6da38..71b3d3d 100644
--- a/chrome/common/chrome_paths.cc
+++ b/chrome/common/chrome_paths.cc
@@ -2,32 +2,30 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "build/build_config.h"
+
+#if defined(OS_WIN)
#include <windows.h>
#include <shellapi.h>
#include <shlobj.h>
+#endif
#include "chrome/common/chrome_paths.h"
#include "base/command_line.h"
#include "base/file_util.h"
+#include "base/logging.h"
#include "base/path_service.h"
+#include "base/sys_info.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
namespace chrome {
-bool GetUserDirectory(int directory_type, std::wstring* result) {
- wchar_t path_buf[MAX_PATH];
- if (FAILED(SHGetFolderPath(NULL, directory_type, NULL,
- SHGFP_TYPE_CURRENT, path_buf)))
- return false;
- result->assign(path_buf);
- return true;
-}
-
// Gets the default user data directory, regardless of whether
// DIR_USER_DATA has been overridden by a command-line option.
bool GetDefaultUserDataDirectory(std::wstring* result) {
+#if defined(OS_WIN)
if (!PathService::Get(base::DIR_LOCAL_APP_DATA, result))
return false;
#if defined(GOOGLE_CHROME_BUILD)
@@ -36,6 +34,11 @@ bool GetDefaultUserDataDirectory(std::wstring* result) {
file_util::AppendToPath(result, chrome::kBrowserAppName);
file_util::AppendToPath(result, chrome::kUserDataDirname);
return true;
+#else // defined(OS_WIN)
+ // TODO(port): Decide what to do on other platforms.
+ NOTIMPLEMENTED();
+ return false;
+#endif // defined(OS_WIN)
}
bool GetGearsPluginPathFromCommandLine(std::wstring *path) {
@@ -64,14 +67,6 @@ bool PathProvider(int key, std::wstring* result) {
return PathService::Get(base::FILE_MODULE, result);
}
- // We need to go compute the value. It would be nice to support paths with
- // names longer than MAX_PATH, but the system functions don't seem to be
- // designed for it either, with the exception of GetTempPath (but other
- // things will surely break if the temp path is too long, so we don't bother
- // handling it.
- wchar_t system_buffer[MAX_PATH];
- system_buffer[0] = 0;
-
// Assume that we will need to create the directory if it does not already
// exist. This flag can be set to true to prevent checking.
bool exists = false;
@@ -83,8 +78,20 @@ bool PathProvider(int key, std::wstring* result) {
return false;
break;
case chrome::DIR_USER_DOCUMENTS:
- if (!GetUserDirectory(CSIDL_MYDOCUMENTS, &cur))
- return false;
+#if defined(OS_WIN)
+ {
+ wchar_t path_buf[MAX_PATH];
+ if (FAILED(SHGetFolderPath(NULL, CSIDL_MYDOCUMENTS, NULL,
+ SHGFP_TYPE_CURRENT, path_buf)))
+ return false;
+ cur.assign(path_buf);
+ }
+#else
+ // TODO(port): Get the path (possibly using xdg-user-dirs)
+ // or decide we don't need it on other platforms.
+ NOTIMPLEMENTED();
+ return false;
+#endif
break;
case chrome::DIR_CRASH_DUMPS:
// The crash reports are always stored relative to the default user data
@@ -96,10 +103,26 @@ bool PathProvider(int key, std::wstring* result) {
file_util::AppendToPath(&cur, L"Crash Reports");
break;
case chrome::DIR_USER_DESKTOP:
- if (FAILED(SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL,
- SHGFP_TYPE_CURRENT, system_buffer)))
- return false;
- cur = system_buffer;
+#if defined(OS_WIN)
+ {
+ // We need to go compute the value. It would be nice to support paths
+ // with names longer than MAX_PATH, but the system functions don't seem
+ // to be designed for it either, with the exception of GetTempPath
+ // (but other things will surely break if the temp path is too long,
+ // so we don't bother handling it.
+ wchar_t system_buffer[MAX_PATH];
+ system_buffer[0] = 0;
+ if (FAILED(SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL,
+ SHGFP_TYPE_CURRENT, system_buffer)))
+ return false;
+ cur.assign(system_buffer);
+ }
+#else
+ // TODO(port): Get the path (possibly using xdg-user-dirs)
+ // or decide we don't need it on other platforms.
+ NOTIMPLEMENTED();
+ return false;
+#endif
exists = true;
break;
case chrome::DIR_RESOURCES:
@@ -131,7 +154,12 @@ bool PathProvider(int key, std::wstring* result) {
break;
case chrome::DIR_USER_SCRIPTS:
// TODO(aa): Figure out where the script directory should live.
+#if defined(OS_WIN)
cur = L"C:\\SCRIPTS\\";
+#else
+ NOTIMPLEMENTED();
+ return false;
+#endif
exists = true; // don't trigger directory creation code
break;
case chrome::FILE_LOCAL_STATE:
diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc
index af6b647..e3ec737 100644
--- a/chrome/common/logging_chrome.cc
+++ b/chrome/common/logging_chrome.cc
@@ -2,7 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "build/build_config.h"
+
+#if defined(OS_WIN)
#include <windows.h>
+#endif
#include <iostream>
#include <fstream>
@@ -10,6 +14,7 @@
#include "chrome/common/logging_chrome.h"
#include "base/command_line.h"
+#include "base/debug_util.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
@@ -31,7 +36,7 @@ static bool chrome_logging_initialized_ = false;
// with that error in the str parameter.
#pragma optimize("", off)
static void SilentRuntimeAssertHandler(const std::string& str) {
- __debugbreak();
+ DebugUtil::BreakDebugger();
}
#pragma optimize("", on)
@@ -43,6 +48,7 @@ static void SuppressDialogs() {
logging::SetLogAssertHandler(SilentRuntimeAssertHandler);
+#if defined(OS_WIN)
UINT new_flags = SEM_FAILCRITICALERRORS |
SEM_NOGPFAULTERRORBOX |
SEM_NOOPENFILEERRORBOX;
@@ -50,6 +56,7 @@ static void SuppressDialogs() {
// Preserve existing error mode, as discussed at http://t/dmea
UINT existing_flags = SetErrorMode(new_flags);
SetErrorMode(existing_flags | new_flags);
+#endif
dialogs_are_suppressed_ = true;
}
@@ -84,7 +91,13 @@ void InitChromeLogging(const CommandLine& command_line,
log_mode = logging::LOG_NONE;
}
- logging::InitLogging(GetLogFileName().c_str(),
+#if defined(OS_POSIX)
+ const char* log_file_name = WideToUTF8(GetLogFileName()).c_str();
+#elif defined(OS_WIN)
+ const wchar_t* log_file_name = GetLogFileName().c_str();
+#endif
+
+ logging::InitLogging(log_file_name,
log_mode,
logging::LOCK_LOG_FILE,
delete_old_log_file);
@@ -130,11 +143,9 @@ void CleanupChromeLogging() {
}
std::wstring GetLogFileName() {
- wchar_t filename[MAX_PATH];
- unsigned status = GetEnvironmentVariable(env_vars::kLogFileName,
- filename, MAX_PATH);
- if (status && (status <= MAX_PATH))
- return std::wstring(filename);
+ std::wstring filename = base::SysInfo::GetEnvVar(env_vars::kLogFileName);
+ if (filename != L"")
+ return filename;
const std::wstring log_filename(L"chrome_debug.log");
std::wstring log_path;
@@ -160,7 +171,11 @@ size_t GetFatalAssertions(AssertionList* assertions) {
size_t assertion_count = 0;
std::ifstream log_file;
+#if defined(OS_WIN)
log_file.open(GetLogFileName().c_str());
+#elif defined(OS_POSIX)
+ log_file.open(WideToUTF8(GetLogFileName()).c_str());
+#endif
if (!log_file.is_open())
return 0;