Revert 157667 - Add new PathService paths for Windows' All Users Desktop and Quick Launch folders.

The previous patch failed PathServiceTest.Get.

This allows usage of PathService to cache the paths and more importantly to mock them in shortcut tests!

Also move chrome::DIR_USER_DESKTOP to base::DIR_USER_DESKTOP; this is really where it belongs. In fact it is only in chrome_paths.h because it used to be called DIR_DEFAULT_DOWNLOAD and cpu@ renamed it to DIR_USER_DESKTOP in http://crrev.com/1753 (early days!) after that it started to be used all over the place as the Desktop path. Finally bringing it to base_paths.h, beside DIR_START_MENU and friends, is the right thing to do imo.

BUG=148539
TEST=Quick Launch shortcut installed in the right place on XP (both Default and current user)
Desktop shortcuts installed in the right place (both All Users and per-user installs).

installer_util_unittests.exe --gtest_filter=ShellUtilShortcutTest*
unit_tests.exe --gtest_filter=ProfileShortcutManagerTest*
base_unittests --gtest_filter=PathServiceTest*

Review URL: https://chromiumcodereview.appspot.com/10910209

TBR=gab@chromium.org
Review URL: https://codereview.chromium.org/10958009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157680 0039d316-1c4b-4281-b951-d872f2087c98


CrOS-Libchrome-Original-Commit: 1f4ae1659132f11a99e4425efdc517838e21b7ae
diff --git a/base/base.gypi b/base/base.gypi
index c4e14ad..0652249 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -63,7 +63,6 @@
           'base_paths_mac.h',
           'base_paths_mac.mm',
           'base_paths_posix.cc',
-          'base_paths_posix.h',
           'base_paths_win.cc',
           'base_paths_win.h',
           'base_switches.h',
diff --git a/base/base_paths.cc b/base/base_paths.cc
index 80105b6..1beb9c7 100644
--- a/base/base_paths.cc
+++ b/base/base_paths.cc
@@ -11,7 +11,7 @@
 namespace base {
 
 bool PathProvider(int key, FilePath* result) {
-  // NOTE: DIR_CURRENT is a special case in PathService::Get
+  // NOTE: DIR_CURRENT is a special cased in PathService::Get
 
   FilePath cur;
   switch (key) {
diff --git a/base/base_paths.h b/base/base_paths.h
index 3251a84..39edd16 100644
--- a/base/base_paths.h
+++ b/base/base_paths.h
@@ -18,10 +18,6 @@
 #include "base/base_paths_android.h"
 #endif
 
-#if defined(OS_POSIX)
-#include "base/base_paths_posix.h"
-#endif
-
 namespace base {
 
 enum BasePathKey {
@@ -38,7 +34,17 @@
   DIR_SOURCE_ROOT,  // Returns the root of the source tree.  This key is useful
                     // for tests that need to locate various resources.  It
                     // should not be used outside of test code.
-  DIR_USER_DESKTOP,  // The current user's Desktop.
+#if defined(OS_POSIX)
+  DIR_CACHE,    // Directory where to put cache data.  Note this is
+                // *not* where the browser cache lives, but the
+                // browser cache can be a subdirectory.
+                // This is $XDG_CACHE_HOME on Linux and
+                // ~/Library/Caches on Mac.
+  DIR_HOME,     // $HOME on POSIX-like systems.
+#endif
+#if defined(OS_ANDROID)
+  DIR_ANDROID_EXTERNAL_STORAGE,  // Android external storage directory.
+#endif
 
   PATH_END
 };
diff --git a/base/base_paths_android.cc b/base/base_paths_android.cc
index ab14ee3..f631c61 100644
--- a/base/base_paths_android.cc
+++ b/base/base_paths_android.cc
@@ -2,14 +2,12 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// Defines base::PathProviderAndroid which replaces base::PathProviderPosix for
-// Android in base/path_service.cc.
+#include "base/base_paths.h"
 
 #include <unistd.h>
 
 #include "base/android/jni_android.h"
 #include "base/android/path_utils.h"
-#include "base/base_paths.h"
 #include "base/file_path.h"
 #include "base/file_util.h"
 #include "base/logging.h"
@@ -30,38 +28,42 @@
       *result = FilePath(bin_dir);
       return true;
     }
-    case base::FILE_MODULE:
+    case base::FILE_MODULE: {
       // dladdr didn't work in Android as only the file name was returned.
       NOTIMPLEMENTED();
       return false;
-    case base::DIR_MODULE:
+    }
+    case base::DIR_MODULE: {
       *result = FilePath(base::android::GetNativeLibraryDirectory());
       return true;
-    case base::DIR_SOURCE_ROOT:
+    }
+    case base::DIR_SOURCE_ROOT: {
       // This const is only used for tests.
       *result = FilePath(base::android::GetExternalStorageDirectory());
       return true;
-    case base::DIR_USER_DESKTOP:
-      // Android doesn't support GetUserDesktop.
-      NOTIMPLEMENTED();
-      return false;
-    case base::DIR_CACHE:
+    }
+    case base::DIR_CACHE: {
       *result = FilePath(base::android::GetCacheDirectory());
       return true;
-    case base::DIR_ANDROID_APP_DATA:
+    }
+    case base::DIR_ANDROID_APP_DATA: {
       *result = FilePath(base::android::GetDataDirectory());
       return true;
-    case base::DIR_HOME:
+    }
+    case base::DIR_HOME: {
       *result = file_util::GetHomeDir();
       return true;
-    case base::DIR_ANDROID_EXTERNAL_STORAGE:
+    }
+    case base::DIR_ANDROID_EXTERNAL_STORAGE: {
       *result = FilePath(base::android::GetExternalStorageDirectory());
       return true;
-    default:
+    }
+    default: {
       // Note: the path system expects this function to override the default
       // behavior. So no need to log an error if we don't support a given
       // path. The system will just use the default.
       return false;
+    }
   }
 }
 
diff --git a/base/base_paths_android.h b/base/base_paths_android.h
index 7a9ac4a..8e59b87 100644
--- a/base/base_paths_android.h
+++ b/base/base_paths_android.h
@@ -15,7 +15,6 @@
   PATH_ANDROID_START = 300,
 
   DIR_ANDROID_APP_DATA,  // Directory where to put Android app's data.
-  DIR_ANDROID_EXTERNAL_STORAGE,  // Android external storage directory.
 
   PATH_ANDROID_END
 };
diff --git a/base/base_paths_posix.cc b/base/base_paths_posix.cc
index 834dee3..95e7585 100644
--- a/base/base_paths_posix.cc
+++ b/base/base_paths_posix.cc
@@ -2,14 +2,12 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// Defines base::PathProviderPosix, default path provider on POSIX OSes that
-// don't have their own base_paths_OS.cc implementation (i.e. all but Mac and
-// Android).
+#include "base/base_paths.h"
 
 #include <ostream>
 #include <string>
 
-#include "base/base_paths.h"
+#include "build/build_config.h"
 #include "base/environment.h"
 #include "base/file_path.h"
 #include "base/file_util.h"
@@ -18,7 +16,6 @@
 #include "base/path_service.h"
 #include "base/process_util.h"
 #include "base/nix/xdg_util.h"
-#include "build/build_config.h"
 
 #if defined(OS_FREEBSD)
 #include <sys/param.h>
@@ -99,9 +96,6 @@
                   << "Try running from your chromium/src directory.";
       return false;
     }
-    case base::DIR_USER_DESKTOP:
-      *result = base::nix::GetXDGUserDirectory("DESKTOP", "Desktop");
-      return true;
     case base::DIR_CACHE: {
       scoped_ptr<base::Environment> env(base::Environment::Create());
       FilePath cache_dir(base::nix::GetXDGDirectory(env.get(), "XDG_CACHE_HOME",
@@ -109,9 +103,10 @@
       *result = cache_dir;
       return true;
     }
-    case base::DIR_HOME:
+    case base::DIR_HOME: {
       *result = file_util::GetHomeDir();
       return true;
+    }
   }
   return false;
 }
diff --git a/base/base_paths_posix.h b/base/base_paths_posix.h
deleted file mode 100644
index 811c8cb..0000000
--- a/base/base_paths_posix.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef BASE_BASE_PATHS_POSIX_H_
-#define BASE_BASE_PATHS_POSIX_H_
-
-// This file declares windows-specific path keys for the base module.
-// These can be used with the PathService to access various special
-// directories and files.
-
-namespace base {
-
-enum {
-  PATH_POSIX_START = 400,
-
-  DIR_CACHE,    // Directory where to put cache data.  Note this is
-                // *not* where the browser cache lives, but the
-                // browser cache can be a subdirectory.
-                // This is $XDG_CACHE_HOME on Linux and
-                // ~/Library/Caches on Mac.
-  DIR_HOME,     // $HOME on POSIX-like systems.
-
-  PATH_POSIX_END
-};
-
-}  // namespace base
-
-#endif  // BASE_BASE_PATHS_POSIX_H_
diff --git a/base/path_service.cc b/base/path_service.cc
index 7a696e9..a3b882c 100644
--- a/base/path_service.cc
+++ b/base/path_service.cc
@@ -26,8 +26,6 @@
 #elif defined(OS_ANDROID)
   bool PathProviderAndroid(int key, FilePath* result);
 #elif defined(OS_POSIX)
-  // PathProviderPosix is the default path provider on POSIX OSes other than
-  // Mac and Android.
   bool PathProviderPosix(int key, FilePath* result);
 #endif
 }
@@ -87,8 +85,8 @@
   base::PathProviderAndroid,
   &base_provider,
 #ifndef NDEBUG
-  base::PATH_ANDROID_START,
-  base::PATH_ANDROID_END,
+  0,
+  0,
 #endif
   true
 };
@@ -99,8 +97,8 @@
   base::PathProviderPosix,
   &base_provider,
 #ifndef NDEBUG
-  base::PATH_POSIX_START,
-  base::PATH_POSIX_END,
+  0,
+  0,
 #endif
   true
 };
diff --git a/base/path_service_unittest.cc b/base/path_service_unittest.cc
index 84564d0..81d1fef 100644
--- a/base/path_service_unittest.cc
+++ b/base/path_service_unittest.cc
@@ -8,14 +8,12 @@
 #include "base/file_util.h"
 #include "base/file_path.h"
 #include "base/scoped_temp_dir.h"
-#include "build/build_config.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "testing/gtest/include/gtest/gtest-spi.h"
-#include "testing/platform_test.h"
-
 #if defined(OS_WIN)
 #include "base/win/windows_version.h"
 #endif
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/gtest/include/gtest/gtest-spi.h"
+#include "testing/platform_test.h"
 
 namespace {
 
@@ -28,15 +26,9 @@
   // If chromium has never been started on this account, the cache path may not
   // exist.
   if (dir_type == base::DIR_CACHE)
-    return result && !path.empty();
+    return result && !path.value().empty();
 #endif
-#if defined(OS_LINUX)
-  // On the linux try-bots: a path is returned (e.g. /home/chrome-bot/Desktop),
-  // but it doesn't exist.
-  if (dir_type == base::DIR_USER_DESKTOP)
-    return result && !path.empty();
-#endif
-  return result && !path.empty() && file_util::PathExists(path);
+  return result && !path.value().empty() && file_util::PathExists(path);
 }
 
 #if defined(OS_WIN)
@@ -61,10 +53,10 @@
 // later changes to Get broke the semantics of the function and yielded the
 // correct value while returning false.)
 TEST_F(PathServiceTest, Get) {
-  for (int key = base::PATH_START + 1; key < base::PATH_END; ++key) {
+  for (int key = base::DIR_CURRENT; key < base::PATH_END; ++key) {
 #if defined(OS_ANDROID)
-    if (key == base::FILE_MODULE || key == base::DIR_USER_DESKTOP)
-      continue;  // Android doesn't implement FILE_MODULE and DIR_USER_DESKTOP;
+    if (key == base::FILE_MODULE)
+      continue;  // Android doesn't implement FILE_MODULE;
 #endif
     EXPECT_PRED1(ReturnsValidPath, key);
   }
@@ -91,17 +83,7 @@
   }
 #elif defined(OS_MACOSX)
   for (int key = base::PATH_MAC_START + 1; key < base::PATH_MAC_END; ++key) {
-    EXPECT_PRED1(ReturnsValidPath, key);
-  }
-#elif defined(OS_ANDROID)
-  for (int key = base::PATH_ANDROID_START + 1; key < base::PATH_ANDROID_END;
-       ++key) {
-    EXPECT_PRED1(ReturnsValidPath, key);
-  }
-#elif defined(OS_POSIX)
-  for (int key = base::PATH_POSIX_START + 1; key < base::PATH_POSIX_END;
-       ++key) {
-    EXPECT_PRED1(ReturnsValidPath, key);
+      EXPECT_PRED1(ReturnsValidPath, key);
   }
 #endif
 }