Chromium Code Reviews| Index: chrome/browser/chromeos/app_mode/app_session_lifetime.cc |
| diff --git a/chrome/browser/chromeos/app_mode/app_session_lifetime.cc b/chrome/browser/chromeos/app_mode/app_session_lifetime.cc |
| index fe40288df2535d8f0a1a2dd87fb364303f7a0de0..741a1c13e6d802a15c37749b19517fccffcb614c 100644 |
| --- a/chrome/browser/chromeos/app_mode/app_session_lifetime.cc |
| +++ b/chrome/browser/chromeos/app_mode/app_session_lifetime.cc |
| @@ -38,23 +38,24 @@ namespace chromeos { |
| namespace { |
| // AppWindowHandler watches for app window and exits the session when the |
| -// last app window is closed. |
| +// last window of a given app is closed. |
| class AppWindowHandler : public AppWindowRegistry::Observer { |
| public: |
| AppWindowHandler() : window_registry_(NULL) {} |
| ~AppWindowHandler() override {} |
| - void Init(Profile* profile) { |
| + void Init(Profile* profile, const std::string& app_id) { |
| DCHECK(!window_registry_); |
| window_registry_ = AppWindowRegistry::Get(profile); |
| if (window_registry_) |
| window_registry_->AddObserver(this); |
| + app_id_ = app_id; |
| } |
| private: |
| // extensions::AppWindowRegistry::Observer overrides: |
| void OnAppWindowRemoved(AppWindow* app_window) override { |
| - if (window_registry_->app_windows().empty()) { |
| + if (window_registry_->GetAppWindowsForApp(app_id_).empty()) { |
| if (DemoAppLauncher::IsDemoAppSession( |
| user_manager::UserManager::Get()->GetActiveUser()->email())) { |
| // If we were in demo mode, we disabled all our network technologies, |
| @@ -72,6 +73,7 @@ class AppWindowHandler : public AppWindowRegistry::Observer { |
| } |
| AppWindowRegistry* window_registry_; |
| + std::string app_id_; |
|
bartfab (slow)
2015/01/26 15:59:46
Nit: const.
xiyuan
2015/01/26 17:21:32
Cannot use const here because we use it as a AppWi
|
| DISALLOW_COPY_AND_ASSIGN(AppWindowHandler); |
| }; |
| @@ -121,7 +123,7 @@ base::LazyInstance<BrowserWindowHandler> browser_window_handler |
| void InitAppSession(Profile* profile, const std::string& app_id) { |
| // Binds the session lifetime with app window counts. |
| CHECK(app_window_handler == NULL); |
| - app_window_handler.Get().Init(profile); |
| + app_window_handler.Get().Init(profile, app_id); |
| CHECK(browser_window_handler == NULL); |
| browser_window_handler.Get(); |