| 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 "apps/app_lifetime_monitor.h" | 5 #include "apps/app_lifetime_monitor.h" |
| 6 | 6 |
| 7 #include "apps/shell_window.h" | 7 #include "apps/shell_window.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 break; | 75 break; |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 void AppLifetimeMonitor::OnShellWindowAdded(ShellWindow* shell_window) { | 80 void AppLifetimeMonitor::OnShellWindowAdded(ShellWindow* shell_window) { |
| 81 if (shell_window->window_type() != ShellWindow::WINDOW_TYPE_DEFAULT) | 81 if (shell_window->window_type() != ShellWindow::WINDOW_TYPE_DEFAULT) |
| 82 return; | 82 return; |
| 83 | 83 |
| 84 ShellWindowRegistry::ShellWindowList windows = | 84 ShellWindowRegistry::ShellWindowList windows = |
| 85 ShellWindowRegistry::Get(shell_window->profile())-> | 85 ShellWindowRegistry::Get(shell_window->browser_context()) |
| 86 GetShellWindowsForApp(shell_window->extension_id()); | 86 ->GetShellWindowsForApp(shell_window->extension_id()); |
| 87 if (windows.size() == 1) | 87 if (windows.size() == 1) |
| 88 NotifyAppActivated(shell_window->extension_id()); | 88 NotifyAppActivated(shell_window->extension_id()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void AppLifetimeMonitor::OnShellWindowIconChanged(ShellWindow* shell_window) {} | 91 void AppLifetimeMonitor::OnShellWindowIconChanged(ShellWindow* shell_window) {} |
| 92 | 92 |
| 93 void AppLifetimeMonitor::OnShellWindowRemoved(ShellWindow* shell_window) { | 93 void AppLifetimeMonitor::OnShellWindowRemoved(ShellWindow* shell_window) { |
| 94 ShellWindowRegistry::ShellWindowList windows = | 94 ShellWindowRegistry::ShellWindowList windows = |
| 95 ShellWindowRegistry::Get(shell_window->profile())-> | 95 ShellWindowRegistry::Get(shell_window->browser_context()) |
| 96 GetShellWindowsForApp(shell_window->extension_id()); | 96 ->GetShellWindowsForApp(shell_window->extension_id()); |
| 97 if (windows.empty()) | 97 if (windows.empty()) |
| 98 NotifyAppDeactivated(shell_window->extension_id()); | 98 NotifyAppDeactivated(shell_window->extension_id()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void AppLifetimeMonitor::Shutdown() { | 101 void AppLifetimeMonitor::Shutdown() { |
| 102 ShellWindowRegistry* shell_window_registry = | 102 ShellWindowRegistry* shell_window_registry = |
| 103 ShellWindowRegistry::Factory::GetForBrowserContext( | 103 ShellWindowRegistry::Factory::GetForBrowserContext( |
| 104 profile_, false /* create */); | 104 profile_, false /* create */); |
| 105 if (shell_window_registry) | 105 if (shell_window_registry) |
| 106 shell_window_registry->RemoveObserver(this); | 106 shell_window_registry->RemoveObserver(this); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 120 | 120 |
| 121 void AppLifetimeMonitor::NotifyAppStop(const std::string& app_id) { | 121 void AppLifetimeMonitor::NotifyAppStop(const std::string& app_id) { |
| 122 FOR_EACH_OBSERVER(Observer, observers_, OnAppStop(profile_, app_id)); | 122 FOR_EACH_OBSERVER(Observer, observers_, OnAppStop(profile_, app_id)); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void AppLifetimeMonitor::NotifyChromeTerminating() { | 125 void AppLifetimeMonitor::NotifyChromeTerminating() { |
| 126 FOR_EACH_OBSERVER(Observer, observers_, OnChromeTerminating()); | 126 FOR_EACH_OBSERVER(Observer, observers_, OnChromeTerminating()); |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace apps | 129 } // namespace apps |
| OLD | NEW |