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