This commit is contained in:
Cheng Zhao 2015-11-13 13:05:16 +08:00
Родитель 05d2e431de
Коммит d3caea91b0
3 изменённых файлов: 22 добавлений и 19 удалений

Просмотреть файл

@ -16,6 +16,7 @@
#include "base/debug/stack_trace.h"
#include "base/environment.h"
#include "base/logging.h"
#include "chrome/common/chrome_paths.h"
#include "content/public/common/content_switches.h"
#include "ui/base/resource/resource_bundle.h"
@ -79,6 +80,8 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
if (enable_stack_dumping)
base::debug::EnableInProcessStackDumping();
chrome::RegisterPathProvider();
return brightray::MainDelegate::BasicStartupComplete(exit_code);
}

Просмотреть файл

@ -22,9 +22,9 @@
#include "base/command_line.h"
#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/nix/xdg_util.h"
#include "base/path_service.h"
#include "brightray/browser/brightray_paths.h"
#include "chrome/common/chrome_paths.h"
#include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/common/content_switches.h"
@ -100,12 +100,22 @@ int GetPathConstant(const std::string& name) {
return base::DIR_HOME;
else if (name == "temp")
return base::DIR_TEMP;
else if (name == "userDesktop")
else if (name == "userDesktop" || name == "desktop")
return base::DIR_USER_DESKTOP;
else if (name == "exe")
return base::FILE_EXE;
else if (name == "module")
return base::FILE_MODULE;
else if (name == "documents")
return chrome::DIR_USER_DOCUMENTS;
else if (name == "downloads")
return chrome::DIR_DEFAULT_DOWNLOADS;
else if (name == "music")
return chrome::DIR_USER_MUSIC;
else if (name == "pictures")
return chrome::DIR_USER_PICTURES;
else if (name == "videos")
return chrome::DIR_USER_VIDEOS;
else
return -1;
}
@ -156,17 +166,6 @@ void PassLoginInformation(scoped_refptr<LoginHandler> login_handler,
login_handler->CancelAuth();
}
bool GetUserDownloadsDirectory(base::FilePath* path) {
#if defined(OS_LINUX)
*path = base::nix::GetXDGUserDirectory("DOWNLOAD", "Downloads");
return true;
#elif defined(OS_MACOSX)
return false;
#elif defined(OS_WIN)
return false;
#endif
}
} // namespace
App::App() {
@ -284,11 +283,8 @@ base::FilePath App::GetPath(mate::Arguments* args, const std::string& name) {
int key = GetPathConstant(name);
if (key >= 0)
succeed = PathService::Get(key, &path);
if (!succeed) {
if (name == "downloads" && GetUserDownloadsDirectory(&path))
return path;
if (!succeed)
args->ThrowError("Failed to get path");
}
return path;
}

Просмотреть файл

@ -238,10 +238,14 @@ You can request the following paths by the name:
* `userData` The directory for storing your app's configuration files, which by
default it is the `appData` directory appended with your app's name.
* `temp` Temporary directory.
* `userDesktop` The current user's Desktop directory.
* `exe` The current executable file.
* `module` The `libchromiumcontent` library.
* `downloads` User's download directory.
* `desktop` The current user's Desktop directory.
* `documents` Directory for a user's "My Documents".
* `downloads` Directory for a user's downloads.
* `music` Directory for a user's music.
* `pictures` Directory for a user's pictures.
* `videos` Directory for a user's videos.
### `app.setPath(name, path)`