diff --git a/app/app_base.gypi b/app/app_base.gypi
index adefed7..ee12622 100644
--- app/app_base.gypi
+++ app/app_base.gypi
@@ -194,7 +194,7 @@
         'surface/io_surface_support_mac.cc',
         'surface/io_surface_support_mac.h',
         'surface/transport_dib.h',
-        'surface/transport_dib_linux.cc',
+        'surface/transport_dib_freebsd.cc',
         'surface/transport_dib_mac.cc',
         'surface/transport_dib_win.cc',
         'table_model.cc',
@@ -296,7 +296,7 @@
             'os_exchange_data.cc',
           ],
         }],
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'sources': [
             'gfx/gl/gl_context_egl.cc',
             'gfx/gl/gl_context_egl.h',
@@ -319,7 +319,6 @@
             'link_settings': {
               'libraries': [
                 '-lX11',
-                '-ldl',
               ],
             },
           },
diff --git a/app/gfx/gl/gl_bindings.h b/app/gfx/gl/gl_bindings.h
index e384bfd..2bf33de 100644
--- app/gfx/gl/gl_bindings.h
+++ app/gfx/gl/gl_bindings.h
@@ -18,7 +18,7 @@
 // The standard OpenGL native extension headers are also included.
 #if defined(OS_WIN)
 #include <GL/wglext.h>
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
 #include <GL/glx.h>
 #include <GL/glxext.h>
 
@@ -42,7 +42,7 @@
 typedef struct osmesa_context *OSMesaContext;
 typedef void (*OSMESAproc)();
 
-#if defined(OS_WIN) || defined(OS_LINUX)
+#if defined(OS_WIN) || defined(OS_NIX)
 
 // Forward declare EGL types.
 typedef unsigned int EGLBoolean;
@@ -65,7 +65,7 @@ typedef Pixmap   EGLNativePixmapType;
 typedef Window   EGLNativeWindowType;
 #endif
 
-#endif  // OS_WIN || OS_LINUX
+#endif  // OS_WIN || OS_NIX
 
 #include "gl_bindings_autogen_gl.h"
 #include "gl_bindings_autogen_osmesa.h"
@@ -73,7 +73,7 @@ typedef Window   EGLNativeWindowType;
 #if defined(OS_WIN)
 #include "gl_bindings_autogen_egl.h"
 #include "gl_bindings_autogen_wgl.h"
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
 #include "gl_bindings_autogen_egl.h"
 #include "gl_bindings_autogen_glx.h"
 #endif
diff --git a/app/gfx/gl/gl_context_egl.cc b/app/gfx/gl/gl_context_egl.cc
index 1d05eb0..c988081 100644
--- app/gfx/gl/gl_context_egl.cc
+++ app/gfx/gl/gl_context_egl.cc
@@ -5,7 +5,7 @@
 #include <EGL/egl.h>
 
 #include "build/build_config.h"
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #include "app/x11_util.h"
 #define EGL_HAS_PBUFFERS 1
 #endif
@@ -28,7 +28,7 @@ bool BaseEGLContext::InitializeOneOff() {
   if (initialized)
     return true;
 
-#ifdef OS_LINUX
+#ifdef OS_NIX
   EGLNativeDisplayType native_display = x11_util::GetXDisplay();
 #else
   EGLNativeDisplayType native_display = EGL_DEFAULT_DISPLAY;
diff --git a/app/surface/transport_dib.h b/app/surface/transport_dib.h
index c392c5f..eb19d04 100644
--- app/surface/transport_dib.h
+++ app/surface/transport_dib.h
@@ -7,7 +7,7 @@
 
 #include "base/basictypes.h"
 
-#if defined(OS_WIN) || defined(OS_MACOSX)
+#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_FREEBSD)
 #include "base/shared_memory.h"
 #endif
 
@@ -80,7 +80,7 @@ class TransportDIB {
     static int fake_handle = 10;
     return reinterpret_cast<Handle>(fake_handle++);
   }
-#elif defined(OS_MACOSX)
+#elif defined(OS_MACOSX) || defined(OS_FREEBSD)
   typedef base::SharedMemoryHandle Handle;
   // On Mac, the inode number of the backing file is used as an id.
   typedef base::SharedMemoryId Id;
@@ -95,7 +95,7 @@ class TransportDIB {
     static int fake_handle = 10;
     return Handle(fake_handle++, false);
   }
-#elif defined(USE_X11)
+#elif defined(OS_LINUX)
   typedef int Handle;  // These two ints are SysV IPC shared memory keys
   typedef int Id;
 
@@ -161,11 +161,12 @@ class TransportDIB {
 
  private:
   TransportDIB();
-#if defined(OS_WIN) || defined(OS_MACOSX)
+#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_FREEBSD)
   explicit TransportDIB(base::SharedMemoryHandle dib);
   base::SharedMemory shared_memory_;
   uint32 sequence_num_;
-#elif defined(USE_X11)
+#endif
+#if defined(USE_X11)
   int key_;  // SysV shared memory id
   void* address_;  // mapped address
   XSharedMemoryId x_shm_;  // X id for the shared segment
diff --git a/app/surface/transport_dib_freebsd.cc b/app/surface/transport_dib_freebsd.cc
new file mode 100644
index 0000000..b49ba71
--- /dev/null
+++ app/surface/transport_dib_freebsd.cc
@@ -0,0 +1,86 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "app/surface/transport_dib.h"
+
+#include <unistd.h>
+#include <sys/stat.h>
+
+#include "base/eintr_wrapper.h"
+#include "base/shared_memory.h"
+#include "skia/ext/platform_canvas.h"
+
+TransportDIB::TransportDIB()
+    : size_(0) {
+}
+
+TransportDIB::TransportDIB(TransportDIB::Handle dib)
+    : shared_memory_(dib, false /* read write */),
+      size_(0) {
+}
+
+TransportDIB::~TransportDIB() {
+}
+
+// static
+TransportDIB* TransportDIB::Create(size_t size, uint32 sequence_num) {
+  TransportDIB* dib = new TransportDIB;
+  if (!dib->shared_memory_.Create(L"", false /* read write */,
+                                  false /* do not open existing */, size)) {
+    delete dib;
+    return NULL;
+  }
+
+  dib->size_ = size;
+  return dib;
+}
+
+// static
+TransportDIB* TransportDIB::Map(TransportDIB::Handle handle) {
+  if (!is_valid(handle))
+    return NULL;
+
+  TransportDIB* dib = new TransportDIB(handle);
+  struct stat st;
+  if ((fstat(handle.fd, &st) != 0) ||
+      (!dib->shared_memory_.Map(st.st_size))) {
+    delete dib;
+    HANDLE_EINTR(close(handle.fd));
+    return NULL;
+  }
+
+  dib->size_ = st.st_size;
+
+  return dib;
+}
+
+bool TransportDIB::is_valid(Handle dib) {
+  return dib.fd >= 0;
+}
+
+skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) {
+  return new skia::PlatformCanvas(w, h, true,
+                                  reinterpret_cast<uint8_t*>(memory()));
+}
+
+void* TransportDIB::memory() const {
+  return shared_memory_.memory();
+}
+
+TransportDIB::Id TransportDIB::id() const {
+  return shared_memory_.id();
+}
+
+TransportDIB::Handle TransportDIB::handle() const {
+  return shared_memory_.handle();
+}
+
+XID TransportDIB::MapToX(Display* display) {
+  if (!x_shm_) {
+    x_shm_ = x11_util::AttachSharedMemory(display, key_);
+    display_ = display;
+  }
+
+  return x_shm_;
+}
diff --git a/app/surface/transport_dib_linux.cc b/app/surface/transport_dib_linux.cc
index 26cad3f..b5feed5 100644
--- app/surface/transport_dib_linux.cc
+++ app/surface/transport_dib_linux.cc
@@ -28,6 +28,9 @@ TransportDIB::TransportDIB()
 TransportDIB::~TransportDIB() {
   if (address_ != kInvalidAddress) {
     shmdt(address_);
+#if defined(OS_FREEBSD)
+    shmctl(key_, IPC_RMID, 0);
+#endif
     address_ = kInvalidAddress;
   }
 
@@ -53,7 +56,13 @@ TransportDIB* TransportDIB::Create(size_t size, uint32 sequence_num) {
   // Here we mark the shared memory for deletion. Since we attached it in the
   // line above, it doesn't actually get deleted but, if we crash, this means
   // that the kernel will automatically clean it up for us.
+#if !defined(OS_FREEBSD)
+// BSD: A shmctl IPC_RMID call here renders all future shared memory calls for
+// BSD: a particular key to fail on FreeBSD, so I moved this call to the
+// BSD: destructor.  Of course, this means chromium crashes on FreeBSD don't
+// BSD: clean up shared memory.
   shmctl(shmkey, IPC_RMID, 0);
+#endif
   if (address == kInvalidAddress)
     return NULL;
 
diff --git a/app/test_suite.h b/app/test_suite.h
index 3a738b2..bf876dd 100644
--- app/test_suite.h
+++ app/test_suite.h
@@ -48,14 +48,14 @@ class AppTestSuite : public TestSuite {
     mac_util::SetOverrideAppBundlePath(path);
 #endif  // OS_MACOSX
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
     FilePath pak_dir;
     PathService::Get(base::DIR_MODULE, &pak_dir);
     pak_dir = pak_dir.AppendASCII("app_unittests_strings");
     PathService::Override(app::DIR_LOCALES, pak_dir);
     PathService::Override(app::FILE_RESOURCES_PAK,
                           pak_dir.AppendASCII("app_resources.pak"));
-#endif  // OS_LINUX
+#endif  // OS_NIX
 
     // Force unittests to run using en-US so if we test against string
     // output, it'll pass regardless of the system language.
diff --git a/base/base.gyp b/base/base.gyp
index d2c9a68..8d2e294 100644
--- base/base.gyp
+++ base/base.gyp
@@ -230,6 +230,13 @@
         'test/test_file_util_posix.cc',
         'test/test_file_util_win.cc',
       ],
+      'conditions': [
+        [ 'OS == "freebsd"', {
+            # fdatasync is not implemented on FreeBSD
+            'sources/': [ ['exclude', '^test/test_file_util_linux.cc$'] ],
+          },
+        ],
+      ],
     },
     {
       'target_name': 'test_support_perf',
diff --git a/base/base.gypi b/base/base.gypi
index ff05d2a..307d902 100644
--- base/base.gypi
+++ base/base.gypi
@@ -319,8 +319,6 @@
           [ 'OS != "linux"', {
               'sources!': [
                 # Not automatically excluded by the *linux.cc rules.
-                'gtk_util.cc',
-                'gtk_util.h',
                 'linux_util.cc',
                 'setproctitle_linux.c',
                 'setproctitle_linux.h',
@@ -556,6 +554,9 @@
           ],
         },],
         [ 'OS == "freebsd" or OS == "openbsd"', {
+          'sources!': [
+            'process_linux.cc',
+          ],
           'link_settings': {
             'libraries': [
               '-L/usr/local/lib -lexecinfo',
@@ -630,7 +631,7 @@
         },
       ],
     }],
-    [ 'OS == "linux" and internal_pdf', {
+    [ '(OS == "linux" or OS == "freebsd") and internal_pdf', {
       'targets': [
         {
           'target_name': 'base_fpic',
diff --git a/base/debug_util_posix.cc b/base/debug_util_posix.cc
index 110cb20..4894cc7 100644
--- base/debug_util_posix.cc
+++ base/debug_util_posix.cc
@@ -225,8 +225,8 @@ bool DebugUtil::BeingDebugged() {
 
 bool DebugUtil::BeingDebugged() {
   // TODO(benl): can we determine this under FreeBSD?
-  NOTIMPLEMENTED();
-  return false;
+  LOG(WARNING) << "Don't know how to do this";
+  return true;
 }
 
 #endif  // defined(OS_FREEBSD)
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 434c859..10d3200 100644
--- base/file_util_posix.cc
+++ base/file_util_posix.cc
@@ -777,7 +777,11 @@ bool GetTempDir(FilePath* path) {
 }
 
 bool GetShmemTempDir(FilePath* path) {
+#if defined(OS_LINUX)
   *path = FilePath("/dev/shm");
+#else
+  *path = FilePath("/tmp");
+#endif
   return true;
 }
 
diff --git a/base/leak_annotations.h b/base/leak_annotations.h
index a402acf..85b4c7e 100644
--- base/leak_annotations.h
+++ base/leak_annotations.h
@@ -7,7 +7,7 @@
 
 #include "build/build_config.h"
 
-#if defined(OS_LINUX) && defined(USE_HEAPCHECKER)
+#if defined(OS_NIX) && defined(USE_HEAPCHECKER)
 
 #include "third_party/tcmalloc/chromium/src/google/heap-checker.h"
 
diff --git a/base/profiler.cc b/base/profiler.cc
index e291117..a6f1486 100644
--- base/profiler.cc
+++ base/profiler.cc
@@ -5,7 +5,7 @@
 #include "base/profiler.h"
 #include "base/string_util.h"
 
-#if defined(USE_TCMALLOC) && defined(OS_LINUX)
+#if defined(USE_TCMALLOC) && defined(OS_NIX)
 #include "third_party/tcmalloc/chromium/src/google/profiler.h"
 #endif
 
@@ -24,7 +24,7 @@ namespace base {
 void Profiler::StartRecording() {
 #ifdef QUANTIFY
   QuantifyStartRecordingData();
-#elif defined(USE_TCMALLOC) && defined(OS_LINUX)
+#elif defined(USE_TCMALLOC) && defined(OS_NIX)
   ProfilerStart("chrome-profile");
 #endif
 }
@@ -32,13 +32,13 @@ void Profiler::StartRecording() {
 void Profiler::StopRecording() {
 #ifdef QUANTIFY
   QuantifyStopRecordingData();
-#elif defined(USE_TCMALLOC) && defined(OS_LINUX)
+#elif defined(USE_TCMALLOC) && defined(OS_NIX)
   ProfilerStop();
 #endif
 }
 
 void Profiler::Flush() {
-#if defined(USE_TCMALLOC) && defined(OS_LINUX)
+#if defined(USE_TCMALLOC) && defined(OS_NIX)
   ProfilerFlush();
 #endif
 }
diff --git a/base/test/test_suite.h b/base/test/test_suite.h
index ff6f131..17d52c0 100644
--- base/test/test_suite.h
+++ base/test/test_suite.h
@@ -63,7 +63,7 @@ class TestSuite {
 #if defined(OS_POSIX) && !defined(OS_MACOSX)
     g_thread_init(NULL);
     gtk_init_check(&argc, &argv);
-#endif  // defined(OS_LINUX)
+#endif  // defined(OS_POSIX) && !defined(OS_MACOSX)
     // Don't add additional code to this constructor.  Instead add it to
     // Initialize().  See bug 6436.
   }
diff --git a/base/worker_pool_linux.cc b/base/worker_pool_linux.cc
index b9c85b3..3dc08b9 100644
--- base/worker_pool_linux.cc
+++ base/worker_pool_linux.cc
@@ -17,7 +17,7 @@ namespace {
 const int kIdleSecondsBeforeExit = 10 * 60;
 // A stack size of 64 KB is too small for the CERT_PKIXVerifyCert
 // function of NSS because of NSS bug 439169.
-const int kWorkerThreadStackSize = 128 * 1024;
+const int kWorkerThreadStackSize = 256 * 1024;
 
 class WorkerPoolImpl {
  public:
diff --git a/build/build_config.h b/build/build_config.h
index c0a7bee..32e215c 100644
--- build/build_config.h
+++ build/build_config.h
@@ -47,6 +47,7 @@
 
 #if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || \
     defined(OS_SOLARIS)
+#define OS_NIX 1
 #define USE_NSS 1  // Use NSS for crypto.
 #define USE_X11 1  // Use X for graphics.
 #endif
@@ -61,12 +62,12 @@
 #endif
 
 // Use tcmalloc
-#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(NO_TCMALLOC)
+#if (defined(OS_WIN) || defined(OS_NIX)) && !defined(NO_TCMALLOC)
 #define USE_TCMALLOC 1
 #endif
 
 // Use heapchecker.
-#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(NO_HEAPCHECKER)
+#if (defined(OS_WIN) || defined(OS_NIX)) && !defined(NO_HEAPCHECKER)
 #define USE_HEAPCHECKER 1
 #endif
 
diff --git a/build/common.gypi b/build/common.gypi
index 8a9fd97..8f9abe4 100644
--- build/common.gypi
+++ build/common.gypi
@@ -106,7 +106,7 @@
       'linux_fpic%': 0,
 
       # Python version.
-      'python_ver%': '2.5',
+      'python_ver%': '2.6',
 
       # Set ARM-v7 compilation flags
       'armv7%': 0,
@@ -208,7 +208,7 @@
 
     # Whether proprietary audio/video codecs are assumed to be included with
     # this build (only meaningful if branding!=Chrome).
-    'proprietary_codecs%': 0,
+    'proprietary_codecs%': 1,
 
     # TODO(bradnelson): eliminate this when possible.
     # To allow local gyp files to prevent release.vsprops from being included.
@@ -246,21 +246,21 @@
     'linux_use_debugallocation%': 0,
 
     # Disable TCMalloc's heapchecker.
-    'linux_use_heapchecker%': 0,
+    'linux_use_heapchecker%': 1,
 
     # Set to 1 to turn on seccomp sandbox by default.
     # (Note: this is ignored for official builds.)
     'linux_use_seccomp_sandbox%': 0,
 
     # Set to 1 to link against libgnome-keyring instead of using dlopen().
-    'linux_link_gnome_keyring%': 0,
+    'linux_link_gnome_keyring%': 1,
 
     # Set to select the Title Case versions of strings in GRD files.
     'use_titlecase_in_grd_files%': 0,
 
     # Used to disable Native Client at compile time, for platforms where it
     # isn't supported
-    'disable_nacl%': 0,
+    'disable_nacl%': 1,
 
     # Set Thumb compilation flags.
     'arm_thumb%': 0,
@@ -279,13 +279,16 @@
     # whether to compile in the sources for the GPU plugin / process.
     'enable_gpu%': 1,
 
+    # Use GConf, the GNOME configuration system.
+    'use_gconf%': 1,
+
     'conditions': [
       ['OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
         # This will set gcc_version to XY if you are running gcc X.Y.*.
         # This is used to tweak build flags for gcc 4.4.
         'gcc_version%': '<!(python <(DEPTH)/build/compiler_version.py)',
         # Figure out the python architecture to decide if we build pyauto.
-        'python_arch%': '<!(<(DEPTH)/build/linux/python_arch.sh <(sysroot)/usr/lib/libpython<(python_ver).so.1.0)',
+        'python_arch%': '<!(<(DEPTH)/build/linux/python_arch.sh <(sysroot)/usr/local/lib/libpython<(python_ver).so.1)',
         'conditions': [
           ['branding=="Chrome" or linux_chromium_breakpad==1', {
             'linux_breakpad%': 1,
@@ -576,7 +576,7 @@
               ['exclude', '/(gtk|x11)_[^/]*\\.cc$'],
             ],
           }],
-          ['OS!="linux"', {
+          ['OS!="linux" and OS!="freebsd" and OS!="openbsd"', {
             'sources/': [
               ['exclude', '_linux(_unittest)?\\.cc$'],
               ['exclude', '/linux/'],
diff --git a/build/features_override.gypi b/build/features_override.gypi
index 2e19776..b12261d 100644
--- build/features_override.gypi
+++ build/features_override.gypi
@@ -61,7 +61,7 @@
     'enable_svg%': '<(enable_svg)',
     'enable_touch_events%': '<(enable_touch_events)',
     'conditions': [
-      ['OS=="win" or OS=="linux" or use_accelerated_compositing==1', {
+      ['OS=="win" or OS=="linux" or OS=="freebsd" or use_accelerated_compositing==1', {
         'feature_defines': [
          'WTF_USE_ACCELERATED_COMPOSITING=1',
          'ENABLE_3D_RENDERING=1',
diff --git a/build/linux/python_arch.sh b/build/linux/python_arch.sh
index f364469..a6c3f43 100755
--- build/linux/python_arch.sh
+++ build/linux/python_arch.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
@@ -10,12 +10,7 @@
 #  python_arch.sh /path/to/sysroot/usr/lib/libpython2.4.so.1.0
 #
 
-python=$(readlink -f "$1")
-if [ ! -r "$python" ]; then
-  echo unknown
-  exit 0;
-fi
-file_out=$(file "$python")
+file_out=$(file "$1")
 if [ $? -ne 0 ]; then
   echo unknown
   exit 0;
diff --git a/build/linux/system.gyp b/build/linux/system.gyp
index 876579a..23d1c6c 100644
--- build/linux/system.gyp
+++ build/linux/system.gyp
@@ -188,11 +188,14 @@
       'target_name': 'gconf',
       'type': 'settings',
       'conditions': [
-        ['_toolset=="target"', {
+        ['use_gconf==1 and _toolset=="target"', {
           'direct_dependent_settings': {
             'cflags': [
               '<!@(<(pkg-config) --cflags gconf-2.0)',
             ],
+            'defines': [
+              'USE_GCONF',
+            ],
           },
           'link_settings': {
             'ldflags': [
@@ -283,7 +283,6 @@
             }, {
               'link_settings': {
                 'libraries': [
-                  '-ldl',
                 ],
               },
             }],
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc
index 9e3feb8..b8013fc 100644
--- chrome/app/chrome_dll_main.cc
+++ chrome/app/chrome_dll_main.cc
@@ -71,7 +71,7 @@
 #include "app/x11_util.h"
 #endif
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h"
 #include "chrome/browser/zygote_host_linux.h"
 #endif
@@ -580,7 +580,7 @@ int ChromeMain(int argc, char** argv) {
     browser_pid = base::GetCurrentProcId();
 #elif defined(OS_POSIX)
     // On linux, we're in the zygote here; so we need the parent process' id.
-    browser_pid = base::GetParentProcessId(base::GetCurrentProcId());
+    //browser_pid = base::GetParentProcessId(base::GetCurrentProcId());
 #endif
 
 #if defined(OS_POSIX)
@@ -819,7 +819,7 @@ int ChromeMain(int argc, char** argv) {
   } else if (process_type == switches::kServiceProcess) {
     rv = ServiceProcessMain(main_params);
   } else if (process_type.empty()) {
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
     const char* sandbox_binary = NULL;
     struct stat st;
 
@@ -863,7 +863,7 @@ int ChromeMain(int argc, char** argv) {
     SetUpGLibLogHandler();
 
     x11_util::SetX11ErrorHandlers();
-#endif  // defined(OS_LINUX)
+#endif  // defined(OS_NIX)
 
     rv = BrowserMain(main_params);
   } else {
diff --git a/chrome/app/chrome_exe_main_gtk.cc b/chrome/app/chrome_exe_main_gtk.cc
index fb3c332..d651fc3 100644
--- chrome/app/chrome_exe_main_gtk.cc
+++ chrome/app/chrome_exe_main_gtk.cc
@@ -4,7 +4,7 @@
 
 #include "base/at_exit.h"
 #include "base/process_util.h"
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#if defined(OS_NIX) && !defined(OS_CHROMEOS)
 #include "chrome/browser/first_run.h"
 #endif
 
@@ -20,11 +20,11 @@
 extern "C" {
 int ChromeMain(int argc, const char** argv);
 
-#if defined(OS_LINUX) && defined(USE_TCMALLOC)
+#if defined(OS_NIX) && defined(USE_TCMALLOC)
 
 int tc_set_new_mode(int mode);
 
-#endif  // defined(OS_LINUX) && defined(USE_TCMALLOC)
+#endif  // defined(OS_NIX) && defined(USE_TCMALLOC)
 }
 
 int main(int argc, const char** argv) {
@@ -37,7 +37,7 @@ int main(int argc, const char** argv) {
   // dependency on TCMalloc.  Really, we ought to have our allocator shim code
   // implement this EnableTerminationOnOutOfMemory() function.  Whateverz.  This
   // works for now.
-#if defined(OS_LINUX) && defined(USE_TCMALLOC)
+#if defined(OS_NIX) && defined(USE_TCMALLOC)
   // For tcmalloc, we need to tell it to behave like new.
   tc_set_new_mode(1);
 #endif
diff --git a/chrome/app/chrome_main_uitest.cc b/chrome/app/chrome_main_uitest.cc
index 8d13b89..88a4a99 100644
--- chrome/app/chrome_main_uitest.cc
+++ chrome/app/chrome_main_uitest.cc
@@ -18,7 +18,7 @@ TEST_F(ChromeMainTest, AppLaunch) {
   if (UITest::in_process_renderer()) {
     EXPECT_EQ(1, UITest::GetBrowserProcessCount());
   } else {
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
     // On Linux we'll have four processes: browser, renderer, zygote and
     // sandbox helper.
     EXPECT_EQ(4, UITest::GetBrowserProcessCount());
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 610d54d..90f4437 100644
--- chrome/app/generated_resources.grd
+++ chrome/app/generated_resources.grd
@@ -8758,7 +8758,7 @@ Keep your key file in a safe place. You will need it to create new versions of y
       Import bookmarks now...
     </message>
 
-    <if expr="os == 'linux2' or os == 'openbsd4' or os=='freebsd6'">
+    <if expr="os == 'linux2' or os.find('bsd') != -1">
       <!-- Linux proxy configuration fallback help -->
       <message name="IDS_ABOUT_LINUX_PROXY_CONFIG_TITLE" desc="Title of HTML page shown on systems where system proxy configuration is unsupported.">
         Proxy Configuration Help
diff --git a/chrome/browser/app_modal_dialog.cc b/chrome/browser/app_modal_dialog.cc
index e8f306d..c40701a 100644
--- chrome/browser/app_modal_dialog.cc
+++ chrome/browser/app_modal_dialog.cc
@@ -11,7 +11,7 @@
 
 AppModalDialog::AppModalDialog(TabContents* tab_contents,
                                const std::wstring& title)
-#if defined(OS_WIN) || defined(OS_LINUX)
+#if defined(OS_WIN) || defined(OS_NIX)
     : dialog_(NULL),
 #elif defined(OS_MACOSX)
     :
diff --git a/chrome/browser/app_modal_dialog.h b/chrome/browser/app_modal_dialog.h
index 92ac494..092d428 100644
--- chrome/browser/app_modal_dialog.h
+++ chrome/browser/app_modal_dialog.h
@@ -92,7 +92,7 @@ class AppModalDialog {
   virtual NativeDialog CreateNativeDialog() = 0;
 
   // A reference to the platform native dialog box.
-#if defined(OS_LINUX) || defined(OS_WIN)
+#if defined(OS_NIX) || defined(OS_WIN)
   NativeDialog dialog_;
 #endif
 
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 364c599..548d8f2 100644
--- chrome/browser/browser.cc
+++ chrome/browser/browser.cc
@@ -254,7 +254,7 @@ Browser::~Browser() {
 
   BrowserList::RemoveBrowser(this);
 
-#if defined(OS_WIN) || defined(OS_LINUX)
+#if defined(OS_WIN) || defined(OS_NIX)
   if (!BrowserList::HasBrowserWithProfile(profile_)) {
     // We're the last browser window with this profile. We need to nuke the
     // TabRestoreService, which will start the shutdown of the
@@ -757,7 +757,7 @@ string16 Browser::GetWindowTitleForCurrentTab() const {
   // On Mac or ChromeOS, we don't want to suffix the page title with
   // the application name.
   return title;
-#elif defined(OS_WIN) || defined(OS_LINUX)
+#elif defined(OS_WIN) || defined(OS_NIX)
   int string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT;
   // Don't append the app name to window titles on app frames and app popups
   if (type_ & TYPE_APP)
@@ -1417,9 +1417,9 @@ void Browser::ToggleFullscreenMode() {
 
   UserMetrics::RecordAction(UserMetricsAction("ToggleFullscreen"), profile_);
   window_->SetFullscreen(!window_->IsFullscreen());
-  // On Linux, setting fullscreen mode is an async call to the X server, which
+  // On X11, setting fullscreen mode is an async call to the X server, which
   // may or may not support fullscreen mode.
-#if !defined(OS_LINUX)
+#if !defined(USE_X11)
   UpdateCommandsForFullscreenMode(window_->IsFullscreen());
 #endif
 }
@@ -1644,7 +1644,7 @@ void Browser::OpenFile() {
 
 void Browser::OpenCreateShortcutsDialog() {
   UserMetrics::RecordAction(UserMetricsAction("CreateShortcut"), profile_);
-#if defined(OS_WIN) || defined(OS_LINUX)
+#if defined(OS_WIN) || defined(OS_NIX)
   TabContents* current_tab = GetSelectedTabContents();
   DCHECK(current_tab && web_app::IsValidUrl(current_tab->GetURL())) <<
       "Menu item should be disabled.";
@@ -2295,7 +2295,7 @@ void Browser::DuplicateContentsAt(int index) {
 }
 
 void Browser::CloseFrameAfterDragSession() {
-#if defined(OS_WIN) || defined(OS_LINUX)
+#if defined(OS_WIN) || defined(OS_NIX)
   // This is scheduled to run after we return to the message loop because
   // otherwise the frame will think the drag session is still active and ignore
   // the request.
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc
index 9607cad..516a755 100644
--- chrome/browser/browser_about_handler.cc
+++ chrome/browser/browser_about_handler.cc
@@ -64,7 +64,7 @@
 #include "chrome/browser/zygote_host_linux.h"
 #elif defined(OS_MACOSX)
 #include "chrome/browser/cocoa/about_ipc_dialog.h"
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
 #include "chrome/browser/zygote_host_linux.h"
 #endif
 
@@ -106,7 +106,7 @@ const char kAboutPath[] = "about";
 const char kNetInternalsPath[] = "net-internals";
 const char kPluginsPath[] = "plugins";
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 const char kLinuxProxyConfigPath[] = "linux-proxy-config";
 const char kSandboxPath[] = "sandbox";
 #endif
@@ -134,7 +134,7 @@ const char *kAllAboutPaths[] = {
   kTcmallocPath,
   kTermsPath,
   kVersionPath,
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   kLinuxProxyConfigPath,
   kSandboxPath,
 #endif
@@ -521,7 +521,7 @@ std::string AboutStats() {
   return data;
 }
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 std::string AboutLinuxProxyConfig() {
   std::string data;
   data.append("<!DOCTYPE HTML>\n");
@@ -898,7 +898,7 @@ void AboutSource::StartDataRequest(const std::string& path_raw,
   } else if (path == kTermsPath) {
     response = ResourceBundle::GetSharedInstance().GetRawDataResource(
         IDR_TERMS_HTML).as_string();
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   } else if (path == kLinuxProxyConfigPath) {
     response = AboutLinuxProxyConfig();
   } else if (path == kSandboxPath) {
diff --git a/chrome/browser/browser_child_process_host.cc b/chrome/browser/browser_child_process_host.cc
index d700475..fe219d8 100644
--- chrome/browser/browser_child_process_host.cc
+++ chrome/browser/browser_child_process_host.cc
@@ -25,9 +25,9 @@
 #include "chrome/common/result_codes.h"
 #include "chrome/installer/util/google_update_settings.h"
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #include "base/linux_util.h"
-#endif  // OS_LINUX
+#endif  // OS_NIX
 
 #if defined(OS_POSIX)
 // This is defined in chrome/browser/google_update_settings_posix.cc.  It's the
diff --git a/chrome/browser/browser_theme_provider.h b/chrome/browser/browser_theme_provider.h
index 0cb4b15..8c2b0c7 100644
--- chrome/browser/browser_theme_provider.h
+++ chrome/browser/browser_theme_provider.h
@@ -129,7 +129,7 @@ class BrowserThemeProvider : public NonThreadSafe,
   virtual bool ShouldUseNativeFrame() const;
   virtual bool HasCustomImage(int id) const;
   virtual RefCountedMemory* GetRawData(int id) const;
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
   // GdkPixbufs returned by GetPixbufNamed and GetRTLEnabledPixbufNamed are
   // shared instances owned by the theme provider and should not be freed.
   virtual GdkPixbuf* GetPixbufNamed(int id) const;
@@ -241,12 +241,12 @@ class BrowserThemeProvider : public NonThreadSafe,
   // Remove preference values for themes that are no longer in use.
   void RemoveUnusedThemes();
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
   // Loads an image and flips it horizontally if |rtl_enabled| is true.
   GdkPixbuf* GetPixbufImpl(int id, bool rtl_enabled) const;
 #endif
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
   typedef std::map<int, GdkPixbuf*> GdkPixbufMap;
   mutable GdkPixbufMap gdk_pixbufs_;
 #elif defined(OS_MACOSX)
diff --git a/chrome/browser/child_process_launcher.cc b/chrome/browser/child_process_launcher.cc
index 60215d5..57fd9d2 100644
--- chrome/browser/child_process_launcher.cc
+++ chrome/browser/child_process_launcher.cc
@@ -18,7 +18,7 @@
 
 #if defined(OS_WIN)
 #include "chrome/common/sandbox_policy.h"
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
 #include "base/singleton.h"
 #include "chrome/browser/crash_handler_host_linux.h"
 #include "chrome/browser/zygote_host_linux.h"
@@ -41,7 +41,7 @@ class ChildProcessLauncher::Context
  public:
   Context()
       : starting_(true)
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
         , zygote_(false)
 #endif
         {
@@ -106,7 +106,7 @@ class ChildProcessLauncher::Context
     handle = sandbox::StartProcessWithAccess(cmd_line, exposed_dir);
 #elif defined(OS_POSIX)
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
     if (use_zygote) {
       base::GlobalDescriptors::Mapping mapping;
       mapping.push_back(std::pair<uint32_t, int>(kPrimaryIPCChannel, ipcfd));
@@ -126,7 +126,7 @@ class ChildProcessLauncher::Context
           ipcfd,
           kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor));
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
       // On Linux, we need to add some extra file descriptors for crash handling
       // and the sandbox.
       bool is_renderer =
@@ -158,7 +158,7 @@ class ChildProcessLauncher::Context
             sandbox_fd,
             kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor));
       }
-#endif  // defined(OS_LINUX)
+#endif  // defined(OS_NIX)
 
       // Actually launch the app.
       bool launched;
@@ -185,20 +185,20 @@ class ChildProcessLauncher::Context
         NewRunnableMethod(
             this,
             &ChildProcessLauncher::Context::Notify,
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
             use_zygote,
 #endif
             handle));
   }
 
   void Notify(
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
       bool zygote,
 #endif
       base::ProcessHandle handle) {
     starting_ = false;
     process_.set_handle(handle);
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
     zygote_ = zygote;
 #endif
     if (client_) {
@@ -218,7 +218,7 @@ class ChildProcessLauncher::Context
         ChromeThread::PROCESS_LAUNCHER, FROM_HERE,
         NewRunnableFunction(
             &ChildProcessLauncher::Context::TerminateInternal,
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
             zygote_,
 #endif
             process_.handle()));
@@ -226,7 +226,7 @@ class ChildProcessLauncher::Context
   }
 
   static void TerminateInternal(
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
       bool zygote,
 #endif
       base::ProcessHandle handle) {
@@ -236,13 +236,13 @@ class ChildProcessLauncher::Context
     process.Terminate(ResultCodes::NORMAL_EXIT);
     // On POSIX, we must additionally reap the child.
 #if defined(OS_POSIX)
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
     if (zygote) {
       // If the renderer was created via a zygote, we have to proxy the reaping
       // through the zygote process.
       Singleton<ZygoteHost>()->EnsureProcessTerminated(handle);
     } else
-#endif  // OS_LINUX
+#endif  // OS_NIX
     {
       ProcessWatcher::EnsureProcessTerminated(handle);
     }
@@ -255,7 +255,7 @@ class ChildProcessLauncher::Context
   base::Process process_;
   bool starting_;
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   bool zygote_;
 #endif
 };
@@ -300,7 +300,7 @@ base::ProcessHandle ChildProcessLauncher::GetHandle() {
 bool ChildProcessLauncher::DidProcessCrash() {
   bool did_crash, child_exited;
   base::ProcessHandle handle = context_->process_.handle();
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   if (context_->zygote_) {
     did_crash = Singleton<ZygoteHost>()->DidProcessCrash(handle, &child_exited);
   } else
diff --git a/chrome/browser/cookie_modal_dialog.h b/chrome/browser/cookie_modal_dialog.h
index 5308186..d9576bd 100644
--- chrome/browser/cookie_modal_dialog.h
+++ chrome/browser/cookie_modal_dialog.h
@@ -13,7 +13,7 @@
 #include "chrome/browser/cookie_prompt_modal_dialog_delegate.h"
 #include "googleurl/src/gurl.h"
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
 #include "app/gtk_signal.h"
 #endif
 
@@ -28,7 +28,7 @@ class NSWindow;
 class HostContentSettingsMap;
 class PrefService;
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
 typedef struct _GtkWidget GtkWidget;
 typedef struct _GParamSpec GParamSpec;
 #endif
@@ -73,7 +73,7 @@ class CookiePromptModalDialog : public AppModalDialog {
   static void RegisterUserPrefs(PrefService* prefs);
 
   // AppModalDialog overrides.
-#if defined(OS_LINUX) || defined(OS_MACOSX)
+#if defined(OS_POSIX)
   virtual void CreateAndShowDialog();
 #endif
   virtual int GetDialogButtons();
@@ -103,7 +103,7 @@ class CookiePromptModalDialog : public AppModalDialog {
  protected:
   // AppModalDialog overrides.
   virtual NativeDialog CreateNativeDialog();
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
   virtual void HandleDialogResponse(GtkDialog* dialog, gint response_id);
   CHROMEGTK_CALLBACK_1(CookiePromptModalDialog,
                        void,
@@ -140,7 +140,7 @@ class CookiePromptModalDialog : public AppModalDialog {
   // delegate could be deleted
   CookiePromptModalDialogDelegate* delegate_;
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
   // The "remember this choice" radio button in the dialog.
   GtkWidget* remember_radio_;
 
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index a3e064f..400ae31 100644
--- chrome/browser/download/download_util.cc
+++ chrome/browser/download/download_util.cc
@@ -43,14 +43,14 @@
 #include "views/drag_utils.h"
 #endif
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #if defined(TOOLKIT_VIEWS)
 #include "app/drag_drop_types.h"
 #include "views/widget/widget_gtk.h"
 #elif defined(TOOLKIT_GTK)
 #include "chrome/browser/gtk/custom_drag.h"
 #endif  // defined(TOOLKIT_GTK)
-#endif  // defined(OS_LINUX)
+#endif  // defined(OS_NIX)
 
 #if defined(OS_WIN)
 #include "app/os_exchange_data_provider_win.h"
@@ -329,7 +329,7 @@ void DragDownload(const DownloadItem* download,
   DWORD effects;
   DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source.get(),
              DROPEFFECT_COPY | DROPEFFECT_LINK, &effects);
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
   GtkWidget* root = gtk_widget_get_toplevel(view);
   if (!root)
     return;
@@ -340,13 +340,13 @@ void DragDownload(const DownloadItem* download,
   widget->DoDrag(data, DragDropTypes::DRAG_COPY | DragDropTypes::DRAG_LINK);
 #endif  // OS_WIN
 }
-#elif defined(OS_LINUX)
+#elif defined(USE_X11)
 void DragDownload(const DownloadItem* download,
                   SkBitmap* icon,
                   gfx::NativeView view) {
   DownloadItemDrag::BeginDrag(download, icon);
 }
-#endif  // OS_LINUX
+#endif // USE_X11
 
 DictionaryValue* CreateDownloadItemValue(DownloadItem* download, int id) {
   DictionaryValue* file_value = new DictionaryValue();
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index cd040f8..ed24185 100644
--- chrome/browser/extensions/extension_process_manager.cc
+++ chrome/browser/extensions/extension_process_manager.cc
@@ -51,10 +51,10 @@ ExtensionProcessManager::ExtensionProcessManager(Profile* profile)
                  NotificationService::AllSources());
   registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSED,
                  NotificationService::AllSources());
-#if defined(OS_WIN) || defined(OS_LINUX)
+#if !defined(OS_MACOSX)
   registrar_.Add(this, NotificationType::BROWSER_CLOSED,
                  NotificationService::AllSources());
-#elif defined(OS_MACOSX)
+#else
   registrar_.Add(this, NotificationType::APP_TERMINATING,
                  NotificationService::AllSources());
 #endif
@@ -285,7 +285,7 @@ void ExtensionProcessManager::Observe(NotificationType type,
       UnregisterExtensionProcess(host->id());
       break;
     }
-#if defined(OS_WIN) || defined(OS_LINUX)
+#if !defined(OS_MACOSX)
     case NotificationType::BROWSER_CLOSED: {
       // Close background hosts when the last browser is closed so that they
       // have time to shutdown various objects on different threads. Our
@@ -295,7 +295,7 @@ void ExtensionProcessManager::Observe(NotificationType type,
         CloseBackgroundHosts();
       break;
     }
-#elif defined(OS_MACOSX)
+#else
     case NotificationType::APP_TERMINATING: {
       CloseBackgroundHosts();
       break;
diff --git a/chrome/browser/first_run.h b/chrome/browser/first_run.h
index 6615d93..e582628 100644
--- chrome/browser/first_run.h
+++ chrome/browser/first_run.h
@@ -139,7 +139,7 @@ class FirstRun {
   // Import browser items in this process. The browser and the items to
   // import are encoded int the command line.
   static int ImportFromBrowser(Profile* profile, const CommandLine& cmdline);
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
   static bool ImportBookmarks(const std::wstring& import_bookmarks_path);
 #endif
 
diff --git a/chrome/browser/geolocation/empty_device_data_provider.cc b/chrome/browser/geolocation/empty_device_data_provider.cc
index 9e9fc27..371c281 100644
--- chrome/browser/geolocation/empty_device_data_provider.cc
+++ chrome/browser/geolocation/empty_device_data_provider.cc
@@ -12,7 +12,7 @@ RadioDataProviderImplBase* RadioDataProvider::DefaultFactoryFunction() {
 }
 
 // Only define for platforms that lack a real wifi data provider.
-#if !defined(OS_WIN) && !defined(OS_MACOSX) && !defined(OS_LINUX)
+#if !defined(OS_WIN) && !defined(OS_MACOSX) && !defined(OS_NIX)
 // static
 template<>
 WifiDataProviderImplBase* WifiDataProvider::DefaultFactoryFunction() {
diff --git a/chrome/browser/gpu_process_host.cc b/chrome/browser/gpu_process_host.cc
index 883f9be..0506ff5 100644
--- chrome/browser/gpu_process_host.cc
+++ chrome/browser/gpu_process_host.cc
@@ -15,7 +15,7 @@
 #include "chrome/common/render_messages.h"
 #include "ipc/ipc_switches.h"
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
 #include "gfx/gtk_native_view_id_manager.h"
 #endif
 
@@ -168,7 +168,7 @@ void GpuProcessHost::OnControlMessageReceived(const IPC::Message& message) {
   IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message)
     IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished)
     IPC_MESSAGE_HANDLER(GpuHostMsg_SynchronizeReply, OnSynchronizeReply)
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
     IPC_MESSAGE_HANDLER(GpuHostMsg_GetViewXID, OnGetViewXID)
 #endif
     IPC_MESSAGE_UNHANDLED_ERROR()
@@ -191,7 +191,7 @@ void GpuProcessHost::OnSynchronizeReply() {
   queued_synchronization_replies_.pop();
 }
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
 void GpuProcessHost::OnGetViewXID(gfx::NativeViewId id, unsigned long* xid) {
   GtkNativeViewManager* manager = Singleton<GtkNativeViewManager>::get();
   if (!manager->GetXIDForId(xid, id)) {
diff --git a/chrome/browser/gpu_process_host.h b/chrome/browser/gpu_process_host.h
index a331f69..3d105d0 100644
--- chrome/browser/gpu_process_host.h
+++ chrome/browser/gpu_process_host.h
@@ -84,7 +84,7 @@ class GpuProcessHost : public BrowserChildProcessHost {
   void OnChannelEstablished(const IPC::ChannelHandle& channel_handle,
                             const GPUInfo& gpu_info);
   void OnSynchronizeReply();
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
   void OnGetViewXID(gfx::NativeViewId id, unsigned long* xid);
 #endif
 
diff --git a/chrome/browser/gtk/browser_titlebar.cc b/chrome/browser/gtk/browser_titlebar.cc
index dea24e6..77adb09 100644
--- chrome/browser/gtk/browser_titlebar.cc
+++ chrome/browser/gtk/browser_titlebar.cc
@@ -23,7 +23,9 @@
 #include "chrome/browser/gtk/accelerators_gtk.h"
 #include "chrome/browser/gtk/browser_window_gtk.h"
 #include "chrome/browser/gtk/custom_button.h"
+#if defined(USE_GCONF)
 #include "chrome/browser/gtk/gconf_titlebar_listener.h"
+#endif
 #include "chrome/browser/gtk/gtk_theme_provider.h"
 #include "chrome/browser/gtk/gtk_util.h"
 #include "chrome/browser/gtk/menu_gtk.h"
@@ -193,6 +195,9 @@ void PopupPageMenuModel::Build() {
 ////////////////////////////////////////////////////////////////////////////////
 // BrowserTitlebar
 
+// static
+const char BrowserTitlebar::kDefaultButtonString[] = ":minimize,maximize,close";
+
 BrowserTitlebar::BrowserTitlebar(BrowserWindowGtk* browser_window,
                                  GtkWindow* window)
     : browser_window_(browser_window),
@@ -299,9 +304,13 @@ void BrowserTitlebar::Init() {
   gtk_box_pack_end(GTK_BOX(container_hbox_), titlebar_right_buttons_vbox_,
                    FALSE, FALSE, 0);
 
+#if defined(USE_GCONF)
   // Either read the gconf database and register for updates (on GNOME), or use
   // the default value (anywhere else).
   Singleton<GConfTitlebarListener>()->SetTitlebarButtons(this);
+#else
+  BuildButtons(kDefaultButtonString);
+#endif
 
   // We use an alignment to control the titlebar height.
   titlebar_alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
@@ -363,7 +372,9 @@ void BrowserTitlebar::Init() {
 
 BrowserTitlebar::~BrowserTitlebar() {
   ActiveWindowWatcherX::RemoveObserver(this);
+#if defined(USE_GCONF)
   Singleton<GConfTitlebarListener>()->RemoveObserver(this);
+#endif
 }
 
 void BrowserTitlebar::BuildButtons(const std::string& button_string) {
diff --git a/chrome/browser/gtk/browser_titlebar.h b/chrome/browser/gtk/browser_titlebar.h
index c6da855..5cd30e6 100644
--- chrome/browser/gtk/browser_titlebar.h
+++ chrome/browser/gtk/browser_titlebar.h
@@ -31,6 +31,10 @@ class BrowserTitlebar : public NotificationObserver,
                         public ActiveWindowWatcherX::Observer,
                         public menus::SimpleMenuModel::Delegate {
  public:
+  // A default button order string for when we aren't asking gconf for the
+  // metacity configuration.
+  static const char kDefaultButtonString[];
+
   BrowserTitlebar(BrowserWindowGtk* browser_window, GtkWindow* window);
   virtual ~BrowserTitlebar();
 
diff --git a/chrome/browser/gtk/gconf_titlebar_listener.cc b/chrome/browser/gtk/gconf_titlebar_listener.cc
index 81b5ef0..237332f 100644
--- chrome/browser/gtk/gconf_titlebar_listener.cc
+++ chrome/browser/gtk/gconf_titlebar_listener.cc
@@ -13,10 +13,6 @@
 
 namespace {
 
-// A default button order string for when we aren't asking gconf for the
-// metacity configuration.
-const char* kDefaultButtonPlacement = ":minimize,maximize,close";
-
 // The GConf key we read for the button placement string. Even through the key
 // has "metacity" in it, it's shared between metacity and compiz.
 const char* kButtonLayoutKey = "/apps/metacity/general/button_layout";
@@ -34,7 +30,7 @@ void GConfTitlebarListener::SetTitlebarButtons(BrowserTitlebar* titlebar) {
     titlebar->BuildButtons(current_value_);
     titlebars_.insert(titlebar);
   } else {
-    titlebar->BuildButtons(kDefaultButtonPlacement);
+    titlebar->BuildButtons(BrowserTitlebar::kDefaultButtonString);
   }
 }
 
@@ -113,8 +109,8 @@ bool GConfTitlebarListener::HandleGError(GError* error, const char* key) {
 void GConfTitlebarListener::ParseAndStoreValue(GConfValue* gconf_value) {
   if (gconf_value) {
     const char* value = gconf_value_get_string(gconf_value);
-    current_value_ = value ? value : kDefaultButtonPlacement;
+    current_value_ = value ? value : BrowserTitlebar::kDefaultButtonString;
   } else {
-    current_value_ = kDefaultButtonPlacement;
+    current_value_ = BrowserTitlebar::kDefaultButtonString;
   }
 }
diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc
index 5c38d97..29a73d7 100644
--- chrome/browser/memory_details.cc
+++ chrome/browser/memory_details.cc
@@ -19,7 +19,7 @@
 #include "chrome/common/url_constants.h"
 #include "grit/chromium_strings.h"
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #include "chrome/browser/zygote_host_linux.h"
 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h"
 #endif
@@ -74,7 +74,7 @@ void MemoryDetails::CollectChildInfoOnIOThread() {
 void MemoryDetails::CollectChildInfoOnUIThread() {
   DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   const pid_t zygote_pid = Singleton<ZygoteHost>()->pid();
   const pid_t sandbox_helper_pid = Singleton<RenderSandboxHostLinux>()->pid();
 #endif
@@ -153,7 +153,7 @@ void MemoryDetails::CollectChildInfoOnUIThread() {
       }
     }
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
     if (process.pid == zygote_pid) {
       process.type = ChildProcessInfo::ZYGOTE_PROCESS;
     } else if (process.pid == sandbox_helper_pid) {
diff --git a/chrome/browser/memory_purger.cc b/chrome/browser/memory_purger.cc
index 9117811..09b8c71 100644
--- chrome/browser/memory_purger.cc
+++ chrome/browser/memory_purger.cc
@@ -137,7 +137,7 @@ void MemoryPurger::PurgeBrowser() {
   // * Purge AppCache memory.  Not yet implemented sufficiently.
   // * Browser-side DatabaseTracker.  Not implemented sufficiently.
 
-#if (defined(OS_WIN) || defined(OS_LINUX)) && defined(USE_TCMALLOC)
+#if !defined(OS_MACOSX) && defined(USE_TCMALLOC)
   // Tell tcmalloc to release any free pages it's still holding.
   //
   // TODO(pkasting): A lot of the above calls kick off actions on other threads.
diff --git a/chrome/browser/net/connection_tester.cc b/chrome/browser/net/connection_tester.cc
index 162be2c..e96b18f 100644
--- chrome/browser/net/connection_tester.cc
+++ chrome/browser/net/connection_tester.cc
@@ -161,7 +161,7 @@ class ExperimentURLRequestContext : public URLRequestContext {
   // Otherwise returns a network error code.
   int CreateSystemProxyConfigService(
       scoped_ptr<net::ProxyConfigService>* config_service) {
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
     // TODO(eroman): This is not supported on Linux yet, because of how
     // construction needs ot happen on the UI thread.
     return net::ERR_NOT_IMPLEMENTED;
diff --git a/chrome/browser/notifications/balloon_collection_impl.h b/chrome/browser/notifications/balloon_collection_impl.h
index cb06230..cc907f1 100644
--- chrome/browser/notifications/balloon_collection_impl.h
+++ chrome/browser/notifications/balloon_collection_impl.h
@@ -54,7 +54,7 @@ class BalloonCollectionImpl : public BalloonCollection
   virtual void WillProcessMessage(const MSG& event) {}
   virtual void DidProcessMessage(const MSG& event);
 #endif
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
   virtual void WillProcessEvent(GdkEvent* event) {}
   virtual void DidProcessEvent(GdkEvent* event);
 #endif
diff --git a/chrome/browser/options_util.cc b/chrome/browser/options_util.cc
index 8bcf063..7d710d4 100644
--- chrome/browser/options_util.cc
+++ chrome/browser/options_util.cc
@@ -28,7 +28,7 @@ void OptionsUtil::ResetToDefaults(Profile* profile) {
     prefs::kCookieBehavior,
     prefs::kDefaultCharset,
     prefs::kDnsPrefetchingEnabled,
-#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_OPENBSD)
+#if defined(OS_NIX)
     prefs::kCertRevocationCheckingEnabled,
     prefs::kSSL2Enabled,
     prefs::kSSL3Enabled,
diff --git a/chrome/browser/process_singleton_linux.cc b/chrome/browser/process_singleton_linux.cc
index bfd6539..5ea70a3 100644
--- chrome/browser/process_singleton_linux.cc
+++ chrome/browser/process_singleton_linux.cc
@@ -281,23 +281,24 @@ void DisplayProfileInUseError(const std::string& lock_path,
 }
 
 bool IsChromeProcess(pid_t pid) {
-  FilePath other_chrome_path(base::GetProcessExecutablePath(pid));
+/*  FilePath other_chrome_path(base::GetProcessExecutablePath(pid));
   return (!other_chrome_path.empty() &&
           other_chrome_path.BaseName() ==
-          FilePath::FromWStringHack(chrome::kBrowserProcessExecutableName));
+          FilePath::FromWStringHack(chrome::kBrowserProcessExecutableName));*/
+  return true;
 }
 
 // Return true if the given pid is one of our child processes.
 // Assumes that the current pid is the root of all pids of the current instance.
 bool IsSameChromeInstance(pid_t pid) {
   pid_t cur_pid = base::GetCurrentProcId();
-  while (pid != cur_pid) {
+/*  while (pid != cur_pid) {
     pid = base::GetParentProcessId(pid);
     if (pid < 0)
       return false;
     if (!IsChromeProcess(pid))
       return false;
-  }
+  }*/
   return true;
 }
 
diff --git a/chrome/browser/renderer_host/backing_store_proxy.cc b/chrome/browser/renderer_host/backing_store_proxy.cc
index ba3538b..4388eb0 100644
--- chrome/browser/renderer_host/backing_store_proxy.cc
+++ chrome/browser/renderer_host/backing_store_proxy.cc
@@ -46,8 +46,12 @@ void BackingStoreProxy::PaintToBackingStore(
   process_id = process->GetHandle();
 #endif
 
+#if defined(OS_FREEBSD)
+  int render_process_id = process->id();
+#endif
+
   if (process_shim_->Send(new GpuMsg_PaintToBackingStore(
-          routing_id_, process_id, bitmap, bitmap_rect, copy_rects))) {
+          routing_id_, render_process_id, bitmap, bitmap_rect, copy_rects))) {
     // Message sent successfully, so the caller can not destroy the
     // TransportDIB. OnDonePaintingToBackingStore will free it later.
     *painted_synchronously = false;
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index d6509e8..2211ef4 100644
--- chrome/browser/renderer_host/browser_render_process_host.cc
+++ chrome/browser/renderer_host/browser_render_process_host.cc
@@ -313,11 +313,11 @@ bool BrowserRenderProcessHost::Init(bool is_extensions_process,
     in_process_renderer_.reset(new RendererMainThread(channel_id));
 
     base::Thread::Options options;
-#if !defined(OS_LINUX)
+#if !defined(USE_X11)
     // In-process plugins require this to be a UI message loop.
     options.message_loop_type = MessageLoop::TYPE_UI;
 #else
-    // We can't have multiple UI loops on Linux, so we don't support
+    // We can't have multiple UI loops on X, so we don't support
     // in-process plugins.
     options.message_loop_type = MessageLoop::TYPE_DEFAULT;
 #endif
@@ -736,13 +736,13 @@ TransportDIB* BrowserRenderProcessHost::MapTransportDIB(
   HANDLE section = win_util::GetSectionFromProcess(
       dib_id.handle, GetHandle(), false /* read write */);
   return TransportDIB::Map(section);
-#elif defined(OS_MACOSX)
+#elif defined(OS_MACOSX) || defined(OS_FREEBSD)
   // On OSX, the browser allocates all DIBs and keeps a file descriptor around
   // for each.
   return widget_helper_->MapTransportDIB(dib_id);
 #elif defined(OS_LINUX)
   return TransportDIB::Map(dib_id);
-#endif  // defined(OS_LINUX)
+#endif  // defined(OS_NIX)
 }
 
 TransportDIB* BrowserRenderProcessHost::GetTransportDIB(
diff --git a/chrome/browser/renderer_host/mock_render_process_host.cc b/chrome/browser/renderer_host/mock_render_process_host.cc
index 21fa34d..22e53ed 100644
--- chrome/browser/renderer_host/mock_render_process_host.cc
+++ chrome/browser/renderer_host/mock_render_process_host.cc
@@ -99,7 +99,7 @@ TransportDIB* MockRenderProcessHost::GetTransportDIB(TransportDIB::Id dib_id) {
   DuplicateHandle(GetCurrentProcess(), dib_id.handle, GetCurrentProcess(),
                   &duped, 0, TRUE, DUPLICATE_SAME_ACCESS);
   transport_dib_ = TransportDIB::Map(duped);
-#elif defined(OS_MACOSX)
+#elif defined(OS_MACOSX) || defined(OS_FREEBSD)
   // On Mac, TransportDIBs are always created in the browser, so we cannot map
   // one from a dib_id.
   transport_dib_ = TransportDIB::Create(100 * 100 * 4, 0);
diff --git a/chrome/browser/renderer_host/render_sandbox_host_linux.cc b/chrome/browser/renderer_host/render_sandbox_host_linux.cc
index 5824fc9..59c6fa5 100644
--- chrome/browser/renderer_host/render_sandbox_host_linux.cc
+++ chrome/browser/renderer_host/render_sandbox_host_linux.cc
@@ -644,7 +644,12 @@ void RenderSandboxHostLinux::Init(const std::string& sandbox_path) {
   // inherit some sockets. With PF_UNIX+SOCK_DGRAM, it can call sendmsg to send
   // a datagram to any (abstract) socket on the same system. With
   // SOCK_SEQPACKET, this is prevented.
+#if defined(OS_FREEBSD)
+  if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, fds) != 0)
+    CHECK(socketpair(AF_UNIX, SOCK_DGRAM, 0, fds) == 0);
+#else
   CHECK(socketpair(AF_UNIX, SOCK_SEQPACKET, 0, fds) == 0);
+#endif
 
   renderer_socket_ = fds[0];
   const int browser_socket = fds[1];
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.cc b/chrome/browser/renderer_host/render_view_host_delegate.cc
index 11f6168..78122cc 100644
--- chrome/browser/renderer_host/render_view_host_delegate.cc
+++ chrome/browser/renderer_host/render_view_host_delegate.cc
@@ -11,7 +11,7 @@
 #include "googleurl/src/gurl.h"
 #include "webkit/glue/webpreferences.h"
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
 #include "chrome/browser/gtk/gtk_util.h"
 #endif
 
diff --git a/chrome/browser/renderer_host/render_widget_helper.cc b/chrome/browser/renderer_host/render_widget_helper.cc
index e2cd531..9e603f7 100644
--- chrome/browser/renderer_host/render_widget_helper.cc
+++ chrome/browser/renderer_host/render_widget_helper.cc
@@ -58,7 +58,7 @@ RenderWidgetHelper::~RenderWidgetHelper() {
   // object, so we should not be destroyed unless pending_paints_ is empty!
   DCHECK(pending_paints_.empty());
 
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(OS_FREEBSD)
   ClearAllocatedDIBs();
 #endif
 }
@@ -257,7 +257,7 @@ void RenderWidgetHelper::OnCreateWidgetOnUI(
     host->CreateNewWidget(route_id, popup_type);
 }
 
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(OS_FREEBSD)
 TransportDIB* RenderWidgetHelper::MapTransportDIB(TransportDIB::Id dib_id) {
   AutoLock locked(allocated_dibs_lock_);
 
diff --git a/chrome/browser/renderer_host/render_widget_helper.h b/chrome/browser/renderer_host/render_widget_helper.h
index d31bf66..ab08823 100644
--- chrome/browser/renderer_host/render_widget_helper.h
+++ chrome/browser/renderer_host/render_widget_helper.h
@@ -109,7 +109,7 @@ class RenderWidgetHelper
                         const base::TimeDelta& max_delay,
                         IPC::Message* msg);
 
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(OS_FREEBSD)
   // Given the id of a transport DIB, return a mapping to it or NULL on error.
   TransportDIB* MapTransportDIB(TransportDIB::Id dib_id);
 #endif
@@ -130,7 +130,7 @@ class RenderWidgetHelper
                        WebKit::WebPopupType popup_type,
                        int* route_id);
 
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(OS_FREEBSD)
   // Called on the IO thread to handle the allocation of a TransportDIB.  If
   // |cache_in_browser| is |true|, then a copy of the shmem is kept by the
   // browser, and it is the caller's repsonsibility to call
@@ -182,7 +182,7 @@ class RenderWidgetHelper
   // Called on the IO thread to resume a cross-site response.
   void OnCrossSiteClosePageACK(ViewMsg_ClosePage_Params params);
 
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(OS_FREEBSD)
   // Called on destruction to release all allocated transport DIBs
   void ClearAllocatedDIBs();
 
diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc
index 1920101..00afa22 100644
--- chrome/browser/renderer_host/render_widget_host.cc
+++ chrome/browser/renderer_host/render_widget_host.cc
@@ -154,7 +154,7 @@ void RenderWidgetHost::OnMessageReceived(const IPC::Message &msg) {
                         OnMsgImeCancelComposition)
     IPC_MESSAGE_HANDLER(ViewHostMsg_GpuRenderingActivated,
                         OnMsgGpuRenderingActivated)
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
     IPC_MESSAGE_HANDLER(ViewHostMsg_CreatePluginContainer,
                         OnMsgCreatePluginContainer)
     IPC_MESSAGE_HANDLER(ViewHostMsg_DestroyPluginContainer,
@@ -909,7 +909,7 @@ void RenderWidgetHost::OnMsgGpuRenderingActivated(bool activated) {
   is_gpu_rendering_active_ = activated;
 }
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 
 void RenderWidgetHost::OnMsgCreatePluginContainer(gfx::PluginWindowHandle id) {
   // TODO(piman): view_ can only be NULL with delayed view creation in
diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h
index 0b0e114..3430042 100644
--- chrome/browser/renderer_host/render_widget_host.h
+++ chrome/browser/renderer_host/render_widget_host.h
@@ -490,7 +490,7 @@ class RenderWidgetHost : public IPC::Channel::Listener,
 
   void OnMsgGpuRenderingActivated(bool activated);
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   void OnMsgCreatePluginContainer(gfx::PluginWindowHandle id);
   void OnMsgDestroyPluginContainer(gfx::PluginWindowHandle id);
 #elif defined(OS_MACOSX)
diff --git a/chrome/browser/renderer_host/render_widget_host_unittest.cc b/chrome/browser/renderer_host/render_widget_host_unittest.cc
index 4ea8193..a8298a6 100644
--- chrome/browser/renderer_host/render_widget_host_unittest.cc
+++ chrome/browser/renderer_host/render_widget_host_unittest.cc
@@ -400,7 +400,7 @@ TEST_F(RenderWidgetHostTest, ResizeThenCrash) {
 
 // Tests setting custom background
 TEST_F(RenderWidgetHostTest, Background) {
-#if defined(OS_WIN) || defined(OS_LINUX)
+#if defined(OS_WIN) || defined(OS_NIX)
   scoped_ptr<RenderWidgetHostView> view(
       RenderWidgetHostView::CreateViewForWidget(host_.get()));
   host_->set_view(view.get());
diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h
index 9a20af0..4b695b4 100644
--- chrome/browser/renderer_host/render_widget_host_view.h
+++ chrome/browser/renderer_host/render_widget_host_view.h
@@ -215,7 +215,7 @@ class RenderWidgetHostView {
   virtual void DrawAcceleratedSurfaceInstances(CGLContextObj context) = 0;
 #endif
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   virtual void CreatePluginContainer(gfx::PluginWindowHandle id) = 0;
   virtual void DestroyPluginContainer(gfx::PluginWindowHandle id) = 0;
 #endif
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 0418487..3cad76b 100644
--- chrome/browser/renderer_host/resource_message_filter.cc
+++ chrome/browser/renderer_host/resource_message_filter.cc
@@ -542,7 +542,7 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) {
 #if defined(OS_WIN)
       IPC_MESSAGE_HANDLER(ViewHostMsg_DuplicateSection, OnDuplicateSection)
 #endif
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(OS_FREEBSD)
       IPC_MESSAGE_HANDLER(ViewHostMsg_AllocatePDFTransport,
                           OnAllocateSharedMemoryBuffer)
 #endif
@@ -566,7 +566,7 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) {
       IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ScriptedPrint,
                                       OnScriptedPrint)
 #endif
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(OS_FREEBSD)
       IPC_MESSAGE_HANDLER(ViewHostMsg_AllocTransportDIB,
                           OnAllocTransportDIB)
       IPC_MESSAGE_HANDLER(ViewHostMsg_FreeTransportDIB,
@@ -1306,7 +1306,7 @@ void ResourceMessageFilter::OnRendererHistograms(
   HistogramSynchronizer::DeserializeHistogramList(sequence_number, histograms);
 }
 
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(OS_FREEBSD)
 void ResourceMessageFilter::OnAllocTransportDIB(
     size_t size, bool cache_in_browser, TransportDIB::Handle* handle) {
   render_widget_helper_->AllocTransportDIB(size, cache_in_browser, handle);
diff --git a/chrome/browser/renderer_host/test/test_render_view_host.h b/chrome/browser/renderer_host/test/test_render_view_host.h
index a2b1c99..90220d5 100644
--- chrome/browser/renderer_host/test/test_render_view_host.h
+++ chrome/browser/renderer_host/test/test_render_view_host.h
@@ -109,7 +109,7 @@ class TestRenderWidgetHostView : public RenderWidgetHostView {
 #endif
   virtual void SetVisuallyDeemphasized(bool deemphasized) { }
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   virtual void CreatePluginContainer(gfx::PluginWindowHandle id) { }
   virtual void DestroyPluginContainer(gfx::PluginWindowHandle id) { }
 #endif
diff --git a/chrome/browser/renderer_host/video_layer_proxy.cc b/chrome/browser/renderer_host/video_layer_proxy.cc
index 3df1d25..9a4341a 100644
--- chrome/browser/renderer_host/video_layer_proxy.cc
+++ chrome/browser/renderer_host/video_layer_proxy.cc
@@ -33,8 +33,12 @@ void VideoLayerProxy::CopyTransportDIB(RenderProcessHost* process,
   process_id = process->GetHandle();
 #endif
 
+#if defined(OS_FREEBSD)
+  int render_process_id = process->id();
+#endif
+
   if (process_shim_->Send(new GpuMsg_PaintToVideoLayer(
-          routing_id_, process_id, bitmap, bitmap_rect))) {
+          routing_id_, render_process_id, bitmap, bitmap_rect))) {
   } else {
     // TODO(scherkus): what to do ?!?!
   }
diff --git a/chrome/browser/renderer_preferences_util.cc b/chrome/browser/renderer_preferences_util.cc
index dd29afc..6fcafe7 100644
--- chrome/browser/renderer_preferences_util.cc
+++ chrome/browser/renderer_preferences_util.cc
@@ -6,7 +6,7 @@
 
 #include "chrome/browser/profile.h"
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
 #include "chrome/browser/gtk/gtk_theme_provider.h"
 #include "chrome/browser/gtk/gtk_util.h"
 #endif
@@ -14,7 +14,7 @@
 namespace renderer_preferences_util {
 
 void UpdateFromSystemSettings(RendererPreferences* prefs, Profile* profile) {
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   gtk_util::UpdateGtkFontSettings(prefs);
 
 #if !defined(TOOLKIT_VIEWS)
@@ -31,7 +31,7 @@ void UpdateFromSystemSettings(RendererPreferences* prefs, Profile* profile) {
   prefs->inactive_selection_fg_color =
       provider->get_inactive_selection_fg_color();
 #endif  // !defined(TOOLKIT_VIEWS)
-#endif  // defined(OS_LINUX)
+#endif  // defined(OS_NIX)
 }
 
 }  // renderer_preferences_util
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.cc b/chrome/browser/search_engines/template_url_prepopulate_data.cc
index 67a5342..7f7dd38 100644
--- chrome/browser/search_engines/template_url_prepopulate_data.cc
+++ chrome/browser/search_engines/template_url_prepopulate_data.cc
@@ -4,7 +4,7 @@
 
 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #include <locale.h>
 #endif
 
diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc
index cf46e37..7fbe364 100644
--- chrome/browser/shell_integration_linux.cc
+++ chrome/browser/shell_integration_linux.cc
@@ -131,6 +131,8 @@ void CreateShortcutOnDesktop(const FilePath& shortcut_filename,
   if (!PathService::Get(chrome::DIR_USER_DESKTOP, &desktop_path))
     return;
 
+#if !defined(OS_FREEBSD)
+// BSD: Linux-specific calls like openat are used so defined out for BSD.
   int desktop_fd = open(desktop_path.value().c_str(), O_RDONLY | O_DIRECTORY);
   if (desktop_fd < 0)
     return;
@@ -159,6 +161,7 @@ void CreateShortcutOnDesktop(const FilePath& shortcut_filename,
 
   if (HANDLE_EINTR(close(desktop_fd)) < 0)
     PLOG(ERROR) << "close";
+#endif  // !defined(OS_FREEBSD)
 }
 
 void CreateShortcutInApplicationsMenu(const FilePath& shortcut_filename,
diff --git a/chrome/browser/shell_integration_unittest.cc b/chrome/browser/shell_integration_unittest.cc
index 0514781..760a8c4 100644
--- chrome/browser/shell_integration_unittest.cc
+++ chrome/browser/shell_integration_unittest.cc
@@ -20,13 +20,13 @@
 
 #if defined(OS_WIN)
 #include "chrome/installer/util/browser_distribution.h"
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
 #include "base/env_var.h"
-#endif  // defined(OS_LINUX)
+#endif  // defined(OS_NIX)
 
 #define FPL FILE_PATH_LITERAL
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 namespace {
 
 // Provides mock environment variables values based on a stored map.
diff --git a/chrome/browser/sync/engine/syncer_thread.cc b/chrome/browser/sync/engine/syncer_thread.cc
index ffc7bcd..e0b94d7 100644
--- chrome/browser/sync/engine/syncer_thread.cc
+++ chrome/browser/sync/engine/syncer_thread.cc
@@ -257,7 +257,7 @@ void SyncerThread::ThreadMainLoop() {
   bool initial_sync_for_thread = true;
   bool continue_sync_cycle = false;
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   idle_query_.reset(new IdleQueryLinux());
 #endif
 
@@ -340,7 +340,7 @@ void SyncerThread::ThreadMainLoop() {
         static_cast<int>(vault_.current_wait_interval_.poll_delta.InSeconds()),
         &user_idle_milliseconds, &continue_sync_cycle, nudged);
   }
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   idle_query_.reset();
 #endif
 }
@@ -755,7 +755,7 @@ int SyncerThread::UserIdleTime() {
   } else {
     return idle_time / 1000000;  // nano to milli
   }
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
   if (idle_query_.get()) {
     return idle_query_->IdleTime();
   } else {
diff --git a/chrome/browser/sync/engine/syncer_thread.h b/chrome/browser/sync/engine/syncer_thread.h
index a54ff7f..ad4e63b 100644
--- chrome/browser/sync/engine/syncer_thread.h
+++ chrome/browser/sync/engine/syncer_thread.h
@@ -22,7 +22,7 @@
 #include "base/time.h"
 #include "base/waitable_event.h"
 #include "chrome/browser/sync/engine/all_status.h"
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #include "chrome/browser/sync/engine/idle_query_linux.h"
 #endif
 #include "chrome/browser/sync/sessions/sync_session.h"
@@ -324,7 +324,7 @@ class SyncerThread : public base::RefCountedThreadSafe<SyncerThread>,
   scoped_ptr<EventListenerHookup> directory_manager_hookup_;
   scoped_ptr<ChannelHookup<SyncerEvent> > syncer_events_;
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   // On Linux, we need this information in order to query idle time.
   scoped_ptr<IdleQueryLinux> idle_query_;
 #endif
diff --git a/chrome/browser/sync/syncable/directory_backing_store.cc b/chrome/br
owser/sync/syncable/directory_backing_store.cc
index 048f016..9516bab 100644
--- chrome/browser/sync/syncable/directory_backing_store.cc
+++ chrome/browser/sync/syncable/directory_backing_store.cc
@@ -303,13 +303,13 @@ bool DirectoryBackingStore::BeginLoad() {
 #else
   UMA_HISTOGRAM_COUNTS_100("Sync.DirectoryOpenFailedNotWinMac", bucket);

-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#if defined(OS_NIX) && !defined(OS_CHROMEOS)
   UMA_HISTOGRAM_COUNTS_100("Sync.DirectoryOpenFailedLinux", bucket);
 #elif defined(OS_CHROMEOS)
   UMA_HISTOGRAM_COUNTS_100("Sync.DirectoryOpenFailedCros", bucket);
 #else
   UMA_HISTOGRAM_COUNTS_100("Sync.DirectoryOpenFailedOther", bucket);
-#endif  // OS_LINUX && !OS_CHROMEOS
+#endif  // OS_NIX && !OS_CHROMEOS
 #endif  // OS_WIN
   return !failed_again;
 }
diff --git a/chrome/browser/sync/syncable/syncable.cc b/chrome/browser/sync/syncable/syncable.cc
index 7c6cc71..29eac9a 100644
--- chrome/browser/sync/syncable/syncable.cc
+++ chrome/browser/sync/syncable/syncable.cc
@@ -82,7 +82,7 @@ int64 Now() {
   LARGE_INTEGER n;
   memcpy(&n, &filetime, sizeof(filetime));
   return n.QuadPart;
-#elif defined(OS_LINUX) || defined(OS_MACOSX)
+#elif defined(OS_POSIX)
   struct timeval tv;
   gettimeofday(&tv, NULL);
   return static_cast<int64>(tv.tv_sec);
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc
index 10c8d7c..742e648 100644
--- chrome/browser/tab_contents/interstitial_page.cc
+++ chrome/browser/tab_contents/interstitial_page.cc
@@ -487,7 +487,7 @@ void InterstitialPage::CancelForNavigation() {
 }
 
 void InterstitialPage::SetSize(const gfx::Size& size) {
-#if defined(OS_WIN) || defined(OS_LINUX)
+#if defined(OS_WIN) || defined(OS_NIX)
   // When a tab is closed, we might be resized after our view was NULLed
   // (typically if there was an info-bar).
   if (render_view_host_->view())
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 37e2e01..6567331 100644
--- chrome/browser/tab_contents/render_view_context_menu.cc
+++ chrome/browser/tab_contents/render_view_context_menu.cc
@@ -879,7 +879,7 @@ bool RenderViewContextMenu::IsCommandIdEnabled(int id) const {
       return true;
 #endif  // OS_MACOSX
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
     // TODO(suzhe): this should not be enabled for password fields.
     case IDC_INPUT_METHODS_MENU:
       return true;
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index b5395cc..88ec57a 100644
--- chrome/browser/tab_contents/tab_contents.cc
+++ chrome/browser/tab_contents/tab_contents.cc
@@ -334,7 +334,7 @@ TabContents::TabContents(Profile* profile,
                  NotificationService::AllSources());
   registrar_.Add(this, NotificationType::RENDER_WIDGET_HOST_DESTROYED,
                  NotificationService::AllSources());
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
   registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
                  NotificationService::AllSources());
 #endif
@@ -3006,7 +3006,7 @@ void TabContents::Observe(NotificationType type,
       break;
     }
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
     case NotificationType::BROWSER_THEME_CHANGED: {
       renderer_preferences_util::UpdateFromSystemSettings(
           &renderer_preferences_, profile());
diff --git a/chrome/browser/task_manager_resource_providers.cc b/chrome/browser/task_manager_resource_providers.cc
index 6dfbc0c..4551285 100644
--- chrome/browser/task_manager_resource_providers.cc
+++ chrome/browser/task_manager_resource_providers.cc
@@ -839,7 +839,7 @@ TaskManagerBrowserProcessResource::TaskManagerBrowserProcessResource()
       default_icon_ = IconUtil::CreateSkBitmapFromHICON(icon, icon_size);
     }
   }
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
   if (!default_icon_) {
     ResourceBundle& rb = ResourceBundle::GetSharedInstance();
     default_icon_ = rb.GetBitmapNamed(IDR_PRODUCT_LOGO_16);
diff --git a/chrome/browser/views/accessible_view_helper.cc b/chrome/browser/views/accessible_view_helper.cc
index f173761..89c639e 100644
--- chrome/browser/views/accessible_view_helper.cc
+++ chrome/browser/views/accessible_view_helper.cc
@@ -20,7 +20,7 @@ AccessibleViewHelper::AccessibleViewHelper(
   if (!accessibility_event_router_->AddViewTree(view_tree_, profile))
     view_tree_ = NULL;
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
   GtkWidget* widget = view_tree->GetWidget()->GetNativeView();
   widget_helper_.reset(new AccessibleWidgetHelper(widget, profile));
 #endif
diff --git a/chrome/browser/views/accessible_view_helper.h b/chrome/browser/views/accessible_view_helper.h
index 2d01238..584b91f 100644
--- chrome/browser/views/accessible_view_helper.h
+++ chrome/browser/views/accessible_view_helper.h
@@ -14,7 +14,7 @@
 #include "chrome/browser/accessibility_events.h"
 #include "chrome/browser/views/accessibility_event_router_views.h"
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
 #include "chrome/browser/gtk/accessible_widget_helper_gtk.h"
 #endif
 
@@ -68,7 +68,7 @@ class AccessibleViewHelper {
   std::string window_title_;
   std::vector<views::View*> managed_views_;
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
   scoped_ptr<AccessibleWidgetHelper> widget_helper_;
 #endif
 
diff --git a/chrome/browser/views/bug_report_view.cc b/chrome/browser/views/bug_report_view.cc
index 564b080..8ebbc7e 100644
--- chrome/browser/views/bug_report_view.cc
+++ chrome/browser/views/bug_report_view.cc
@@ -39,7 +39,7 @@
 #include "views/window/client_view.h"
 #include "views/window/window.h"
 
-#if defined(OS_LINUX)
+#if defined(USE_X11)
 #include "app/x11_util.h"
 #else
 #include "app/win_util.h"
@@ -209,7 +209,7 @@ void ShowBugReportView(views::Window* parent,
   // rendered--do not re-render, and include windowed plugins).
   std::vector<unsigned char> *screenshot_png = new std::vector<unsigned char>;
 
-#if defined(OS_LINUX)
+#if defined(USE_X11)
   x11_util::GrabWindowSnapshot(parent->GetNativeWindow(), screenshot_png);
 #else
   win_util::GrabWindowSnapshot(parent->GetNativeWindow(), screenshot_png);
diff --git a/chrome/browser/views/content_blocked_bubble_contents.cc b/chrome/browser/views/content_blocked_bubble_contents.cc
index bef80be..1cf055e 100644
--- chrome/browser/views/content_blocked_bubble_contents.cc
+++ chrome/browser/views/content_blocked_bubble_contents.cc
@@ -4,7 +4,7 @@
 
 #include "chrome/browser/views/content_blocked_bubble_contents.h"
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
 #include <gdk/gdk.h>
 #endif
 
@@ -87,7 +87,7 @@ gfx::NativeCursor ContentSettingBubbleContents::Favicon::GetCursorForPoint(
   if (!g_hand_cursor)
     g_hand_cursor = LoadCursor(NULL, IDC_HAND);
   return g_hand_cursor;
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
   return gdk_cursor_new(GDK_HAND2);
 #endif
 }
diff --git a/chrome/browser/views/create_application_shortcut_view.cc b/chrome/browser/views/create_application_shortcut_view.cc
index b0a66b3..68d0002 100644
--- chrome/browser/views/create_application_shortcut_view.cc
+++ chrome/browser/views/create_application_shortcut_view.cc
@@ -267,7 +267,7 @@ void CreateApplicationShortcutView::Init() {
         l10n_util::GetString(IDS_PIN_TO_TASKBAR_CHKBOX) :
         l10n_util::GetString(IDS_CREATE_SHORTCUTS_QUICK_LAUNCH_BAR_CHKBOX),
       profile->GetPrefs()->GetBoolean(prefs::kWebAppCreateInQuickLaunchBar));
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
   menu_check_box_ = AddCheckbox(
       l10n_util::GetString(IDS_CREATE_SHORTCUTS_MENU_CHKBOX),
       profile->GetPrefs()->GetBoolean(prefs::kWebAppCreateInAppsMenu));
diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc
index 348c86d..9318b17 100644
--- chrome/browser/views/download_item_view.cc
+++ chrome/browser/views/download_item_view.cc
@@ -261,7 +261,7 @@ DownloadItemView::DownloadItemView(DownloadItem* download,
 
     // Extract the file extension (if any).
     FilePath filepath(download->original_name());
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
     std::wstring extension = base::SysNativeMBToWide(filepath.Extension());
 #else
     std::wstring extension = filepath.Extension();
@@ -270,7 +270,7 @@ DownloadItemView::DownloadItemView(DownloadItem* download,
     // Remove leading '.'
     if (extension.length() > 0)
       extension = extension.substr(1);
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
     std::wstring rootname =
         base::SysNativeMBToWide(filepath.BaseName().RemoveExtension().value());
 #else
diff --git a/chrome/browser/views/dropdown_bar_host.cc b/chrome/browser/views/dropdown_bar_host.cc
index 4878e15..f396de6 100644
--- chrome/browser/views/dropdown_bar_host.cc
+++ chrome/browser/views/dropdown_bar_host.cc
@@ -20,7 +20,7 @@
 #include "views/focus/view_storage.h"
 #include "views/widget/widget.h"
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
 #include "app/scoped_handle_gtk.h"
 #endif
 
diff --git a/chrome/browser/views/extensions/extension_popup.cc b/chrome/browser/views/extensions/extension_popup.cc
index a669d69..81ab297 100644
--- chrome/browser/views/extensions/extension_popup.cc
+++ chrome/browser/views/extensions/extension_popup.cc
@@ -23,7 +23,7 @@
 #include "views/widget/root_view.h"
 #include "views/window/window.h"
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
 #include "views/widget/widget_gtk.h"
 #endif
 
@@ -104,7 +104,7 @@ ExtensionPopup::ExtensionPopup(ExtensionHost* host,
   // The bubble chrome requires a separate window, so construct it here.
   if (BUBBLE_CHROME == popup_chrome_) {
     gfx::NativeView native_window = frame->GetNativeView();
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
     border_widget_ = new views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW);
     static_cast<views::WidgetGtk*>(border_widget_)->MakeTransparent();
     static_cast<views::WidgetGtk*>(border_widget_)->make_transient_to_parent();
diff --git a/chrome/browser/views/extensions/extension_view.cc b/chrome/browser/views/extensions/extension_view.cc
index 0090bda..6d2ab07 100644
--- chrome/browser/views/extensions/extension_view.cc
+++ chrome/browser/views/extensions/extension_view.cc
@@ -12,7 +12,7 @@
 
 #if defined(OS_WIN)
 #include "chrome/browser/renderer_host/render_widget_host_view_win.h"
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
 #endif
 
@@ -100,7 +100,7 @@ void ExtensionView::CreateWidgetHostView() {
   HWND hwnd = view_win->Create(GetWidget()->GetNativeView());
   view_win->ShowWindow(SW_SHOW);
   Attach(hwnd);
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
   RenderWidgetHostViewGtk* view_gtk =
       static_cast<RenderWidgetHostViewGtk*>(view);
   view_gtk->InitAsChild();
diff --git a/chrome/browser/views/find_bar_host_interactive_uitest.cc b/chrome/browser/views/find_bar_host_interactive_uitest.cc
index 51080bf..25a661f 100644
--- chrome/browser/views/find_bar_host_interactive_uitest.cc
+++ chrome/browser/views/find_bar_host_interactive_uitest.cc
@@ -38,7 +38,7 @@ class FindInPageTest : public InProcessBrowserTest {
 #if defined(TOOLKIT_VIEWS)
     views::View* view =
         reinterpret_cast<BrowserView*>(browser_window)->GetViewByID(view_id);
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
     gfx::NativeWindow window = browser_window->GetNativeHandle();
     ASSERT_TRUE(window);
     GtkWidget* view = ViewIDUtil::GetWidget(GTK_WIDGET(window), view_id);
diff --git a/chrome/browser/views/find_bar_view.cc b/chrome/browser/views/find_bar_view.cc
index ae78c3c..e1d8820 100644
--- chrome/browser/views/find_bar_view.cc
+++ chrome/browser/views/find_bar_view.cc
@@ -80,7 +80,7 @@ static const int kDefaultCharWidth = 43;
 
 FindBarView::FindBarView(FindBarHost* host)
     : DropdownBarView(host),
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
       ignore_contents_changed_(false),
 #endif
       find_text_(NULL),
@@ -170,11 +170,11 @@ FindBarView::~FindBarView() {
 }
 
 void FindBarView::SetFindText(const string16& find_text) {
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
   ignore_contents_changed_ = true;
 #endif
   find_text_->SetText(find_text);
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
   ignore_contents_changed_ = false;
 #endif
 }
@@ -441,7 +441,7 @@ void FindBarView::ButtonPressed(
 
 void FindBarView::ContentsChanged(views::Textfield* sender,
                                   const string16& new_contents) {
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
   // On gtk setting the text in the find view causes a notification.
   if (ignore_contents_changed_)
     return;
diff --git a/chrome/browser/views/find_bar_view.h b/chrome/browser/views/find_bar_view.h
index efedc94..8709304 100644
--- chrome/browser/views/find_bar_view.h
+++ chrome/browser/views/find_bar_view.h
@@ -102,7 +102,7 @@ class FindBarView : public DropdownBarView,
   // between us and the TabContentsView.
   FindBarHost* find_bar_host() const;
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
   // In gtk we get changed signals if we programatically set the text. If we
   // don't ignore them we run into problems. For example, switching tabs back
   // to one with the find bar visible will cause a search to the next found
diff --git a/chrome/browser/views/frame/app_panel_browser_frame_view.cc b/chrome/browser/views/frame/app_panel_browser_frame_view.cc
index 16ebec3..804ebde 100644
--- chrome/browser/views/frame/app_panel_browser_frame_view.cc
+++ chrome/browser/views/frame/app_panel_browser_frame_view.cc
@@ -21,7 +21,7 @@
 #include "views/window/window.h"
 #include "views/window/window_resources.h"
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #include "views/window/hit_test.h"
 #endif
 
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index a34ab3a..e8d40e9 100644
--- chrome/browser/views/frame/browser_view.cc
+++ chrome/browser/views/frame/browser_view.cc
@@ -4,7 +4,7 @@
 
 #include "chrome/browser/views/frame/browser_view.h"
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
 #include <gtk/gtk.h>
 #endif
 
@@ -67,7 +67,7 @@
 #include "app/win_util.h"
 #include "chrome/browser/aeropeek_manager.h"
 #include "chrome/browser/jumplist_win.h"
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_USES_GTK)
 #include "chrome/browser/views/accelerator_table_gtk.h"
 #include "views/window/hit_test.h"
 #endif
@@ -1095,7 +1095,7 @@ void BrowserView::ShowProfileErrorDialog(int message_id) {
   std::wstring message = l10n_util::GetString(message_id);
   win_util::MessageBox(GetNativeHandle(), message, title,
                        MB_OK | MB_ICONWARNING | MB_TOPMOST);
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
   std::string title = l10n_util::GetStringUTF8(IDS_PRODUCT_NAME);
   std::string message = l10n_util::GetStringUTF8(message_id);
   GtkWidget* dialog = gtk_message_dialog_new(GetNativeHandle(),
@@ -2066,7 +2066,7 @@ void BrowserView::ProcessFullscreen(bool fullscreen) {
 #endif  // No need to invoke SetFullscreen for linux as this code is executed
         // once we're already fullscreen on linux.
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
   // Updating of commands for fullscreen mode is called from SetFullScreen on
   // Wndows (see just above), but for ChromeOS, this method (ProcessFullScreen)
   // is called after full screen has happened successfully (via GTK's
diff --git a/chrome/browser/views/frame/browser_view_layout.cc b/chrome/browser/views/frame/browser_view_layout.cc
index a332beb..df7cbfd 100644
--- chrome/browser/views/frame/browser_view_layout.cc
+++ chrome/browser/views/frame/browser_view_layout.cc
@@ -18,7 +18,7 @@
 #include "gfx/scrollbar_size.h"
 #include "views/window/window.h"
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #include "views/window/hit_test.h"
 #endif
 
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc
index fc6f4de..25bc28f 100644
--- chrome/browser/views/frame/opaque_browser_frame_view.cc
+++ chrome/browser/views/frame/opaque_browser_frame_view.cc
@@ -32,7 +32,7 @@
 #include "app/win_util.h"
 #endif
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #include "views/window/hit_test.h"
 #endif
 
diff --git a/chrome/browser/views/fullscreen_exit_bubble.cc b/chrome/browser/views/fullscreen_exit_bubble.cc
index e216bd2..c889fae 100644
--- chrome/browser/views/fullscreen_exit_bubble.cc
+++ chrome/browser/views/fullscreen_exit_bubble.cc
@@ -17,7 +17,7 @@
 #if defined(OS_WIN)
 #include "app/l10n_util_win.h"
 #include "views/widget/widget_win.h"
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
 #include "views/widget/widget_gtk.h"
 #endif
 
@@ -114,7 +114,7 @@ class FullscreenExitBubble::FullscreenExitPopup : public views::WidgetWin {
     return MA_NOACTIVATE;
   }
 };
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
 // TODO: figure out the equivalent of MA_NOACTIVATE for gtk.
 #endif
 
@@ -149,7 +149,7 @@ FullscreenExitBubble::FullscreenExitBubble(
   popup_->set_window_style(WS_POPUP);
   popup_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
                               l10n_util::GetExtendedTooltipStyles());
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
   popup_ = new views::WidgetGtk(views::WidgetGtk::TYPE_POPUP);
   popup_->MakeTransparent();
 #endif
@@ -197,7 +197,7 @@ void FullscreenExitBubble::AnimationProgressed(
 #if defined(OS_WIN)
     popup_->MoveWindow(popup_rect.x(), popup_rect.y(), popup_rect.width(),
                        popup_rect.height());
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
     popup_->SetBounds(popup_rect);
 #endif
     popup_->Show();
diff --git a/chrome/browser/views/fullscreen_exit_bubble.h b/chrome/browser/views/fullscreen_exit_bubble.h
index c9db5bb..3e0ca96 100644
--- chrome/browser/views/fullscreen_exit_bubble.h
+++ chrome/browser/views/fullscreen_exit_bubble.h
@@ -11,7 +11,7 @@
 #include "chrome/browser/command_updater.h"
 #include "views/controls/link.h"
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
 namespace views {
 class WidgetGtk;
 }
@@ -73,7 +73,7 @@ class FullscreenExitBubble : public views::LinkController,
   // The popup itself, which is a slightly modified WidgetWin.  We need to use
   // a WidgetWin (and thus an HWND) to make the popup float over other HWNDs.
   FullscreenExitPopup* popup_;
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
   views::WidgetGtk* popup_;
 #endif
 
diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc
index 34645a0..a0369fb 100644
--- chrome/browser/views/info_bubble.cc
+++ chrome/browser/views/info_bubble.cc
@@ -307,7 +307,7 @@ void InfoBubble::AnimationProgressed(const Animation* animation) {
 
 InfoBubble::InfoBubble()
     :
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
       WidgetGtk(TYPE_WINDOW),
       border_contents_(NULL),
 #elif defined(OS_WIN)
@@ -367,7 +367,7 @@ void InfoBubble::Init(views::Widget* parent,
   WidgetWin::Init(border_->GetNativeView(), gfx::Rect());
 
   SetWindowText(GetNativeView(), delegate_->accessible_name().c_str());
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_USES_GTK)
   MakeTransparent();
   make_transient_to_parent();
   WidgetGtk::InitWithWidget(parent, gfx::Rect());
@@ -439,7 +439,7 @@ void InfoBubble::Init(views::Widget* parent,
   ShowWindow(SW_SHOW);
   if (fade_in)
     FadeIn();
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_USES_GTK)
   views::WidgetGtk::Show();
 #endif
 }
@@ -479,7 +479,7 @@ void InfoBubble::OnActivate(UINT action, BOOL minimized, HWND window) {
     GetRootView()->GetChildViewAt(0)->RequestFocus();
   }
 }
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
 void InfoBubble::IsActiveChanged() {
   if (!IsActive())
     Close();
@@ -498,7 +498,7 @@ void InfoBubble::DoClose(bool closed_by_escape) {
 #if defined(OS_WIN)
   border_->Close();
   WidgetWin::Close();
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
   WidgetGtk::Close();
 #endif
 }
diff --git a/chrome/browser/views/info_bubble.h b/chrome/browser/views/info_bubble.h
index 30b3719..a2d09dc 100644
--- chrome/browser/views/info_bubble.h
+++ chrome/browser/views/info_bubble.h
@@ -12,7 +12,7 @@
 #include "chrome/browser/views/bubble_border.h"
 #if defined(OS_WIN)
 #include "views/widget/widget_win.h"
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
 #include "views/widget/widget_gtk.h"
 #endif
 
@@ -174,7 +174,7 @@ class InfoBubbleDelegate {
 class InfoBubble
 #if defined(OS_WIN)
     : public views::WidgetWin,
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
     : public views::WidgetGtk,
 #endif
       public views::AcceleratorTarget,
@@ -248,7 +248,7 @@ class InfoBubble
 #if defined(OS_WIN)
   // Overridden from WidgetWin:
   virtual void OnActivate(UINT action, BOOL minimized, HWND window);
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
   // Overridden from WidgetGtk:
   virtual void IsActiveChanged();
 #endif
@@ -256,7 +256,7 @@ class InfoBubble
 #if defined(OS_WIN)
   // The window used to render the padding, border and arrow.
   BorderWidget* border_;
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
   // The view displaying the border.
   BorderContents* border_contents_;
 #endif
diff --git a/chrome/browser/views/location_bar/location_bar_view.cc b/chrome/browser/views/location_bar/location_bar_view.cc
index 4dffa4e..0402591 100644
--- chrome/browser/views/location_bar/location_bar_view.cc
+++ chrome/browser/views/location_bar/location_bar_view.cc
@@ -4,7 +4,7 @@
 
 #include "chrome/browser/views/location_bar/location_bar_view.h"
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
 #include <gtk/gtk.h>
 #endif
 
diff --git a/chrome/browser/views/location_bar/location_bar_view.h b/chrome/browser/views/location_bar/location_bar_view.h
index 84270dd..389d121 100644
--- chrome/browser/views/location_bar/location_bar_view.h
+++ chrome/browser/views/location_bar/location_bar_view.h
@@ -357,7 +357,7 @@ class LocationBarView : public LocationBar,
   // focused. Used when the toolbar is in full keyboard accessibility mode.
   bool show_focus_rect_;
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
   scoped_ptr<AccessibleWidgetHelper> accessible_widget_helper_;
 #endif
 
diff --git a/chrome/browser/views/notifications/balloon_view.cc b/chrome/browser/views/notifications/balloon_view.cc
index c89280b..7047f8f 100644
--- chrome/browser/views/notifications/balloon_view.cc
+++ chrome/browser/views/notifications/balloon_view.cc
@@ -37,7 +37,7 @@
 #if defined(OS_WIN)
 #include "views/widget/widget_win.h"
 #endif
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
 #include "views/widget/widget_gtk.h"
 #endif
 
diff --git a/chrome/browser/views/notifications/balloon_view_host.cc b/chrome/browser/views/notifications/balloon_view_host.cc
index b2c2a5c..7c305da 100644
--- chrome/browser/views/notifications/balloon_view_host.cc
+++ chrome/browser/views/notifications/balloon_view_host.cc
@@ -10,14 +10,14 @@
 #if defined(OS_WIN)
 #include "chrome/browser/renderer_host/render_widget_host_view_win.h"
 #endif
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
 #endif
 #include "views/widget/widget.h"
 #if defined(OS_WIN)
 #include "views/widget/widget_win.h"
 #endif
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
 #include "views/widget/widget_gtk.h"
 #endif
 
@@ -70,7 +70,7 @@ void BalloonViewHost::InitRenderWidgetHostView() {
   HWND hwnd = view_win->Create(parent_native_view_);
   view_win->ShowWindow(SW_SHOW);
   native_host_->Attach(hwnd);
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
   RenderWidgetHostViewGtk* view_gtk =
       static_cast<RenderWidgetHostViewGtk*>(render_widget_host_view_);
   view_gtk->InitAsChild();
diff --git a/chrome/browser/views/tabs/dragged_tab_view.cc b/chrome/browser/views/tabs/dragged_tab_view.cc
index 5ee2626..cca2b27 100644
--- chrome/browser/views/tabs/dragged_tab_view.cc
+++ chrome/browser/views/tabs/dragged_tab_view.cc
@@ -11,7 +11,7 @@
 
 #if defined(OS_WIN)
 #include "views/widget/widget_win.h"
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
 #include "views/widget/widget_gtk.h"
 #endif
 
diff --git a/chrome/browser/views/tabs/dragged_tab_view.h b/chrome/browser/views/tabs/dragged_tab_view.h
index f2ded5a..653ccd7 100644
--- chrome/browser/views/tabs/dragged_tab_view.h
+++ chrome/browser/views/tabs/dragged_tab_view.h
@@ -13,7 +13,7 @@
 namespace views {
 #if defined(OS_WIN)
 class WidgetWin;
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
 class WidgetGtk;
 #endif
 }
@@ -70,7 +70,7 @@ class DraggedTabView : public views::View {
   // The window that contains the DraggedTabView.
 #if defined(OS_WIN)
   scoped_ptr<views::WidgetWin> container_;
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
   scoped_ptr<views::WidgetGtk> container_;
 #endif
 
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index 03cc42f..925d96b 100644
--- chrome/browser/views/tabs/tab_strip.cc
+++ chrome/browser/views/tabs/tab_strip.cc
@@ -31,7 +31,7 @@
 #if defined(OS_WIN)
 #include "app/win_util.h"
 #include "views/widget/widget_win.h"
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
 #include "views/widget/widget_gtk.h"
 #endif
 
@@ -769,7 +769,7 @@ bool TabStrip::IsCursorInTabStripZone() const {
 #if defined(OS_WIN)
   DWORD pos = GetMessagePos();
   gfx::Point cursor_point(pos);
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_USES_GTK)
   // TODO(sky): make sure this is right with multiple monitors.
   GdkScreen* screen = gdk_screen_get_default();
   GdkDisplay* display = gdk_screen_get_display(screen);
diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h
index 92ba7f9..8a1d646 100644
--- chrome/browser/views/tabs/tab_strip.h
+++ chrome/browser/views/tabs/tab_strip.h
@@ -18,7 +18,7 @@ class Tab;
 
 namespace views {
 class ImageView;
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
 class WidgetGtk;
 #elif defined(OS_WIN)
 class WidgetWin;
diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc
index 97a2329..741743f 100644
--- chrome/browser/web_applications/web_app.cc
+++ chrome/browser/web_applications/web_app.cc
@@ -32,9 +32,9 @@
 #include "chrome/common/url_constants.h"
 #include "webkit/glue/dom_operations.h"
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #include "base/env_var.h"
-#endif  // defined(OS_LINUX)
+#endif  // defined(OS_NIX)
 
 #if defined(OS_WIN)
 #include "base/win_util.h"
@@ -258,7 +258,7 @@ void CreateShortcutTask::Run() {
 bool CreateShortcutTask::CreateShortcut() {
   DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   scoped_ptr<base::EnvVarGetter> env_getter(base::EnvVarGetter::Create());
 
   std::string shortcut_template;
diff --git a/chrome/browser/wrench_menu_model.cc b/chrome/browser/wrench_menu_model.cc
index 637ab57..bf6ab61 100644
--- chrome/browser/wrench_menu_model.cc
+++ chrome/browser/wrench_menu_model.cc
@@ -200,7 +200,7 @@ void WrenchMenuModel::Build() {
   AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW);
 
   AddSeparator();
-#if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS))
+#if defined(OS_POSIX) && !defined(TOOLKIT_VIEWS)
   // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the
   // layout for this menu item in Toolbar.xib. It does, however, use the
   // command_id value from AddButtonItem() to identify this special item.
@@ -215,7 +215,7 @@ void WrenchMenuModel::Build() {
 #endif
 
   AddSeparator();
-#if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS))
+#if defined(OS_POSIX) && !defined(TOOLKIT_VIEWS)
   // WARNING: See above comment.
   zoom_menu_item_model_.reset(
       new menus::ButtonMenuItemModel(IDS_ZOOM_MENU, this));
diff --git a/chrome/browser/zygote_host_linux.cc b/chrome/browser/zygote_host_linux.cc
index 9423598..b8e035d 100644
--- chrome/browser/zygote_host_linux.cc
+++ chrome/browser/zygote_host_linux.cc
@@ -55,7 +55,12 @@ ZygoteHost::ZygoteHost()
 }
 
 ZygoteHost::~ZygoteHost() {
+    Pickle pickle;
   if (init_)
+#if defined(OS_FREEBSD)
+    pickle.WriteInt(kCmdEnd);
+    HANDLE_EINTR(write(control_fd_, pickle.data(), pickle.size()));
+#endif
     close(control_fd_);
 }
 
@@ -71,7 +76,12 @@ void ZygoteHost::Init(const std::string& sandbox_cmd) {
                                  switches::kZygoteProcess);
 
   int fds[2];
+#if defined(OS_FREEBSD)
+  if (socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) != 0)
+    CHECK(socketpair(PF_UNIX, SOCK_DGRAM, 0, fds) == 0);
+#else
   CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0);
+#endif
   base::file_handle_mapping_vector fds_to_map;
   fds_to_map.push_back(std::make_pair(fds[1], 3));
 
@@ -153,6 +163,7 @@ void ZygoteHost::Init(const std::string& sandbox_cmd) {
     // We need to look for it.
     // But first, wait for the zygote to tell us it's running.
     // The sending code is in chrome/browser/zygote_main_linux.cc.
+#if defined(OS_LINUX)
     std::vector<int> fds_vec;
     const int kExpectedLength = sizeof(kZygoteMagic);
     char buf[kExpectedLength];
@@ -182,6 +193,7 @@ void ZygoteHost::Init(const std::string& sandbox_cmd) {
       // Reap the sandbox.
       ProcessWatcher::EnsureProcessGetsReaped(process);
     }
+#endif // defined(OS_LINUX)
   } else {
     // Not using the SUID sandbox.
     pid_ = process;
@@ -277,6 +289,7 @@ pid_t ZygoteHost::ForkRenderer(
     selinux_valid = true;
   }
 
+#if defined(OS_LINUX)
   const int kRendererScore = 5;
   if (using_suid_sandbox_ && !selinux) {
     base::ProcessHandle sandbox_helper_process;
@@ -296,6 +309,7 @@ pid_t ZygoteHost::ForkRenderer(
     if (!base::AdjustOOMScore(pid, kRendererScore))
       LOG(ERROR) << "Failed to adjust OOM score of renderer";
   }
+#endif  // defined(OS_LINUX)
 
   return pid;
 }
diff --git a/chrome/browser/zygote_host_linux.h b/chrome/browser/zygote_host_linux.h
index 545df8d..749996e 100644
--- chrome/browser/zygote_host_linux.h
+++ chrome/browser/zygote_host_linux.h
@@ -45,6 +45,9 @@ class ZygoteHost {
     kCmdReap = 1,             // Reap a renderer child.
     kCmdDidProcessCrash = 2,  // Check if child process crashed.
     kCmdGetSandboxStatus = 3, // Read a bitmask of kSandbox*
+#if defined(OS_FREEBSD)
+    kCmdEnd = 5,              // Kill zygote for SOCK_DGRAM.
+#endif
   };
 
   // These form a bitmask which describes the conditions of the sandbox that
diff --git a/chrome/browser/zygote_main_linux.cc b/chrome/browser/zygote_main_linux.cc
index 51a658e..1d1e99d 100644
--- chrome/browser/zygote_main_linux.cc
+++ chrome/browser/zygote_main_linux.cc
@@ -2,11 +2,17 @@
 // 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"
+
 #include <dlfcn.h>
 #include <fcntl.h>
+#if defined(OS_FREEBSD)
+#include <signal.h>
+#else
 #include <sys/epoll.h>
 #include <sys/prctl.h>
 #include <sys/signal.h>
+#endif
 #include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -47,7 +53,7 @@
 
 #include "unicode/timezone.h"
 
-#if defined(ARCH_CPU_X86_FAMILY) && !defined(CHROMIUM_SELINUX)
+#if defined(ARCH_CPU_X86_FAMILY) && defined(OS_LINUX) && !defined(CHROMIUM_SELINUX)
 // The seccomp sandbox is enabled on all ia32 and x86-64 processor as long as
 // we aren't using SELinux.
 #define SECCOMP_SANDBOX
@@ -169,6 +175,11 @@ class Zygote {
         case ZygoteHost::kCmdGetSandboxStatus:
           HandleGetSandboxStatus(fd, pickle, iter);
           return false;
+#if defined(OS_FREEBSD)
+        case ZygoteHost::kCmdEnd:
+          _exit(0);
+          return false;
+#endif
         default:
           NOTREACHED();
           break;
@@ -237,7 +248,11 @@ class Zygote {
     int argc, numfds;
     base::GlobalDescriptors::Mapping mapping;
     base::ProcessId child;
+#if defined(OS_FREEBSD)
+    uint32_t dummy_inode = 0;
+#elif
     uint64_t dummy_inode = 0;
+#endif
     int dummy_fd = -1;
 
     if (!pickle.ReadInt(&iter, &argc))
@@ -265,6 +280,7 @@ class Zygote {
     mapping.push_back(std::make_pair(
         static_cast<uint32_t>(kSandboxIPCChannel), kMagicSandboxIPCDescriptor));
 
+#if defined(OS_LINUX)
     if (g_suid_sandbox_active) {
       dummy_fd = socket(PF_UNIX, SOCK_DGRAM, 0);
       if (dummy_fd < 0)
@@ -273,6 +289,7 @@ class Zygote {
       if (!base::FileDescriptorGetInode(&dummy_inode, dummy_fd))
         goto error;
     }
+#endif // defined(OS_LINUX)
 
     child = fork();
 
@@ -280,10 +297,13 @@ class Zygote {
 #if defined(SECCOMP_SANDBOX)
       // Try to open /proc/self/maps as the seccomp sandbox needs access to it
       if (g_proc_fd >= 0) {
+#if defined(OS_LINUX)
+// BSD: Removing all Seccomp Sandbox code if not on linux
         int proc_self_maps = openat(g_proc_fd, "self/maps", O_RDONLY);
         if (proc_self_maps >= 0) {
           SeccompSandboxSetProcSelfMaps(proc_self_maps);
         }
+#endif
         close(g_proc_fd);
         g_proc_fd = -1;
       }
@@ -593,6 +613,8 @@ static bool EnterSandbox() {
 
     SkiaFontConfigUseIPCImplementation(kMagicSandboxIPCDescriptor);
 
+    // TODO(benl): Do something for FreeBSD...
+#if !defined(OS_FREEBSD)
     // Previously, we required that the binary be non-readable. This causes the
     // kernel to mark the process as non-dumpable at startup. The thinking was
     // that, although we were putting the renderers into a PID namespace (with
@@ -618,6 +640,7 @@ static bool EnterSandbox() {
         return false;
       }
     }
+#endif
   } else {
     SkiaFontConfigUseDirectImplementation();
   }
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index ebd8304..1e833f3 100644
--- chrome/chrome.gyp
+++ chrome/chrome.gyp
@@ -95,6 +95,10 @@
           }],
         ],
       },],
+      ['OS=="freebsd" or OS=="openbsd"', {
+        'platform_locale_settings_grd':
+            'app/resources/locale_settings_linux.grd',
+      },],
       ['OS=="mac"', {
         'tweak_info_plist_path': 'tools/build/mac/tweak_info_plist',
         'nacl_defines': [
@@ -658,7 +662,7 @@
         '..',
       ],
       'conditions': [
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': [
             '../build/linux/system.gyp:gtk',
           ],
@@ -716,7 +720,7 @@
             '<(DEPTH)/third_party/wtl/include',
           ],
         }],
-        ['OS=="linux" and target_arch!="arm"', {
+        ['(OS=="linux" or OS=="freebsd") and target_arch!="arm"', {
           'sources': [
             'gpu/gpu_backing_store_glx.cc',
             'gpu/gpu_backing_store_glx.h',
@@ -1078,7 +1082,7 @@
             'service/cloud_print/print_system_win.cc',
           ],
         }],
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': [
             '../build/linux/system.gyp:gtk',
           ],
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 05a38da..b64be85 100644
--- chrome/chrome_browser.gypi
+++ chrome/chrome_browser.gypi
@@ -2883,12 +2883,18 @@
             ],
           },
         }],
+        ['use_gconf==0', {
+          'sources!': [
+            'browser/gtk/gconf_titlebar_listener.cc',
+            'browser/gtk/gconf_titlebar_listener.h',
+          ],
+        }],
         ['touchui==0', {
           'sources!': [
             # Nothing yet.
           ],
         }],
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': [
             '../build/linux/system.gyp:dbus-glib',
             '../build/linux/system.gyp:gconf',
@@ -2870,12 +2870,6 @@
             '../build/linux/system.gyp:gtkprint',
             '../build/linux/system.gyp:nss',
           ],
-          'link_settings': {
-            'libraries': [
-              # For dlsym() in 'browser/zygote_main_linux.cc'
-              '-ldl',
-            ],
-          },
           'sources!': [
              # Exclude extension shelf for toolstrips.
             'browser/views/extensions/extension_shelf.cc',
@@ -2935,6 +2929,9 @@
           'sources': [
             'browser/file_watcher_stub.cc',
           ],
+          'sources!': [
+            'browser/file_watcher_inotify.cc',
+          ],
         }],
         ['OS=="mac"', {
           'sources!': [
@@ -3481,7 +3478,7 @@
               ],
             }],
             # GTK build only
-            ['OS=="linux" and toolkit_views==0', {
+            ['(OS=="linux" or OS=="freebsd") and toolkit_views==0', {
               'sources/': [
                 ['include', '^browser/printing/print_dialog_gtk.cc'],
                 ['include', '^browser/printing/print_dialog_gtk.h'],
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index b0b2532..901204a 100644
--- chrome/chrome_renderer.gypi
+++ chrome/chrome_renderer.gypi
@@ -226,6 +226,14 @@
         }],
         # BSD-specific rules.
         ['OS=="openbsd" or OS=="freebsd"', {
+          'conditions': [
+            [ 'linux_use_tcmalloc==1', {
+                'dependencies': [
+                  '../base/allocator/allocator.gyp:allocator',
+                ],
+	      },
+	    ],
+	  ],
           'dependencies': [
             '../build/linux/system.gyp:gtk',
           ],
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 28cd15b..adfae38 100644
--- chrome/chrome_tests.gypi
+++ chrome/chrome_tests.gypi
@@ -126,7 +126,7 @@
         'test/ui_test_utils_win.cc',
       ],
       'conditions': [
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': [
             '../build/linux/system.gyp:gtk',
             '../build/linux/system.gyp:nss',
@@ -172,7 +172,7 @@
         'test/ui/ui_test_suite.h',
       ],
       'conditions': [
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': [
             '../build/linux/system.gyp:gtk',
           ],
@@ -196,7 +196,7 @@
         'test/unit/run_all_unittests.cc',
       ],
       'conditions': [
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': [
             # Needed for the following #include chain:
             #   test/unit/run_all_unittests.cc
@@ -231,7 +231,7 @@
         'test/automated_ui_tests/automated_ui_tests.h',
       ],
       'conditions': [
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': [
             '../tools/xdisplaycheck/xdisplaycheck.gyp:xdisplaycheck',
           ],
@@ -345,7 +345,7 @@
             '../webkit/webkit.gyp:npapi_pepper_test_plugin',
           ],
         }],
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': [
             '../build/linux/system.gyp:gtk',
             '../tools/xdisplaycheck/xdisplaycheck.gyp:xdisplaycheck',
@@ -1232,7 +1232,7 @@
             ['exclude', '^browser/chromeos/'],
           ],
         }],
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'conditions': [
             ['gcc_version==44', {
               # Avoid gcc 4.4 strict aliasing issues in stl_tree.h when
@@ -1662,7 +1662,7 @@
             'browser/renderer_host/test/render_view_host_manager_browsertest.cc',
           ],
         }],
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': [
             '../build/linux/system.gyp:gtk',
             '../tools/xdisplaycheck/xdisplaycheck.gyp:xdisplaycheck',
@@ -1735,7 +1735,7 @@
         'test/startup/startup_test.cc',
       ],
       'conditions': [
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': [
             '../build/linux/system.gyp:gtk',
             '../tools/xdisplaycheck/xdisplaycheck.gyp:xdisplaycheck',
@@ -1816,7 +1816,7 @@
             '<(allocator_target)',
           ],
         },],
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': [
             '../build/linux/system.gyp:gtk',
           ],
@@ -1842,7 +1842,7 @@
         'test/page_cycler/page_cycler_test.cc',
       ],
       'conditions': [
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': [
             '../build/linux/system.gyp:gtk',
             '../tools/xdisplaycheck/xdisplaycheck.gyp:xdisplaycheck',
@@ -1879,7 +1879,7 @@
         'test/tab_switching/tab_switching_test.cc',
       ],
       'conditions': [
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': [
             '../build/linux/system.gyp:gtk',
             '../tools/xdisplaycheck/xdisplaycheck.gyp:xdisplaycheck',
@@ -1913,7 +1913,7 @@
         'test/memory_test/memory_test.cc',
       ],
       'conditions': [
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': [
             '../build/linux/system.gyp:gtk',
             '../tools/xdisplaycheck/xdisplaycheck.gyp:xdisplaycheck',
@@ -2057,7 +2057,7 @@
             'browser/sync/util/data_encryption_unittest.cc',
           ],
         }],
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': [
             '../build/linux/system.gyp:gtk',
             '../build/linux/system.gyp:nss',
@@ -2157,7 +2157,7 @@
       ],
       'conditions': [
         # Plugin code.
-        ['OS=="linux" or OS=="win"', {
+        ['OS=="linux" or OS=="freebsd" or OS=="win"', {
           'dependencies': [
             'plugin',
            ],
@@ -2165,7 +2165,7 @@
             'plugin',
           ],
         }],
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
            'dependencies': [
              '../build/linux/system.gyp:gtk',
              '../build/linux/system.gyp:nss',
@@ -2294,7 +2294,7 @@
             'test/perf/url_parse_perftest.cc',
           ],
           'conditions': [
-            ['OS=="linux"', {
+            ['OS=="linux" or OS=="freebsd"', {
               'dependencies': [
                 '../build/linux/system.gyp:gtk',
                 '../tools/xdisplaycheck/xdisplaycheck.gyp:xdisplaycheck',
@@ -2422,7 +2422,7 @@
       ]},  # 'targets'
     ],  # OS=="win"
     # Build on linux x86_64 only if linux_fpic==1
     ['OS=="mac" or (OS=="win" and component=="static_library") '
-     'or (OS=="linux" and target_arch==python_arch '
+     'or ((OS=="linux" or OS=="freebsd") and target_arch==python_arch '
      'and (target_arch!="x64" or linux_fpic==1))', {
       'targets': [
         {
diff --git a/chrome/common/chrome_constants.cc b/chrome/common/chrome_constants.cc
index 47f0d52..48779e7 100644
--- chrome/common/chrome_constants.cc
+++ chrome/common/chrome_constants.cc
@@ -27,7 +27,7 @@ namespace chrome {
 #if defined(OS_WIN)
 const wchar_t kBrowserProcessExecutableName[] = L"chrome.exe";
 const wchar_t kHelperProcessExecutableName[] = L"chrome.exe";
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
 const wchar_t kBrowserProcessExecutableName[] = L"chrome";
 // Helper processes end up with a name of "exe" due to execing via
 // /proc/self/exe.  See bug 22703.
@@ -39,7 +39,7 @@ const wchar_t kHelperProcessExecutableName[] = PRODUCT_STRING_W L" Helper";
 #if defined(OS_WIN)
 const wchar_t kBrowserProcessExecutablePath[] = L"chrome.exe";
 const FilePath::CharType kHelperProcessExecutablePath[] = FPL("chrome.exe");
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
 const wchar_t kBrowserProcessExecutablePath[] = L"chrome";
 const FilePath::CharType kHelperProcessExecutablePath[] = FPL("chrome");
 #elif defined(OS_MACOSX)
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc
index 6f77510..f4d4183 100644
--- chrome/common/chrome_paths.cc
+++ chrome/common/chrome_paths.cc
@@ -164,7 +164,7 @@ bool PathProvider(int key, FilePath* result) {
       cur = cur.Append(FILE_PATH_LITERAL("inspector"));
       break;
     case chrome::DIR_APP_DICTIONARIES:
-#if defined(OS_LINUX) || defined(OS_MACOSX)
+#if defined(OS_POSIX)
       // We can't write into the EXE dir on Linux, so keep dictionaries
       // alongside the safe browsing database in the user data dir.
       // And we don't want to write into the bundle on the Mac, so push
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index b78c3e7..da0c8ce 100644
--- chrome/common/chrome_switches.cc
+++ chrome/common/chrome_switches.cc
@@ -1029,7 +1029,7 @@ const char kServicesManifest[]              = "services-manifest";
 
 #endif
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 // Specify the amount the trackpad should scroll by.
 const char kScrollPixels[]                  = "scroll-pixels";
 #endif
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 7262bde..caf128f 100644
--- chrome/common/chrome_switches.h
+++ chrome/common/chrome_switches.h
@@ -302,7 +302,7 @@ extern const char kStartupManifest[];
 extern const char kServicesManifest[];
 #endif
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 extern const char kScrollPixels[];
 #endif
 
diff --git a/chrome/common/gpu_messages_internal.h b/chrome/common/gpu_messages_internal.h
index fa9a83f..8a3e65b 100644
--- chrome/common/gpu_messages_internal.h
+++ chrome/common/gpu_messages_internal.h
@@ -98,7 +98,7 @@ IPC_BEGIN_MESSAGES(GpuHost)
   // Response to a GpuMsg_Synchronize message.
   IPC_MESSAGE_CONTROL0(GpuHostMsg_SynchronizeReply)
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   // Get the XID for a view ID.
   IPC_SYNC_MESSAGE_CONTROL1_1(GpuHostMsg_GetViewXID,
                               gfx::NativeViewId, /* view */
diff --git a/chrome/common/native_web_keyboard_event.h b/chrome/common/native_web_keyboard_event.h
index 381ad31..d5675ae 100644
--- chrome/common/native_web_keyboard_event.h
+++ chrome/common/native_web_keyboard_event.h
@@ -32,7 +32,7 @@ struct NativeWebKeyboardEvent : public WebKit::WebKeyboardEvent {
   NativeWebKeyboardEvent(wchar_t character,
                          int state,
                          double time_stamp_seconds);
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
   explicit NativeWebKeyboardEvent(const GdkEventKey* event);
   NativeWebKeyboardEvent(wchar_t character,
                          int state,
@@ -48,7 +48,7 @@ struct NativeWebKeyboardEvent : public WebKit::WebKeyboardEvent {
   MSG os_event;
 #elif defined(OS_MACOSX)
   NSEvent* os_event;
-#elif defined(OS_LINUX)
+#elif defined(TOOLKIT_GTK)
   GdkEventKey* os_event;
 #endif
 
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 3704777..abbb050 100644
--- chrome/common/render_messages_internal.h
+++ chrome/common/render_messages_internal.h
@@ -1778,7 +1778,7 @@ IPC_BEGIN_MESSAGES(ViewHost)
                        int /* fd in browser */)
 #endif
 
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(OS_FREEBSD)
   // Asks the browser to create a block of shared memory for the renderer to
   // pass NativeMetafile data to the browser.
   IPC_SYNC_MESSAGE_ROUTED1_1(ViewHostMsg_AllocatePDFTransport,
@@ -1957,7 +1957,7 @@ IPC_BEGIN_MESSAGES(ViewHost)
   IPC_MESSAGE_CONTROL1(ViewHostMsg_ExtensionRemoveListener,
                        std::string /* name */)
 
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(OS_FREEBSD)
   // On OSX, we cannot allocated shared memory from within the sandbox, so
   // this call exists for the renderer to ask the browser to allocate memory
   // on its behalf. We return a file descriptor to the POSIX shared memory.
diff --git a/chrome/default_plugin/default_plugin.gyp b/chrome/default_plugin/default_plugin.gyp
index a0d8a6d..2093868 100644
--- chrome/default_plugin/default_plugin.gyp
+++ chrome/default_plugin/default_plugin.gyp
@@ -53,7 +53,7 @@
               'plugin_install_job_monitor.h',
             ],
          }],
-         ['OS=="linux"', {
+         ['OS=="linux" or OS=="freebsd"', {
             'dependencies': [
               '<(DEPTH)/build/linux/system.gyp:gtk',
             ],
diff --git a/chrome/gpu/gpu_backing_store_glx.cc b/chrome/gpu/gpu_backing_store_glx.cc
index 37076cc..821611e 100644
--- chrome/gpu/gpu_backing_store_glx.cc
+++ chrome/gpu/gpu_backing_store_glx.cc
@@ -7,6 +7,7 @@
 #include "app/gfx/gl/gl_bindings.h"
 #include "app/surface/transport_dib.h"
 #include "base/scoped_ptr.h"
+#include "chrome/browser/renderer_host/render_process_host.h"
 #include "chrome/common/gpu_messages.h"
 #include "chrome/gpu/gpu_backing_store_glx_context.h"
 #include "chrome/gpu/gpu_thread.h"
@@ -63,7 +64,7 @@ void GpuBackingStoreGLX::OnPaintToBackingStore(
     TransportDIB::Id id,
     const gfx::Rect& bitmap_rect,
     const std::vector<gfx::Rect>& copy_rects) {
-  scoped_ptr<TransportDIB> dib(TransportDIB::Map(id));
+  scoped_ptr<TransportDIB> dib(RenderProcessHost::FromID(source_process_id)->GetTransportDIB(id));
   view_->BindContext();
 
   scoped_ptr<skia::PlatformCanvas> canvas(
diff --git a/chrome/gpu/gpu_channel.cc b/chrome/gpu/gpu_channel.cc
index 091410c..d2fdb49 100644
--- chrome/gpu/gpu_channel.cc
+++ chrome/gpu/gpu_channel.cc
@@ -116,7 +116,7 @@ void GpuChannel::OnCreateViewCommandBuffer(gfx::NativeViewId view_id,
   if (view_renderer_id != renderer_id_)
     return;
   handle = view;
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
   ChildThread* gpu_thread = ChildThread::current();
   // Ask the browser for the view's XID.
   // TODO(piman): This assumes that it doesn't change. It can change however
diff --git a/chrome/gpu/gpu_config.h b/chrome/gpu/gpu_config.h
index 41ca6a3..288bf3c 100644
--- chrome/gpu/gpu_config.h
+++ chrome/gpu/gpu_config.h
@@ -9,7 +9,7 @@
 
 #include "build/build_config.h"
 
-#if defined(OS_LINUX) && !defined(ARCH_CPU_ARMEL)
+#if defined(OS_NIX) && !defined(ARCH_CPU_ARMEL)
 
 // Only define GLX support for Intel CPUs for now until we can get the
 // proper dependencies and build setup for ARM.
diff --git a/chrome/gpu/gpu_thread.cc b/chrome/gpu/gpu_thread.cc
index c5ac79f..257ed34 100644
--- chrome/gpu/gpu_thread.cc
+++ chrome/gpu/gpu_thread.cc
@@ -24,7 +24,7 @@
 #include <X11/Xutil.h>  // Must be last.
 #endif
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
 #include <gtk/gtk.h>
 #endif
 
@@ -32,7 +32,7 @@ GpuThread::GpuThread() {
 #if defined(GPU_USE_GLX)
   display_ = ::XOpenDisplay(NULL);
 #endif
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
   {
     // The X11 port of the command buffer code assumes it can access the X
     // display via the macro GDK_DISPLAY(), which implies that Gtk has been
diff --git a/chrome/gpu/gpu_video_layer_glx.cc b/chrome/gpu/gpu_video_layer_glx.cc
index d0578ad..985dc1a 100644
--- chrome/gpu/gpu_video_layer_glx.cc
+++ chrome/gpu/gpu_video_layer_glx.cc
@@ -5,6 +5,7 @@
 #include "chrome/gpu/gpu_video_layer_glx.h"
 
 #include "app/gfx/gl/gl_bindings.h"
+#include "chrome/browser/renderer_host/render_process_host.h"
 #include "chrome/common/gpu_messages.h"
 #include "chrome/gpu/gpu_thread.h"
 #include "chrome/gpu/gpu_view_x.h"
@@ -264,7 +265,7 @@ void GpuVideoLayerGLX::OnPaintToVideoLayer(base::ProcessId source_process_id,
       height <= 0 || height > kMaxVideoLayerSize)
     return;
 
-  TransportDIB* dib = TransportDIB::Map(id);
+  TransportDIB* dib = RenderProcessHost::FromID(source_process_id)->GetTransportDIB(id);
   if (!dib)
     return;
 
diff --git a/chrome/gpu/x_util.h b/chrome/gpu/x_util.h
index 512b232..c201e07 100644
--- chrome/gpu/x_util.h
+++ chrome/gpu/x_util.h
@@ -11,7 +11,7 @@
 #include "build/build_config.h"
 #include "chrome/gpu/gpu_config.h"
 
-#if defined(OS_LINUX)
+#if defined(USE_X11)
 
 // Forward declares ------------------------------------------------------------
 //
@@ -41,6 +41,6 @@ class ScopedPtrXFree {
   void operator()(void* x) const;
 };
 
-#endif  // OS_LINUX
+#endif  // USE_X11
 
 #endif  // CHROME_GPU_X_UTIL_H_
diff --git a/chrome/plugin/plugin_main_linux.cc b/chrome/plugin/plugin_main_linux.cc
index 6bb9da7..27f7996 100644
--- chrome/plugin/plugin_main_linux.cc
+++ chrome/plugin/plugin_main_linux.cc
@@ -11,7 +11,7 @@
 #include "build/build_config.h"
 
 // This whole file is only useful on 64-bit architectures.
-#if defined(ARCH_CPU_64_BITS)
+#if defined(ARCH_CPU_64_BITS) && !defined(OS_FREEBSD)
 
 namespace {
 
diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc
index 1ae410e..84375a6 100644
--- chrome/plugin/plugin_thread.cc
+++ chrome/plugin/plugin_thread.cc
@@ -6,7 +6,7 @@
 
 #include "build/build_config.h"
 
-#if defined(USE_X11)
+#if defined(TOOLKIT_USES_GTK)
 #include <gtk/gtk.h>
 #elif defined(OS_MACOSX)
 #include <CoreFoundation/CoreFoundation.h>
@@ -52,7 +52,7 @@ PluginThread::PluginThread()
           switches::kPluginPath);
 
   lazy_tls.Pointer()->Set(this);
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
   {
     // XEmbed plugins assume they are hosted in a Gtk application, so we need
     // to initialize Gtk in the plugin process.
diff --git a/chrome/renderer/mock_render_thread.cc b/chrome/renderer/mock_render_thread.cc
index 57e9d80..e1e3b22 100644
--- chrome/renderer/mock_render_thread.cc
+++ chrome/renderer/mock_render_thread.cc
@@ -105,7 +105,7 @@ void MockRenderThread::OnMessageReceived(const IPC::Message& msg) {
     IPC_MESSAGE_HANDLER(ViewHostMsg_AllocatePDFTransport,
                         OnAllocatePDFTransport)
 #endif
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
     IPC_MESSAGE_HANDLER(ViewHostMsg_AllocateTempFileForPrinting,
                         OnAllocateTempFileForPrinting)
     IPC_MESSAGE_HANDLER(ViewHostMsg_TempFileForPrintingWritten,
@@ -154,7 +154,7 @@ void MockRenderThread::OnAllocatePDFTransport(
 }
 #endif
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 void MockRenderThread::OnAllocateTempFileForPrinting(
     base::FileDescriptor* renderer_fd,
     int* browser_fd) {
diff --git a/chrome/renderer/mock_render_thread.h b/chrome/renderer/mock_render_thread.h
index c297cb8..b69a369 100644
--- chrome/renderer/mock_render_thread.h
+++ chrome/renderer/mock_render_thread.h
@@ -101,7 +101,7 @@ class MockRenderThread : public RenderThreadBase {
                               base::SharedMemoryHandle* handle);
 #endif
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   void OnAllocateTempFileForPrinting(base::FileDescriptor* renderer_fd,
                                      int* browser_fd);
   void OnTempFileForPrintingWritten(int browser_fd);
diff --git a/chrome/renderer/pepper_scrollbar_widget.h b/chrome/renderer/pepper_scrollbar_widget.h
index ac36f5e..3d9be56 100644
--- chrome/renderer/pepper_scrollbar_widget.h
+++ chrome/renderer/pepper_scrollbar_widget.h
@@ -37,7 +37,7 @@ class PepperScrollbarWidget : public PepperWidget,
   virtual void getTickmarks(WebKit::WebScrollbar*,
                             WebKit::WebVector<WebKit::WebRect>*) const;
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   static void SetScrollbarColors(unsigned inactive_color,
                                  unsigned active_color,
                                  unsigned track_color);
diff --git a/chrome/renderer/render_process_impl.cc b/chrome/renderer/render_process_impl.cc
index e610df9..c4155d0 100644
--- chrome/renderer/render_process_impl.cc
+++ chrome/renderer/render_process_impl.cc
@@ -225,7 +225,7 @@ TransportDIB* RenderProcessImpl::CreateTransportDIB(size_t size) {
 #if defined(OS_WIN) || defined(OS_LINUX)
   // Windows and Linux create transport DIBs inside the renderer
   return TransportDIB::Create(size, transport_dib_next_sequence_number_++);
-#elif defined(OS_MACOSX)  // defined(OS_WIN) || defined(OS_LINUX)
+#elif defined(OS_MACOSX) || defined(OS_FREEBSD) // defined(OS_WIN) || defined(OS_NIX)
   // Mac creates transport DIBs in the browser, so we need to do a sync IPC to
   // get one.  The TransportDIB is cached in the browser.
   TransportDIB::Handle handle;
@@ -242,7 +242,7 @@ void RenderProcessImpl::FreeTransportDIB(TransportDIB* dib) {
   if (!dib)
     return;
 
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(OS_FREEBSD)
   // On Mac we need to tell the browser that it can drop a reference to the
   // shared memory.
   IPC::Message* msg = new ViewHostMsg_FreeTransportDIB(dib->id());
@@ -260,7 +260,7 @@ skia::PlatformCanvas* RenderProcessImpl::GetDrawingCanvas(
   int width = rect.width();
   int height = rect.height();
   const size_t stride = skia::PlatformCanvas::StrideForWidth(rect.width());
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   const size_t max_size = base::SysInfo::MaxSharedMemorySize();
 #else
   const size_t max_size = 0;
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index 3573488..e662023 100644
--- chrome/renderer/render_thread.cc
+++ chrome/renderer/render_thread.cc
@@ -901,7 +901,7 @@ void RenderThread::EnsureWebKitInitialized() {
 }
 
 void RenderThread::IdleHandler() {
-#if (defined(OS_WIN) || defined(OS_LINUX)) && defined(USE_TCMALLOC)
+#if !defined(OS_MACOSX) && defined(USE_TCMALLOC)
   MallocExtension::instance()->ReleaseFreeMemory();
 #endif
 
@@ -977,7 +977,7 @@ void RenderThread::OnPurgeMemory() {
   while (!v8::V8::IdleNotification()) {
   }
 
-#if (defined(OS_WIN) || defined(OS_LINUX)) && defined(USE_TCMALLOC)
+#if !defined(OS_MACOSX) && defined(USE_TCMALLOC)
   // Tell tcmalloc to release any free pages it's still holding.
   MallocExtension::instance()->ReleaseFreeMemory();
 #endif
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 25ef1e6..fe8feba 100644
--- chrome/renderer/render_view.h
+++ chrome/renderer/render_view.h
@@ -961,7 +961,7 @@ class RenderView : public RenderWidget,
   // periodic timer so we don't send too many messages.
   void SyncNavigationState();
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   void UpdateFontRenderingFromRendererPrefs();
 #else
   void UpdateFontRenderingFromRendererPrefs() {}
diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc
index 849565a..8930fc2 100644
--- chrome/renderer/renderer_glue.cc
+++ chrome/renderer/renderer_glue.cc
@@ -39,7 +39,7 @@
 
 #if defined(OS_WIN)
 #include <strsafe.h>  // note: per msdn docs, this must *follow* other includes
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
 #include "chrome/renderer/renderer_sandbox_support_linux.h"
 #endif
 
@@ -313,7 +313,7 @@ bool IsSingleProcess() {
   return CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess);
 }
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 int MatchFontWithFallback(const std::string& face, bool bold,
                           bool italic, int charset) {
   return renderer_sandbox_support::MatchFontWithFallback(
diff --git a/chrome/renderer/renderer_main.cc b/chrome/renderer/renderer_main.cc
index f521e11..95982a7 100644
--- chrome/renderer/renderer_main.cc
+++ chrome/renderer/renderer_main.cc
@@ -267,7 +267,7 @@ int RendererMain(const MainFunctionParams& parameters) {
   PepperPluginRegistry::GetInstance();
 
   {
-#if !defined(OS_LINUX)
+#if !defined(OS_NIX)
     // TODO(markus): Check if it is OK to unconditionally move this
     // instruction down.
     RenderProcessImpl render_process;
@@ -277,7 +277,7 @@ int RendererMain(const MainFunctionParams& parameters) {
     if (!no_sandbox) {
       run_loop = platform.EnableSandbox();
     }
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
     RenderProcessImpl render_process;
     render_process.set_main_thread(new RenderThread());
 #endif
diff --git a/chrome/renderer/renderer_main_platform_delegate_linux.cc b/chrome/renderer/renderer_main_platform_delegate_linux.cc
index 98b0aca..ca7df2e 100644
--- chrome/renderer/renderer_main_platform_delegate_linux.cc
+++ chrome/renderer/renderer_main_platform_delegate_linux.cc
@@ -36,7 +36,7 @@ bool RendererMainPlatformDelegate::EnableSandbox() {
   //
   // The seccomp sandbox is started in the renderer.
   // http://code.google.com/p/seccompsandbox/
-#if defined(ARCH_CPU_X86_FAMILY) && !defined(CHROMIUM_SELINUX)
+#if defined(OS_LINUX) && defined(ARCH_CPU_X86_FAMILY) && !defined(CHROMIUM_SELINUX)
   // N.b. SupportsSeccompSandbox() returns a cached result, as we already
   // called it earlier in the zygote. Thus, it is OK for us to not pass in
   // a file descriptor for "/proc".
diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc
index 27329ee..0bdbcdf 100644
--- chrome/renderer/renderer_webkitclient_impl.cc
+++ chrome/renderer/renderer_webkitclient_impl.cc
@@ -42,7 +42,7 @@
 #include "chrome/common/font_loader_mac.h"
 #endif
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #include "chrome/renderer/renderer_sandbox_support_linux.h"
 #endif
 
@@ -311,7 +311,7 @@ bool RendererWebKitClientImpl::SandboxSupport::ensureFontLoaded(HFONT font) {
   return RenderThread::current()->Send(new ViewHostMsg_PreCacheFont(logfont));
 }
 
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
 
 WebString RendererWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters(
     const WebKit::WebUChar* characters, size_t num_characters) {
diff --git a/chrome/renderer/renderer_webkitclient_impl.h b/chrome/renderer/renderer_webkitclient_impl.h
index 86fdf1f..8c1e874 100644
--- chrome/renderer/renderer_webkitclient_impl.h
+++ chrome/renderer/renderer_webkitclient_impl.h
@@ -15,7 +15,7 @@
 
 #if defined(OS_WIN)
 #include "third_party/WebKit/WebKit/chromium/public/win/WebSandboxSupport.h"
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
 #include <string>
 #include <map>
 #include "base/lock.h"
@@ -99,7 +99,7 @@ class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl {
    public:
     virtual bool ensureFontLoaded(HFONT);
   };
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
   class SandboxSupport : public WebKit::WebSandboxSupport {
    public:
     virtual WebKit::WebString getFontFamilyForCharacters(
diff --git a/chrome/renderer/webplugin_delegate_pepper.cc b/chrome/renderer/webplugin_delegate_pepper.cc
index 58f1a23..64bfaa4 100644
--- chrome/renderer/webplugin_delegate_pepper.cc
+++ chrome/renderer/webplugin_delegate_pepper.cc
@@ -9,7 +9,7 @@
 #include <string>
 #include <vector>
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #include <unistd.h>
 #endif
 
@@ -33,7 +33,7 @@
 #include "chrome/common/render_messages.h"
 #include "chrome/renderer/pepper_widget.h"
 #include "chrome/renderer/render_thread.h"
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #include "chrome/renderer/renderer_sandbox_support_linux.h"
 #endif
 #include "chrome/renderer/webplugin_delegate_proxy.h"
@@ -455,7 +455,7 @@ bool WebPluginDelegatePepper::SetCursor(NPCursorType type) {
 NPError NPMatchFontWithFallback(NPP instance,
                                 const NPFontDescription* description,
                                 NPFontID* id) {
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   int fd = renderer_sandbox_support::MatchFontWithFallback(
       description->face, description->weight >= 700, description->italic,
       description->charset);
@@ -474,7 +474,7 @@ NPError GetFontTable(NPP instance,
                      uint32_t table,
                      void* output,
                      size_t* output_length) {
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   bool rv = renderer_sandbox_support::GetFontTable(
       id, table, static_cast<uint8_t*>(output), output_length);
   return rv ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
@@ -485,7 +485,7 @@ NPError GetFontTable(NPP instance,
 }
 
 NPError NPDestroyFont(NPP instance, NPFontID id) {
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   close(id);
   return NPERR_NO_ERROR;
 #else
@@ -1158,10 +1158,10 @@ int WebPluginDelegatePepper::PrintBegin(const gfx::Rect& printable_area,
       current_printer_dpi_ = printer_dpi;
     }
   }
-#if defined (OS_LINUX)
+#if defined (OS_NIX)
   num_pages_ = num_pages;
   pdf_output_done_ = false;
-#endif  // (OS_LINUX)
+#endif  // (OS_NIX)
   return num_pages;
 }
 
@@ -1187,7 +1187,7 @@ bool WebPluginDelegatePepper::VectorPrintPage(int page_number,
   unsigned char* pdf_output = NULL;
   int32 output_size = 0;
   NPPrintPageNumberRange page_range;
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   // On Linux we will try and output all pages as PDF in the first call to
   // PrintPage. This is a temporary hack.
   // TODO(sanjeevr): Remove this hack and fix this by changing the print
@@ -1196,9 +1196,9 @@ bool WebPluginDelegatePepper::VectorPrintPage(int page_number,
     return pdf_output_done_;
   page_range.firstPageNumber = 0;
   page_range.lastPageNumber = num_pages_ - 1;
-#else  // defined(OS_LINUX)
+#else  // defined(OS_NIX)
   page_range.firstPageNumber = page_range.lastPageNumber = page_number;
-#endif  // defined(OS_LINUX)
+#endif  // defined(OS_NIX)
   NPError err = print_extensions->printPagesAsPDF(instance()->npp(),
                                                   &page_range, 1,
                                                   &pdf_output, &output_size);
@@ -1206,7 +1206,7 @@ bool WebPluginDelegatePepper::VectorPrintPage(int page_number,
     return false;
 
   bool ret = false;
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   // On Linux we need to get the backing PdfPsMetafile and write the bits
   // directly.
   cairo_t* context = canvas->beginPlatformPaint();
@@ -1359,10 +1359,10 @@ void WebPluginDelegatePepper::PrintEnd() {
   current_printer_dpi_ = -1;
 #if defined(OS_MACOSX)
   last_printed_page_ = SkBitmap();
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
   num_pages_ = 0;
   pdf_output_done_ = false;
-#endif  // defined(OS_LINUX)
+#endif  // defined(OS_NIX)
 }
 
 WebPluginDelegatePepper::WebPluginDelegatePepper(
@@ -1373,10 +1373,10 @@ WebPluginDelegatePepper::WebPluginDelegatePepper(
       instance_(instance),
       nested_delegate_(NULL),
       current_printer_dpi_(-1),
-#if defined (OS_LINUX)
+#if defined (OS_NIX)
       num_pages_(0),
       pdf_output_done_(false),
-#endif  // (OS_LINUX)
+#endif  // (OS_NIX)
 #if defined(ENABLE_GPU)
       command_buffer_(NULL),
 #endif
diff --git a/chrome/renderer/webplugin_delegate_pepper.h b/chrome/renderer/webplugin_delegate_pepper.h
index be9c1ce..e38a3d7 100644
--- chrome/renderer/webplugin_delegate_pepper.h
+++ chrome/renderer/webplugin_delegate_pepper.h
@@ -305,7 +305,7 @@ class WebPluginDelegatePepper : public webkit_glue::WebPluginDelegate,
   // variable to hold on to the pixels.
   SkBitmap last_printed_page_;
 #endif   // defined(OS_MACOSX)
-#if defined (OS_LINUX)
+#if defined (OS_NIX)
   // On Linux, we always send all pages from the renderer to the browser.
   // So, if the plugin supports printPagesAsPDF we print the entire output
   // in one shot in the first call to PrintPage.
@@ -316,7 +316,7 @@ class WebPluginDelegatePepper : public webkit_glue::WebPluginDelegate,
   // Specifies whether we have already output all pages. This is used to ignore
   // subsequent PrintPage requests.
   bool pdf_output_done_;
-#endif   // defined(OS_LINUX)
+#endif   // defined(OS_NIX)
 
 #if defined(ENABLE_GPU)
   // The command buffer used to issue commands to the nested GPU plugin.
diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc
index 408be65..973ccf8 100644
--- chrome/service/service_process.cc
+++ chrome/service/service_process.cc
@@ -17,7 +17,7 @@
 #if defined(OS_WIN)
 #include "remoting/host/capturer_gdi.h"
 #include "remoting/host/event_executor_win.h"
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
 #include "remoting/host/capturer_linux.h"
 #include "remoting/host/event_executor_linux.h"
 #elif defined(OS_MACOSX)
@@ -78,7 +78,7 @@ remoting::ChromotingHost* ServiceProcess::CreateChromotingHost(
 #if defined(OS_WIN)
   capturer.reset(new remoting::CapturerGdi());
   executor.reset(new remoting::EventExecutorWin());
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
   capturer.reset(new remoting::CapturerLinux());
   executor.reset(new remoting::EventExecutorLinux());
 #elif defined(OS_MACOSX)
diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc
index bace790..88b40bf 100644
--- chrome/test/automation/automation_proxy_uitest.cc
+++ chrome/test/automation/automation_proxy_uitest.cc
@@ -1306,7 +1306,7 @@ TEST_F(ExternalTabUITestPopupEnabled, UserGestureTargetBlank) {
 #endif  // defined(OS_WIN)
 
 // TODO(port): Need to port autocomplete_edit_proxy.* first.
-#if defined(OS_WIN) || defined(OS_LINUX)
+#if defined(OS_WIN) || defined(OS_NIX)
 TEST_F(AutomationProxyTest, AutocompleteGetSetText) {
   scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
   ASSERT_TRUE(browser.get());
@@ -1350,7 +1350,7 @@ TEST_F(AutomationProxyTest, AutocompleteParallelProxy) {
   EXPECT_EQ(text_to_set2, actual_text2);
 }
 
-#endif  // defined(OS_WIN) || defined(OS_LINUX)
+#endif  // defined(OS_WIN) || defined(OS_NIX)
 
 #if defined(OS_MACOSX)
 // TODO(port): Implement AutocompleteEditProxy on Mac.
diff --git a/chrome/test/chrome_process_util.cc b/chrome/test/chrome_process_util.cc
index a3c4d6f..d76886e 100644
--- chrome/test/chrome_process_util.cc
+++ chrome/test/chrome_process_util.cc
@@ -79,7 +79,7 @@ ChromeProcessList GetRunningChromeProcesses(base::ProcessId browser_pid) {
     result.push_back(process_entry->pid());
   }
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   // On Linux we might be running with a zygote process for the renderers.
   // Because of that we sweep the list of processes again and pick those which
   // are children of one of the processes that we've already seen.
@@ -90,9 +90,9 @@ ChromeProcessList GetRunningChromeProcesses(base::ProcessId browser_pid) {
     while (const base::ProcessEntry* process_entry = it.NextProcessEntry())
       result.push_back(process_entry->pid());
   }
-#endif  // defined(OS_LINUX)
+#endif  // defined(OS_NIX)
 
-#if defined(OS_LINUX) || defined(OS_MACOSX)
+#if defined(OS_POSIX)
   // On Mac OS X we run the subprocesses with a different bundle, and
   // on Linux via /proc/self/exe, so they end up with a different
   // name.  We must collect them in a second pass.
diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc
index 438a34c..5eb3588 100644
--- chrome/test/in_process_browser_test.cc
+++ chrome/test/in_process_browser_test.cc
@@ -38,7 +38,7 @@
 #include "net/base/mock_host_resolver.h"
 #include "sandbox/src/dep.h"
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #include "base/singleton.h"
 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h"
 #include "chrome/browser/zygote_host_linux.h"
@@ -213,7 +213,7 @@ void InProcessBrowserTest::SetUp() {
 #endif
   CHECK(PathService::Override(base::FILE_EXE, chrome_path));
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   // Initialize the RenderSandbox and Zygote hosts. Apparently they get used
   // for InProcessBrowserTest, and this is not the normal browser startup path.
   Singleton<LinuxHostInit>::get();
diff --git a/chrome/test/interactive_ui/interactive_ui_tests.gypi b/chrome/test/interactive_ui/interactive_ui_tests.gypi
index 2da3179..7ad785e 100644
--- chrome/test/interactive_ui/interactive_ui_tests.gypi
+++ chrome/test/interactive_ui/interactive_ui_tests.gypi
@@ -52,7 +52,7 @@
     '<(DEPTH)/chrome/test/unit/chrome_test_suite.h',
   ],
   'conditions': [
-    ['OS=="linux"', {
+    ['OS=="linux" or OS=="freebsd"', {
       'dependencies': [
         '<(DEPTH)/build/linux/system.gyp:gtk',
         '<(DEPTH)/build/linux/system.gyp:nss',
diff --git a/chrome/test/page_cycler/page_cycler_test.cc b/chrome/test/page_cycler/page_cycler_test.cc
index 1f5b49a..6aac289 100644
--- chrome/test/page_cycler/page_cycler_test.cc
+++ chrome/test/page_cycler/page_cycler_test.cc
@@ -286,7 +286,7 @@ class PageCyclerReferenceTest : public PageCyclerTest {
     dir = dir.AppendASCII("reference_build");
 #if defined(OS_WIN)
     dir = dir.AppendASCII("chrome");
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
     dir = dir.AppendASCII("chrome_linux");
 #elif defined(OS_MACOSX)
     dir = dir.AppendASCII("chrome_mac");
diff --git a/chrome/test/reliability/page_load_test.cc b/chrome/test/reliability/page_load_test.cc
index e39d342..ce3bcf5 100644
--- chrome/test/reliability/page_load_test.cc
+++ chrome/test/reliability/page_load_test.cc
@@ -162,7 +162,7 @@ class PageLoadTest : public UITest {
     scoped_ptr<FileVersionInfo> file_info;
 #if defined(OS_WIN)
     file_info.reset(FileVersionInfo::CreateFileVersionInfo(kChromeDll));
-#elif defined(OS_LINUX) || defined(OS_MACOSX)
+#elif defined(OS_POSIX)
     // TODO(fmeawad): On Mac, the version retrieved here belongs to the test
     // module and not the chrome binary, need to be changed to chrome binary
     // instead.
diff --git a/chrome/test/startup/feature_startup_test.cc b/chrome/test/startup/feature_startup_test.cc
index df68386..f39143e 100644
--- chrome/test/startup/feature_startup_test.cc
+++ chrome/test/startup/feature_startup_test.cc
@@ -192,7 +192,7 @@ TEST_F(NewTabUIStartupTest, NewTabTimingTestsCold) {
   RunNewTabTimingTest();
 }
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_GTK)
 TEST_F(NewTabUIStartupTest, GtkThemeCold) {
   RunStartupTest("tab_gtk_theme_cold", false /* cold */,
                  false /* not important */,
diff --git a/chrome/test/startup/startup_test.cc b/chrome/test/startup/startup_test.cc
index 7f6f47f..73055ee 100644
--- chrome/test/startup/startup_test.cc
+++ chrome/test/startup/startup_test.cc
@@ -389,7 +389,7 @@ TEST_F(StartupTest, PerfComplexTheme) {
                  UITest::COMPLEX_THEME, 0, 0);
 }
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
 TEST_F(StartupTest, PerfGtkTheme) {
   RunStartupTest("warm", "gtk-theme", WARM, NOT_IMPORTANT,
                  UITest::NATIVE_THEME, 0, 0);
diff --git a/chrome/test/testing_browser_process.h b/chrome/test/testing_browser_process.h
index c69af1c..974cb0a 100644
--- chrome/test/testing_browser_process.h
+++ chrome/test/testing_browser_process.h
@@ -48,7 +48,7 @@ class TestingBrowserProcess : public BrowserProcess {
     return NULL;
   }
 
-#if defined(OS_LINUX)
+#if defined(USE_X11)
   virtual base::Thread* background_x11_thread() {
     return NULL;
   }
diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc
index 60e423a..2805b7b 100644
--- chrome/test/testing_profile.cc
+++ chrome/test/testing_profile.cc
@@ -22,7 +22,7 @@
 #include "testing/gmock/include/gmock/gmock.h"
 #include "webkit/database/database_tracker.h"
 
-#if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
+#if defined(TOOLKIT_GTK) && !defined(TOOLKIT_VIEWS)
 #include "chrome/browser/gtk/gtk_theme_provider.h"
 #endif
 
@@ -295,7 +295,7 @@ webkit_database::DatabaseTracker* TestingProfile::GetDatabaseTracker() {
 
 void TestingProfile::InitThemes() {
   if (!created_theme_provider_) {
-#if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
+#if defined(TOOLKIT_GTK) && !defined(TOOLKIT_VIEWS)
     theme_provider_.reset(new GtkThemeProvider);
 #else
     theme_provider_.reset(new BrowserThemeProvider);
diff --git a/chrome/test/ui/history_uitest.cc b/chrome/test/ui/history_uitest.cc
index 45e0983..9310407 100644
--- chrome/test/ui/history_uitest.cc
+++ chrome/test/ui/history_uitest.cc
@@ -116,7 +116,7 @@ TEST_F(HistoryTester, ConsiderRedirectAfterGestureAsUserInitiated) {
   WaitForFinish("History_Length_Test_12", "1", url, kTestCompleteCookie,
                 kTestCompleteSuccess, action_max_timeout_ms());
 }
-#endif  // defined(OS_WIN) || defined(OS_LINUX)
+#endif  // defined(OS_WIN) || defined(OS_NIX)
 
 TEST_F(HistoryTester, ConsiderSlowRedirectAsUserInitiated) {
   // Test the history length for the following page transition.
diff --git a/chrome/test/ui/sunspider_uitest.cc b/chrome/test/ui/sunspider_uitest.cc
index 1c4f484..b544407 100644
--- chrome/test/ui/sunspider_uitest.cc
+++ chrome/test/ui/sunspider_uitest.cc
@@ -128,7 +128,7 @@ class SunSpiderReferenceTest : public SunSpiderTest {
     dir = dir.AppendASCII("reference_build");
 #if defined(OS_WIN)
     dir = dir.AppendASCII("chrome");
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
     dir = dir.AppendASCII("chrome_linux");
 #elif defined(OS_MACOSX)
     dir = dir.AppendASCII("chrome_mac");
diff --git a/chrome/test/ui/ui_layout_test.cc b/chrome/test/ui/ui_layout_test.cc
index 6c5415f..2472bda 100644
--- chrome/test/ui/ui_layout_test.cc
+++ chrome/test/ui/ui_layout_test.cc
@@ -18,7 +18,7 @@
 static const char kPlatformName[] = "chromium-win";
 #elif defined(OS_MACOSX)
 static const char kPlatformName[] = "chromium-mac";
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
 static const char kPlatformName[] = "chromium-linux";
 #else
 #error No known OS defined
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index 90e1550..efc3f00 100644
--- chrome/test/ui/ui_test.cc
+++ chrome/test/ui/ui_test.cc
@@ -66,7 +66,7 @@ const wchar_t UITestBase::kFailedNoCrashService[] =
     L"NOTE: This test is expected to fail if crash_service.exe is not "
     L"running. Start it manually before running this test (see the build "
     L"output directory).";
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
     L"NOTE: This test is expected to fail if breakpad is not built in "
     L"or if chromium is not running headless (try CHROME_HEADLESS=1).";
 #else
@@ -1460,7 +1460,7 @@ void UITestBase::PrintMemoryUsageInfo(const char* test_name) {
   PrintResult("ws_final_t", "", "ws_f_t" + trace_name,
               total_working_set_size, "bytes",
               false /* not important */);
-#elif defined(OS_LINUX) || defined(OS_MACOSX)
+#elif defined(OS_POSIX)
   PrintResult("vm_size_final_b", "", "vm_size_f_b" + trace_name,
               browser_virtual_size, "bytes",
               true /* important */);
diff --git a/chrome/test/ui/v8_benchmark_uitest.cc b/chrome/test/ui/v8_benchmark_uitest.cc
index b020af1..ba8c221 100644
--- chrome/test/ui/v8_benchmark_uitest.cc
+++ chrome/test/ui/v8_benchmark_uitest.cc
@@ -130,7 +130,7 @@ class V8BenchmarkReferenceTest : public V8BenchmarkTest {
     dir = dir.AppendASCII("reference_build");
 #if defined(OS_WIN)
     dir = dir.AppendASCII("chrome");
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
     dir = dir.AppendASCII("chrome_linux");
 #elif defined(OS_MACOSX)
     dir = dir.AppendASCII("chrome_mac");
diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc
index c464229..214652e 100644
--- chrome/test/ui_test_utils.cc
+++ chrome/test/ui_test_utils.cc
@@ -307,7 +307,7 @@ void RunMessageLoop() {
 #if defined(TOOLKIT_VIEWS)
   views::AcceleratorHandler handler;
   loop->Run(&handler);
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
   loop->Run(NULL);
 #else
   loop->Run();
diff --git a/chrome/test/url_fetch_test/url_fetch_test.cc b/chrome/test/url_fetch_test/url_fetch_test.cc
index ec87c76..3246efd 100644
--- chrome/test/url_fetch_test/url_fetch_test.cc
+++ chrome/test/url_fetch_test/url_fetch_test.cc
@@ -34,7 +34,7 @@ class UrlFetchTest : public UITest {
       dir = dir.AppendASCII("reference_build");
 #if defined(OS_WIN)
       dir = dir.AppendASCII("chrome");
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
       dir = dir.AppendASCII("chrome_linux");
 #elif defined(OS_MACOSX)
       dir = dir.AppendASCII("chrome_mac");
diff --git a/chrome/tools/build/linux/sed.sh b/chrome/tools/build/linux/sed.sh
index 22615cb..bc59956 100755
--- chrome/tools/build/linux/sed.sh
+++ chrome/tools/build/linux/sed.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style license that can be
diff --git a/chrome/worker/worker_uitest.cc b/chrome/worker/worker_uitest.cc
index 061c3f2..84a04a1 100644
--- chrome/worker/worker_uitest.cc
+++ chrome/worker/worker_uitest.cc
@@ -84,7 +84,7 @@ class WorkerTest : public UILayoutTest {
     // The 1 is for the browser process.
     int number_of_processes = 1 + workers +
         (UITest::in_process_renderer() ? 0 : tabs);
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
     // On Linux, we also have a zygote process and a sandbox host process.
     number_of_processes += 2;
 #endif
diff --git a/gpu/demos/demos.gyp b/gpu/demos/demos.gyp
index a7ba2b9..2598548 100644
--- gpu/demos/demos.gyp
+++ gpu/demos/demos.gyp
@@ -11,7 +11,7 @@
       # also be compiled with -fPIC flag. Setting GYP_DEFINES="linux_fpic=1"
       # compiles everything with -fPIC. Disable pepper demos on linux/x64
       # unless linux_fpic is 1.
-      ['OS=="linux" and (target_arch=="x64" or target_arch=="arm") and linux_fpic!=1', {
+      ['(OS=="linux" or OS=="freebsd") and (target_arch=="x64" or target_arch=="arm") and linux_fpic!=1', {
         'enable_pepper_demos%': 0,
       }, {
         'enable_pepper_demos%': 1,
@@ -48,7 +48,7 @@
         'framework/window.h',
       ],
       'conditions': [
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': ['../../build/linux/system.gyp:gtk'],
         }],
       ],
@@ -103,7 +103,7 @@
               'framework/plugin.rc',
             ],
           }],
-          ['OS=="linux"', {
+          ['OS=="linux" or OS=="freebsd"', {
             # -gstabs, used in the official builds, causes an ICE. Remove it.
             'cflags!': ['-gstabs'],
           }],
diff --git a/gpu/demos/framework/main_exe.cc b/gpu/demos/framework/main_exe.cc
index bc42e6c..d1e1916 100644
--- gpu/demos/framework/main_exe.cc
+++ gpu/demos/framework/main_exe.cc
@@ -6,9 +6,9 @@
 #include "base/logging.h"
 #include "gpu/demos/framework/window.h"
 
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
 #include <gtk/gtk.h>
-#endif  // OS_LINUX
+#endif  // TOOLKIT_USES_GTK
 
 namespace {
 static const int kWindowWidth = 512;
@@ -16,9 +16,9 @@ static const int kWindowHeight = 512;
 }  // namespace.
 
 int main(int argc, char *argv[]) {
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
   gtk_init(&argc, &argv);
-#endif  // OS_LINUX
+#endif  // TOOLKIT_USES_GTK
 
   // AtExitManager is used by singleton classes to delete themselves when
   // the program terminates.
diff --git a/gpu/demos/framework/main_pepper.cc b/gpu/demos/framework/main_pepper.cc
index 887c853..108e645 100644
--- gpu/demos/framework/main_pepper.cc
+++ gpu/demos/framework/main_pepper.cc
@@ -106,7 +106,7 @@ NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value) {
   NPError err = NPERR_NO_ERROR;
 
   switch (variable) {
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
     case NPPVpluginNameString:
       *(static_cast<const char**>(value)) = "Pepper GPU Demo";
       break;
@@ -163,17 +163,17 @@ EXPORT NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) {
 }
 
 EXPORT NPError API_CALL NP_Initialize(NPNetscapeFuncs* browser_funcs
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
                                      , NPPluginFuncs* plugin_funcs
-#endif  // OS_LINUX
+#endif  // OS_NIX
                                      ) {
   g_at_exit_manager = new base::AtExitManager();
   gpu::demos::g_browser = browser_funcs;
   pglInitialize();
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   NP_GetEntryPoints(plugin_funcs);
-#endif  // OS_LINUX
+#endif  // OS_NIX
   return NPERR_NO_ERROR;
 }
 
@@ -182,7 +182,7 @@ EXPORT void API_CALL NP_Shutdown() {
   delete g_at_exit_manager;
 }
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 EXPORT NPError API_CALL NP_GetValue(NPP instance, NPPVariable variable,
                                     void* value) {
   return gpu::demos::NPP_GetValue(instance, variable, value);
@@ -191,5 +191,5 @@ EXPORT NPError API_CALL NP_GetValue(NPP instance, NPPVariable variable,
 EXPORT const char* API_CALL NP_GetMIMEDescription() {
   return "pepper-application/x-gpu-demo::Pepper GPU Demo";
 }
-#endif  // OS_LINUX
+#endif  // OS_NIX
 }  // extern "C"
diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp
index 6c9a525..efc5751 100644
--- gpu/gpu.gyp
+++ gpu/gpu.gyp
@@ -179,7 +179,7 @@
         'command_buffer/service/texture_manager.cc',
       ],
       'conditions': [
-        ['OS == "linux"', {
+        ['OS == "linux" or OS=="freebsd"', {
           'dependencies': [
             '../build/linux/system.gyp:gtk',
           ],
diff --git a/ipc/ipc.gyp b/ipc/ipc.gyp
index 5560abe..c393ba8 100644
--- ipc/ipc.gyp
+++ ipc/ipc.gyp
@@ -58,7 +58,7 @@
             '../build/linux/system.gyp:gtk',
           ],
         }],
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'conditions': [
             ['linux_use_tcmalloc==1', {
               'dependencies': [
diff --git a/ipc/sync_socket_unittest.cc b/ipc/sync_socket_unittest.cc
index e07fdf9..b6e3372 100644
--- ipc/sync_socket_unittest.cc
+++ ipc/sync_socket_unittest.cc
@@ -8,9 +8,9 @@
 #include <sstream>
 
 #include "base/message_loop.h"
-#if defined(OS_LINUX) || defined(OS_MACOSX)
+#if defined(OS_POSIX)
 #include "base/file_descriptor_posix.h"
-#endif  // defined(OS_LINUX) || defined(OS_MACOSX)
+#endif  // defined(OS_POSIX)
 #include "base/platform_thread.h"
 #include "base/process_util.h"
 #include "base/sync_socket.h"
diff --git a/media/base/media_switches.cc b/media/base/media_switches.cc
index 3b684ce..cd64c80 100644
--- media/base/media_switches.cc
+++ media/base/media_switches.cc
@@ -6,7 +6,7 @@
 
 namespace switches {
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 // The Alsa device to use when opening an audio stream.
 const char kAlsaDevice[] = "alsa-device";
 #endif
diff --git a/media/base/media_switches.h b/media/base/media_switches.h
index 6e0e0d3..69b264f 100644
--- media/base/media_switches.h
+++ media/base/media_switches.h
@@ -11,7 +11,7 @@
 
 namespace switches {
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 extern const char kAlsaDevice[];
 #endif
 
diff --git a/media/media.gyp b/media/media.gyp
index 7ef2bae..9d92635 100644
--- media/media.gyp
+++ media/media.gyp
@@ -435,7 +435,6 @@
           ],
           'link_settings': {
             'libraries': [
-              '-ldl',
               '-lX11',
               '-lXrender',
               '-lXext',
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc
index ffba57f..f567569 100644
--- net/base/host_resolver_impl.cc
+++ net/base/host_resolver_impl.cc
@@ -133,13 +133,11 @@ class HostResolveFailedParams : public NetLog::EventParameters {
 std::vector<int> GetAllGetAddrinfoOSErrors() {
   int os_errors[] = {
 #if defined(OS_POSIX)
-    EAI_ADDRFAMILY,
     EAI_AGAIN,
     EAI_BADFLAGS,
     EAI_FAIL,
     EAI_FAMILY,
     EAI_MEMORY,
-    EAI_NODATA,
     EAI_NONAME,
     EAI_SERVICE,
     EAI_SOCKTYPE,
@@ -726,7 +724,7 @@ HostResolverImpl::HostResolverImpl(
 #if defined(OS_WIN)
   EnsureWinsockInit();
 #endif
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   if (HaveOnlyLoopbackAddresses())
     additional_resolver_flags_ |= HOST_RESOLVER_LOOPBACK_ONLY;
 #endif
@@ -1059,7 +1057,7 @@ void HostResolverImpl::OnIPAddressChanged() {
     ipv6_probe_job_ = new IPv6ProbeJob(this);
     ipv6_probe_job_->Start();
   }
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   if (HaveOnlyLoopbackAddresses()) {
     additional_resolver_flags_ |= HOST_RESOLVER_LOOPBACK_ONLY;
   } else {
diff --git a/net/base/host_resolver_proc.cc b/net/base/host_resolver_proc.cc
index 804135c..08669e9 100644
--- net/base/host_resolver_proc.cc
+++ net/base/host_resolver_proc.cc
@@ -6,10 +6,6 @@
 
 #include "build/build_config.h"
 
-#if defined(OS_POSIX) && !defined(OS_MACOSX)
-#include <resolv.h>
-#endif
-
 #include "base/logging.h"
 #include "base/time.h"
 #include "net/base/address_list.h"
@@ -17,6 +13,7 @@
 #include "net/base/sys_addrinfo.h"
 
 #if defined(OS_POSIX) && !defined(OS_MACOSX)
+#include <resolv.h>
 #include "base/singleton.h"
 #include "base/thread_local_storage.h"
 #endif
diff --git a/net/base/listen_socket_unittest.cc b/net/base/listen_socket_unittest.cc
index b38019d..38c0812 100644
--- net/base/listen_socket_unittest.cc
+++ net/base/listen_socket_unittest.cc
@@ -5,6 +5,7 @@
 #include "net/base/listen_socket_unittest.h"
 
 #include <fcntl.h>
+#include <netinet/in.h>
 
 #include "base/eintr_wrapper.h"
 #include "net/base/net_util.h"
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index c7b6a6f..166bcf7 100644
--- net/base/net_util.cc
+++ net/base/net_util.cc
@@ -24,9 +24,9 @@
 #include <fcntl.h>
 #include <ifaddrs.h>
 #include <netdb.h>
+#include <sys/socket.h>
 #include <net/if.h>
 #include <netinet/in.h>
-#include <sys/socket.h>
 #endif
 
 #include "base/base64.h"
diff --git a/net/base/network_change_notifier.cc b/net/base/network_change_notifier.cc
index a0bc6b5..7db2396 100644
--- net/base/network_change_notifier.cc
+++ net/base/network_change_notifier.cc
@@ -37,7 +37,6 @@ NetworkChangeNotifier* NetworkChangeNotifier::Create() {
 #elif defined(OS_MACOSX)
   return new NetworkChangeNotifierMac();
 #else
-  NOTIMPLEMENTED();
   return NULL;
 #endif
 }
diff --git a/net/net.gyp b/net/net.gyp
index 98dc526..7fdddc9 100644
--- net/net.gyp
+++ net/net.gyp
@@ -115,11 +115,9 @@
         'base/net_util_win.cc',
         'base/network_change_notifier.cc',
         'base/network_change_notifier.h',
-        'base/network_change_notifier_linux.cc',
         'base/network_change_notifier_linux.h',
         'base/network_change_notifier_mac.cc',
         'base/network_change_notifier_mac.h',
-        'base/network_change_notifier_netlink_linux.cc',
         'base/network_change_notifier_netlink_linux.h',
         'base/network_change_notifier_win.cc',
         'base/network_change_notifier_win.h',
@@ -579,6 +577,7 @@
           ],
         }],
         [ 'OS == "linux" or OS == "freebsd" or OS == "openbsd"', {
+            'sources!': [ 'proxy/proxy_config_service_linux.cc', ],
             'dependencies': [
               '../build/linux/system.gyp:gconf',
               '../build/linux/system.gyp:gdk',
@@ -742,7 +741,6 @@
         'proxy/mock_proxy_resolver.h',
         'proxy/multi_threaded_proxy_resolver_unittest.cc',
         'proxy/proxy_bypass_rules_unittest.cc',
-        'proxy/proxy_config_service_linux_unittest.cc',
         'proxy/proxy_config_service_win_unittest.cc',
         'proxy/proxy_config_unittest.cc',
         'proxy/proxy_list_unittest.cc',
@@ -795,7 +793,7 @@
             ],
           },
         ],
-        ['OS == "linux"', {
+        ['OS == "linux" or OS == "freebsd"', {
           'conditions': [
             ['linux_use_tcmalloc==1', {
               'dependencies': [
@@ -930,7 +928,7 @@
             '../build/linux/system.gyp:nss',
           ],
         }],
-        ['OS == "linux"', {
+        ['OS == "linux" or OS == "freebsd"', {
           'conditions': [
             ['linux_use_tcmalloc==1', {
               'dependencies': [
diff --git a/printing/printing.gyp b/printing/printing.gyp
index ec1872a..649e500 100644
--- printing/printing.gyp
+++ printing/printing.gyp
@@ -103,7 +103,7 @@
         'units_unittest.cc',
       ],
       'conditions': [
-        ['OS!="linux"', {'sources/': [['exclude', '_cairo_unittest\\.cc$']]}],
+        ['OS!="linux" and OS!="freebsd"', {'sources/': [['exclude', '_cairo_unittest\\.cc$']]}],
         ['OS!="mac"', {'sources/': [['exclude', '_mac_unittest\\.(cc|mm?)$']]}],
         ['OS!="win"', {'sources/': [['exclude', '_win_unittest\\.cc$']]
           }, {  # else: OS=="win"
@@ -114,14 +114,12 @@
             'dependencies': [
               '../build/linux/system.gyp:gtk',
            ],
-        }],
-        ['OS=="linux"', {
-          'conditions': [
-            ['linux_use_tcmalloc==1', {
+            'conditions': [
+              ['linux_use_tcmalloc==1', {
               'dependencies': [
                 '../base/allocator/allocator.gyp:allocator',
-              ],
-            }],
+                ],
+              }],
           ],
         }],
       ],
diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc
index 035fa32..8efbd2b 100644
--- remoting/host/simple_host_process.cc
+++ remoting/host/simple_host_process.cc
@@ -34,7 +34,7 @@
 #if defined(OS_WIN)
 #include "remoting/host/capturer_gdi.h"
 #include "remoting/host/event_executor_win.h"
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
 #include "remoting/host/capturer_linux.h"
 #include "remoting/host/event_executor_linux.h"
 #elif defined(OS_MACOSX)
@@ -77,7 +77,7 @@ int main(int argc, char** argv) {
 #if defined(OS_WIN)
   capturer.reset(new remoting::CapturerGdi());
   executor.reset(new remoting::EventExecutorWin());
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
   capturer.reset(new remoting::CapturerLinux());
   executor.reset(new remoting::EventExecutorLinux());
 #elif defined(OS_MACOSX)
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index bda9e60..cf19115 100644
--- remoting/remoting.gyp
+++ remoting/remoting.gyp
@@ -16,7 +16,7 @@
   },
 
   'conditions': [
-    ['OS=="linux" or OS=="mac"', {
+    ['OS=="linux" or OS=="freebsd" or OS=="mac"', {
       'targets': [
         # Simple webserver for testing chromoting client plugin.
         {
@@ -187,7 +187,7 @@
             'host/event_executor_win.h',
           ],
         }],
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'sources': [
             'host/capturer_linux.cc',
             'host/capturer_linux.h',
@@ -374,7 +374,7 @@
             'host/capturer_gdi_unittest.cc',
           ],
         }],
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'dependencies': [
             # Needed for the following #include chain:
             #   base/run_all_unittests.cc
diff --git a/third_party/glew/src/glew.c b/third_party/glew/src/glew.c
index 8d89d8a..00b011a 100644
--- third_party/glew/src/glew.c
+++ third_party/glew/src/glew.c
@@ -162,7 +162,7 @@ void* NSGLGetProcAddress (const GLubyte *name)
 }
 #endif /* __APPLE__ */
 
-#if defined(__sgi) || defined (__sun) || defined(__linux__)
+#if defined(__sgi) || defined (__sun) || defined(__linux__) || defined(__FreeBSD__)
 #include <dlfcn.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -198,7 +198,7 @@ void* dlGetProcAddress (const GLubyte* name)
 #  if defined(__APPLE__)
 #    define glewGetProcAddress(name) NSGLGetProcAddress(name)
 #  else
-#    if defined(__sgi) || defined(__sun) || defined(__linux__)
+#    if defined(__sgi) || defined(__sun) || defined(__linux__) || defined(__FreeBSD__)
 #      define glewGetProcAddress(name) dlGetProcAddress(name)
 #    else /* Used to use this for Linux, but no longer */
 #      define glewGetProcAddress(name) (*glXGetProcAddressARB)(name)
diff --git a/third_party/libevent/event-config.h b/third_party/libevent/event-config.h
index 66a53de..d3b8486 100644
--- third_party/libevent/event-config.h
+++ third_party/libevent/event-config.h
@@ -9,6 +9,8 @@
 #include "mac/event-config.h"
 #elif defined(__linux__)
 #include "linux/event-config.h"
+#elif defined(__FreeBSD__)
+#include "freebsd/event-config.h"
 #else
 #error generate event-config.h for your platform
 #endif
diff --git a/third_party/libevent/freebsd/event-config.h b/third_party/libevent/freebsd/event-config.h
new file mode 100644
index 0000000..1e0ae89
--- /dev/null
+++ third_party/libevent/freebsd/event-config.h
@@ -0,0 +1,262 @@
+/* event-config.h
+ * Generated by autoconf; post-processed by libevent.
+ * Do not edit this file.
+ * Do not rely on macros in this file existing in later versions.
+ */
+#ifndef _EVENT_CONFIG_H_
+#define _EVENT_CONFIG_H_
+/* config.h.  Generated from config.h.in by configure.  */
+/* config.h.in.  Generated from configure.in by autoheader.  */
+
+/* Define if clock_gettime is available in libc */
+#define _EVENT_DNS_USE_CPU_CLOCK_FOR_ID 1
+
+/* Define is no secure id variant is available */
+/* #undef _EVENT_DNS_USE_GETTIMEOFDAY_FOR_ID */
+
+/* Define to 1 if you have the `clock_gettime' function. */
+#define _EVENT_HAVE_CLOCK_GETTIME 1
+
+/* Define if /dev/poll is available */
+/* #undef _EVENT_HAVE_DEVPOLL */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define _EVENT_HAVE_DLFCN_H 1
+
+/* Define if your system supports the epoll system calls */
+/* #undef _EVENT_HAVE_EPOLL */
+
+/* Define to 1 if you have the `epoll_ctl' function. */
+/* #undef _EVENT_HAVE_EPOLL_CTL */
+
+/* Define if your system supports event ports */
+/* #undef _EVENT_HAVE_EVENT_PORTS */
+
+/* Define to 1 if you have the `fcntl' function. */
+#define _EVENT_HAVE_FCNTL 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define _EVENT_HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the `getaddrinfo' function. */
+#define _EVENT_HAVE_GETADDRINFO 1
+
+/* Define to 1 if you have the `getnameinfo' function. */
+#define _EVENT_HAVE_GETNAMEINFO 1
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#define _EVENT_HAVE_GETTIMEOFDAY 1
+
+/* Define to 1 if you have the `inet_ntop' function. */
+#define _EVENT_HAVE_INET_NTOP 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define _EVENT_HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `kqueue' function. */
+#define _EVENT_HAVE_KQUEUE 1
+
+/* Define to 1 if you have the `nsl' library (-lnsl). */
+/* #undef _EVENT_HAVE_LIBNSL */
+
+/* Define to 1 if you have the `resolv' library (-lresolv). */
+/* #undef _EVENT_HAVE_LIBRESOLV */
+
+/* Define to 1 if you have the `rt' library (-lrt). */
+#define _EVENT_HAVE_LIBRT 1
+
+/* Define to 1 if you have the `socket' library (-lsocket). */
+/* #undef _EVENT_HAVE_LIBSOCKET */
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define _EVENT_HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the <netinet/in6.h> header file. */
+/* #undef _EVENT_HAVE_NETINET_IN6_H */
+
+/* Define to 1 if you have the `poll' function. */
+#define _EVENT_HAVE_POLL 1
+
+/* Define to 1 if you have the <poll.h> header file. */
+#define _EVENT_HAVE_POLL_H 1
+
+/* Define to 1 if you have the `port_create' function. */
+/* #undef _EVENT_HAVE_PORT_CREATE */
+
+/* Define to 1 if you have the <port.h> header file. */
+/* #undef _EVENT_HAVE_PORT_H */
+
+/* Define to 1 if you have the `select' function. */
+#define _EVENT_HAVE_SELECT 1
+
+/* Define if F_SETFD is defined in <fcntl.h> */
+#define _EVENT_HAVE_SETFD 1
+
+/* Define to 1 if you have the `sigaction' function. */
+#define _EVENT_HAVE_SIGACTION 1
+
+/* Define to 1 if you have the `signal' function. */
+#define _EVENT_HAVE_SIGNAL 1
+
+/* Define to 1 if you have the <signal.h> header file. */
+#define _EVENT_HAVE_SIGNAL_H 1
+
+/* Define to 1 if you have the <stdarg.h> header file. */
+#define _EVENT_HAVE_STDARG_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define _EVENT_HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define _EVENT_HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define _EVENT_HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define _EVENT_HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strlcpy' function. */
+#define _EVENT_HAVE_STRLCPY 1
+
+/* Define to 1 if you have the `strsep' function. */
+#define _EVENT_HAVE_STRSEP 1
+
+/* Define to 1 if you have the `strtok_r' function. */
+#define _EVENT_HAVE_STRTOK_R 1
+
+/* Define to 1 if you have the `strtoll' function. */
+#define _EVENT_HAVE_STRTOLL 1
+
+/* Define to 1 if the system has the type `struct in6_addr'. */
+#define _EVENT_HAVE_STRUCT_IN6_ADDR 1
+
+/* Define to 1 if you have the <sys/devpoll.h> header file. */
+/* #undef _EVENT_HAVE_SYS_DEVPOLL_H */
+
+/* Define to 1 if you have the <sys/epoll.h> header file. */
+/* #undef _EVENT_HAVE_SYS_EPOLL_H */
+
+/* Define to 1 if you have the <sys/event.h> header file. */
+#define _EVENT_HAVE_SYS_EVENT_H 1
+
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+#define _EVENT_HAVE_SYS_IOCTL_H 1
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#define _EVENT_HAVE_SYS_PARAM_H 1
+
+/* Define to 1 if you have the <sys/queue.h> header file. */
+#define _EVENT_HAVE_SYS_QUEUE_H 1
+
+/* Define to 1 if you have the <sys/select.h> header file. */
+#define _EVENT_HAVE_SYS_SELECT_H 1
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#define _EVENT_HAVE_SYS_SOCKET_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define _EVENT_HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define _EVENT_HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define _EVENT_HAVE_SYS_TYPES_H 1
+
+/* Define if TAILQ_FOREACH is defined in <sys/queue.h> */
+#define _EVENT_HAVE_TAILQFOREACH 1
+
+/* Define if timeradd is defined in <sys/time.h> */
+#define _EVENT_HAVE_TIMERADD 1
+
+/* Define if timerclear is defined in <sys/time.h> */
+#define _EVENT_HAVE_TIMERCLEAR 1
+
+/* Define if timercmp is defined in <sys/time.h> */
+#define _EVENT_HAVE_TIMERCMP 1
+
+/* Define if timerisset is defined in <sys/time.h> */
+#define _EVENT_HAVE_TIMERISSET 1
+
+/* Define to 1 if the system has the type `uint16_t'. */
+#define _EVENT_HAVE_UINT16_T 1
+
+/* Define to 1 if the system has the type `uint32_t'. */
+#define _EVENT_HAVE_UINT32_T 1
+
+/* Define to 1 if the system has the type `uint64_t'. */
+#define _EVENT_HAVE_UINT64_T 1
+
+/* Define to 1 if the system has the type `uint8_t'. */
+#define _EVENT_HAVE_UINT8_T 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define _EVENT_HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `vasprintf' function. */
+#define _EVENT_HAVE_VASPRINTF 1
+
+/* Define if kqueue works correctly with pipes */
+#define _EVENT_HAVE_WORKING_KQUEUE 1
+
+/* Name of package */
+#define _EVENT_PACKAGE "libevent"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define _EVENT_PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define _EVENT_PACKAGE_NAME ""
+
+/* Define to the full name and version of this package. */
+#define _EVENT_PACKAGE_STRING ""
+
+/* Define to the one symbol short name of this package. */
+#define _EVENT_PACKAGE_TARNAME ""
+
+/* Define to the version of this package. */
+#define _EVENT_PACKAGE_VERSION ""
+
+/* The size of `int', as computed by sizeof. */
+#define _EVENT_SIZEOF_INT 4
+
+/* The size of `long', as computed by sizeof. */
+#define _EVENT_SIZEOF_LONG 8
+
+/* The size of `long long', as computed by sizeof. */
+#define _EVENT_SIZEOF_LONG_LONG 8
+
+/* The size of `short', as computed by sizeof. */
+#define _EVENT_SIZEOF_SHORT 2
+
+/* Define to 1 if you have the ANSI C header files. */
+#define _EVENT_STDC_HEADERS 1
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#define _EVENT_TIME_WITH_SYS_TIME 1
+
+/* Version number of package */
+#define _EVENT_VERSION "1.4.13-stable"
+
+/* Define to appropriate substitue if compiler doesnt have __func__ */
+/* #undef _EVENT___func__ */
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef _EVENT_const */
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef _EVENT___cplusplus
+/* #undef _EVENT_inline */
+#endif
+
+/* Define to `int' if <sys/types.h> does not define. */
+/* #undef _EVENT_pid_t */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef _EVENT_size_t */
+
+/* Define to unsigned int if you dont have it */
+/* #undef _EVENT_socklen_t */
+#endif
diff --git a/third_party/libxslt/libxslt.gyp b/third_party/libxslt/libxslt.gyp
index cc6a377..632749b 100644
--- third_party/libxslt/libxslt.gyp
+++ third_party/libxslt/libxslt.gyp
@@ -21,7 +21,7 @@
     {
       'target_name': 'libxslt',
       'conditions': [
-        ['OS=="linux" and use_system_libxml', {
+        ['(OS=="linux" or OS=="freebsd") and use_system_libxml', {
           'type': 'settings',
           'direct_dependent_settings': {
             'cflags': [
diff --git a/third_party/mesa/mesa.gyp b/third_party/mesa/mesa.gyp
index 277add5..23185e5 100644
--- third_party/mesa/mesa.gyp
+++ third_party/mesa/mesa.gyp
@@ -7,7 +7,7 @@
   },
   'target_defaults': {
     'conditions': [
-      ['OS=="linux"', {
+      ['OS=="linux" or OS=="freebsd"', {
         'cflags': [
           '-fPIC',
         ],
diff --git a/third_party/tcmalloc/chromium/src/config.h b/third_party/tcmalloc/chromium/src/config.h
index 812c67c..047b878 100644
--- third_party/tcmalloc/chromium/src/config.h
+++ third_party/tcmalloc/chromium/src/config.h
@@ -15,6 +15,8 @@
 #include "third_party/tcmalloc/chromium/src/config_win.h"
 #elif defined(OS_LINUX)
 #include "third_party/tcmalloc/chromium/src/config_linux.h"
+#elif defined(OS_FREEBSD)
+#include "third_party/tcmalloc/chromium/src/config_freebsd.h"
 #endif
 
 #endif // CONFIG_H_
diff --git a/third_party/tcmalloc/chromium/src/config_freebsd.h b/third_party/tcmalloc/chromium/src/config_freebsd.h
new file mode 100644
index 0000000..d286c35
--- /dev/null
+++ third_party/tcmalloc/chromium/src/config_freebsd.h
@@ -0,0 +1,234 @@
+/* src/config.h.  Generated from config.h.in by configure.  */
+/* src/config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to 1 if compiler supports __builtin_stack_pointer */
+/* #undef HAVE_BUILTIN_STACK_POINTER */
+
+/* Define to 1 if you have the <conflict-signal.h> header file. */
+/* #undef HAVE_CONFLICT_SIGNAL_H */
+
+/* Define to 1 if you have the declaration of `cfree', and to 0 if you don't.
+   */
+#define HAVE_DECL_CFREE 0
+
+/* Define to 1 if you have the declaration of `memalign', and to 0 if you
+   don't. */
+#define HAVE_DECL_MEMALIGN 0
+
+/* Define to 1 if you have the declaration of `posix_memalign', and to 0 if
+   you don't. */
+#define HAVE_DECL_POSIX_MEMALIGN 0
+
+/* Define to 1 if you have the declaration of `pvalloc', and to 0 if you
+   don't. */
+#define HAVE_DECL_PVALLOC 0
+
+/* Define to 1 if you have the declaration of `uname', and to 0 if you don't.
+   */
+#define HAVE_DECL_UNAME 1
+
+/* Define to 1 if you have the declaration of `valloc', and to 0 if you don't.
+   */
+#define HAVE_DECL_VALLOC 0
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if the system has the type `Elf32_Versym'. */
+#define HAVE_ELF32_VERSYM 1
+
+/* Define to 1 if you have the <execinfo.h> header file. */
+#define HAVE_EXECINFO_H 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the <features.h> header file. */
+/* #undef HAVE_FEATURES_H */
+
+/* Define to 1 if you have the `geteuid' function. */
+#define HAVE_GETEUID 1
+
+/* Define to 1 if you have the `getpagesize' function. */
+#define HAVE_GETPAGESIZE 1
+
+/* Define to 1 if you have the <glob.h> header file. */
+#define HAVE_GLOB_H 1
+
+/* Define to 1 if you have the <grp.h> header file. */
+#define HAVE_GRP_H 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <libunwind.h> header file. */
+/* #undef HAVE_LIBUNWIND_H */
+
+/* Define to 1 if you have the <linux/ptrace.h> header file. */
+/* #undef HAVE_LINUX_PTRACE_H */
+
+/* Define to 1 if you have the <malloc.h> header file. */
+/* #undef HAVE_MALLOC_H */
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have a working `mmap' system call. */
+#define HAVE_MMAP 1
+
+/* define if the compiler implements namespaces */
+#define HAVE_NAMESPACES 1
+
+/* Define to 1 if you have the <poll.h> header file. */
+#define HAVE_POLL_H 1
+
+/* define if libc has program_invocation_name */
+/* #undef HAVE_PROGRAM_INVOCATION_NAME */
+
+/* Define if you have POSIX threads libraries and header files. */
+#define HAVE_PTHREAD 1
+
+/* Define to 1 if you have the <pwd.h> header file. */
+#define HAVE_PWD_H 1
+
+/* Define to 1 if you have the `sbrk' function. */
+#define HAVE_SBRK 1
+
+/* Define to 1 if you have the <sched.h> header file. */
+#define HAVE_SCHED_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if the system has the type `struct mallinfo'. */
+/* #undef HAVE_STRUCT_MALLINFO */
+
+/* Define to 1 if you have the <sys/prctl.h> header file. */
+/* #undef HAVE_SYS_PRCTL_H */
+
+/* Define to 1 if you have the <sys/resource.h> header file. */
+#define HAVE_SYS_RESOURCE_H 1
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#define HAVE_SYS_SOCKET_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/syscall.h> header file. */
+#define HAVE_SYS_SYSCALL_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <sys/wait.h> header file. */
+#define HAVE_SYS_WAIT_H 1
+
+/* Define to 1 if compiler supports __thread */
+#define HAVE_TLS 1
+
+/* Define to 1 if you have the <ucontext.h> header file. */
+#define HAVE_UCONTEXT_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the <unwind.h> header file. */
+/* #undef HAVE_UNWIND_H */
+
+/* define if your compiler has __attribute__ */
+#define HAVE___ATTRIBUTE__ 1
+
+/* Define to 1 if the system has the type `__int64'. */
+/* #undef HAVE___INT64 */
+
+/* prefix where we look for installed files */
+#define INSTALL_PREFIX "/usr/local"
+
+/* Define to 1 if int32_t is equivalent to intptr_t */
+/* #undef INT32_EQUALS_INTPTR */
+#if defined(__i386__)
+#define INT32_EQUALS_INTPTR 1
+#endif
+
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+/* #undef NO_MINUS_C_MINUS_O */
+
+/* Name of package */
+#define PACKAGE "google-perftools"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "opensource@google.com"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "google-perftools"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "google-perftools 1.3"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "google-perftools"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.3"
+
+/* How to access the PC from a struct ucontext */
+#if defined(__i386__)
+#define PC_FROM_UCONTEXT uc_mcontext.mc_eip
+#else
+#define PC_FROM_UCONTEXT uc_mcontext.mc_rip
+#endif
+
+/* Always the empty-string on non-windows systems. On windows, should be
+   "__declspec(dllexport)". This way, when we compile the dll, we export our
+   functions/classes. It's safe to define this here because config.h is only
+   used internally, to compile the DLL, and every DLL source file #includes
+   "config.h" before anything else. */
+#define PERFTOOLS_DLL_DECL
+
+/* printf format code for printing a size_t and ssize_t */
+#define PRIdS "zd"
+
+/* printf format code for printing a size_t and ssize_t */
+#define PRIuS "zu"
+
+/* printf format code for printing a size_t and ssize_t */
+#define PRIxS "zx"
+
+/* Define to necessary symbol if this constant uses a non-standard name on
+   your system. */
+/* #undef PTHREAD_CREATE_JOINABLE */
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* the namespace where STL code like vector<> is defined */
+#define STL_NAMESPACE std
+
+/* Version number of package */
+#define VERSION "1.3"
+
+/* C99 says: define this to get the PRI... macros from stdint.h */
+#ifndef __STDC_FORMAT_MACROS
+# define __STDC_FORMAT_MACROS 1
+#endif
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+/* #undef inline */
+#endif
+
+
+#ifdef __MINGW32__
+#include "windows/mingw.h"
+#endif
diff --git a/webkit/glue/plugins/pepper_font.cc b/webkit/glue/plugins/pepper_font.cc
index 8bc48a3..1d7a655 100644
--- webkit/glue/plugins/pepper_font.cc
+++ webkit/glue/plugins/pepper_font.cc
@@ -6,7 +6,7 @@
 
 #include "webkit/glue/plugins/pepper_font.h"
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #include <unistd.h>
 #endif
 
@@ -21,7 +21,7 @@ namespace {
 
 PP_Resource MatchFontWithFallback(PP_Module module_id,
                                   const PP_FontDescription* description) {
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   PluginModule* module = PluginModule::FromPPModule(module_id);
   if (!module)
     return NULL;
@@ -73,7 +73,7 @@ Font::Font(PluginModule* module, int fd)
 }
 
 Font::~Font() {
-#if defined (OS_LINUX)
+#if defined (OS_NIX)
   close(fd_);
 #endif
 }
@@ -86,7 +86,7 @@ const PPB_Font* Font::GetInterface() {
 bool Font::GetFontTable(uint32_t table,
                         void* output,
                         uint32_t* output_length) {
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   size_t temp_size = static_cast<size_t>(*output_length);
   bool rv = webkit_glue::GetFontTable(
       fd_, table, static_cast<uint8_t*>(output), &temp_size);
diff --git a/webkit/glue/plugins/pepper_plugin_instance.cc b/webkit/glue/plugins/pepper_plugin_instance.cc
index dcc7ea2..215241e 100644
--- webkit/glue/plugins/pepper_plugin_instance.cc
+++ webkit/glue/plugins/pepper_plugin_instance.cc
@@ -228,10 +228,10 @@ PluginInstance::PluginInstance(PluginDelegate* delegate,
       find_identifier_(-1),
       plugin_find_interface_(NULL),
       plugin_zoom_interface_(NULL),
-#if defined (OS_LINUX)
+#if defined (OS_NIX)
       num_pages_(0),
       pdf_output_done_(false),
-#endif  // defined (OS_LINUX)
+#endif  // defined (OS_NIX)
       plugin_print_interface_(NULL) {
   memset(&current_print_settings_, 0, sizeof(current_print_settings_));
   DCHECK(delegate);
@@ -542,17 +542,17 @@ int PluginInstance::PrintBegin(const gfx::Rect& printable_area,
   if (!num_pages)
     return 0;
   current_print_settings_ = print_settings;
-#if defined (OS_LINUX)
+#if defined (OS_NIX)
   num_pages_ = num_pages;
   pdf_output_done_ = false;
-#endif  // (OS_LINUX)
+#endif  // (OS_NIX)
   return num_pages;
 }
 
 bool PluginInstance::PrintPage(int page_number, WebKit::WebCanvas* canvas) {
   DCHECK(plugin_print_interface_);
   PP_PrintPageNumberRange page_range;
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF) {
     // On Linux we will try and output all pages as PDF in the first call to
     // PrintPage. This is a temporary hack.
@@ -563,9 +563,9 @@ bool PluginInstance::PrintPage(int page_number, WebKit::WebCanvas* canvas) {
     page_range.first_page_number = 0;
     page_range.last_page_number = num_pages_ - 1;
   }
-#else  // defined(OS_LINUX)
+#else  // defined(OS_NIX)
   page_range.first_page_number = page_range.last_page_number = page_number;
-#endif  // defined(OS_LINUX)
+#endif  // defined(OS_NIX)
 
   PP_Resource print_output =
       plugin_print_interface_->PrintPages(GetPPInstance(), &page_range, 1);
@@ -593,10 +593,10 @@
   memset(&current_print_settings_, 0, sizeof(current_print_settings_));
 #if defined(OS_MACOSX)
   last_printed_page_ = NULL;
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
   num_pages_ = 0;
   pdf_output_done_ = false;
-#endif  // defined(OS_LINUX)
+#endif  // defined(OS_NIX)
 }

 bool PluginInstance::PrintPDFOutput(PP_Resource print_output,
@@ -619,7 +619,7 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output,
 #endif  // defined(OS_WIN)
 
   bool ret = false;
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
   // On Linux we need to get the backing PdfPsMetafile and write the bits
   // directly.
   cairo_t* context = canvas->beginPlatformPaint();
diff --git a/webkit/glue/plugins/pepper_plugin_instance.h b/webkit/glue/plugins/pepper_plugin_instance.h
index 4528a99..96d9c29 100644
--- webkit/glue/plugins/pepper_plugin_instance.h
+++ webkit/glue/plugins/pepper_plugin_instance.h
@@ -184,7 +184,7 @@
   // to keep the pixels valid until CGContextEndPage is called. We use this
   // variable to hold on to the pixels.
   scoped_refptr<ImageData> last_printed_page_;
-#elif defined(OS_LINUX)
+#elif defined(OS_NIX)
   // On Linux, we always send all pages from the renderer to the browser.
   // So, if the plugin supports printPagesAsPDF we print the entire output
   // in one shot in the first call to PrintPage.
@@ -195,7 +195,7 @@
   // Specifies whether we have already output all pages. This is used to ignore
   // subsequent PrintPage requests.
   bool pdf_output_done_;
-#endif  // defined(OS_LINUX)
+#endif  // defined(OS_NIX)

   // The plugin print interface.
   const PPP_Printing* plugin_print_interface_;
diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h
index 541836b..5d3b64c 100644
--- webkit/glue/webkit_glue.h
+++ webkit/glue/webkit_glue.h
@@ -265,7 +265,7 @@ std::string GetProductVersion();
 // Returns true if the embedder is running in single process mode.
 bool IsSingleProcess();
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 // Return a read-only file descriptor to the font which best matches the given
 // properties or -1 on failure.
 //   charset: specifies the language(s) that the font must cover. See
diff --git a/webkit/glue/webkitclient_impl.cc b/webkit/glue/webkitclient_impl.cc
index b05e7d9..9bcb0dd 100644
--- webkit/glue/webkitclient_impl.cc
+++ webkit/glue/webkitclient_impl.cc
@@ -37,7 +37,7 @@
 #include "webkit/glue/websocketstreamhandle_impl.h"
 #include "webkit/glue/weburlloader_impl.h"
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 #include "v8/include/v8.h"
 #endif
 
diff --git a/webkit/support/webkit_support_glue.cc b/webkit/support/webkit_support_glue.cc
index bae6374..6f13174 100644
--- webkit/support/webkit_support_glue.cc
+++ webkit/support/webkit_support_glue.cc
@@ -72,7 +72,7 @@ bool IsSingleProcess() {
   return true;
 }
 
-#if defined(OS_LINUX)
+#if defined(OS_NIX)
 int MatchFontWithFallback(const std::string& face, bool bold,
                           bool italic, int charset) {
   return -1;
