Chromium Code Reviews| Index: apps/app_shim/app_shim_handler_mac.cc |
| diff --git a/apps/app_shim/app_shim_handler_mac.cc b/apps/app_shim/app_shim_handler_mac.cc |
| index 18cca9242674fbf4a19bb1d1d65e7704234e3bfe..54a45b73c4e9102452b65e76ba74ad13e34cbbed 100644 |
| --- a/apps/app_shim/app_shim_handler_mac.cc |
| +++ b/apps/app_shim/app_shim_handler_mac.cc |
| @@ -25,7 +25,7 @@ class AppShimHandlerRegistry { |
| if (it != handlers_.end()) |
| return it->second; |
| - return NULL; |
| + return default_handler_; |
| } |
| bool SetForAppMode(const std::string& app_mode_id, AppShimHandler* handler) { |
| @@ -36,14 +36,21 @@ class AppShimHandlerRegistry { |
| return inserted_or_removed; |
| } |
| + bool SetDefaultHandler(AppShimHandler* handler) { |
| + AppShimHandler* old_default_handler = default_handler_; |
|
tapted
2013/05/21 06:15:37
I think we can omit the return and add an appropri
jackhou1
2013/05/22 23:54:44
Done.
|
| + default_handler_ = handler; |
| + return default_handler_ == old_default_handler; |
| + } |
| + |
| private: |
| friend struct DefaultSingletonTraits<AppShimHandlerRegistry>; |
| typedef std::map<std::string, AppShimHandler*> HandlerMap; |
| - AppShimHandlerRegistry() {} |
| + AppShimHandlerRegistry() : default_handler_(NULL) {} |
| ~AppShimHandlerRegistry() {} |
| HandlerMap handlers_; |
| + AppShimHandler* default_handler_; |
| DISALLOW_COPY_AND_ASSIGN(AppShimHandlerRegistry); |
| }; |
| @@ -67,4 +74,9 @@ AppShimHandler* AppShimHandler::GetForAppMode(const std::string& app_mode_id) { |
| return AppShimHandlerRegistry::GetInstance()->GetForAppMode(app_mode_id); |
| } |
| +// static |
| +void AppShimHandler::SetDefaultHandler(AppShimHandler* handler) { |
| + AppShimHandlerRegistry::GetInstance()->SetDefaultHandler(handler); |
| +} |
| + |
| } // namespace apps |