From a0784bd0386f9b090fa7a01a253b9af780e4811a Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Thu, 9 Jul 2015 15:57:17 -0700 Subject: [PATCH 1/4] Add a new renderer switch to pass down the app model ID --- atom/common/options_switches.cc | 3 +++ atom/common/options_switches.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index 71469b9601..8f457116ec 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -107,6 +107,9 @@ const char kDisableHttpCache[] = "disable-http-cache"; // Register schemes to standard. const char kRegisterStandardSchemes[] = "register-standard-schemes"; +// The browser process app model ID +const char kAppUserModelId[] = "app-user-model-id"; + } // namespace switches } // namespace atom diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index fc25208a60..2dd48ee32a 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -58,6 +58,8 @@ extern const char kPageVisibility[]; extern const char kDisableHttpCache[]; extern const char kRegisterStandardSchemes[]; +extern const char kAppUserModelId[]; + } // namespace switches } // namespace atom From 779583adf52fc64f79be87ee5c79857b59bbf964 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Thu, 9 Jul 2015 15:57:52 -0700 Subject: [PATCH 2/4] Append the app user model ID as a switch --- atom/browser/native_window.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index a1c839679c..031366e1df 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -50,6 +50,7 @@ #if defined(OS_WIN) #include "ui/gfx/switches.h" +#include #endif using content::NavigationEntry; @@ -388,6 +389,16 @@ void NativeWindow::AppendExtraCommandLineSwitches( command_line->AppendSwitchASCII(switches::kZoomFactor, base::DoubleToString(zoom_factor_)); +#if defined(OS_WIN) + PWSTR explicit_app_id; + + if (SUCCEEDED(GetCurrentProcessExplicitAppUserModelID(&explicit_app_id))) { + base::string16 appId = base::string16(explicit_app_id); + command_line->AppendSwitchNative(switches::kAppUserModelId, appId); + CoTaskMemFree(explicit_app_id); + } +#endif + if (web_preferences_.IsEmpty()) return; From 35aaad68d78b35c0183ff5d4fbdb7cc1b2c6fb75 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Thu, 9 Jul 2015 16:48:02 -0700 Subject: [PATCH 3/4] Set the AppUserModelId on the renderer side --- atom/renderer/atom_renderer_client.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index e2a114af01..c052039173 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -27,6 +27,10 @@ #include "atom/common/node_includes.h" +#if defined(OS_WIN) +#include +#endif + namespace atom { namespace { @@ -87,6 +91,15 @@ void AtomRendererClient::WebKitInitialized() { blink::WebCustomElement::addEmbedderCustomElementName("webview"); blink::WebCustomElement::addEmbedderCustomElementName("browserplugin"); +#if defined(OS_WIN) + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); + base::string16 explicit_app_id = command_line->GetSwitchValueNative(switches::kAppUserModelId); + + if (explicit_app_id.length() > 0) { + SetCurrentProcessExplicitAppUserModelID(explicit_app_id.c_str()); + } +#endif + node_bindings_->Initialize(); node_bindings_->PrepareMessageLoop(); From 39c6e2d2e52503b22c81d65cbced8f3fb9a3070f Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Thu, 9 Jul 2015 17:00:19 -0700 Subject: [PATCH 4/4] Linter fixes --- atom/browser/native_window.cc | 5 ++++- atom/renderer/atom_renderer_client.cc | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 031366e1df..bd5a5c4666 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -8,6 +8,10 @@ #include #include +#if defined(OS_WIN) +#include +#endif + #include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_main_parts.h" #include "atom/browser/browser.h" @@ -50,7 +54,6 @@ #if defined(OS_WIN) #include "ui/gfx/switches.h" -#include #endif using content::NavigationEntry; diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index c052039173..178be33900 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -92,8 +92,10 @@ void AtomRendererClient::WebKitInitialized() { blink::WebCustomElement::addEmbedderCustomElementName("browserplugin"); #if defined(OS_WIN) - base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); - base::string16 explicit_app_id = command_line->GetSwitchValueNative(switches::kAppUserModelId); + base::CommandLine* command_line = + base::CommandLine::ForCurrentProcess(); + base::string16 explicit_app_id = + command_line->GetSwitchValueNative(switches::kAppUserModelId); if (explicit_app_id.length() > 0) { SetCurrentProcessExplicitAppUserModelID(explicit_app_id.c_str());