| 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/launcher.h" | 5 #include "apps/launcher.h" |
| 6 | 6 |
| 7 #include "apps/apps_client.h" | 7 #include "apps/apps_client.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 | 370 |
| 371 void RestartPlatformApp(Profile* profile, const Extension* extension) { | 371 void RestartPlatformApp(Profile* profile, const Extension* extension) { |
| 372 #if defined(OS_WIN) | 372 #if defined(OS_WIN) |
| 373 // On Windows 8's single window Metro mode we can not launch platform apps. | 373 // On Windows 8's single window Metro mode we can not launch platform apps. |
| 374 // In restart we are just making sure launch doesn't slip through. | 374 // In restart we are just making sure launch doesn't slip through. |
| 375 if (win8::IsSingleWindowMetroMode()) | 375 if (win8::IsSingleWindowMetroMode()) |
| 376 return; | 376 return; |
| 377 #endif | 377 #endif |
| 378 extensions::EventRouter* event_router = | 378 extensions::EventRouter* event_router = |
| 379 ExtensionSystem::Get(profile)->event_router(); | 379 ExtensionSystem::Get(profile)->event_router(); |
| 380 bool listening_to_restart = event_router-> | 380 // We check for registered events, rather than listeners, because listeners |
| 381 ExtensionHasEventListener(extension->id(), | 381 // may not be instantiated for the events yet. |
| 382 app_runtime::OnRestarted::kEventName); | 382 std::set<std::string> events = |
| 383 event_router->GetRegisteredEvents(extension->id()); |
| 384 bool listening_to_restart = |
| 385 events.count(app_runtime::OnRestarted::kEventName) > 0; |
| 383 | 386 |
| 384 if (listening_to_restart) { | 387 if (listening_to_restart) { |
| 385 extensions::AppEventRouter::DispatchOnRestartedEvent(profile, extension); | 388 extensions::AppEventRouter::DispatchOnRestartedEvent(profile, extension); |
| 386 return; | 389 return; |
| 387 } | 390 } |
| 388 | 391 |
| 389 extensions::ExtensionPrefs* extension_prefs = ExtensionSystem::Get(profile)-> | 392 extensions::ExtensionPrefs* extension_prefs = ExtensionSystem::Get(profile)-> |
| 390 extension_service()->extension_prefs(); | 393 extension_service()->extension_prefs(); |
| 391 bool had_windows = extension_prefs->IsActive(extension->id()); | 394 bool had_windows = extension_prefs->IsActive(extension->id()); |
| 392 extension_prefs->SetIsActive(extension->id(), false); | 395 extension_prefs->SetIsActive(extension->id(), false); |
| 393 bool listening_to_launch = event_router-> | 396 bool listening_to_launch = |
| 394 ExtensionHasEventListener(extension->id(), | 397 events.count(app_runtime::OnLaunched::kEventName) > 0; |
| 395 app_runtime::OnLaunched::kEventName); | |
| 396 | 398 |
| 397 if (listening_to_launch && had_windows) | 399 if (listening_to_launch && had_windows) |
| 398 LaunchPlatformAppWithNoData(profile, extension); | 400 LaunchPlatformAppWithNoData(profile, extension); |
| 399 } | 401 } |
| 400 | 402 |
| 401 void LaunchPlatformAppWithUrl(Profile* profile, | 403 void LaunchPlatformAppWithUrl(Profile* profile, |
| 402 const Extension* extension, | 404 const Extension* extension, |
| 403 const std::string& handler_id, | 405 const std::string& handler_id, |
| 404 const GURL& url, | 406 const GURL& url, |
| 405 const GURL& referrer_url) { | 407 const GURL& referrer_url) { |
| 406 extensions::AppEventRouter::DispatchOnLaunchedEventWithUrl( | 408 extensions::AppEventRouter::DispatchOnLaunchedEventWithUrl( |
| 407 profile, extension, handler_id, url, referrer_url); | 409 profile, extension, handler_id, url, referrer_url); |
| 408 } | 410 } |
| 409 | 411 |
| 410 } // namespace apps | 412 } // namespace apps |
| OLD | NEW |