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.
4
5#include "content/shell/app/shell_breakpad_client.h"
6
7#include "base/command_line.h"
8#include "base/files/file_path.h"
9#include "base/strings/string16.h"
10#include "base/strings/utf_string_conversions.h"
11#include "content/public/common/content_switches.h"
12#include "content/shell/common/shell_switches.h"
13
14#if defined(OS_ANDROID)
15#include "content/shell/android/shell_descriptors.h"
16#endif
17
18namespace content {
19
20ShellBreakpadClient::ShellBreakpadClient() {}
21ShellBreakpadClient::~ShellBreakpadClient() {}
22
23#if defined(OS_WIN)
24void ShellBreakpadClient::GetProductNameAndVersion(
25    const base::FilePath& exe_path,
26    base::string16* product_name,
27    base::string16* version,
28    base::string16* special_build,
29    base::string16* channel_name) {
30  *product_name = ASCIIToUTF16("content_shell");
31  *version = ASCIIToUTF16(CONTENT_SHELL_VERSION);
32  *special_build = base::string16();
33  *channel_name = base::string16();
34}
35#endif
36
37#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_IOS)
38void ShellBreakpadClient::GetProductNameAndVersion(std::string* product_name,
39                                                   std::string* version) {
40  *product_name = "content_shell";
41  *version = CONTENT_SHELL_VERSION;
42}
43
44base::FilePath ShellBreakpadClient::GetReporterLogFilename() {
45  return base::FilePath(FILE_PATH_LITERAL("uploads.log"));
46}
47#endif
48
49bool ShellBreakpadClient::GetCrashDumpLocation(base::FilePath* crash_dir) {
50  if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kCrashDumpsDir))
51    return false;
52  *crash_dir = CommandLine::ForCurrentProcess()->GetSwitchValuePath(
53      switches::kCrashDumpsDir);
54  return true;
55}
56
57#if defined(OS_ANDROID)
58int ShellBreakpadClient::GetAndroidMinidumpDescriptor() {
59  return kAndroidMinidumpDescriptor;
60}
61#endif
62
63bool ShellBreakpadClient::EnableBreakpadForProcess(
64    const std::string& process_type) {
65  return process_type == switches::kRendererProcess ||
66         process_type == switches::kPluginProcess ||
67         process_type == switches::kPpapiPluginProcess ||
68         process_type == switches::kZygoteProcess ||
69         process_type == switches::kGpuProcess;
70}
71
72}  // namespace content
73