Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: chrome/browser/apps/app_launch_for_metro_restart_win.cc

Issue 657023008: Add a new field "source" in launchData of chrome.app.runtime.onLaunched() to trace launch source. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/prefs/pref_registry_simple.h" 11 #include "base/prefs/pref_registry_simple.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.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 "extensions/browser/api/app_runtime/app_runtime_api.h" 19 #include "extensions/browser/api/app_runtime/app_runtime_api.h"
20 #include "extensions/browser/extension_system.h" 20 #include "extensions/browser/extension_system.h"
21 #include "extensions/common/constants.h"
21 22
22 using extensions::AppRuntimeEventRouter; 23 using extensions::AppRuntimeEventRouter;
23 using extensions::Extension; 24 using extensions::Extension;
24 using extensions::ExtensionSystem; 25 using extensions::ExtensionSystem;
25 26
26 namespace app_metro_launch { 27 namespace app_metro_launch {
27 28
28 namespace { 29 namespace {
29 30
30 void LaunchAppWithId(Profile* profile, 31 void LaunchAppWithId(Profile* profile,
31 const std::string& extension_id) { 32 const std::string& extension_id) {
32 ExtensionService* extension_service = 33 ExtensionService* extension_service =
33 ExtensionSystem::Get(profile)->extension_service(); 34 ExtensionSystem::Get(profile)->extension_service();
34 if (!extension_service) 35 if (!extension_service)
35 return; 36 return;
36 37
37 const Extension* extension = 38 const Extension* extension =
38 extension_service->GetExtensionById(extension_id, false); 39 extension_service->GetExtensionById(extension_id, false);
39 if (!extension) 40 if (!extension)
40 return; 41 return;
41 42
42 AppRuntimeEventRouter::DispatchOnLaunchedEvent(profile, extension); 43 AppRuntimeEventRouter::DispatchOnLaunchedEvent(profile, extension,
44 extensions::SOURCE_WIN_METRO);
benwells 2014/10/28 21:22:47 This should just be the same as the other restart
cylee1 2014/10/29 16:39:59 Done.
43 } 45 }
44 46
45 } // namespace 47 } // namespace
46 48
47 void HandleAppLaunchForMetroRestart(Profile* profile) { 49 void HandleAppLaunchForMetroRestart(Profile* profile) {
48 PrefService* prefs = g_browser_process->local_state(); 50 PrefService* prefs = g_browser_process->local_state();
49 if (!prefs->HasPrefPath(prefs::kAppLaunchForMetroRestartProfile)) 51 if (!prefs->HasPrefPath(prefs::kAppLaunchForMetroRestartProfile))
50 return; 52 return;
51 53
52 // This will be called for each profile that had a browser window open before 54 // This will be called for each profile that had a browser window open before
(...skipping 30 matching lines...) Expand all
83 profile->GetPath().BaseName().MaybeAsASCII()); 85 profile->GetPath().BaseName().MaybeAsASCII());
84 prefs->SetString(prefs::kAppLaunchForMetroRestart, extension_id); 86 prefs->SetString(prefs::kAppLaunchForMetroRestart, extension_id);
85 } 87 }
86 88
87 void RegisterPrefs(PrefRegistrySimple* registry) { 89 void RegisterPrefs(PrefRegistrySimple* registry) {
88 registry->RegisterStringPref(prefs::kAppLaunchForMetroRestart, ""); 90 registry->RegisterStringPref(prefs::kAppLaunchForMetroRestart, "");
89 registry->RegisterStringPref(prefs::kAppLaunchForMetroRestartProfile, ""); 91 registry->RegisterStringPref(prefs::kAppLaunchForMetroRestartProfile, "");
90 } 92 }
91 93
92 } // namespace app_metro_launch 94 } // namespace app_metro_launch
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698