From b48a9faf31ab1d31bd71ebc1dfdcd2db37b68d20 Mon Sep 17 00:00:00 2001 From: Rick Edgecombe Date: Mon, 9 Mar 2015 14:11:48 -0700 Subject: [PATCH 01/41] Desktop capture monitor --- nw.gypi | 2 + src/api/dispatcher_host.cc | 3 + src/api/screen/desktop_capture_monitor.cc | 144 ++++++++++++++++++++++ src/api/screen/desktop_capture_monitor.h | 49 ++++++++ src/api/screen/screen.js | 70 +++++++++++ 5 files changed, 268 insertions(+) create mode 100644 src/api/screen/desktop_capture_monitor.cc create mode 100644 src/api/screen/desktop_capture_monitor.h diff --git a/nw.gypi b/nw.gypi index da4cfcce2a..ec6a05fc76 100644 --- a/nw.gypi +++ b/nw.gypi @@ -207,6 +207,8 @@ 'src/api/event/event.cc', 'src/api/screen/desktop_capture_api.h', 'src/api/screen/desktop_capture_api.cc', + 'src/api/screen/desktop_capture_monitor.cc', + 'src/api/screen/desktop_capture_monitor.h', '<(DEPTH)/chrome/browser/media/desktop_media_list.h', '<(DEPTH)/chrome/browser/media/desktop_media_list_observer.h', '<(DEPTH)/chrome/browser/media/desktop_media_picker.h', diff --git a/src/api/dispatcher_host.cc b/src/api/dispatcher_host.cc index f5f25e7936..dbbcd7b86c 100644 --- a/src/api/dispatcher_host.cc +++ b/src/api/dispatcher_host.cc @@ -34,6 +34,7 @@ #include "content/nw/src/api/menu/menu.h" #include "content/nw/src/api/menuitem/menuitem.h" #include "content/nw/src/api/screen/screen.h" +#include "content/nw/src/api/screen/desktop_capture_monitor.h" #include "content/nw/src/api/shell/shell.h" #include "content/nw/src/api/shortcut/shortcut.h" #include "content/nw/src/api/tray/tray.h" @@ -171,6 +172,8 @@ void DispatcherHost::OnAllocateObject(int object_id, objects_registry_.AddWithID(new Shortcut(object_id, weak_ptr_factory_.GetWeakPtr(), option), object_id); } else if (type == "Screen") { objects_registry_.AddWithID(new EventListener(object_id, weak_ptr_factory_.GetWeakPtr(), option), object_id); + }else if (type == "DesktopCaptureMonitor") { + objects_registry_.AddWithID(new DesktopCaptureMonitor(object_id, weak_ptr_factory_.GetWeakPtr(), option), object_id); } else { LOG(ERROR) << "Allocate an object of unknown type: " << type; objects_registry_.AddWithID(new Base(object_id, weak_ptr_factory_.GetWeakPtr(), option), object_id); diff --git a/src/api/screen/desktop_capture_monitor.cc b/src/api/screen/desktop_capture_monitor.cc new file mode 100644 index 0000000000..3d56a26e6d --- /dev/null +++ b/src/api/screen/desktop_capture_monitor.cc @@ -0,0 +1,144 @@ +// Copyright (c) 2012 Intel Corp +// Copyright (c) 2012 The Chromium Authors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co +// pies of the Software, and to permit persons to whom the Software is furnished +// to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in al +// l copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM +// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES +// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH +// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#include "content/nw/src/api/screen/desktop_capture_monitor.h" + +#include "base/values.h" +#include "base/strings/utf_string_conversions.h" +#include "base/strings/string16.h" +#include "content/nw/src/api/dispatcher_host.h" +#include "chrome/browser/media/desktop_streams_registry.h" +#include "chrome/browser/media/media_capture_devices_dispatcher.h" + +#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" +#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" +#include "third_party/webrtc/modules/desktop_capture/window_capturer.h" + +#include "base/base64.h" +#include "ui/gfx/codec/png_codec.h" +#include "ui/gfx/image/image.h" +#include "ui/gfx/image/image_skia.h" + + +namespace nwapi { + +DesktopCaptureMonitor::DesktopCaptureMonitor(int id, + const base::WeakPtr& dispatcher_host, + const base::DictionaryValue& option) + : Base(id, dispatcher_host, option) { +} + +DesktopCaptureMonitor::~DesktopCaptureMonitor() {} + + +void DesktopCaptureMonitor::CallSync(const std::string& method, const base::ListValue& arguments, base::ListValue* result){ + if (method == "start") { + bool screens, windows; + if (arguments.GetBoolean(0, &screens) && arguments.GetBoolean(1, &windows)) + Start(screens, windows); + }else if (method == "stop") { + Stop(); + } + else { + NOTREACHED() << "Invalid call to DesktopCapture method:" << method + << " arguments:" << arguments; + } +} + +void DesktopCaptureMonitor::Start(bool screens, bool windows) { + webrtc::DesktopCaptureOptions options = webrtc::DesktopCaptureOptions::CreateDefault(); + options.set_disable_effects(false); + scoped_ptr screen_capturer(screens ? webrtc::ScreenCapturer::Create(options) : NULL); + scoped_ptr window_capturer(windows ? webrtc::WindowCapturer::Create(options) : NULL); + + media_list_.reset(new NativeDesktopMediaList(screen_capturer.Pass(), window_capturer.Pass())); + + media_list_->StartUpdating(this); +} + +void DesktopCaptureMonitor::Stop() { + media_list_.reset(); +} + +void DesktopCaptureMonitor::OnSourceAdded(int index){ + DesktopMediaList::Source src = media_list_->GetSource(index); + + std::string type; + if (src.id.type == content::DesktopMediaID::TYPE_AURA_WINDOW || src.id.type == content::DesktopMediaID::TYPE_WINDOW){ + type = "window"; + } + else if (src.id.type == content::DesktopMediaID::TYPE_SCREEN){ + type = "screen"; + } + else if (src.id.type == content::DesktopMediaID::TYPE_NONE){ + type = "none"; + } + else{ + type = "unknown"; + } + + base::ListValue param; + param.AppendString(src.id.ToString()); + param.AppendString(src.name); + param.AppendInteger(index); + param.AppendString(type); + this->dispatcher_host()->SendEvent(this, "__nw_desktop_capture_monitor_listner_added", param); +} +void DesktopCaptureMonitor::OnSourceRemoved(int index){ + base::ListValue param; + param.AppendInteger(index); //pass by index here, because the information about which ID was at that index is lost before the removed callback is called. Its saved in the javascript though, so we can look it up there + this->dispatcher_host()->SendEvent(this, "__nw_desktop_capture_monitor_listner_removed", param); +} +void DesktopCaptureMonitor::OnSourceMoved(int old_index, int new_index){ + DesktopMediaList::Source src = media_list_->GetSource(new_index); + base::ListValue param; + param.AppendString(src.id.ToString()); + param.AppendInteger(new_index); + param.AppendInteger(old_index); + this->dispatcher_host()->SendEvent(this, "__nw_desktop_capture_monitor_listner_moved", param); +} +void DesktopCaptureMonitor::OnSourceNameChanged(int index){ + DesktopMediaList::Source src = media_list_->GetSource(index); + + base::ListValue param; + param.AppendString(src.id.ToString()); + param.AppendString(src.name); + this->dispatcher_host()->SendEvent(this, "__nw_desktop_capture_monitor_listner_namechanged", param); +} + +void DesktopCaptureMonitor::OnSourceThumbnailChanged(int index){ + std::string base64; + + DesktopMediaList::Source src = media_list_->GetSource(index); + SkBitmap bitmap = src.thumbnail.GetRepresentation(1).sk_bitmap(); + SkAutoLockPixels lock_image(bitmap); + std::vector data; + bool success = gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &data); + if (success){ + base::StringPiece raw_str(reinterpret_cast(&data[0]), data.size()); + base::Base64Encode(raw_str, &base64); + } + base::ListValue param; + param.AppendString(src.id.ToString()); + param.AppendString(base64); + this->dispatcher_host()->SendEvent(this, "__nw_desktop_capture_monitor_listner_thumbnailchanged", param); +} + +} // namespace nwapi diff --git a/src/api/screen/desktop_capture_monitor.h b/src/api/screen/desktop_capture_monitor.h new file mode 100644 index 0000000000..82dc160ff6 --- /dev/null +++ b/src/api/screen/desktop_capture_monitor.h @@ -0,0 +1,49 @@ +// Copyright (c) 2012 Intel Corp +// Copyright (c) 2012 The Chromium Authors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co +// pies of the Software, and to permit persons to whom the Software is furnished +// to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in al +// l copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM +// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES +// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH +// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#ifndef CONTENT_NW_SRC_API_DESKTOPCAPTURE_H_ +#define CONTENT_NW_SRC_API_DESKTOPCAPTURE_H_ +#include "base/compiler_specific.h" +#include "content/nw/src/api/base/base.h" +#include "chrome/browser/media/desktop_media_list_observer.h" +#include "chrome/browser/media/native_desktop_media_list.h" + +namespace nwapi { + class DesktopCaptureMonitor : public Base, public DesktopMediaListObserver { + public: + DesktopCaptureMonitor(int id, + const base::WeakPtr& dispatcher_host, + const base::DictionaryValue& option); + virtual ~DesktopCaptureMonitor(); + virtual void CallSync(const std::string& method, const base::ListValue& arguments, base::ListValue* result) override; + virtual void OnSourceAdded(int index); + virtual void OnSourceRemoved(int index); + virtual void OnSourceMoved(int old_index, int new_index); + virtual void OnSourceNameChanged(int index); + virtual void OnSourceThumbnailChanged(int index); + private: + DesktopCaptureMonitor(); + DISALLOW_COPY_AND_ASSIGN(DesktopCaptureMonitor); + void Start(bool screens, bool windows); + void Stop(); + + scoped_ptr media_list_; + }; +} // namespace api +#endif // CONTENT_NW_SRC_API_DESKTOPCAPTURE_H_ \ No newline at end of file diff --git a/src/api/screen/screen.js b/src/api/screen/screen.js index 770a056639..d05d2be4ea 100644 --- a/src/api/screen/screen.js +++ b/src/api/screen/screen.js @@ -18,11 +18,81 @@ // ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +function DesktopCaptureMonitor() { + nw.allocateObject(this, {}); + this.sources = new Array(); + this.started = false; +} +require('util').inherits(DesktopCaptureMonitor, exports.Base); + +DesktopCaptureMonitor.prototype.start = function (screens, windows) { + if (this.started) + return false; + this.started = true; + nw.callObjectMethodSync(this, 'start', [screens, windows]); + return true; +} + +DesktopCaptureMonitor.prototype.stop = function () { + if (!this.started) + return false; + nw.callObjectMethodSync(this, 'stop', []); + this.started = false; + this.sources = new Array(); + return true; +} + +DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_added', function (id, name, order, type) { + this.sources.splice(order, 0, id); + this.emit("added", id, name, order, type); + for (var i = order + 1; i <= this.sources.length - 1; i++) { + this.emit("orderchanged", this.sources[i], i, i - 1); + } +}); + + +DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_removed', function (index) { + var id = this.sources[index]; + if (index != -1) { + this.sources.splice(index, 1); + this.emit("removed", id); + for (var i = index; i <= this.sources.length - 1; i++) { + this.emit("orderchanged", this.sources[i], i, i + 1); + } + } +}); + +DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_moved', function (id, new_index, old_index) { + var temp = this.sources[old_index]; + this.sources.splice(old_index, 1); + this.sources.splice(new_index, 0, temp); + this.emit("orderchanged", temp, new_index, old_index); + for (var i = new_index; i < old_index; i++) + this.emit("orderchanged", this.sources[i + 1], i + 1, i); +}); + +DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_namechanged', function (id, name) { + this.emit("namechanged", id, name); +}); + +DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_thumbnailchanged', function (id, thumbnail) { + this.emit("thumbnailchanged", id, thumbnail); +}); + +DesktopCaptureMonitor.prototype.on = DesktopCaptureMonitor.prototype.addListener = function (ev, callback) { + //throw except if unsupported event + if (ev != "added" && ev != "removed" && ev != "orderchanged" && ev != "namechanged" && ev != "thumbnailchanged") + throw new String("only following events can be listened: added, removed, moved, namechanged, thumbnailchanged"); + + process.EventEmitter.prototype.addListener.apply(this, arguments); +} + var screenInstance = null; function Screen() { nw.allocateObject(this, {}); this._numListener = 0; + this.DesktopCaptureMonitor = new DesktopCaptureMonitor(); } require('util').inherits(Screen, exports.Base); From 8b9b7f5ea38ad9278684ec786fa1769d055ea060 Mon Sep 17 00:00:00 2001 From: Rick Edgecombe Date: Wed, 11 Mar 2015 15:04:33 -0700 Subject: [PATCH 02/41] Add capture of audio loopback on windows --- src/nw_shell.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/nw_shell.cc b/src/nw_shell.cc index 022dace36e..554be138a3 100644 --- a/src/nw_shell.cc +++ b/src/nw_shell.cc @@ -78,6 +78,7 @@ using nw::NativeWindowAura; #endif #include "content/public/browser/media_capture_devices.h" +#include "media/audio/audio_manager_base.h" #include "chrome/browser/printing/print_view_manager_basic.h" #include "extensions/common/extension_messages.h" @@ -722,6 +723,11 @@ void Shell::RequestMediaAccessPermission( devices.push_back(content::MediaStreamDevice( content::MEDIA_DESKTOP_VIDEO_CAPTURE, media_id.ToString(), "Screen")); } +#if defined(OS_WIN) + if (request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE) { + devices.push_back(content::MediaStreamDevice(content::MEDIA_DESKTOP_AUDIO_CAPTURE, media::AudioManagerBase::kLoopbackInputDeviceId, "System Audio")); + } +#endif // TODO(jamescook): Should we show a recording icon somewhere? If so, where? scoped_ptr ui; callback.Run(devices, From 27b821e1194365a4e6276379cc961a5e2c17e186 Mon Sep 17 00:00:00 2001 From: Anton Khlynovskiy Date: Mon, 23 Mar 2015 13:19:46 +0300 Subject: [PATCH 03/41] AUTHORS file (about PR #3251) @rogerwang told me to do so --- AUTHORS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index c468b7237c..2e8de893f7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -33,4 +33,5 @@ Cong Liu Eric Newport Marco Fabbri Daniel Braun -Chase Willden \ No newline at end of file +Chase Willden +Anton Khlynovskiy From 78bbb2c183222ff8e0ed5415a4e900cbef0b9299 Mon Sep 17 00:00:00 2001 From: Cong Liu Date: Sat, 10 Jan 2015 01:19:18 +0800 Subject: [PATCH 04/41] Fixed devtools issue fixed rogerwang/node-webkit#2660 fixed rogerwang/node-webkit#2603 --- src/nw_shell.cc | 5 ++--- src/shell_devtools_frontend.cc | 37 +++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/nw_shell.cc b/src/nw_shell.cc index f1c4b78b0e..b8ba1ac424 100644 --- a/src/nw_shell.cc +++ b/src/nw_shell.cc @@ -449,13 +449,12 @@ void Shell::ShowDevTools(const char* jail_id, bool headless) { DevToolsHttpHandler* http_handler = browser_client->shell_browser_main_parts()->devtools_handler(); - GURL url = http_handler->GetFrontendURL(agent.get()); + GURL url = http_handler->GetFrontendURL("/devtools/devtools.html"); http_handler->EnumerateTargets(); #if 0 if (headless) { DevToolsAgentHost* agent_host = DevToolsAgentHost::GetOrCreateFor(web_contents()).get(); - url = delegate->devtools_http_handler()->GetFrontendURL(agent_host); DevToolsHttpHandlerImpl* http_handler = static_cast(delegate->devtools_http_handler()); http_handler->EnumerateTargets(); @@ -484,7 +483,7 @@ void Shell::ShowDevTools(const char* jail_id, bool headless) { new ShellDevToolsFrontend( shell, - DevToolsAgentHost::GetOrCreateFor(web_contents_.get()).get()); + agent.get()); int rh_id = shell->web_contents_->GetRenderProcessHost()->GetID(); ChildProcessSecurityPolicyImpl::GetInstance()->GrantScheme(rh_id, url::kFileScheme); diff --git a/src/shell_devtools_frontend.cc b/src/shell_devtools_frontend.cc index 4fdc8c7b22..1e9cb3d24d 100644 --- a/src/shell_devtools_frontend.cc +++ b/src/shell_devtools_frontend.cc @@ -26,6 +26,10 @@ namespace content { +// This constant should be in sync with +// the constant at devtools_ui_bindings.cc. +const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4; + #if 0 // static ShellDevToolsFrontend* ShellDevToolsFrontend::Show( @@ -70,17 +74,16 @@ ShellDevToolsFrontend::~ShellDevToolsFrontend() { void ShellDevToolsFrontend::RenderViewCreated( RenderViewHost* render_view_host) { -#if 0 if (!frontend_host_) { - frontend_host_.reset(DevToolsFrontendHost::Create(render_view_host, this)); - DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( - agent_host_.get(), this); + frontend_host_.reset( + DevToolsFrontendHost::Create(web_contents()->GetMainFrame(), this)); + agent_host_->AttachClient(this); } -#endif } void ShellDevToolsFrontend::WebContentsDestroyed() { - agent_host_->DetachClient(); + if (agent_host_) + agent_host_->DetachClient(); delete this; } @@ -128,12 +131,22 @@ void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontendToBackend( void ShellDevToolsFrontend::DispatchProtocolMessage( DevToolsAgentHost* agent_host, const std::string& message) { - base::StringValue message_value(message); - std::string param; - base::JSONWriter::Write(&message_value, ¶m); - std::string code = "DevToolsAPI.dispatchMessage(" + param + ");"; - base::string16 javascript = base::UTF8ToUTF16(code); - web_contents()->GetMainFrame()->ExecuteJavaScript(javascript); + if (message.length() < kMaxMessageChunkSize) { + base::string16 javascript = base::UTF8ToUTF16( + "DevToolsAPI.dispatchMessage(" + message + ");"); + web_contents()->GetMainFrame()->ExecuteJavaScript(javascript); + return; + } + + base::FundamentalValue total_size(static_cast(message.length())); + for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) { + base::StringValue message_value(message.substr(pos, kMaxMessageChunkSize)); + std::string param; + base::JSONWriter::Write(&message_value, ¶m); + std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + ");"; + base::string16 javascript = base::UTF8ToUTF16(code); + web_contents()->GetMainFrame()->ExecuteJavaScript(javascript); + } } void ShellDevToolsFrontend::AgentHostClosed( From f30e9ba13fc71bca6032bf70ab7acea1e434a6f0 Mon Sep 17 00:00:00 2001 From: Yuehang Wu Date: Mon, 6 Apr 2015 23:14:54 +0800 Subject: [PATCH 05/41] Fix #3143: remote debugging devtools page blank ShellDevToolsDelegate::GetDiscoveryPageHTML should load resource bundle from IDR_NW_DEVTOOLS_DISCOVERY_PAGE other than IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE --- src/browser/shell_devtools_manager_delegate.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/browser/shell_devtools_manager_delegate.cc b/src/browser/shell_devtools_manager_delegate.cc index f97aa62ef7..967bd0e410 100644 --- a/src/browser/shell_devtools_manager_delegate.cc +++ b/src/browser/shell_devtools_manager_delegate.cc @@ -23,7 +23,7 @@ #include "content/public/common/url_constants.h" #include "content/public/common/user_agent.h" #include "content/nw/src/nw_shell.h" -#include "grit/shell_resources.h" +#include "grit/nw_resources.h" #include "net/socket/tcp_server_socket.h" #include "ui/base/resource/resource_bundle.h" @@ -202,7 +202,7 @@ std::string ShellDevToolsDelegate::GetDiscoveryPageHTML() { return std::string(); #else return ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string(); + IDR_NW_DEVTOOLS_DISCOVERY_PAGE).as_string(); #endif } From 3049140ca185398fb6f04cfee9713b61b194319e Mon Sep 17 00:00:00 2001 From: Yuehang Wu Date: Tue, 7 Apr 2015 10:45:25 +0800 Subject: [PATCH 06/41] Update AUTHORS file for PR #3340 --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 2e8de893f7..1f41d665ef 100644 --- a/AUTHORS +++ b/AUTHORS @@ -35,3 +35,4 @@ Marco Fabbri Daniel Braun Chase Willden Anton Khlynovskiy +Wu Yuehang From da7a71d65aa32e757d3ae0ab0d69f8c5a944a32d Mon Sep 17 00:00:00 2001 From: Roger Date: Tue, 7 Apr 2015 13:25:55 +0800 Subject: [PATCH 07/41] Fix crash dump See #3226 --- src/browser/chrome_crash_reporter_client.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/browser/chrome_crash_reporter_client.cc b/src/browser/chrome_crash_reporter_client.cc index b620fbd977..de5f3ef308 100644 --- a/src/browser/chrome_crash_reporter_client.cc +++ b/src/browser/chrome_crash_reporter_client.cc @@ -284,7 +284,7 @@ bool ChromeCrashReporterClient::ReportingIsEnforcedByPolicy( return true; } #endif - return false; + return true; } #endif // defined(OS_WIN) @@ -326,8 +326,7 @@ size_t ChromeCrashReporterClient::RegisterCrashKeys() { } bool ChromeCrashReporterClient::IsRunningUnattended() { - scoped_ptr env(base::Environment::Create()); - return env->HasVar(env_vars::kHeadless); + return true; } bool ChromeCrashReporterClient::GetCollectStatsConsent() { From 19358ac57fd3d05d254ff9a6570f77f569b0b0ee Mon Sep 17 00:00:00 2001 From: Anton Khlynovskiy Date: Tue, 7 Apr 2015 14:24:32 +0300 Subject: [PATCH 08/41] More precise RegExp for App.argv filtering --- src/api/app/app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/app/app.js b/src/api/app/app.js index 32c397f448..5573d6d4f2 100644 --- a/src/api/app/app.js +++ b/src/api/app/app.js @@ -26,10 +26,10 @@ function App() { require('util').inherits(App, exports.Base); App.filteredArgv = [ - /--no-toolbar/, - /--url=.*/, - /--remote-debugging-port=.*/, - /--renderer-cmd-prefix.*/, + /^--no-toolbar$/, + /^--url=/, + /^--remote-debugging-port=/, + /^--renderer-cmd-prefix/, ]; App.prototype.quit = function() { From 8e1bade2c5a6eb39952072f4cdea64b411dbbb80 Mon Sep 17 00:00:00 2001 From: Roger Wang Date: Wed, 8 Apr 2015 12:33:47 +0800 Subject: [PATCH 09/41] [WIN] Fix High DPI support on text Fix #2998, #3272 --- src/shell_main.cc | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/src/shell_main.cc b/src/shell_main.cc index 1e4a1b0fd5..7b999ebd30 100644 --- a/src/shell_main.cc +++ b/src/shell_main.cc @@ -25,6 +25,9 @@ #include "sandbox/win/src/sandbox_types.h" #if defined(OS_WIN) +#include +#include + #include "base/win/win_util.h" #include "base/win/windows_version.h" #include "content/public/app/startup_helper_win.h" @@ -39,13 +42,49 @@ using base::CommandLine; #if defined(OS_WIN) +// Win8.1 supports monitor-specific DPI scaling. +bool SetProcessDpiAwarenessWrapper(PROCESS_DPI_AWARENESS value) { + typedef HRESULT(WINAPI *SetProcessDpiAwarenessPtr)(PROCESS_DPI_AWARENESS); + SetProcessDpiAwarenessPtr set_process_dpi_awareness_func = + reinterpret_cast( + GetProcAddress(GetModuleHandleA("user32.dll"), + "SetProcessDpiAwarenessInternal")); + if (set_process_dpi_awareness_func) { + HRESULT hr = set_process_dpi_awareness_func(value); + if (SUCCEEDED(hr)) { + VLOG(1) << "SetProcessDpiAwareness succeeded."; + return true; + } else if (hr == E_ACCESSDENIED) { + LOG(ERROR) << "Access denied error from SetProcessDpiAwareness. " + "Function called twice, or manifest was used."; + } + } + return false; +} + +// This function works for Windows Vista through Win8. Win8.1 must use +// SetProcessDpiAwareness[Wrapper]. +BOOL SetProcessDPIAwareWrapper() { + typedef BOOL(WINAPI *SetProcessDPIAwarePtr)(VOID); + SetProcessDPIAwarePtr set_process_dpi_aware_func = + reinterpret_cast( + GetProcAddress(GetModuleHandleA("user32.dll"), + "SetProcessDPIAware")); + return set_process_dpi_aware_func && + set_process_dpi_aware_func(); +} + +void EnableHighDPISupport() { + if (!SetProcessDpiAwarenessWrapper(PROCESS_SYSTEM_DPI_AWARE)) { + SetProcessDPIAwareWrapper(); + } +} + int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { CommandLine::Init(0, NULL); -#if 0 //FIXME - if (base::win::GetVersion() > base::win::VERSION_VISTA) - gfx::EnableHighDPISupport(); -#endif + if (base::win::GetVersion() >= base::win::VERSION_WIN7) + EnableHighDPISupport(); sandbox::SandboxInterfaceInfo sandbox_info = {0}; content::InitializeSandboxInfo(&sandbox_info); From f19f7139e0d182fb3724089431faeb918a5aa527 Mon Sep 17 00:00:00 2001 From: Roger Date: Wed, 8 Apr 2015 14:17:54 +0800 Subject: [PATCH 10/41] bump version to 0.12.1 --- src/mac/app-Info.plist | 2 +- src/nw_version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mac/app-Info.plist b/src/mac/app-Info.plist index 3cd9e0d3c2..7f3c1fdac9 100644 --- a/src/mac/app-Info.plist +++ b/src/mac/app-Info.plist @@ -19,7 +19,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.11.4 + 0.12.1 NSPrincipalClass NSApplication LSMinimumSystemVersion diff --git a/src/nw_version.h b/src/nw_version.h index 701c3a8c3b..1fda1b5713 100644 --- a/src/nw_version.h +++ b/src/nw_version.h @@ -23,7 +23,7 @@ #define NW_MAJOR_VERSION 0 #define NW_MINOR_VERSION 12 -#define NW_PATCH_VERSION 0 +#define NW_PATCH_VERSION 1 #define NW_VERSION_IS_RELEASE 1 #ifndef NW_STRINGIFY From c5fb1b81174d40547eb8f8a5edb0d4799178dd6c Mon Sep 17 00:00:00 2001 From: Tim Pulver Date: Thu, 9 Apr 2015 18:14:44 +0200 Subject: [PATCH 11/41] Correct Mac OS X example app name App-name did not match in readme + removed comment from code-block. --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8881261964..d1d10dfc10 100644 --- a/README.md +++ b/README.md @@ -78,10 +78,9 @@ $ /path/to/nw . (suppose the current directory contains 'package.json') Note: on Windows, you can drag the folder containing `package.json` to `nw.exe` to open it. -Note: on OSX, the executable binary is in a hidden directory within the .app file. To run node-webkit on OSX, type: -```bash -$ /path/to/node-webkit.app/Contents/MacOS/node-webkit . (suppose the current directory contains 'package.json') -``` +Note: on OSX, the executable binary is in a hidden directory within the .app file. To run node-webkit on OSX, type: +`/path/to/nwjs.app/Contents/MacOS/nwjs .` *(suppose the current directory contains 'package.json')* + ## Documents For more information on how to write/package/run apps, see: From 30b03004289883bd7406389abfba99a0468a7352 Mon Sep 17 00:00:00 2001 From: Falkirks Date: Fri, 10 Apr 2015 09:44:52 -0700 Subject: [PATCH 12/41] Updated link to nwjs.io in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d1d10dfc10..776ff38cca 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ It was created in the Intel Open Source Technology Center. * Windows: [win32](http://dl.node-webkit.org/v0.8.6/node-webkit-v0.8.6-win-ia32.zip) * Mac: [32bit, 10.7+](http://dl.node-webkit.org/v0.8.6/node-webkit-v0.8.6-osx-ia32.zip) -* **latest live build**: git tip version; build triggered from every git commit: http://dl.node-webkit.org/live-build/ +* **latest live build**: git tip version; build triggered from every git commit: http://dl.nwjs.io/live-build/ * [Previous versions](https://github.com/rogerwang/node-webkit/wiki/Downloads-of-old-versions) From b381949fb1a0e8619b89c6430a70033937c0b381 Mon Sep 17 00:00:00 2001 From: Roger Date: Mon, 13 Apr 2015 10:20:35 +0800 Subject: [PATCH 13/41] [CHANGELOG] update for 0.12.1 --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0269106140..c03e2eb0a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +0.12.1 / 04-13-2015 +=================== +- Fix crash dump generation +- [WIN] Fix blurry text with High DPI display +- Fix: Webview : contentWindow not available at this time (#3126) +- More precise RegExp for App.argv filtering (Thanks to Anton Khlynovskiy) +- Fix #3143: remote debugging devtools page blank (Thanks to Yuehang Wu) +- [Notification][Win] fix for missing windows events +- add Window 'progress' event (Thanks to vadim-kudr ) +- nw-headers is built automatically now in buildbot (Thanks to Xue Yang) + 0.12.0 / 03-05-2015 ======================= - Chromium updated to 41.0.2272.76 From 380c830ce329f1c4f667055560d8a6fff9c1e248 Mon Sep 17 00:00:00 2001 From: Roger Date: Mon, 13 Apr 2015 10:32:48 +0800 Subject: [PATCH 14/41] [README] update for 0.12.1 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d1d10dfc10..0c800bb9d4 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ It was created in the Intel Open Source Technology Center. * Available on Linux, Mac OS X and Windows ## Downloads -* **v0.12.0:** (Mar 5, 2015, based off of IO.js v1.2.0, Chromium 41.0.2272.76): [release notes](https://groups.google.com/d/msg/nwjs-general/NJA-Up4MFug/1jmBPjzklSUJ) - * Linux: [32bit](http://dl.nwjs.io/v0.12.0/nwjs-v0.12.0-linux-ia32.tar.gz) / [64bit](http://dl.nwjs.io/v0.12.0/nwjs-v0.12.0-linux-x64.tar.gz) - * Windows: [32bit](http://dl.nwjs.io/v0.12.0/nwjs-v0.12.0-win-ia32.zip) / [64bit](http://dl.nwjs.io/v0.12.0/nwjs-v0.12.0-win-x64.zip) - * Mac 10.7+: [32bit](http://dl.nwjs.io/v0.12.0/nwjs-v0.12.0-osx-ia32.zip) / [64bit](http://dl.nwjs.io/v0.12.0/nwjs-v0.12.0-osx-x64.zip) +* **v0.12.1:** (Apr 13, 2015, based off of IO.js v1.2.0, Chromium 41.0.2272.76): [release notes](https://groups.google.com/d/msg/nwjs-general/bvdnDJAx91U/0womlMli4FUJ) + * Linux: [32bit](http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-linux-ia32.tar.gz) / [64bit](http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-linux-x64.tar.gz) + * Windows: [32bit](http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-win-ia32.zip) / [64bit](http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-win-x64.zip) + * Mac 10.7+: [32bit](http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-osx-ia32.zip) / [64bit](http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-osx-x64.zip) * **0.8.6:** (Apr 18, 2014, based off of Node v0.10.22, Chrome 30.0.1599.66) **If your native Node module works only with Node v0.10, then you should use node-webkit v0.8.x, which is also a maintained branch. [More info](https://groups.google.com/d/msg/nwjs-general/2OJ1cEMPLlA/09BvpTagSA0J)** [release notes](https://groups.google.com/d/msg/nwjs-general/CLPkgfV-i7s/hwkkQuJ1kngJ) From 154b760c2464f07401fd49f324ddc60c2d13fdd7 Mon Sep 17 00:00:00 2001 From: Roger Date: Mon, 13 Apr 2015 20:19:37 +0800 Subject: [PATCH 15/41] Fix #2819: enable cookie support for web sockets --- src/net/shell_url_request_context_getter.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net/shell_url_request_context_getter.cc b/src/net/shell_url_request_context_getter.cc index 16872a7f46..d9bc339678 100644 --- a/src/net/shell_url_request_context_getter.cc +++ b/src/net/shell_url_request_context_getter.cc @@ -190,8 +190,8 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { cookie_store->GetCookieMonster()->SetPersistSessionCookies(true); storage_->set_cookie_store(cookie_store.get()); - const char* schemes[] = {"http", "https", "file", "app"}; - cookie_store->GetCookieMonster()->SetCookieableSchemes(schemes, 4); + const char* schemes[] = {"http", "https", "ws", "wss", "app", "file"}; + cookie_store->GetCookieMonster()->SetCookieableSchemes(schemes, 6); storage_->set_channel_id_service(new net::ChannelIDService( new net::DefaultChannelIDStore(NULL), From e62c9f39b50fa68e2a2f92615b5c3796bb91e22e Mon Sep 17 00:00:00 2001 From: Roger Date: Tue, 14 Apr 2015 15:04:01 +0800 Subject: [PATCH 16/41] enter parent frame context when called from iframe Fix #2713 --- src/api/dispatcher.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api/dispatcher.cc b/src/api/dispatcher.cc index 4238ea03d8..edfc4965ae 100644 --- a/src/api/dispatcher.cc +++ b/src/api/dispatcher.cc @@ -217,8 +217,10 @@ void Dispatcher::willHandleNavigationPolicy( v8::HandleScope handleScope(isolate); v8::Handle id_val; - if (web_view->mainFrame() && !web_view->mainFrame()->mainWorldScriptContext().IsEmpty()) + if (web_view->mainFrame() && !web_view->mainFrame()->mainWorldScriptContext().IsEmpty()) { + v8::Context::Scope cscope (web_view->mainFrame()->mainWorldScriptContext()); id_val = nwapi::Dispatcher::GetWindowId(web_view->mainFrame()); + } if (id_val.IsEmpty()) return; if (id_val->IsUndefined() || id_val->IsNull()) From a77b0854957651e3a5df36a10d10f9c3b9c2d195 Mon Sep 17 00:00:00 2001 From: Roger Date: Tue, 14 Apr 2015 16:15:55 +0800 Subject: [PATCH 17/41] support no-displaying-insecure-content and allow-running-insecure-content Fix #3123 --- src/shell_content_browser_client.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/shell_content_browser_client.cc b/src/shell_content_browser_client.cc index dddcc46ebd..b61a1cfab7 100644 --- a/src/shell_content_browser_client.cc +++ b/src/shell_content_browser_client.cc @@ -370,6 +370,7 @@ void ShellContentBrowserClient::OverrideWebkitPrefs( const GURL& url, content::WebPreferences* prefs) { nw::Package* package = shell_browser_main_parts()->package(); + CommandLine* cmd_line = CommandLine::ForCurrentProcess(); // Disable web security. prefs->dom_paste_enabled = true; @@ -384,6 +385,11 @@ void ShellContentBrowserClient::OverrideWebkitPrefs( prefs->plugins_enabled = true; prefs->java_enabled = false; + prefs->allow_displaying_insecure_content = + !(cmd_line->HasSwitch(switches::kNoDisplayingInsecureContent)); + prefs->allow_running_insecure_content = + cmd_line->HasSwitch(switches::kAllowRunningInsecureContent); + base::DictionaryValue* webkit; if (package->root()->GetDictionary(switches::kmWebkit, &webkit)) { webkit->GetBoolean(switches::kmJava, &prefs->java_enabled); From 4b4d1b22367cb322addbe6d969d6d23dc375583d Mon Sep 17 00:00:00 2001 From: Sander Boom Date: Tue, 21 Apr 2015 10:27:46 +0200 Subject: [PATCH 18/41] Added mandatory version to package.json example in README.md. Countering the error: "Please make sure that your project's package.json includes a version and a name value" while starting with `nwbuild -r .`. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0c800bb9d4..f8cf2d37ba 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ Create `package.json`: ```json { "name": "nw-demo", + "version": "0.0.1", "main": "index.html" } ``` From f94f2c07c2859d27b10e1edc7d2eae90fdbd045b Mon Sep 17 00:00:00 2001 From: xueeinstein Date: Thu, 23 Apr 2015 12:57:06 +0800 Subject: [PATCH 19/41] add pre-release support --- tools/make-nw-headers.py | 3 +++ tools/package_binaries.py | 49 +++++++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/tools/make-nw-headers.py b/tools/make-nw-headers.py index 03b0ce0410..27fbde92da 100644 --- a/tools/make-nw-headers.py +++ b/tools/make-nw-headers.py @@ -2,6 +2,7 @@ import os import tarfile import sys +import getnwisrelease import getnwversion import shutil import distutils.core @@ -25,6 +26,8 @@ def update_uvh(tmp_dir, header_files): tmp_dir = os.path.normpath(os.path.join(nw_root, 'tmp')) nw_version = getnwversion.nw_version +if getnwisrelease.release == 0: + nw_version += getnwisrelease.postfix #parse command line arguments ''' diff --git a/tools/package_binaries.py b/tools/package_binaries.py index 9e630b336e..7c7eae8521 100755 --- a/tools/package_binaries.py +++ b/tools/package_binaries.py @@ -12,7 +12,7 @@ from subprocess import call -steps = ['nw', 'chromedriver', 'symbol', 'others'] +steps = ['nw', 'chromedriver', 'symbol', 'headers', 'others'] ################################ # Parse command line args parser = argparse.ArgumentParser(description='Package nw binaries.') @@ -33,8 +33,6 @@ nw_ver = None # x.xx dist_dir = None # .../out/Release/dist -is_headers_ok = False # record whether nw-headers generated - step = args.step skip = args.skip binaries_location = args.path @@ -201,26 +199,48 @@ def generate_target_symbols(platform_name, arch, version): exit(-1) return target -def generate_target_others(platform_name, arch, version): +def generate_target_headers(platform_name, arch, version): + # here, call make_nw_header tool to generate headers + # then, move to binaries_location target = {} target['output'] = '' target['compress'] = None - if platform_name == 'win': - target['input'] = ['nw.exp', 'nw.lib'] - elif platform_name == 'linux' : + if platform_name == 'osx': target['input'] = [] # here , call make-nw-headers.py to generate nw headers - # after generated, move to dist_dir make_nw_header = os.path.join(os.path.dirname(__file__), \ 'make-nw-headers.py') print make_nw_header res = call(['python', make_nw_header]) if res == 0: - global is_headers_ok - is_headers_ok = True print 'nw-headers generated' + nw_headers_name = 'nw-headers-v' + version + '.tar.gz' + nw_headers_path = os.path.join(os.path.dirname(__file__), \ + os.pardir, 'tmp', nw_headers_name) + if os.path.isfile(os.path.join(binaries_location, nw_headers_name)): + os.remove(os.path.join(binaries_location, nw_headers_name)) + shutil.move(nw_headers_path, binaries_location) + target['input'].append(nw_headers_name) else: + #TODO, handle err print 'nw-headers generate failed' + elif platform_name == 'win': + target['input'] = [] + elif platform_name == 'linux': + target['input'] = [] + else: + print 'Unsupported platform: ' + platform_name + exit(-1) + return target + +def generate_target_others(platform_name, arch, version): + target = {} + target['output'] = '' + target['compress'] = None + if platform_name == 'win': + target['input'] = ['nw.exp', 'nw.lib'] + elif platform_name == 'linux' : + target['input'] = [] else: target['input'] = [] return target @@ -282,14 +302,6 @@ def make_packages(targets): # now let's do it os.mkdir(dist_dir) - # here check whether nw headers generated - # if generated, mv to dist_dir - if is_headers_ok: - nw_headers_name = 'nw-headers-v' + nw_ver + '.tar.gz' - nw_headers_path = os.path.join(os.path.dirname(__file__), \ - os.pardir, 'tmp', nw_headers_name) - print 'Moving "' + nw_headers_name + '"' - shutil.move(nw_headers_path, dist_dir) for t in targets: if len(t['input']) == 0: continue @@ -327,6 +339,7 @@ def make_packages(targets): generators['nw'] = generate_target_nw generators['chromedriver'] = generate_target_chromedriver generators['symbol'] = generate_target_symbols +generators['headers'] = generate_target_headers generators['others'] = generate_target_others ################################ # Process targets From 946ee50b6f4a2691906843a296af8b40d3abaf4c Mon Sep 17 00:00:00 2001 From: Jefry Date: Mon, 27 Apr 2015 16:38:24 +0800 Subject: [PATCH 20/41] [Notification] [WIN] disable audio for toast notification, better fallback for toast notification, it immediately pass the failed message to the windows default bubble notification --- src/nw_notification_manager_toast_win.cc | 43 ++++++++++++++++++++---- src/nw_notification_manager_toast_win.h | 5 ++- src/nw_notification_manager_win.cc | 5 +-- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/nw_notification_manager_toast_win.cc b/src/nw_notification_manager_toast_win.cc index f37fbb3067..683f809397 100644 --- a/src/nw_notification_manager_toast_win.cc +++ b/src/nw_notification_manager_toast_win.cc @@ -106,7 +106,7 @@ typedef ABI::Windows::Foundation::ITypedEventHandler { public: - ToastEventHandler::ToastEventHandler(const int render_process_id, const int notification_id); + ToastEventHandler::ToastEventHandler(const int render_process_id, const int notification_id, const content::PlatformNotificationData& params, const SkBitmap& icon); ~ToastEventHandler(); // DesktopToastActivatedEventHandler @@ -150,12 +150,15 @@ class ToastEventHandler : private: ULONG _ref; const int _render_process_id, _notification_id; + // _params and _icon is stored for fallback to bubble notification + const content::PlatformNotificationData _params; + const SkBitmap _icon; }; // ============= ToastEventHandler Implementation ============= -ToastEventHandler::ToastEventHandler(const int render_process_id, const int notification_id) : -_ref(0), _render_process_id(render_process_id), _notification_id(notification_id) { +ToastEventHandler::ToastEventHandler(const int render_process_id, const int notification_id, const content::PlatformNotificationData& params, const SkBitmap& icon) : +_ref(0), _render_process_id(render_process_id), _notification_id(notification_id), _params(params), _icon(icon) { } ToastEventHandler::~ToastEventHandler() { @@ -195,6 +198,7 @@ IFACEMETHODIMP ToastEventHandler::Invoke(_In_ IToastNotification* /* sender */, if (fallBack) { NotificationManagerToastWin::ForceDisable = true; delete nmtw; + NotificationManager::getSingleton()->AddDesktopNotification(_params, _render_process_id, _notification_id, _icon); } return succeeded ? S_OK : E_FAIL; } @@ -244,6 +248,30 @@ HRESULT NotificationManagerToastWin::SetTextValues(_In_reads_(textValuesCount) c return hr; } +HRESULT NotificationManagerToastWin::SilentAudio(_In_ IXmlDocument *toastXml) { + ComPtr nodeList; + HRESULT hr = toastXml->GetElementsByTagName(StringReferenceWrapper(L"toast").Get(), &nodeList); + if (SUCCEEDED(hr)) { + ComPtr toastNode; + hr = nodeList->Item(0, &toastNode); + if (SUCCEEDED(hr)) { + ComPtr soundElement; + hr = toastXml->CreateElement(StringReferenceWrapper(L"audio").Get(), &soundElement); + if (SUCCEEDED(hr)) { + hr = soundElement->SetAttribute(StringReferenceWrapper(L"silent").Get(), StringReferenceWrapper(L"true").Get()); + if (SUCCEEDED(hr)) { + ComPtr soundNode, appendedSoundNode; + hr = soundElement.As(&soundNode); + if (SUCCEEDED(hr)) { + hr = toastNode->AppendChild(soundNode.Get(), &appendedSoundNode); + } + } + } + } + } + return hr; +} + HRESULT NotificationManagerToastWin::SetImageSrc(_In_z_ const wchar_t *imagePath, _In_ IXmlDocument *toastXml) { wchar_t imageSrc[MAX_PATH] = L""; HRESULT hr = StringCchCat(imageSrc, ARRAYSIZE(imageSrc), imagePath); @@ -304,13 +332,16 @@ HRESULT NotificationManagerToastWin::CreateToastXml(_In_ IToastNotificationManag }; UINT32 textLengths[] = { params.title.length(), params.body.length() }; hr = SetTextValues(textValues, 2, textLengths, *inputXml); + if (SUCCEEDED(hr)) { + hr = SilentAudio(*inputXml); + } } } return hr; } HRESULT NotificationManagerToastWin::CreateToast(_In_ IToastNotificationManagerStatics *toastManager, _In_ IXmlDocument *xml, - const int render_process_id, const int notification_id) { + const int render_process_id, const int notification_id, const content::PlatformNotificationData& params, const SkBitmap& icon) { ComPtr factory; HRESULT hr = GetActivationFactory(StringReferenceWrapper(RuntimeClass_Windows_UI_Notifications_ToastNotification).Get(), &factory); if (SUCCEEDED(hr)) { @@ -319,7 +350,7 @@ HRESULT NotificationManagerToastWin::CreateToast(_In_ IToastNotificationManagerS if (SUCCEEDED(hr)) { // Register the event handlers EventRegistrationToken activatedToken, dismissedToken, failedToken; - ComPtr eventHandler = new ToastEventHandler(render_process_id, notification_id); + ComPtr eventHandler = new ToastEventHandler(render_process_id, notification_id, params, icon); hr = toast->add_Activated(eventHandler.Get(), &activatedToken); if (SUCCEEDED(hr)) { @@ -384,7 +415,7 @@ bool NotificationManagerToastWin::AddDesktopNotification(const content::Platform ComPtr toastXml; HRESULT hr = CreateToastXml(toastStatics_.Get(), params, icon, &toastXml); if (SUCCEEDED(hr)) { - hr = CreateToast(toastStatics_.Get(), toastXml.Get(), render_process_id, notification_id); + hr = CreateToast(toastStatics_.Get(), toastXml.Get(), render_process_id, notification_id, params, icon); if (SUCCEEDED(hr)) DesktopNotificationPostDisplay(render_process_id, notification_id); } diff --git a/src/nw_notification_manager_toast_win.h b/src/nw_notification_manager_toast_win.h index e2dbaad0c2..3aeebeff80 100644 --- a/src/nw_notification_manager_toast_win.h +++ b/src/nw_notification_manager_toast_win.h @@ -39,7 +39,7 @@ class NotificationManagerToastWin : public NotificationManager { static bool ForceDisable; HRESULT CreateToast(_In_ IToastNotificationManagerStatics *toastManager, _In_ IXmlDocument *xml, - const int render_process_id, const int notification_id); + const int render_process_id, const int notification_id, const content::PlatformNotificationData& params, const SkBitmap& icon); // Create the toast XML from a template HRESULT CreateToastXml(_In_ IToastNotificationManagerStatics *toastManager, @@ -48,6 +48,9 @@ class NotificationManagerToastWin : public NotificationManager { // Set the value of the "src" attribute of the "image" node HRESULT SetImageSrc(_In_z_ const wchar_t *imagePath, _In_ IXmlDocument *toastXml); + // Set the value of the "silent" attribute of the "audio" node + HRESULT SilentAudio( _In_ IXmlDocument *toastXml); + // Set the values of each of the text nodes HRESULT SetTextValues(_In_reads_(textValuesCount) const wchar_t **textValues, _In_ UINT32 textValuesCount, _In_reads_(textValuesCount) UINT32 *textValuesLengths, _In_ IXmlDocument *toastXml); diff --git a/src/nw_notification_manager_win.cc b/src/nw_notification_manager_win.cc index 59ee0bc864..5ad90c2356 100644 --- a/src/nw_notification_manager_win.cc +++ b/src/nw_notification_manager_win.cc @@ -132,7 +132,8 @@ NotificationManagerWin::~NotificationManagerWin() { bool NotificationManagerWin::AddDesktopNotification(const content::PlatformNotificationData& params, const int render_process_id, const int notification_id, const SkBitmap& bitmap_icon) { - if (status_tray_ == NULL) Init(); + if (status_tray_ == NULL) + if(!Init()) return false; content::Shell* shell = content::Shell::windows()[0]; @@ -150,7 +151,7 @@ bool NotificationManagerWin::AddDesktopNotification(const content::PlatformNotif if (status_icon == NULL) { nw::Package* package = shell->GetPackage(); status_icon_ = status_tray_->CreateStatusIcon(StatusTray::NOTIFICATION_TRAY_ICON, - *(shell->window()->app_icon().ToImageSkia()), base::UTF8ToUTF16(package->GetName())); + icon.IsEmpty() ? gfx::ImageSkia() : *icon.ToImageSkia(), base::UTF8ToUTF16(package->GetName())); status_icon = status_icon_; status_observer_ = new TrayObserver(this); status_icon->AddObserver(status_observer_); From 0038f722e779f977df9d43e195c7e706c4b2b2a4 Mon Sep 17 00:00:00 2001 From: Roger Date: Mon, 11 May 2015 10:32:27 +0800 Subject: [PATCH 21/41] [README] update for 0.13.0-alpha0 --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 0bf491c8c9..79d7ccc2b8 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,12 @@ It was created in the Intel Open Source Technology Center. * Windows: [32bit](http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-win-ia32.zip) / [64bit](http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-win-x64.zip) * Mac 10.7+: [32bit](http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-osx-ia32.zip) / [64bit](http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-osx-x64.zip) +* **v0.13.0-alpha0:** (May 10, 2015, based off of IO.js v1.5.1, Chromium 43.0.2357.45): [release notes](https://groups.google.com/d/msg/nwjs-general/IqfH1RXNGlw/2PgeRGHO-B4J) + **NOTE** You might want the **SDK build**. Please read the [release notes](https://groups.google.com/d/msg/nwjs-general/IqfH1RXNGlw/2PgeRGHO-B4J) + * Linux: [32bit](http://dl.nwjs.io/v0.13.0/alpha0/nwjs-v0.13.0-alpha0-linux-ia32.tar.gz) / [64bit](http://dl.nwjs.io/v0.13.0/alpha0/nwjs-v0.13.0-alpha0-linux-x64.tar.gz) + * Windows: [32bit](http://dl.nwjs.io/v0.13.0/alpha0/nwjs-v0.13.0-alpha0-win-ia32.zip) / [64bit](http://dl.nwjs.io/v0.13.0/alpha0/nwjs-v0.13.0-alpha0-win-x64.zip) + * Mac 10.7+: [32bit](http://dl.nwjs.io/v0.13.0/alpha0/nwjs-v0.13.0-alpha0-osx-ia32.zip) / [64bit](http://dl.nwjs.io/v0.13.0/alpha0/nwjs-v0.13.0-alpha0-osx-x64.zip) + * **0.8.6:** (Apr 18, 2014, based off of Node v0.10.22, Chrome 30.0.1599.66) **If your native Node module works only with Node v0.10, then you should use node-webkit v0.8.x, which is also a maintained branch. [More info](https://groups.google.com/d/msg/nwjs-general/2OJ1cEMPLlA/09BvpTagSA0J)** [release notes](https://groups.google.com/d/msg/nwjs-general/CLPkgfV-i7s/hwkkQuJ1kngJ) From 14bc8807b06ae8b529ab5d99a942abcfd670e59a Mon Sep 17 00:00:00 2001 From: Roger Date: Thu, 21 May 2015 09:19:46 +0800 Subject: [PATCH 22/41] enable protocol interceptors --- src/net/shell_url_request_context_getter.cc | 18 ++++++++++++++++-- src/net/shell_url_request_context_getter.h | 2 ++ src/shell_browser_context.cc | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/net/shell_url_request_context_getter.cc b/src/net/shell_url_request_context_getter.cc index d9bc339678..9c9ea85eb4 100644 --- a/src/net/shell_url_request_context_getter.cc +++ b/src/net/shell_url_request_context_getter.cc @@ -60,6 +60,7 @@ #include "net/url_request/static_http_user_agent_settings.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_storage.h" +#include "net/url_request/url_request_intercepting_job_factory.h" #include "net/url_request/url_request_job_factory_impl.h" #include "ui/base/l10n/l10n_util.h" @@ -132,6 +133,7 @@ ShellURLRequestContextGetter::ShellURLRequestContextGetter( MessageLoop* file_loop, ProtocolHandlerMap* protocol_handlers, ShellBrowserContext* browser_context, + URLRequestInterceptorScopedVector request_interceptors, const std::string& auth_schemes, const std::string& auth_server_whitelist, const std::string& auth_delegate_whitelist, @@ -149,6 +151,7 @@ ShellURLRequestContextGetter::ShellURLRequestContextGetter( io_loop_(io_loop), file_loop_(file_loop), browser_context_(browser_context), + request_interceptors_(request_interceptors.Pass()), extension_info_map_(extension_info_map){ // Must first be created on the UI thread. DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -244,7 +247,7 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { net::HttpCache::DefaultBackend* main_backend = new net::HttpCache::DefaultBackend( net::DISK_CACHE, - net::CACHE_BACKEND_SIMPLE, + net::CACHE_BACKEND_BLOCKFILE, cache_path, 10 * 1024 * 1024, // 10M BrowserThread::GetMessageLoopProxyForThread( @@ -292,8 +295,19 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { new net::AppProtocolHandler(root_path_)); job_factory->SetProtocolHandler("nw", new nw::NwProtocolHandler()); - storage_->set_job_factory(job_factory.release()); + // Set up interceptors in the reverse order. + scoped_ptr top_job_factory = + job_factory.Pass(); + for (URLRequestInterceptorScopedVector::reverse_iterator i = + request_interceptors_.rbegin(); + i != request_interceptors_.rend(); + ++i) { + top_job_factory.reset(new net::URLRequestInterceptingJobFactory( + top_job_factory.Pass(), make_scoped_ptr(*i))); + } + request_interceptors_.weak_clear(); + storage_->set_job_factory(top_job_factory.release()); } return url_request_context_.get(); diff --git a/src/net/shell_url_request_context_getter.h b/src/net/shell_url_request_context_getter.h index a594714346..130000da3f 100644 --- a/src/net/shell_url_request_context_getter.h +++ b/src/net/shell_url_request_context_getter.h @@ -62,6 +62,7 @@ class ShellBrowserContext; base::MessageLoop* file_loop, ProtocolHandlerMap* protocol_handlers, ShellBrowserContext*, + URLRequestInterceptorScopedVector request_interceptors, const std::string& auth_schemes, const std::string& auth_server_whitelist, const std::string& auth_delegate_whitelist, @@ -108,6 +109,7 @@ class ShellBrowserContext; scoped_ptr url_security_manager_; ProtocolHandlerMap protocol_handlers_; ShellBrowserContext* browser_context_; + URLRequestInterceptorScopedVector request_interceptors_; extensions::InfoMap* extension_info_map_; DISALLOW_COPY_AND_ASSIGN(ShellURLRequestContextGetter); diff --git a/src/shell_browser_context.cc b/src/shell_browser_context.cc index eb52368f8d..a5299d1125 100644 --- a/src/shell_browser_context.cc +++ b/src/shell_browser_context.cc @@ -185,7 +185,7 @@ net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( package_->path(), BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE), - protocol_handlers, this, + protocol_handlers, this, protocol_interceptors.Pass(), auth_schemes, auth_server_whitelist, auth_delegate_whitelist, gssapi_library_name, extension_info_map); From 9e81217bd3e207a346ad07221a475eaeb640b724 Mon Sep 17 00:00:00 2001 From: Roger Date: Thu, 21 May 2015 09:27:24 +0800 Subject: [PATCH 23/41] bump version to 0.12.2 --- src/nw_version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nw_version.h b/src/nw_version.h index 1fda1b5713..9b69198793 100644 --- a/src/nw_version.h +++ b/src/nw_version.h @@ -23,7 +23,7 @@ #define NW_MAJOR_VERSION 0 #define NW_MINOR_VERSION 12 -#define NW_PATCH_VERSION 1 +#define NW_PATCH_VERSION 2 #define NW_VERSION_IS_RELEASE 1 #ifndef NW_STRINGIFY From caedb6a2bec6b339fc86d0f229807aa752b11818 Mon Sep 17 00:00:00 2001 From: Jefry Date: Wed, 20 May 2015 14:31:20 +0800 Subject: [PATCH 24/41] [Screen Selection] add application name to the UI, cancelChooseDesktopMedia implementation --- src/api/screen/desktop_capture_api.cc | 9 ++++++--- src/api/screen/screen.cc | 8 ++++++++ src/api/screen/screen.js | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/api/screen/desktop_capture_api.cc b/src/api/screen/desktop_capture_api.cc index 7a03e36fbb..91339c79b6 100644 --- a/src/api/screen/desktop_capture_api.cc +++ b/src/api/screen/desktop_capture_api.cc @@ -12,6 +12,8 @@ #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#include "content/nw/src/nw_package.h" +#include "content/nw/src/nw_shell.h" #include "net/base/net_util.h" #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" @@ -68,7 +70,8 @@ bool DesktopCaptureChooseDesktopMediaFunction::RunSync() { // also be used to determine where to show the picker's UI. content::WebContents* web_contents = content::WebContents::FromRenderViewHost(render_view_host()); DCHECK(web_contents); - base::string16 target_name; + content::Shell* shell = content::Shell::windows()[0]; + base::string16 app_name = base::UTF8ToUTF16(shell->GetPackage()->GetName()); // Register to be notified when the tab is closed. Observe(web_contents); @@ -136,8 +139,8 @@ bool DesktopCaptureChooseDesktopMediaFunction::RunSync() { picker_->Show(web_contents, parent_window, parent_window, - target_name, - target_name, + app_name, + app_name, media_list.Pass(), callback); return true; diff --git a/src/api/screen/screen.cc b/src/api/screen/screen.cc index 2045ad5105..51ca93028b 100644 --- a/src/api/screen/screen.cc +++ b/src/api/screen/screen.cc @@ -164,6 +164,14 @@ void Screen::Call(DispatcherHost* dispatcher_host, // Screen Picker GUI is still active, return false; result->AppendBoolean(false); } + } else if (method == "CancelChooseDesktopMedia") { + if (gpDCCDMF) { + gpDCCDMF->Cancel(); + gpDCCDMF = NULL; + result->AppendBoolean(true); + } else { + result->AppendBoolean(false); + } } } diff --git a/src/api/screen/screen.js b/src/api/screen/screen.js index 544757e21b..af9e41a7ab 100644 --- a/src/api/screen/screen.js +++ b/src/api/screen/screen.js @@ -74,6 +74,9 @@ Screen.prototype.chooseDesktopMedia = function(array, callback) { return false; } +Screen.prototype.cancelChooseDesktopMedia = function() { + return nw.callStaticMethodSync('Screen', 'CancelChooseDesktopMedia', [ this.id ])[0]; +} // ======== Screen functions End ======== // Store App object in node's context. From 242d1c8d5be7d856e49e143a5b9de8e674867143 Mon Sep 17 00:00:00 2001 From: Roger Date: Fri, 22 May 2015 22:14:45 +0800 Subject: [PATCH 25/41] [CHANGELOG] update for 0.12.2 --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c03e2eb0a2..5190ad9173 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +0.12.2 / 05-22-2015 +=================== +- Fix #2723: [OSX] cpu hog in some cases +- Fix #3361: application cache +- Fix #2720: [Linux] launching sudo hits error: effective uid is not 0 +- Fix #2819: enable cookie support for web sockets +- Fix #2713: crash with 'new-win-policy' and opening window from iframe +- Fix #3123: support no-displaying-insecure-content and allow-running-insecure-content +- [Screen Selection] add application name to the UI; cancelChooseDesktopMedia implementation +- [Notification] [WIN] disable audio for toast notification, better fallback for toast notification +- Change cache backend from "simple" to "blockfile" + 0.12.1 / 04-13-2015 =================== - Fix crash dump generation From 757cfcb1ebdec803fec30059e3b9ff189d1847c7 Mon Sep 17 00:00:00 2001 From: Roger Date: Fri, 22 May 2015 22:25:41 +0800 Subject: [PATCH 26/41] [README] update for 0.12.2 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 79d7ccc2b8..17058f1123 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ It was created in the Intel Open Source Technology Center. * Available on Linux, Mac OS X and Windows ## Downloads -* **v0.12.1:** (Apr 13, 2015, based off of IO.js v1.2.0, Chromium 41.0.2272.76): [release notes](https://groups.google.com/d/msg/nwjs-general/bvdnDJAx91U/0womlMli4FUJ) - * Linux: [32bit](http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-linux-ia32.tar.gz) / [64bit](http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-linux-x64.tar.gz) - * Windows: [32bit](http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-win-ia32.zip) / [64bit](http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-win-x64.zip) - * Mac 10.7+: [32bit](http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-osx-ia32.zip) / [64bit](http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-osx-x64.zip) +* **v0.12.2:** (May 22, 2015, based off of IO.js v1.2.0, Chromium 41.0.2272.76): [release notes](https://groups.google.com/d/msg/nwjs-general/Xbq64dUKZsk/_pTwW7hgAfkJ) + * Linux: [32bit](http://dl.nwjs.io/v0.12.2/nwjs-v0.12.2-linux-ia32.tar.gz) / [64bit](http://dl.nwjs.io/v0.12.2/nwjs-v0.12.2-linux-x64.tar.gz) + * Windows: [32bit](http://dl.nwjs.io/v0.12.2/nwjs-v0.12.2-win-ia32.zip) / [64bit](http://dl.nwjs.io/v0.12.2/nwjs-v0.12.2-win-x64.zip) + * Mac 10.7+: [32bit](http://dl.nwjs.io/v0.12.2/nwjs-v0.12.2-osx-ia32.zip) / [64bit](http://dl.nwjs.io/v0.12.2/nwjs-v0.12.2-osx-x64.zip) * **v0.13.0-alpha0:** (May 10, 2015, based off of IO.js v1.5.1, Chromium 43.0.2357.45): [release notes](https://groups.google.com/d/msg/nwjs-general/IqfH1RXNGlw/2PgeRGHO-B4J) **NOTE** You might want the **SDK build**. Please read the [release notes](https://groups.google.com/d/msg/nwjs-general/IqfH1RXNGlw/2PgeRGHO-B4J) From 9976ae8fe26bd145eb0484f3a7200b6b2864db0c Mon Sep 17 00:00:00 2001 From: Rick Edgecombe Date: Wed, 3 Jun 2015 15:29:35 -0700 Subject: [PATCH 27/41] Handle handling of duplicate "add" events that were appearing in some platforms, fix some spacing --- nw.gypi | 2 +- src/api/screen/desktop_capture_monitor.cc | 8 ++++---- src/api/screen/desktop_capture_monitor.h | 2 +- src/api/screen/screen.js | 18 ++++++++++++++---- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/nw.gypi b/nw.gypi index ec6a05fc76..16100e38dd 100644 --- a/nw.gypi +++ b/nw.gypi @@ -207,7 +207,7 @@ 'src/api/event/event.cc', 'src/api/screen/desktop_capture_api.h', 'src/api/screen/desktop_capture_api.cc', - 'src/api/screen/desktop_capture_monitor.cc', + 'src/api/screen/desktop_capture_monitor.cc', 'src/api/screen/desktop_capture_monitor.h', '<(DEPTH)/chrome/browser/media/desktop_media_list.h', '<(DEPTH)/chrome/browser/media/desktop_media_list_observer.h', diff --git a/src/api/screen/desktop_capture_monitor.cc b/src/api/screen/desktop_capture_monitor.cc index 3d56a26e6d..f2ebf77191 100644 --- a/src/api/screen/desktop_capture_monitor.cc +++ b/src/api/screen/desktop_capture_monitor.cc @@ -98,12 +98,12 @@ void DesktopCaptureMonitor::OnSourceAdded(int index){ param.AppendString(src.id.ToString()); param.AppendString(src.name); param.AppendInteger(index); - param.AppendString(type); + param.AppendString(type); this->dispatcher_host()->SendEvent(this, "__nw_desktop_capture_monitor_listner_added", param); } void DesktopCaptureMonitor::OnSourceRemoved(int index){ base::ListValue param; - param.AppendInteger(index); //pass by index here, because the information about which ID was at that index is lost before the removed callback is called. Its saved in the javascript though, so we can look it up there + param.AppendInteger(index); //pass by index here, because the information about which ID was at that index is lost before the removed callback is called. Its saved in the javascript though, so we can look it up there this->dispatcher_host()->SendEvent(this, "__nw_desktop_capture_monitor_listner_removed", param); } void DesktopCaptureMonitor::OnSourceMoved(int old_index, int new_index){ @@ -111,7 +111,7 @@ void DesktopCaptureMonitor::OnSourceMoved(int old_index, int new_index){ base::ListValue param; param.AppendString(src.id.ToString()); param.AppendInteger(new_index); - param.AppendInteger(old_index); + param.AppendInteger(old_index); this->dispatcher_host()->SendEvent(this, "__nw_desktop_capture_monitor_listner_moved", param); } void DesktopCaptureMonitor::OnSourceNameChanged(int index){ @@ -119,7 +119,7 @@ void DesktopCaptureMonitor::OnSourceNameChanged(int index){ base::ListValue param; param.AppendString(src.id.ToString()); - param.AppendString(src.name); + param.AppendString(src.name); this->dispatcher_host()->SendEvent(this, "__nw_desktop_capture_monitor_listner_namechanged", param); } diff --git a/src/api/screen/desktop_capture_monitor.h b/src/api/screen/desktop_capture_monitor.h index 82dc160ff6..e6032f448b 100644 --- a/src/api/screen/desktop_capture_monitor.h +++ b/src/api/screen/desktop_capture_monitor.h @@ -30,7 +30,7 @@ namespace nwapi { DesktopCaptureMonitor(int id, const base::WeakPtr& dispatcher_host, const base::DictionaryValue& option); - virtual ~DesktopCaptureMonitor(); + virtual ~DesktopCaptureMonitor() override; virtual void CallSync(const std::string& method, const base::ListValue& arguments, base::ListValue* result) override; virtual void OnSourceAdded(int index); virtual void OnSourceRemoved(int index); diff --git a/src/api/screen/screen.js b/src/api/screen/screen.js index d05d2be4ea..5928d7ec7f 100644 --- a/src/api/screen/screen.js +++ b/src/api/screen/screen.js @@ -25,6 +25,7 @@ function DesktopCaptureMonitor() { } require('util').inherits(DesktopCaptureMonitor, exports.Base); + DesktopCaptureMonitor.prototype.start = function (screens, windows) { if (this.started) return false; @@ -43,6 +44,11 @@ DesktopCaptureMonitor.prototype.stop = function () { } DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_added', function (id, name, order, type) { + if(this.sources.indexOf(id)!=-1) + { + //TODO: Find out what this event comes twice on some platforms + return; + } this.sources.splice(order, 0, id); this.emit("added", id, name, order, type); for (var i = order + 1; i <= this.sources.length - 1; i++) { @@ -51,7 +57,7 @@ DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_added', }); -DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_removed', function (index) { +DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_removed', function (index) { var id = this.sources[index]; if (index != -1) { this.sources.splice(index, 1); @@ -62,7 +68,7 @@ DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_removed } }); -DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_moved', function (id, new_index, old_index) { +DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_moved', function (id, new_index, old_index) { var temp = this.sources[old_index]; this.sources.splice(old_index, 1); this.sources.splice(new_index, 0, temp); @@ -71,14 +77,15 @@ DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_moved', this.emit("orderchanged", this.sources[i + 1], i + 1, i); }); -DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_namechanged', function (id, name) { +DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_namechanged', function (id, name) { this.emit("namechanged", id, name); }); -DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_thumbnailchanged', function (id, thumbnail) { +DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_thumbnailchanged', function (id, thumbnail) { this.emit("thumbnailchanged", id, thumbnail); }); +var listenerCount=0; DesktopCaptureMonitor.prototype.on = DesktopCaptureMonitor.prototype.addListener = function (ev, callback) { //throw except if unsupported event if (ev != "added" && ev != "removed" && ev != "orderchanged" && ev != "namechanged" && ev != "thumbnailchanged") @@ -87,6 +94,9 @@ DesktopCaptureMonitor.prototype.on = DesktopCaptureMonitor.prototype.addListener process.EventEmitter.prototype.addListener.apply(this, arguments); } + +exports.DesktopCaptureMonitor=DesktopCaptureMonitor; + var screenInstance = null; function Screen() { From 355fac7bfc32aa90871cf9441bffc3e602d086dd Mon Sep 17 00:00:00 2001 From: Roger Date: Thu, 11 Jun 2015 10:49:57 +0800 Subject: [PATCH 28/41] [README] update for 0.13.0-alpha1 --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 17058f1123..3cbd624fb9 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,11 @@ It was created in the Intel Open Source Technology Center. * Windows: [32bit](http://dl.nwjs.io/v0.12.2/nwjs-v0.12.2-win-ia32.zip) / [64bit](http://dl.nwjs.io/v0.12.2/nwjs-v0.12.2-win-x64.zip) * Mac 10.7+: [32bit](http://dl.nwjs.io/v0.12.2/nwjs-v0.12.2-osx-ia32.zip) / [64bit](http://dl.nwjs.io/v0.12.2/nwjs-v0.12.2-osx-x64.zip) -* **v0.13.0-alpha0:** (May 10, 2015, based off of IO.js v1.5.1, Chromium 43.0.2357.45): [release notes](https://groups.google.com/d/msg/nwjs-general/IqfH1RXNGlw/2PgeRGHO-B4J) - **NOTE** You might want the **SDK build**. Please read the [release notes](https://groups.google.com/d/msg/nwjs-general/IqfH1RXNGlw/2PgeRGHO-B4J) - * Linux: [32bit](http://dl.nwjs.io/v0.13.0/alpha0/nwjs-v0.13.0-alpha0-linux-ia32.tar.gz) / [64bit](http://dl.nwjs.io/v0.13.0/alpha0/nwjs-v0.13.0-alpha0-linux-x64.tar.gz) - * Windows: [32bit](http://dl.nwjs.io/v0.13.0/alpha0/nwjs-v0.13.0-alpha0-win-ia32.zip) / [64bit](http://dl.nwjs.io/v0.13.0/alpha0/nwjs-v0.13.0-alpha0-win-x64.zip) - * Mac 10.7+: [32bit](http://dl.nwjs.io/v0.13.0/alpha0/nwjs-v0.13.0-alpha0-osx-ia32.zip) / [64bit](http://dl.nwjs.io/v0.13.0/alpha0/nwjs-v0.13.0-alpha0-osx-x64.zip) +* **v0.13.0-alpha1:** (Jun 11, 2015, based off of IO.js v1.5.1, Chromium 43.0.2357.45): [release notes](https://groups.google.com/d/msg/nwjs-general/c25l_jGMqj8/rsAtdSQuxeUJ) + **NOTE** You might want the **SDK build**. Please read the release notes + * Linux: [32bit](http://dl.nwjs.io/v0.13.0/alpha1/nwjs-v0.13.0-alpha1-linux-ia32.tar.gz) / [64bit](http://dl.nwjs.io/v0.13.0/alpha1/nwjs-v0.13.0-alpha1-linux-x64.tar.gz) + * Windows: [32bit](http://dl.nwjs.io/v0.13.0/alpha1/nwjs-v0.13.0-alpha1-win-ia32.zip) / [64bit](http://dl.nwjs.io/v0.13.0/alpha1/nwjs-v0.13.0-alpha1-win-x64.zip) + * Mac 10.7+: [32bit](http://dl.nwjs.io/v0.13.0/alpha1/nwjs-v0.13.0-alpha1-osx-ia32.zip) / [64bit](http://dl.nwjs.io/v0.13.0/alpha1/nwjs-v0.13.0-alpha1-osx-x64.zip) * **0.8.6:** (Apr 18, 2014, based off of Node v0.10.22, Chrome 30.0.1599.66) **If your native Node module works only with Node v0.10, then you should use node-webkit v0.8.x, which is also a maintained branch. [More info](https://groups.google.com/d/msg/nwjs-general/2OJ1cEMPLlA/09BvpTagSA0J)** [release notes](https://groups.google.com/d/msg/nwjs-general/CLPkgfV-i7s/hwkkQuJ1kngJ) From 8b944e51378343d64f3d2cc01384e38ed3b71bdd Mon Sep 17 00:00:00 2001 From: Rick Edgecombe Date: Thu, 11 Jun 2015 13:35:29 -0700 Subject: [PATCH 29/41] Detect primary monitor on windows --- src/api/screen/desktop_capture_monitor.cc | 25 +++++++++++++++++++++++ src/api/screen/desktop_capture_monitor.h | 1 + src/api/screen/screen.js | 4 ++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/api/screen/desktop_capture_monitor.cc b/src/api/screen/desktop_capture_monitor.cc index f2ebf77191..6afa1e291d 100644 --- a/src/api/screen/desktop_capture_monitor.cc +++ b/src/api/screen/desktop_capture_monitor.cc @@ -36,6 +36,9 @@ #include "ui/gfx/image/image.h" #include "ui/gfx/image/image_skia.h" +#ifdef _WIN32 +#include +#endif namespace nwapi { @@ -47,6 +50,25 @@ DesktopCaptureMonitor::DesktopCaptureMonitor(int id, DesktopCaptureMonitor::~DesktopCaptureMonitor() {} +int DesktopCaptureMonitor::GetPrimaryMonitorIndex(){ +#ifdef _WIN32 + int count=0; + for (int i = 0;; ++i) { + DISPLAY_DEVICE device; + device.cb = sizeof(device); + BOOL ret = EnumDisplayDevices(NULL, i, &device, 0); + if(!ret) + break; + if (device.StateFlags & DISPLAY_DEVICE_ACTIVE){ + if (device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE){ + return count; + } + count++; + } + } +#endif + return -1; +} void DesktopCaptureMonitor::CallSync(const std::string& method, const base::ListValue& arguments, base::ListValue* result){ if (method == "start") { @@ -99,6 +121,9 @@ void DesktopCaptureMonitor::OnSourceAdded(int index){ param.AppendString(src.name); param.AppendInteger(index); param.AppendString(type); + if(src.id.type == content::DesktopMediaID::TYPE_SCREEN){ + param.AppendBoolean(GetPrimaryMonitorIndex()==index); + } this->dispatcher_host()->SendEvent(this, "__nw_desktop_capture_monitor_listner_added", param); } void DesktopCaptureMonitor::OnSourceRemoved(int index){ diff --git a/src/api/screen/desktop_capture_monitor.h b/src/api/screen/desktop_capture_monitor.h index e6032f448b..95b868b2ef 100644 --- a/src/api/screen/desktop_capture_monitor.h +++ b/src/api/screen/desktop_capture_monitor.h @@ -40,6 +40,7 @@ namespace nwapi { private: DesktopCaptureMonitor(); DISALLOW_COPY_AND_ASSIGN(DesktopCaptureMonitor); + int GetPrimaryMonitorIndex(); void Start(bool screens, bool windows); void Stop(); diff --git a/src/api/screen/screen.js b/src/api/screen/screen.js index 867b23bf59..0f2c290fef 100644 --- a/src/api/screen/screen.js +++ b/src/api/screen/screen.js @@ -43,14 +43,14 @@ DesktopCaptureMonitor.prototype.stop = function () { return true; } -DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_added', function (id, name, order, type) { +DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_added', function (id, name, order, type, primaryindex) { if(this.sources.indexOf(id)!=-1) { //TODO: Find out what this event comes twice on some platforms return; } this.sources.splice(order, 0, id); - this.emit("added", id, name, order, type); + this.emit("added", id, name, order, type, primaryindex); for (var i = order + 1; i <= this.sources.length - 1; i++) { this.emit("orderchanged", this.sources[i], i, i - 1); } From 588fba7cd80934891d70adb1eaa6b060036d692a Mon Sep 17 00:00:00 2001 From: Brad Metcalf Date: Mon, 15 Jun 2015 16:53:33 -0500 Subject: [PATCH 30/41] Updated license year Updated license year per instruction given in the description of commit fb491827d885702a14d715b6db0b333f046011f2 --- LICENSE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 3a4009653d..ba52b7c91d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ -Copyright (c) 2012-2014 Intel Corp -Copyright (c) 2012-2014 The Chromium Authors +Copyright (c) 2012-2015 Intel Corp +Copyright (c) 2012-2015 The Chromium Authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in th From f2de859c26ce75b6f6e7a4a5e3f9ba5f725ded25 Mon Sep 17 00:00:00 2001 From: Roger Date: Fri, 17 Jul 2015 15:23:43 +0800 Subject: [PATCH 31/41] support MAS packaging --- nw.gypi | 11 ++++++++++- tools/package_binaries.py | 27 ++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/nw.gypi b/nw.gypi index 16100e38dd..0b4bc0f863 100644 --- a/nw.gypi +++ b/nw.gypi @@ -914,6 +914,15 @@ { 'target_name': 'dist', 'type': 'none', + 'variables': { + 'conditions': [ + ['nwjs_mas==1', { + 'package_mode': 'mas', + }, { + 'package_mode': 'regular', + }], + ], # conditions + }, # variables 'actions': [ { 'action_name': 'package_nw_binaries', @@ -926,7 +935,7 @@ 'outputs':[ '<(PRODUCT_DIR)/new_package.re', ], - 'action': ['python', '<(package_script)', '-p', '<(PRODUCT_DIR)', '-a', '<(target_arch)'], + 'action': ['python', '<(package_script)', '-p', '<(PRODUCT_DIR)', '-a', '<(target_arch)', '-m', '<(package_mode)'], }, ], 'dependencies': [ diff --git a/tools/package_binaries.py b/tools/package_binaries.py index 7c7eae8521..cd1b8540cb 100755 --- a/tools/package_binaries.py +++ b/tools/package_binaries.py @@ -18,6 +18,7 @@ parser = argparse.ArgumentParser(description='Package nw binaries.') parser.add_argument('-p','--path', help='Where to find the binaries, like out/Release', required=False) parser.add_argument('-a','--arch', help='target arch', required=False) +parser.add_argument('-m','--mode', help='package mode', required=False) group = parser.add_mutually_exclusive_group() group.add_argument('-s','--step', choices=steps, help='Execute specified step.', required=False) group.add_argument('-n','--skip', choices=steps, help='Skip specified step.', required=False) @@ -33,6 +34,11 @@ nw_ver = None # x.xx dist_dir = None # .../out/Release/dist +package_name = 'nwjs' + +if args.mode == 'mas': + package_name = 'nwjs-macappstore' + step = args.step skip = args.skip binaries_location = args.path @@ -105,7 +111,7 @@ def generate_target_nw(platform_name, arch, version): target = {} # Output target['output'] = ''.join([ - 'nwjs-', + package_name, '-', 'v', version, '-', platform_name, '-', arch]) @@ -151,6 +157,9 @@ def generate_target_nw(platform_name, arch, version): return target def generate_target_chromedriver(platform_name, arch, version): + if args.mode == 'mas': + return generate_target_empty(platform_name, arch, version) + target = {} # Output target['output'] = ''.join([ @@ -173,7 +182,7 @@ def generate_target_chromedriver(platform_name, arch, version): def generate_target_symbols(platform_name, arch, version): target = {} - target['output'] = ''.join(['nwjs-symbol-', + target['output'] = ''.join([package_name, '-symbol-', 'v', version, '-', platform_name, '-', arch]) @@ -184,7 +193,7 @@ def generate_target_symbols(platform_name, arch, version): elif platform_name == 'win': target['compress'] = None target['input'] = ['nw.sym.7z'] - target['output'] = ''.join(['nwjs-symbol-', + target['output'] = ''.join([package_name, '-symbol-', 'v', version, '-', platform_name, '-', arch, '.7z']) @@ -233,6 +242,18 @@ def generate_target_headers(platform_name, arch, version): exit(-1) return target +def generate_target_empty(platform_name, arch, version): + target = {} + target['output'] = '' + target['compress'] = None + if platform_name == 'win': + target['input'] = [] + elif platform_name == 'linux' : + target['input'] = [] + else: + target['input'] = [] + return target + def generate_target_others(platform_name, arch, version): target = {} target['output'] = '' From b34e91dda7a64b00726d91f8b76f2645a6c967d4 Mon Sep 17 00:00:00 2001 From: Roger Date: Fri, 17 Jul 2015 15:24:18 +0800 Subject: [PATCH 32/41] bump version to v0.12.3 --- src/mac/app-Info.plist | 2 +- src/nw_version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mac/app-Info.plist b/src/mac/app-Info.plist index 7f3c1fdac9..f521c701d6 100644 --- a/src/mac/app-Info.plist +++ b/src/mac/app-Info.plist @@ -19,7 +19,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.12.1 + 0.12.3 NSPrincipalClass NSApplication LSMinimumSystemVersion diff --git a/src/nw_version.h b/src/nw_version.h index 9b69198793..b7afd76345 100644 --- a/src/nw_version.h +++ b/src/nw_version.h @@ -23,7 +23,7 @@ #define NW_MAJOR_VERSION 0 #define NW_MINOR_VERSION 12 -#define NW_PATCH_VERSION 2 +#define NW_PATCH_VERSION 3 #define NW_VERSION_IS_RELEASE 1 #ifndef NW_STRINGIFY From 40418e9148a23dae4a15415ffcdd0e56329cbc51 Mon Sep 17 00:00:00 2001 From: Rick Edgecombe Date: Tue, 21 Jul 2015 12:42:16 -0700 Subject: [PATCH 33/41] Add name to authors --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 1f41d665ef..0679037506 100644 --- a/AUTHORS +++ b/AUTHORS @@ -36,3 +36,4 @@ Daniel Braun Chase Willden Anton Khlynovskiy Wu Yuehang +Rick Edgecombe From 591068bf6df8e37350b539745d0d289dc54c433f Mon Sep 17 00:00:00 2001 From: Roger Wang Date: Wed, 29 Jul 2015 13:40:21 +0800 Subject: [PATCH 34/41] fix desktop_capture_monitor style --- src/api/screen/desktop_capture_monitor.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/api/screen/desktop_capture_monitor.h b/src/api/screen/desktop_capture_monitor.h index 95b868b2ef..5397897425 100644 --- a/src/api/screen/desktop_capture_monitor.h +++ b/src/api/screen/desktop_capture_monitor.h @@ -30,13 +30,13 @@ namespace nwapi { DesktopCaptureMonitor(int id, const base::WeakPtr& dispatcher_host, const base::DictionaryValue& option); - virtual ~DesktopCaptureMonitor() override; - virtual void CallSync(const std::string& method, const base::ListValue& arguments, base::ListValue* result) override; - virtual void OnSourceAdded(int index); - virtual void OnSourceRemoved(int index); - virtual void OnSourceMoved(int old_index, int new_index); - virtual void OnSourceNameChanged(int index); - virtual void OnSourceThumbnailChanged(int index); + ~DesktopCaptureMonitor() override; + void CallSync(const std::string& method, const base::ListValue& arguments, base::ListValue* result) override; + void OnSourceAdded(int index) override; + void OnSourceRemoved(int index) override; + void OnSourceMoved(int old_index, int new_index) override; + void OnSourceNameChanged(int index) override; + void OnSourceThumbnailChanged(int index) override; private: DesktopCaptureMonitor(); DISALLOW_COPY_AND_ASSIGN(DesktopCaptureMonitor); @@ -47,4 +47,4 @@ namespace nwapi { scoped_ptr media_list_; }; } // namespace api -#endif // CONTENT_NW_SRC_API_DESKTOPCAPTURE_H_ \ No newline at end of file +#endif // CONTENT_NW_SRC_API_DESKTOPCAPTURE_H_ From 9cf4fa8105186f6cc14d67e257461aba19dc9414 Mon Sep 17 00:00:00 2001 From: Roger Wang Date: Fri, 31 Jul 2015 11:37:47 +0800 Subject: [PATCH 35/41] [CHANGELOG] update for v0.12.3 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5190ad9173..55766cde31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +0.12.3 / 07-31-2015 +=================== +- Support Mac App Store with the 'macappstore' flavor +- [WIN] Screen.DesktopCaptureMonitor API: https://github.com/nwjs/nw.js/wiki/Screen#screendesktopcapturemonitor (Thanks to Rick Edgecombe) +- [HighDPI][WIN] fix for Tray menu is huge on High-DPI Windows machine (#2847) (Thanks to Jefry) + 0.12.2 / 05-22-2015 =================== - Fix #2723: [OSX] cpu hog in some cases From 9f37d7b31e4db97170521e0480d21873c6d366c7 Mon Sep 17 00:00:00 2001 From: Roger Wang Date: Sat, 1 Aug 2015 07:46:44 +0800 Subject: [PATCH 36/41] [README] update for 0.12.3 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3cbd624fb9..5f1c5ba13c 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ It was created in the Intel Open Source Technology Center. * Available on Linux, Mac OS X and Windows ## Downloads -* **v0.12.2:** (May 22, 2015, based off of IO.js v1.2.0, Chromium 41.0.2272.76): [release notes](https://groups.google.com/d/msg/nwjs-general/Xbq64dUKZsk/_pTwW7hgAfkJ) - * Linux: [32bit](http://dl.nwjs.io/v0.12.2/nwjs-v0.12.2-linux-ia32.tar.gz) / [64bit](http://dl.nwjs.io/v0.12.2/nwjs-v0.12.2-linux-x64.tar.gz) - * Windows: [32bit](http://dl.nwjs.io/v0.12.2/nwjs-v0.12.2-win-ia32.zip) / [64bit](http://dl.nwjs.io/v0.12.2/nwjs-v0.12.2-win-x64.zip) - * Mac 10.7+: [32bit](http://dl.nwjs.io/v0.12.2/nwjs-v0.12.2-osx-ia32.zip) / [64bit](http://dl.nwjs.io/v0.12.2/nwjs-v0.12.2-osx-x64.zip) +* **v0.12.3:** (Jul 31, 2015, based off of IO.js v1.2.0, Chromium 41.0.2272.76): [release notes](https://groups.google.com/d/msg/nwjs-general/hhXCS4aXGV0/TUQmcu5XDwAJ) + * Linux: [32bit](http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-linux-ia32.tar.gz) / [64bit](http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-linux-x64.tar.gz) + * Windows: [32bit](http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-win-ia32.zip) / [64bit](http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-win-x64.zip) + * Mac 10.7+: [32bit](http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-osx-ia32.zip) / [64bit](http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-osx-x64.zip) * **v0.13.0-alpha1:** (Jun 11, 2015, based off of IO.js v1.5.1, Chromium 43.0.2357.45): [release notes](https://groups.google.com/d/msg/nwjs-general/c25l_jGMqj8/rsAtdSQuxeUJ) **NOTE** You might want the **SDK build**. Please read the release notes From 98b1ef82d55f12accd55f2f04fff76a53474dccb Mon Sep 17 00:00:00 2001 From: Doug Tedd Date: Thu, 13 Aug 2015 13:35:44 +0800 Subject: [PATCH 37/41] Fix for issue 934: added URL scheme support for MAC --- src/browser/app_controller_mac.h | 4 ++++ src/browser/app_controller_mac.mm | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/browser/app_controller_mac.h b/src/browser/app_controller_mac.h index 6199be75b8..f2158498f1 100644 --- a/src/browser/app_controller_mac.h +++ b/src/browser/app_controller_mac.h @@ -24,7 +24,11 @@ #import @interface AppController : NSObject { + BOOL appReady; } + +@property(nonatomic) BOOL appReady; + @end #endif // CONTENT_NW_SRC_BROWSER_APP_CONTROLLER_MAC_H_ diff --git a/src/browser/app_controller_mac.mm b/src/browser/app_controller_mac.mm index 71497e0ab1..27883fa865 100644 --- a/src/browser/app_controller_mac.mm +++ b/src/browser/app_controller_mac.mm @@ -31,6 +31,8 @@ @implementation AppController +@synthesize appReady; + - (BOOL)application:(NSApplication*)sender openFile:(NSString*)filename { if (content::Shell::windows().size() == 0) { @@ -52,6 +54,15 @@ - (BOOL)application:(NSApplication*)sender return FALSE; } +- (void) applicationWillFinishLaunching: (NSNotification *) note { + self.appReady = FALSE; + NSAppleEventManager *eventManager = [NSAppleEventManager sharedAppleEventManager]; + [eventManager setEventHandler:self + andSelector:@selector(handleGetURLEvent:withReplyEvent:) + forEventClass:kInternetEventClass + andEventID:kAEGetURL]; +} + - (void) applicationDidFinishLaunching: (NSNotification *) note { // Initlialize everything here content::ShellContentBrowserClient* browser_client = @@ -66,6 +77,8 @@ - (void) applicationDidFinishLaunching: (NSNotification *) note { [NSApp setMainMenu:[[[NSMenu alloc] init] autorelease]]; [[NSApp mainMenu] addItem:[[[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""] autorelease]]; + + self.appReady = TRUE; #if 0 nw::StandardMenusMac standard_menus( browser_client->shell_browser_main_parts()->package()->GetName()); @@ -92,4 +105,20 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)app { return NSTerminateCancel; } +- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent +{ + NSString *urlString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; + if (self.appReady) { + // Immediate handle of get url event + nwapi::App::EmitOpenEvent([urlString UTF8String]); + } else { + // App is not ready yet, add the URL to the command line arguments. + // This happens when the app is started by opening a link with the registered URL. + if (content::Shell::windows().size() == 0) { + CommandLine::ForCurrentProcess()->AppendArg([urlString UTF8String]); + CommandLine::ForCurrentProcess()->FixOrigArgv4Finder([urlString UTF8String]); + } + } +} + @end From c45f6864d3693056d2d13871441a9f49e73ec830 Mon Sep 17 00:00:00 2001 From: Roger Wang Date: Fri, 14 Aug 2015 15:10:19 +0800 Subject: [PATCH 38/41] Fix #916: support pac_url and auto proxy detection --- src/api/app/app.cc | 18 ++++++++++++++---- src/api/app/app.h | 3 ++- src/api/app/app.js | 4 ++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/api/app/app.cc b/src/api/app/app.cc index 30f4b6d084..1207db7410 100644 --- a/src/api/app/app.cc +++ b/src/api/app/app.cc @@ -202,9 +202,10 @@ void App::Call(Shell* shell, shortcut->GetAccelerator(), shortcut); return; } else if (method == "SetProxyConfig") { - std::string proxy_config; + std::string proxy_config, pac_url; arguments.GetString(0, &proxy_config); - SetProxyConfig(GetRenderProcessHost(), proxy_config); + arguments.GetString(1, &pac_url); + SetProxyConfig(GetRenderProcessHost(), proxy_config, pac_url); return; } else if (method == "DoneMenuShow") { dispatcher_host->quit_run_loop(); @@ -299,9 +300,18 @@ void App::ClearCache(content::RenderProcessHost* render_process_host) { } void App::SetProxyConfig(content::RenderProcessHost* render_process_host, - const std::string& proxy_config) { + const std::string& proxy_config, + const std::string& pac_url) { net::ProxyConfig config; - config.proxy_rules().ParseFromString(proxy_config); + if (!pac_url.empty()) { + if (pac_url == "") + config = net::ProxyConfig::CreateDirect(); + else if (pac_url == "") + config = net::ProxyConfig::CreateAutoDetect(); + else + config = net::ProxyConfig::CreateFromCustomPacURL(GURL(pac_url)); + } else + config.proxy_rules().ParseFromString(proxy_config); net::URLRequestContextGetter* context_getter = render_process_host->GetBrowserContext()-> GetRequestContextForRenderProcess(render_process_host->GetID()); diff --git a/src/api/app/app.h b/src/api/app/app.h index 47040ff6dc..969b01fadc 100644 --- a/src/api/app/app.h +++ b/src/api/app/app.h @@ -63,7 +63,8 @@ class App { static void ClearCache(content::RenderProcessHost* render_view_host); static void SetProxyConfig(content::RenderProcessHost* render_process_host, - const std::string& proxy_config); + const std::string& proxy_config, + const std::string& pac_url); private: App(); diff --git a/src/api/app/app.js b/src/api/app/app.js index 5573d6d4f2..7ff009ffe3 100644 --- a/src/api/app/app.js +++ b/src/api/app/app.js @@ -69,8 +69,8 @@ App.prototype.getProxyForURL = function (url) { return nw.callStaticMethodSync('App', 'getProxyForURL', [ url ]); } -App.prototype.setProxyConfig = function (proxy_config) { - return nw.callStaticMethodSync('App', 'SetProxyConfig', [ proxy_config ]); +App.prototype.setProxyConfig = function (proxy_config, pac_url) { + return nw.callStaticMethodSync('App', 'SetProxyConfig', [ proxy_config, pac_url ]); } App.prototype.addOriginAccessWhitelistEntry = function(sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains) { From 37561cb96ba7273566071f21f21e990011b4efc4 Mon Sep 17 00:00:00 2001 From: Jefry Date: Tue, 18 Aug 2015 14:22:05 +0700 Subject: [PATCH 39/41] Fix for issue 934: added URL scheme support for MAC - compile error fix --- src/browser/app_controller_mac.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/browser/app_controller_mac.mm b/src/browser/app_controller_mac.mm index 27883fa865..7de1d69375 100644 --- a/src/browser/app_controller_mac.mm +++ b/src/browser/app_controller_mac.mm @@ -115,8 +115,8 @@ - (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppl // App is not ready yet, add the URL to the command line arguments. // This happens when the app is started by opening a link with the registered URL. if (content::Shell::windows().size() == 0) { - CommandLine::ForCurrentProcess()->AppendArg([urlString UTF8String]); - CommandLine::ForCurrentProcess()->FixOrigArgv4Finder([urlString UTF8String]); + base::CommandLine::ForCurrentProcess()->AppendArg([urlString UTF8String]); + base::CommandLine::ForCurrentProcess()->FixOrigArgv4Finder([urlString UTF8String]); } } } From f5019bc643599246e2cc1ea8cc97b4cb6bcfb156 Mon Sep 17 00:00:00 2001 From: jtg-gg Date: Tue, 22 Sep 2015 18:53:51 +0800 Subject: [PATCH 40/41] Fix #3651: Window.requestAttention doesn't seem to do anything on Fedora/Ubuntu, also fix Window.setBadgeLabel and Window.setProgressBar --- src/browser/native_window_aura.cc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/browser/native_window_aura.cc b/src/browser/native_window_aura.cc index f4590345d9..bb3ab1e425 100644 --- a/src/browser/native_window_aura.cc +++ b/src/browser/native_window_aura.cc @@ -36,6 +36,9 @@ #endif #include "chrome/browser/platform_util.h" +#ifdef OS_LINUX +#include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" +#endif #include "content/nw/src/api/menu/menu.h" #include "content/nw/src/browser/browser_view_layout.h" #include "content/nw/src/browser/menubar_view.h" @@ -115,6 +118,24 @@ bool IsParent(gfx::NativeView child, gfx::NativeView possible_parent) { return false; } +#ifdef OS_LINUX +static void SetDeskopEnvironment() { + static bool runOnce = false; + if (runOnce) return; + runOnce = true; + + scoped_ptr env(base::Environment::Create()); + std::string name; + //if (env->GetVar("CHROME_DESKTOP", &name) && !name.empty()) + // return; + + if (!env->GetVar("NW_DESKTOP", &name) || name.empty()) + name = "nw.desktop"; + + env->SetVar("CHROME_DESKTOP", name); +} +#endif + class NativeWindowClientView : public views::ClientView { public: NativeWindowClientView(views::Widget* widget, @@ -357,6 +378,10 @@ NativeWindowAura::NativeWindowAura(const base::WeakPtr& shell, window_->SetInitialFocus(ui::SHOW_STATE_NORMAL); window_->SetNativeWindowProperty("__BROWSER_VIEW__", this); + +#ifdef OS_LINUX + SetDeskopEnvironment(); +#endif } NativeWindowAura::~NativeWindowAura() { @@ -664,6 +689,8 @@ void NativeWindowAura::FlashFrame(int count) { fwi.dwFlags = FLASHW_STOP; } FlashWindowEx(&fwi); +#elif defined(OS_LINUX) + window_->FlashFrame(count); #endif } @@ -715,6 +742,8 @@ void NativeWindowAura::SetBadgeLabel(const std::string& badge) { taskbar->SetOverlayIcon(hWnd, icon, L"Status"); DestroyIcon(icon); +#elif defined(OS_LINUX) + views::LinuxUI::instance()->SetDownloadCount(atoi(badge.c_str())); #endif } @@ -748,6 +777,8 @@ void NativeWindowAura::SetProgressBar(double progress) { } taskbar->SetProgressState(hWnd, tbpFlag); +#elif defined(OS_LINUX) + views::LinuxUI::instance()->SetProgressFraction(progress); #endif } From ad9396ff55260078956308e0b0ba317f33248d00 Mon Sep 17 00:00:00 2001 From: Adam Lynch Date: Wed, 23 Sep 2015 19:50:41 +0100 Subject: [PATCH 41/41] Fixing whitespace in example manifest --- tests/manual_tests/notification/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/manual_tests/notification/package.json b/tests/manual_tests/notification/package.json index a504bbc01f..7efd8aac98 100644 --- a/tests/manual_tests/notification/package.json +++ b/tests/manual_tests/notification/package.json @@ -1,5 +1,5 @@ { "name": "nw-notification-test", "main": "index.html", - "app-id": "com.node.webkit.notification.test" + "app-id": "com.node.webkit.notification.test" }