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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 bool listening_to_restart = event_router-> |
381 ExtensionHasEventListener(extension->id(), | 381 ExtensionHasEventListener(extension->id(), |
tapted
2013/12/13 04:34:24
Should this be updated as well, to be consistent?
koz (OOO until 15th September)
2013/12/16 01:49:00
Ooh, actually this should be consistent. The effec
| |
382 app_runtime::OnRestarted::kEventName); | 382 app_runtime::OnRestarted::kEventName); |
383 | 383 |
384 if (listening_to_restart) { | 384 if (listening_to_restart) { |
385 extensions::AppEventRouter::DispatchOnRestartedEvent(profile, extension); | 385 extensions::AppEventRouter::DispatchOnRestartedEvent(profile, extension); |
386 return; | 386 return; |
387 } | 387 } |
388 | 388 |
389 extensions::ExtensionPrefs* extension_prefs = ExtensionSystem::Get(profile)-> | 389 extensions::ExtensionPrefs* extension_prefs = ExtensionSystem::Get(profile)-> |
390 extension_service()->extension_prefs(); | 390 extension_service()->extension_prefs(); |
391 bool had_windows = extension_prefs->IsActive(extension->id()); | 391 bool had_windows = extension_prefs->IsActive(extension->id()); |
392 extension_prefs->SetIsActive(extension->id(), false); | 392 extension_prefs->SetIsActive(extension->id(), false); |
393 bool listening_to_launch = event_router-> | 393 std::set<std::string> events = |
tapted
2013/12/13 04:34:24
nit: you could avoid the local `events` variable w
koz (OOO until 15th September)
2013/12/16 01:49:00
Sam has informed me of ContainsKey() which seems l
| |
394 ExtensionHasEventListener(extension->id(), | 394 event_router->GetRegisteredEvents(extension->id()); |
395 app_runtime::OnLaunched::kEventName); | 395 bool listening_to_launch = |
396 events.find(app_runtime::OnLaunched::kEventName) != events.end(); | |
396 | 397 |
397 if (listening_to_launch && had_windows) | 398 if (listening_to_launch && had_windows) |
398 LaunchPlatformAppWithNoData(profile, extension); | 399 LaunchPlatformAppWithNoData(profile, extension); |
399 } | 400 } |
400 | 401 |
401 void LaunchPlatformAppWithUrl(Profile* profile, | 402 void LaunchPlatformAppWithUrl(Profile* profile, |
402 const Extension* extension, | 403 const Extension* extension, |
403 const std::string& handler_id, | 404 const std::string& handler_id, |
404 const GURL& url, | 405 const GURL& url, |
405 const GURL& referrer_url) { | 406 const GURL& referrer_url) { |
406 extensions::AppEventRouter::DispatchOnLaunchedEventWithUrl( | 407 extensions::AppEventRouter::DispatchOnLaunchedEventWithUrl( |
407 profile, extension, handler_id, url, referrer_url); | 408 profile, extension, handler_id, url, referrer_url); |
408 } | 409 } |
409 | 410 |
410 } // namespace apps | 411 } // namespace apps |
OLD | NEW |