win: Set app user model ID in one place
authorCheng Zhao <zcbenz@gmail.com>
Tue, 3 Nov 2015 07:09:31 +0000 (15:09 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 3 Nov 2015 07:09:31 +0000 (15:09 +0800)
Fix #3297.
Fix #2573.

atom/browser/api/atom_api_app.cc
atom/browser/api/atom_api_app.h
atom/browser/browser.h
atom/browser/browser_linux.cc
atom/browser/browser_mac.mm
atom/browser/browser_win.cc

index bd49f9f..04ed06e 100644 (file)
@@ -7,10 +7,6 @@
 #include <string>
 #include <vector>
 
-#if defined(OS_WIN)
-#include <shlobj.h>
-#endif
-
 #include "atom/browser/api/atom_api_menu.h"
 #include "atom/browser/api/atom_api_session.h"
 #include "atom/browser/api/atom_api_web_contents.h"
@@ -299,13 +295,6 @@ void App::SetDesktopName(const std::string& desktop_name) {
 #endif
 }
 
-void App::SetAppUserModelId(const std::string& app_id) {
-#if defined(OS_WIN)
-  base::string16 app_id_utf16 = base::UTF8ToUTF16(app_id);
-  SetCurrentProcessExplicitAppUserModelID(app_id_utf16.c_str());
-#endif
-}
-
 void App::AllowNTLMCredentialsForAllDomains(bool should_allow) {
   auto browser_context = static_cast<AtomBrowserContext*>(
         AtomBrowserMainParts::Get()->browser_context());
@@ -360,6 +349,8 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
                  base::Bind(&Browser::AddRecentDocument, browser))
       .SetMethod("clearRecentDocuments",
                  base::Bind(&Browser::ClearRecentDocuments, browser))
+      .SetMethod("setAppUserModelId",
+                 base::Bind(&Browser::SetAppUserModelID, browser))
 #if defined(OS_WIN)
       .SetMethod("setUserTasks",
                  base::Bind(&Browser::SetUserTasks, browser))
@@ -367,7 +358,6 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
       .SetMethod("setPath", &App::SetPath)
       .SetMethod("getPath", &App::GetPath)
       .SetMethod("setDesktopName", &App::SetDesktopName)
-      .SetMethod("setAppUserModelId", &App::SetAppUserModelId)
       .SetMethod("allowNTLMCredentialsForAllDomains",
                  &App::AllowNTLMCredentialsForAllDomains)
       .SetMethod("getLocale", &App::GetLocale)
index 63cda44..683093d 100644 (file)
@@ -67,7 +67,6 @@ class App : public mate::EventEmitter,
                const base::FilePath& path);
 
   void SetDesktopName(const std::string& desktop_name);
-  void SetAppUserModelId(const std::string& app_id);
   void AllowNTLMCredentialsForAllDomains(bool should_allow);
   bool MakeSingleInstance(
       const ProcessSingleton::NotificationCallback& callback);
index 0500e31..9f27816 100644 (file)
@@ -66,6 +66,9 @@ class Browser : public WindowListObserver {
   // Clear the recent documents list.
   void ClearRecentDocuments();
 
+  // Set the application user model ID.
+  void SetAppUserModelID(const base::string16& name);
+
 #if defined(OS_MACOSX)
   // Bounce the dock icon.
   enum BounceType {
@@ -100,9 +103,6 @@ class Browser : public WindowListObserver {
   // Add a custom task to jump list.
   void SetUserTasks(const std::vector<UserTask>& tasks);
 
-  // Set the application user model ID.
-  void SetAppUserModelID(const base::string16& name);
-
   // Returns the application user model ID, if there isn't one, then create
   // one from app's name.
   // The returned string managed by Browser, and should not be modified.
index ea8fb7c..25cb9a0 100644 (file)
@@ -31,6 +31,9 @@ void Browser::AddRecentDocument(const base::FilePath& path) {
 void Browser::ClearRecentDocuments() {
 }
 
+void Browser::SetAppUserModelID(const base::string16& name) {
+}
+
 std::string Browser::GetExecutableFileVersion() const {
   return brightray::GetApplicationVersion();
 }
index 2353aa6..6589057 100644 (file)
@@ -26,6 +26,9 @@ void Browser::AddRecentDocument(const base::FilePath& path) {
 void Browser::ClearRecentDocuments() {
 }
 
+void Browser::SetAppUserModelID(const base::string16& name) {
+}
+
 std::string Browser::GetExecutableFileVersion() const {
   return brightray::GetApplicationVersion();
 }
index 0e5ce8e..a2725b1 100644 (file)
@@ -71,6 +71,11 @@ void Browser::ClearRecentDocuments() {
   destinations->RemoveAllDestinations();
 }
 
+void Browser::SetAppUserModelID(const base::string16& name) {
+  app_user_model_id_ = name;
+  SetCurrentProcessExplicitAppUserModelID(app_user_model_id_.c_str());
+}
+
 void Browser::SetUserTasks(const std::vector<UserTask>& tasks) {
   CComPtr<ICustomDestinationList> destinations;
   if (FAILED(destinations.CoCreateInstance(CLSID_DestinationList)))
@@ -117,11 +122,6 @@ void Browser::SetUserTasks(const std::vector<UserTask>& tasks) {
   destinations->CommitList();
 }
 
-void Browser::SetAppUserModelID(const base::string16& name) {
-  app_user_model_id_ = name;
-  SetCurrentProcessExplicitAppUserModelID(app_user_model_id_.c_str());
-}
-
 PCWSTR Browser::GetAppUserModelID() {
   if (app_user_model_id_.empty())
     SetAppUserModelID(base::UTF8ToUTF16(GetName()));