Chromium Code Reviews| 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_shim/extension_app_shim_handler_mac.h" | 5 #include "apps/app_shim/extension_app_shim_handler_mac.h" |
| 6 | 6 |
| 7 #include "apps/app_lifetime_monitor_factory.h" | 7 #include "apps/app_lifetime_monitor_factory.h" |
| 8 #include "apps/app_shim/app_shim_host_manager_mac.h" | 8 #include "apps/app_shim/app_shim_host_manager_mac.h" |
| 9 #include "apps/app_shim/app_shim_messages.h" | 9 #include "apps/app_shim/app_shim_messages.h" |
| 10 #include "apps/launcher.h" | 10 #include "apps/launcher.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 Profile::CreateStatus status) { | 41 Profile::CreateStatus status) { |
| 42 if (status == Profile::CREATE_STATUS_INITIALIZED) { | 42 if (status == Profile::CREATE_STATUS_INITIALIZED) { |
| 43 callback.Run(profile); | 43 callback.Run(profile); |
| 44 return; | 44 return; |
| 45 } | 45 } |
| 46 | 46 |
| 47 // This should never get an error since it only loads existing profiles. | 47 // This should never get an error since it only loads existing profiles. |
| 48 DCHECK_EQ(Profile::CREATE_STATUS_CREATED, status); | 48 DCHECK_EQ(Profile::CREATE_STATUS_CREATED, status); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void SetAppHidden(Profile* profile, const std::string& app_id, bool hidden) { | 51 void SetAppHidden(Profile* profile, const std::string& app_id, bool hidden) { |
|
tapted
2014/02/17 05:25:59
This should be able to take a BrowserContext witho
| |
| 52 ShellWindowList windows = | 52 ShellWindowList windows = |
| 53 apps::ShellWindowRegistry::Get(profile)->GetShellWindowsForApp(app_id); | 53 apps::ShellWindowRegistry::Get(profile)->GetShellWindowsForApp(app_id); |
| 54 for (ShellWindowList::const_reverse_iterator it = windows.rbegin(); | 54 for (ShellWindowList::const_reverse_iterator it = windows.rbegin(); |
| 55 it != windows.rend(); ++it) { | 55 it != windows.rend(); ++it) { |
| 56 if (hidden) | 56 if (hidden) |
| 57 (*it)->GetBaseWindow()->HideWithApp(); | 57 (*it)->GetBaseWindow()->HideWithApp(); |
| 58 else | 58 else |
| 59 (*it)->GetBaseWindow()->ShowWithApp(); | 59 (*it)->GetBaseWindow()->ShowWithApp(); |
| 60 } | 60 } |
| 61 } | 61 } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 const std::string& app_id) { | 223 const std::string& app_id) { |
| 224 HostMap::iterator it = hosts_.find(make_pair(profile, app_id)); | 224 HostMap::iterator it = hosts_.find(make_pair(profile, app_id)); |
| 225 return it == hosts_.end() ? NULL : it->second; | 225 return it == hosts_.end() ? NULL : it->second; |
| 226 } | 226 } |
| 227 | 227 |
| 228 // static | 228 // static |
| 229 void ExtensionAppShimHandler::QuitAppForWindow(ShellWindow* shell_window) { | 229 void ExtensionAppShimHandler::QuitAppForWindow(ShellWindow* shell_window) { |
| 230 ExtensionAppShimHandler* handler = | 230 ExtensionAppShimHandler* handler = |
| 231 g_browser_process->platform_part()->app_shim_host_manager()-> | 231 g_browser_process->platform_part()->app_shim_host_manager()-> |
| 232 extension_app_shim_handler(); | 232 extension_app_shim_handler(); |
| 233 Host* host = handler->FindHost(shell_window->profile(), | 233 Host* host = handler->FindHost( |
| 234 shell_window->extension_id()); | 234 Profile::FromBrowserContext(shell_window->browser_context()), |
| 235 shell_window->extension_id()); | |
| 235 if (host) { | 236 if (host) { |
| 236 handler->OnShimQuit(host); | 237 handler->OnShimQuit(host); |
| 237 } else { | 238 } else { |
| 238 // App shims might be disabled or the shim is still starting up. | 239 // App shims might be disabled or the shim is still starting up. |
| 239 ShellWindowRegistry::Get(shell_window->profile())-> | 240 ShellWindowRegistry::Get( |
| 240 CloseAllShellWindowsForApp(shell_window->extension_id()); | 241 Profile::FromBrowserContext(shell_window->browser_context())) |
|
tapted
2014/02/17 05:25:59
nit: The `FromBrowserContext` cast probably not ne
| |
| 242 ->CloseAllShellWindowsForApp(shell_window->extension_id()); | |
| 241 } | 243 } |
| 242 } | 244 } |
| 243 | 245 |
| 244 void ExtensionAppShimHandler::HideAppForWindow(ShellWindow* shell_window) { | 246 void ExtensionAppShimHandler::HideAppForWindow(ShellWindow* shell_window) { |
| 245 ExtensionAppShimHandler* handler = | 247 ExtensionAppShimHandler* handler = |
| 246 g_browser_process->platform_part()->app_shim_host_manager()-> | 248 g_browser_process->platform_part()->app_shim_host_manager()-> |
| 247 extension_app_shim_handler(); | 249 extension_app_shim_handler(); |
| 248 Profile* profile = shell_window->profile(); | 250 Profile* profile = |
| 251 Profile::FromBrowserContext(shell_window->browser_context()); | |
| 249 Host* host = handler->FindHost(profile, shell_window->extension_id()); | 252 Host* host = handler->FindHost(profile, shell_window->extension_id()); |
| 250 if (host) | 253 if (host) |
| 251 host->OnAppHide(); | 254 host->OnAppHide(); |
| 252 else | 255 else |
| 253 SetAppHidden(profile, shell_window->extension_id(), true); | 256 SetAppHidden(profile, shell_window->extension_id(), true); |
| 254 } | 257 } |
| 255 | 258 |
| 256 | 259 |
| 257 void ExtensionAppShimHandler::FocusAppForWindow(ShellWindow* shell_window) { | 260 void ExtensionAppShimHandler::FocusAppForWindow(ShellWindow* shell_window) { |
| 258 ExtensionAppShimHandler* handler = | 261 ExtensionAppShimHandler* handler = |
| 259 g_browser_process->platform_part()->app_shim_host_manager()-> | 262 g_browser_process->platform_part()->app_shim_host_manager()-> |
| 260 extension_app_shim_handler(); | 263 extension_app_shim_handler(); |
| 261 Profile* profile = shell_window->profile(); | 264 Profile* profile = |
| 265 Profile::FromBrowserContext(shell_window->browser_context()); | |
| 262 const std::string& app_id = shell_window->extension_id(); | 266 const std::string& app_id = shell_window->extension_id(); |
| 263 Host* host = handler->FindHost(profile, app_id); | 267 Host* host = handler->FindHost(profile, app_id); |
| 264 if (host) { | 268 if (host) { |
| 265 handler->OnShimFocus(host, | 269 handler->OnShimFocus(host, |
| 266 APP_SHIM_FOCUS_NORMAL, | 270 APP_SHIM_FOCUS_NORMAL, |
| 267 std::vector<base::FilePath>()); | 271 std::vector<base::FilePath>()); |
| 268 } else { | 272 } else { |
| 269 FocusWindows( | 273 FocusWindows( |
| 270 apps::ShellWindowRegistry::Get(profile)->GetShellWindowsForApp(app_id)); | 274 apps::ShellWindowRegistry::Get(profile)->GetShellWindowsForApp(app_id)); |
| 271 } | 275 } |
| 272 } | 276 } |
| 273 | 277 |
| 274 // static | 278 // static |
| 275 bool ExtensionAppShimHandler::RequestUserAttentionForWindow( | 279 bool ExtensionAppShimHandler::RequestUserAttentionForWindow( |
| 276 ShellWindow* shell_window) { | 280 ShellWindow* shell_window) { |
| 277 ExtensionAppShimHandler* handler = | 281 ExtensionAppShimHandler* handler = |
| 278 g_browser_process->platform_part()->app_shim_host_manager()-> | 282 g_browser_process->platform_part()->app_shim_host_manager()-> |
| 279 extension_app_shim_handler(); | 283 extension_app_shim_handler(); |
| 280 Profile* profile = shell_window->profile(); | 284 Profile* profile = |
| 285 Profile::FromBrowserContext(shell_window->browser_context()); | |
| 281 Host* host = handler->FindHost(profile, shell_window->extension_id()); | 286 Host* host = handler->FindHost(profile, shell_window->extension_id()); |
| 282 if (host) { | 287 if (host) { |
| 283 // Bring the window to the front without showing it. | 288 // Bring the window to the front without showing it. |
| 284 ShellWindowRegistry::Get(profile)->ShellWindowActivated(shell_window); | 289 ShellWindowRegistry::Get(profile)->ShellWindowActivated(shell_window); |
| 285 host->OnAppRequestUserAttention(); | 290 host->OnAppRequestUserAttention(); |
| 286 return true; | 291 return true; |
| 287 } else { | 292 } else { |
| 288 // Just show the app. | 293 // Just show the app. |
| 289 SetAppHidden(profile, shell_window->extension_id(), false); | 294 SetAppHidden(profile, shell_window->extension_id(), false); |
| 290 return false; | 295 return false; |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 if (hosts_.empty()) | 527 if (hosts_.empty()) |
| 523 delegate_->MaybeTerminate(); | 528 delegate_->MaybeTerminate(); |
| 524 } | 529 } |
| 525 | 530 |
| 526 void ExtensionAppShimHandler::OnAppStop(Profile* profile, | 531 void ExtensionAppShimHandler::OnAppStop(Profile* profile, |
| 527 const std::string& app_id) {} | 532 const std::string& app_id) {} |
| 528 | 533 |
| 529 void ExtensionAppShimHandler::OnChromeTerminating() {} | 534 void ExtensionAppShimHandler::OnChromeTerminating() {} |
| 530 | 535 |
| 531 } // namespace apps | 536 } // namespace apps |
| OLD | NEW |