| 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/location.h" |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 13 #include "base/message_loop/message_loop.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "chrome/browser/apps/app_window_registry_util.h" | 16 #include "chrome/browser/apps/app_window_registry_util.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/lifetime/application_lifetime.h" | 18 #include "chrome/browser/lifetime/application_lifetime.h" |
| 17 #include "chrome/browser/ui/app_list/app_list_service.h" | 19 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 18 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
| 20 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 21 | 23 |
| 22 namespace apps { | 24 namespace apps { |
| 23 | 25 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 59 |
| 58 void SetDefaultHandler(AppShimHandler* handler) { | 60 void SetDefaultHandler(AppShimHandler* handler) { |
| 59 DCHECK_NE(default_handler_ == NULL, handler == NULL); | 61 DCHECK_NE(default_handler_ == NULL, handler == NULL); |
| 60 default_handler_ = handler; | 62 default_handler_ = handler; |
| 61 } | 63 } |
| 62 | 64 |
| 63 void MaybeTerminate() { | 65 void MaybeTerminate() { |
| 64 if (!browser_session_running_) { | 66 if (!browser_session_running_) { |
| 65 // Post this to give AppWindows a chance to remove themselves from the | 67 // Post this to give AppWindows a chance to remove themselves from the |
| 66 // registry. | 68 // registry. |
| 67 base::MessageLoop::current()->PostTask( | 69 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 68 FROM_HERE, base::Bind(&TerminateIfNoAppWindows)); | 70 FROM_HERE, base::Bind(&TerminateIfNoAppWindows)); |
| 69 } | 71 } |
| 70 } | 72 } |
| 71 | 73 |
| 72 bool ShouldRestoreSession() { | 74 bool ShouldRestoreSession() { |
| 73 return !browser_session_running_; | 75 return !browser_session_running_; |
| 74 } | 76 } |
| 75 | 77 |
| 76 private: | 78 private: |
| 77 friend struct base::DefaultSingletonTraits<AppShimHandlerRegistry>; | 79 friend struct base::DefaultSingletonTraits<AppShimHandlerRegistry>; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 void AppShimHandler::MaybeTerminate() { | 148 void AppShimHandler::MaybeTerminate() { |
| 147 AppShimHandlerRegistry::GetInstance()->MaybeTerminate(); | 149 AppShimHandlerRegistry::GetInstance()->MaybeTerminate(); |
| 148 } | 150 } |
| 149 | 151 |
| 150 // static | 152 // static |
| 151 bool AppShimHandler::ShouldRestoreSession() { | 153 bool AppShimHandler::ShouldRestoreSession() { |
| 152 return AppShimHandlerRegistry::GetInstance()->ShouldRestoreSession(); | 154 return AppShimHandlerRegistry::GetInstance()->ShouldRestoreSession(); |
| 153 } | 155 } |
| 154 | 156 |
| 155 } // namespace apps | 157 } // namespace apps |
| OLD | NEW |