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