| 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 "chrome/browser/apps/app_launch_for_metro_restart_win.h" | 5 #include "chrome/browser/apps/app_launch_for_metro_restart_win.h" |
| 6 | 6 |
| 7 #include "apps/launcher.h" | 7 #include "apps/launcher.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
| 18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 19 #include "components/prefs/pref_registry_simple.h" | 19 #include "components/prefs/pref_registry_simple.h" |
| 20 #include "components/prefs/pref_service.h" | 20 #include "components/prefs/pref_service.h" |
| 21 #include "extensions/browser/api/app_runtime/app_runtime_api.h" | 21 #include "extensions/browser/api/app_runtime/app_runtime_api.h" |
| 22 #include "extensions/browser/extension_system.h" | 22 #include "extensions/browser/extension_system.h" |
| 23 #include "extensions/common/api/app_runtime.h" |
| 23 #include "extensions/common/constants.h" | 24 #include "extensions/common/constants.h" |
| 24 | 25 |
| 25 using extensions::AppRuntimeEventRouter; | 26 using extensions::AppRuntimeEventRouter; |
| 26 using extensions::Extension; | 27 using extensions::Extension; |
| 27 using extensions::ExtensionSystem; | 28 using extensions::ExtensionSystem; |
| 28 | 29 |
| 29 namespace app_metro_launch { | 30 namespace app_metro_launch { |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 void LaunchAppWithId(Profile* profile, | 34 void LaunchAppWithId(Profile* profile, |
| 34 const std::string& extension_id) { | 35 const std::string& extension_id) { |
| 35 ExtensionService* extension_service = | 36 ExtensionService* extension_service = |
| 36 ExtensionSystem::Get(profile)->extension_service(); | 37 ExtensionSystem::Get(profile)->extension_service(); |
| 37 if (!extension_service) | 38 if (!extension_service) |
| 38 return; | 39 return; |
| 39 | 40 |
| 40 const Extension* extension = | 41 const Extension* extension = |
| 41 extension_service->GetExtensionById(extension_id, false); | 42 extension_service->GetExtensionById(extension_id, false); |
| 42 if (!extension) | 43 if (!extension) |
| 43 return; | 44 return; |
| 44 | 45 |
| 45 AppRuntimeEventRouter::DispatchOnLaunchedEvent( | 46 AppRuntimeEventRouter::DispatchOnLaunchedEvent( |
| 46 profile, extension, extensions::SOURCE_RESTART); | 47 profile, extension, extensions::SOURCE_RESTART, |
| 48 std::unique_ptr<extensions::api::app_runtime::ActionData>()); |
| 47 } | 49 } |
| 48 | 50 |
| 49 } // namespace | 51 } // namespace |
| 50 | 52 |
| 51 void HandleAppLaunchForMetroRestart(Profile* profile) { | 53 void HandleAppLaunchForMetroRestart(Profile* profile) { |
| 52 PrefService* prefs = g_browser_process->local_state(); | 54 PrefService* prefs = g_browser_process->local_state(); |
| 53 if (!prefs->HasPrefPath(prefs::kAppLaunchForMetroRestartProfile)) | 55 if (!prefs->HasPrefPath(prefs::kAppLaunchForMetroRestartProfile)) |
| 54 return; | 56 return; |
| 55 | 57 |
| 56 // This will be called for each profile that had a browser window open before | 58 // This will be called for each profile that had a browser window open before |
| (...skipping 29 matching lines...) Expand all Loading... |
| 86 profile->GetPath().BaseName().MaybeAsASCII()); | 88 profile->GetPath().BaseName().MaybeAsASCII()); |
| 87 prefs->SetString(prefs::kAppLaunchForMetroRestart, extension_id); | 89 prefs->SetString(prefs::kAppLaunchForMetroRestart, extension_id); |
| 88 } | 90 } |
| 89 | 91 |
| 90 void RegisterPrefs(PrefRegistrySimple* registry) { | 92 void RegisterPrefs(PrefRegistrySimple* registry) { |
| 91 registry->RegisterStringPref(prefs::kAppLaunchForMetroRestart, ""); | 93 registry->RegisterStringPref(prefs::kAppLaunchForMetroRestart, ""); |
| 92 registry->RegisterStringPref(prefs::kAppLaunchForMetroRestartProfile, ""); | 94 registry->RegisterStringPref(prefs::kAppLaunchForMetroRestartProfile, ""); |
| 93 } | 95 } |
| 94 | 96 |
| 95 } // namespace app_metro_launch | 97 } // namespace app_metro_launch |
| OLD | NEW |