| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/apps/app_shim/app_shim_handler_mac.h" | 5 #include "chrome/browser/apps/app_shim/app_shim_handler_mac.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 if (!app_windows_left && | 28 if (!app_windows_left && |
| 29 !AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE) | 29 !AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE) |
| 30 ->IsAppListVisible()) { | 30 ->IsAppListVisible()) { |
| 31 chrome::AttemptExit(); | 31 chrome::AttemptExit(); |
| 32 } | 32 } |
| 33 } | 33 } |
| 34 | 34 |
| 35 class AppShimHandlerRegistry : public content::NotificationObserver { | 35 class AppShimHandlerRegistry : public content::NotificationObserver { |
| 36 public: | 36 public: |
| 37 static AppShimHandlerRegistry* GetInstance() { | 37 static AppShimHandlerRegistry* GetInstance() { |
| 38 return Singleton<AppShimHandlerRegistry, | 38 return base::Singleton< |
| 39 LeakySingletonTraits<AppShimHandlerRegistry> >::get(); | 39 AppShimHandlerRegistry, |
| 40 base::LeakySingletonTraits<AppShimHandlerRegistry>>::get(); |
| 40 } | 41 } |
| 41 | 42 |
| 42 AppShimHandler* GetForAppMode(const std::string& app_mode_id) const { | 43 AppShimHandler* GetForAppMode(const std::string& app_mode_id) const { |
| 43 HandlerMap::const_iterator it = handlers_.find(app_mode_id); | 44 HandlerMap::const_iterator it = handlers_.find(app_mode_id); |
| 44 if (it != handlers_.end()) | 45 if (it != handlers_.end()) |
| 45 return it->second; | 46 return it->second; |
| 46 | 47 |
| 47 return default_handler_; | 48 return default_handler_; |
| 48 } | 49 } |
| 49 | 50 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 67 base::MessageLoop::current()->PostTask( | 68 base::MessageLoop::current()->PostTask( |
| 68 FROM_HERE, base::Bind(&TerminateIfNoAppWindows)); | 69 FROM_HERE, base::Bind(&TerminateIfNoAppWindows)); |
| 69 } | 70 } |
| 70 } | 71 } |
| 71 | 72 |
| 72 bool ShouldRestoreSession() { | 73 bool ShouldRestoreSession() { |
| 73 return !browser_session_running_; | 74 return !browser_session_running_; |
| 74 } | 75 } |
| 75 | 76 |
| 76 private: | 77 private: |
| 77 friend struct DefaultSingletonTraits<AppShimHandlerRegistry>; | 78 friend struct base::DefaultSingletonTraits<AppShimHandlerRegistry>; |
| 78 typedef std::map<std::string, AppShimHandler*> HandlerMap; | 79 typedef std::map<std::string, AppShimHandler*> HandlerMap; |
| 79 | 80 |
| 80 AppShimHandlerRegistry() | 81 AppShimHandlerRegistry() |
| 81 : default_handler_(NULL), | 82 : default_handler_(NULL), |
| 82 browser_session_running_(false) { | 83 browser_session_running_(false) { |
| 83 registrar_.Add( | 84 registrar_.Add( |
| 84 this, chrome::NOTIFICATION_BROWSER_OPENED, | 85 this, chrome::NOTIFICATION_BROWSER_OPENED, |
| 85 content::NotificationService::AllBrowserContextsAndSources()); | 86 content::NotificationService::AllBrowserContextsAndSources()); |
| 86 registrar_.Add( | 87 registrar_.Add( |
| 87 this, chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, | 88 this, chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 void AppShimHandler::MaybeTerminate() { | 147 void AppShimHandler::MaybeTerminate() { |
| 147 AppShimHandlerRegistry::GetInstance()->MaybeTerminate(); | 148 AppShimHandlerRegistry::GetInstance()->MaybeTerminate(); |
| 148 } | 149 } |
| 149 | 150 |
| 150 // static | 151 // static |
| 151 bool AppShimHandler::ShouldRestoreSession() { | 152 bool AppShimHandler::ShouldRestoreSession() { |
| 152 return AppShimHandlerRegistry::GetInstance()->ShouldRestoreSession(); | 153 return AppShimHandlerRegistry::GetInstance()->ShouldRestoreSession(); |
| 153 } | 154 } |
| 154 | 155 |
| 155 } // namespace apps | 156 } // namespace apps |
| OLD | NEW |