Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / mojo / runner / init.cc
blobdc527c1ab821d1675db750b17f5be93d4a5258d2
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
3 // found in the LICENSE file.
5 #include "mojo/runner/init.h"
7 #include "base/base_switches.h"
8 #include "base/command_line.h"
9 #include "base/debug/debugger.h"
10 #include "base/logging.h"
11 #include "base/stl_util.h"
12 #include "base/strings/string_split.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "mojo/runner/switches.h"
16 #if defined(OS_WIN)
17 #include <windows.h>
18 #elif (OS_POSIX)
19 #include <unistd.h>
20 #endif
22 namespace mojo {
23 namespace runner {
25 void InitializeLogging() {
26 logging::LoggingSettings settings;
27 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
28 logging::InitLogging(settings);
29 // To view log output with IDs and timestamps use "adb logcat -v threadtime".
30 logging::SetLogItems(false, // Process ID
31 false, // Thread ID
32 false, // Timestamp
33 false); // Tick count
36 void WaitForDebuggerIfNecessary() {
37 const base::CommandLine* command_line =
38 base::CommandLine::ForCurrentProcess();
39 if (command_line->HasSwitch(switches::kWaitForDebugger)) {
40 std::vector<std::string> apps_to_debug;
41 base::SplitString(
42 command_line->GetSwitchValueASCII(switches::kWaitForDebugger), ',',
43 &apps_to_debug);
44 std::string app = command_line->GetSwitchValueASCII(switches::kApp);
45 if (app.empty())
46 app = "launcher"; // If we're not in a child process look for "launcher".
47 if (apps_to_debug.empty() || ContainsValue(apps_to_debug, app)) {
48 #if defined(OS_WIN)
49 base::string16 appw = base::UTF8ToUTF16(app);
50 MessageBox(NULL, appw.c_str(), appw.c_str(), MB_OK | MB_SETFOREGROUND);
51 #else
52 LOG(ERROR) << app << " waiting for GDB. pid: " << getpid();
53 base::debug::WaitForDebugger(60, true);
54 #endif
59 } // namespace runner
60 } // namespace mojo