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/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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/stl_util.h" | |
| 13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" | 16 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" |
| 16 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" | 17 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" |
| 17 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 18 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
| 18 #include "chrome/browser/extensions/extension_host.h" | 19 #include "chrome/browser/extensions/extension_host.h" |
| 19 #include "chrome/browser/extensions/extension_prefs.h" | 20 #include "chrome/browser/extensions/extension_prefs.h" |
| 20 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
| 21 #include "chrome/browser/extensions/extension_system.h" | 22 #include "chrome/browser/extensions/extension_system.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 | 371 |
| 371 void RestartPlatformApp(Profile* profile, const Extension* extension) { | 372 void RestartPlatformApp(Profile* profile, const Extension* extension) { |
| 372 #if defined(OS_WIN) | 373 #if defined(OS_WIN) |
| 373 // On Windows 8's single window Metro mode we can not launch platform apps. | 374 // 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. | 375 // In restart we are just making sure launch doesn't slip through. |
| 375 if (win8::IsSingleWindowMetroMode()) | 376 if (win8::IsSingleWindowMetroMode()) |
| 376 return; | 377 return; |
| 377 #endif | 378 #endif |
| 378 extensions::EventRouter* event_router = | 379 extensions::EventRouter* event_router = |
| 379 ExtensionSystem::Get(profile)->event_router(); | 380 ExtensionSystem::Get(profile)->event_router(); |
| 380 bool listening_to_restart = event_router-> | 381 // We check for registered events, rather than listeners, because listeners |
| 381 ExtensionHasEventListener(extension->id(), | 382 // may not be instantiated for the events yet. |
| 382 app_runtime::OnRestarted::kEventName); | 383 std::set<std::string> events = |
| 384 event_router->GetRegisteredEvents(extension->id()); | |
| 385 bool listening_to_restart = | |
| 386 ContainsKey(events, std::string(app_runtime::OnRestarted::kEventName)); | |
|
tapted
2013/12/16 03:23:17
what's wrong with .count()? you should get an impl
koz (OOO until 15th September)
2013/12/16 03:52:35
Oh, but I'm old-school, too! Sort of. Java is olds
| |
| 383 | 387 |
| 384 if (listening_to_restart) { | 388 if (listening_to_restart) { |
| 385 extensions::AppEventRouter::DispatchOnRestartedEvent(profile, extension); | 389 extensions::AppEventRouter::DispatchOnRestartedEvent(profile, extension); |
| 386 return; | 390 return; |
| 387 } | 391 } |
| 388 | 392 |
| 389 extensions::ExtensionPrefs* extension_prefs = ExtensionSystem::Get(profile)-> | 393 extensions::ExtensionPrefs* extension_prefs = ExtensionSystem::Get(profile)-> |
| 390 extension_service()->extension_prefs(); | 394 extension_service()->extension_prefs(); |
| 391 bool had_windows = extension_prefs->IsActive(extension->id()); | 395 bool had_windows = extension_prefs->IsActive(extension->id()); |
| 392 extension_prefs->SetIsActive(extension->id(), false); | 396 extension_prefs->SetIsActive(extension->id(), false); |
| 393 bool listening_to_launch = event_router-> | 397 bool listening_to_launch = |
| 394 ExtensionHasEventListener(extension->id(), | 398 ContainsKey(events, std::string(app_runtime::OnLaunched::kEventName)); |
| 395 app_runtime::OnLaunched::kEventName); | |
| 396 | 399 |
| 397 if (listening_to_launch && had_windows) | 400 if (listening_to_launch && had_windows) |
| 398 LaunchPlatformAppWithNoData(profile, extension); | 401 LaunchPlatformAppWithNoData(profile, extension); |
| 399 } | 402 } |
| 400 | 403 |
| 401 void LaunchPlatformAppWithUrl(Profile* profile, | 404 void LaunchPlatformAppWithUrl(Profile* profile, |
| 402 const Extension* extension, | 405 const Extension* extension, |
| 403 const std::string& handler_id, | 406 const std::string& handler_id, |
| 404 const GURL& url, | 407 const GURL& url, |
| 405 const GURL& referrer_url) { | 408 const GURL& referrer_url) { |
| 406 extensions::AppEventRouter::DispatchOnLaunchedEventWithUrl( | 409 extensions::AppEventRouter::DispatchOnLaunchedEventWithUrl( |
| 407 profile, extension, handler_id, url, referrer_url); | 410 profile, extension, handler_id, url, referrer_url); |
| 408 } | 411 } |
| 409 | 412 |
| 410 } // namespace apps | 413 } // namespace apps |
| OLD | NEW |