From 3d5437e0a45b884d850ff125d38c0c49edc4d86f Mon Sep 17 00:00:00 2001 From: Robo Date: Fri, 13 Nov 2015 02:36:38 +0530 Subject: [PATCH 1/3] tracing: fix docs and allow null values in file path conversion fromv8 --- atom/common/native_mate_converters/file_path_converter.h | 3 +++ docs/api/content-tracing.md | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/atom/common/native_mate_converters/file_path_converter.h b/atom/common/native_mate_converters/file_path_converter.h index 468f506de8..7df1289e24 100644 --- a/atom/common/native_mate_converters/file_path_converter.h +++ b/atom/common/native_mate_converters/file_path_converter.h @@ -21,6 +21,9 @@ struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, base::FilePath* out) { + if (val->IsNull()) + return true; + base::FilePath::StringType path; if (Converter::FromV8(isolate, val, &path)) { *out = base::FilePath(path); diff --git a/docs/api/content-tracing.md b/docs/api/content-tracing.md index 2e05fc6766..9fc335b3bc 100644 --- a/docs/api/content-tracing.md +++ b/docs/api/content-tracing.md @@ -6,9 +6,14 @@ so you need to open `chrome://tracing/` in a Chrome browser and load the generated file to view the result. ```javascript -var contentTracing = require('content-tracing'); +const contentTracing = require('content-tracing'); -contentTracing.startRecording('*', contentTracing.DEFAULT_OPTIONS, function() { +const options = { + categoryFilter: '*', + traceOptions: 'record-until-full,enable-sampling' +} + +contentTracing.startRecording(options, function() { console.log('Tracing started'); setTimeout(function() { From bb439c5f1c1a6a4af88f80067bc7eac262c11dff Mon Sep 17 00:00:00 2001 From: Robo Date: Fri, 13 Nov 2015 02:43:21 +0530 Subject: [PATCH 2/3] browser: check window liveness before setting title --- atom/browser/native_window.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 8027fdfa4c..ba5dad74f5 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -512,7 +512,7 @@ void NativeWindow::TitleWasSet(content::NavigationEntry* entry, FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnPageTitleUpdated(&prevent_default, text)); - if (!prevent_default) + if (!prevent_default && !is_closed_) SetTitle(text); } From bfaa50a79ea2c28c7a0c71fde17efd048ed6eaff Mon Sep 17 00:00:00 2001 From: Robo Date: Fri, 13 Nov 2015 07:44:05 +0530 Subject: [PATCH 3/3] retrieve download directory using on linux --- atom/browser/api/atom_api_app.cc | 17 ++++++++++++++++- docs/api/app.md | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 1c5c2c04f1..d6d961a08d 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -22,6 +22,7 @@ #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 "content/public/browser/client_certificate_delegate.h" @@ -155,6 +156,17 @@ void PassLoginInformation(scoped_refptr 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() { @@ -272,8 +284,11 @@ 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 (!succeed) { + if (name == "downloads" && GetUserDownloadsDirectory(&path)) + return path; args->ThrowError("Failed to get path"); + } return path; } diff --git a/docs/api/app.md b/docs/api/app.md index fdb9f99805..4282b2d133 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -241,6 +241,7 @@ You can request the following paths by the name: * `userDesktop` The current user's Desktop directory. * `exe` The current executable file. * `module` The `libchromiumcontent` library. +* `downloads` User's download directory. ### `app.setPath(name, path)`