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

Unified Diff: chrome/browser/media_galleries/fileapi/picasa_finder.cc

Issue 23456035: Media Galleries API Picasa: Windows Custom Database Locations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media_galleries/fileapi/picasa_finder.cc
diff --git a/chrome/browser/media_galleries/fileapi/picasa_finder.cc b/chrome/browser/media_galleries/fileapi/picasa_finder.cc
index b3b4b2525c7c4a95c66899f2c8ee9f6de6052347..ef58e906218040d3f48ea3e06783f8fed3aace81 100644
--- a/chrome/browser/media_galleries/fileapi/picasa_finder.cc
+++ b/chrome/browser/media_galleries/fileapi/picasa_finder.cc
@@ -4,39 +4,84 @@
#include "chrome/browser/media_galleries/fileapi/picasa_finder.h"
+#if defined(OS_WIN)
+#include <windows.h>
+#endif
+
#include "base/base_paths.h"
#include "base/bind.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
+#include "base/strings/string16.h"
#include "chrome/browser/storage_monitor/storage_info.h"
#include "chrome/common/media_galleries/picasa_types.h"
#include "content/public/browser/browser_thread.h"
+#if defined(OS_WIN)
+#include "base/win/registry.h"
+#endif
+
namespace picasa {
-namespace {
+#if defined(OS_WIN)
+const wchar_t kPicasaRegistryPath[] =
+ L"Software\\Google\\Picasa\\Picasa2\\Preferences";
+const wchar_t kPicasaRegistryAppDataKey[] = L"AppLocalDataPath";
+#endif
-// Returns path of Picasa's DB3 database directory. May only be called on
-// threads that allow for disk IO, like the FILE thread or MediaTaskRunner.
-base::FilePath FindPicasaDatabaseOnFileThread() {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
- base::FilePath path;
+namespace {
#if defined(OS_WIN)
- // TODO(tommycli): Check registry for alternative path.
- if (!PathService::Get(base::DIR_LOCAL_APP_DATA, &path))
+base::FilePath GetCustomPicasaRoot() {
+ base::win::RegKey key;
+ if (key.Open(HKEY_CURRENT_USER, kPicasaRegistryPath, KEY_READ) !=
+ ERROR_SUCCESS || !key.Valid()) {
+ return base::FilePath();
+ }
+
+ string16 value;
+ if (key.ReadValue(kPicasaRegistryAppDataKey, &value) != ERROR_SUCCESS)
return base::FilePath();
-#elif defined(OS_MACOSX)
- // TODO(tommycli): Check Mac Preferences for alternative path.
+ if (value.empty())
+ return base::FilePath();
+
+ return base::FilePath(value);
+}
+
+base::FilePath GetPicasaDatabasePathWin() {
+ base::FilePath path = GetCustomPicasaRoot();
+ if (path.empty() && !PathService::Get(base::DIR_LOCAL_APP_DATA, &path))
+ return base::FilePath();
+
+ return path.AppendASCII("Google").AppendASCII("Picasa2").AppendASCII(
Greg Billock 2013/10/04 23:52:50 Would it be worth checking this first before looki
tommycli 2013/10/05 00:18:44 I believe the desired logic is to check the regist
+ kPicasaDatabaseDirName);
+}
+#endif
+
+#if defined (OS_MACOSX)
+base::FilePath GetPicasaDatabasePathMac() {
+ // TODO(tommycli): Support Picasa Mac's custom path.
+ base::FilePath path;
if (!PathService::Get(base::DIR_APP_DATA, &path))
return base::FilePath();
-#else
- return base::FilePath();
+
+ // On Mac, the database is in "Picasa3", not "Picasa2".
+ return path.AppendASCII("Google").AppendASCII("Picasa3").AppendASCII(
+ kPicasaDatabaseDirName);
+}
#endif
- path = path.AppendASCII("Google").AppendASCII("Picasa2").AppendASCII(
- kPicasaDatabaseDirName);
+// Returns path of Picasa's DB3 database directory. May only be called on
+// threads that allow for disk IO, like the FILE thread or MediaTaskRunner.
+base::FilePath FindPicasaDatabaseOnFileThread() {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
+ base::FilePath path;
+ #if defined(OS_WIN)
+ path = GetPicasaDatabasePathWin();
+ #elif defined(OS_MACOSX)
+ path = GetPicasaDatabasePathMac();
+ #endif
// Verify actual existence
if (!base::DirectoryExists(path))

Powered by Google App Engine
This is Rietveld 408576698