Add the crash client ID to the uninstall URL params.

BUG=504370

Review URL: https://codereview.chromium.org/1546673002

Cr-Commit-Position: refs/heads/master@{#369407}
diff --git a/chrome/app/chrome_crash_reporter_client.cc b/chrome/app/chrome_crash_reporter_client.cc
index 392b218..8c77d940 100644
--- a/chrome/app/chrome_crash_reporter_client.cc
+++ b/chrome/app/chrome_crash_reporter_client.cc
@@ -14,10 +14,10 @@
 #include "build/build_config.h"
 #include "chrome/common/chrome_constants.h"
 #include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_paths_internal.h"
 #include "chrome/common/chrome_result_codes.h"
 #include "chrome/common/crash_keys.h"
 #include "chrome/common/env_vars.h"
-#include "chrome/installer/util/browser_distribution.h"
 #include "chrome/installer/util/google_update_settings.h"
 #include "content/public/common/content_switches.h"
 
@@ -281,20 +281,9 @@
 bool ChromeCrashReporterClient::GetCrashDumpLocation(
     base::FilePath* crash_dir) {
 #if defined(OS_WIN)
-  // In order to be able to start crash handling very early, we do not rely on
-  // chrome's PathService entries (for DIR_CRASH_DUMPS) being available on
-  // Windows. See https://crbug.com/564398.
-  base::FilePath result;
-  if (!PathService::Get(base::DIR_LOCAL_APP_DATA, &result))
-    return false;
-  BrowserDistribution* dist = BrowserDistribution::GetDistribution();
-  result = result.Append(dist->GetInstallSubDir());
   // TODO(scottmg): Consider supporting --user-data-dir. See
   // https://crbug.com/565446.
-  result = result.Append(chrome::kUserDataDirname);
-  result = result.Append(FILE_PATH_LITERAL("Crashpad"));
-  *crash_dir = result;
-  return true;
+  return chrome::GetDefaultCrashDumpLocation(crash_dir);
 #else
   // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
   // location to write breakpad crash dumps can be set.
diff --git a/chrome/chrome_installer_util.gypi b/chrome/chrome_installer_util.gypi
index 1425a88..757f4d8 100644
--- a/chrome/chrome_installer_util.gypi
+++ b/chrome/chrome_installer_util.gypi
@@ -126,6 +126,7 @@
             '<(DEPTH)/courgette/courgette.gyp:courgette_lib',
             '<(DEPTH)/crypto/crypto.gyp:crypto',
             '<(DEPTH)/third_party/bspatch/bspatch.gyp:bspatch',
+            '<(DEPTH)/third_party/crashpad/crashpad/client/client.gyp:crashpad_client',
             '<(DEPTH)/third_party/icu/icu.gyp:icui18n',
             '<(DEPTH)/third_party/icu/icu.gyp:icuuc',
             '<(DEPTH)/third_party/lzma_sdk/lzma_sdk.gyp:lzma_sdk',
diff --git a/chrome/common/chrome_paths_internal.h b/chrome/common/chrome_paths_internal.h
index ae1cd623..70618287 100644
--- a/chrome/common/chrome_paths_internal.h
+++ b/chrome/common/chrome_paths_internal.h
@@ -107,6 +107,12 @@
 // Checks if the |process_type| has the rights to access the profile.
 bool ProcessNeedsProfileDir(const std::string& process_type);
 
+#if defined(OS_WIN)
+// Populates |crash_dir| with the default crash dump location regardless of
+// whether DIR_USER_DATA or DIR_CRASH_DUMPS has been overridden.
+bool GetDefaultCrashDumpLocation(base::FilePath* crash_dir);
+#endif
+
 }  // namespace chrome
 
 #endif  // CHROME_COMMON_CHROME_PATHS_INTERNAL_H_
diff --git a/chrome/common/chrome_paths_win.cc b/chrome/common/chrome_paths_win.cc
index 78d3573..37a262c 100644
--- a/chrome/common/chrome_paths_win.cc
+++ b/chrome/common/chrome_paths_win.cc
@@ -118,4 +118,14 @@
   return false;
 }
 
+bool GetDefaultCrashDumpLocation(base::FilePath* crash_dir) {
+  // In order to be able to start crash handling very early, we do not rely on
+  // chrome's PathService entries (for DIR_CRASH_DUMPS) being available on
+  // Windows. See https://crbug.com/564398.
+  if (!GetDefaultUserDataDirectory(crash_dir))
+    return false;
+  *crash_dir = crash_dir->Append(FILE_PATH_LITERAL("Crashpad"));
+  return true;
+}
+
 }  // namespace chrome
diff --git a/chrome/installer/util/BUILD.gn b/chrome/installer/util/BUILD.gn
index 2aaea9f9..0faa59e 100644
--- a/chrome/installer/util/BUILD.gn
+++ b/chrome/installer/util/BUILD.gn
@@ -112,6 +112,7 @@
       "//courgette:courgette_lib",
       "//crypto",
       "//third_party/bspatch",
+      "//third_party/crashpad/crashpad/client",
       "//third_party/icu",
       "//third_party/lzma_sdk",
     ]
diff --git a/chrome/installer/util/DEPS b/chrome/installer/util/DEPS
index 66dc0df7..448e750 100644
--- a/chrome/installer/util/DEPS
+++ b/chrome/installer/util/DEPS
@@ -4,4 +4,5 @@
   "+chrome/grit/chromium_strings.h",
 
   "+components/metrics",
+  "+third_party/crashpad",
 ]
diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc
index 49490d4..2b8d6bafc 100644
--- a/chrome/installer/util/google_chrome_distribution.cc
+++ b/chrome/installer/util/google_chrome_distribution.cc
@@ -20,6 +20,7 @@
 #include "base/win/scoped_comptr.h"
 #include "base/win/windows_version.h"
 #include "chrome/common/chrome_icon_resources_win.h"
+#include "chrome/common/chrome_paths_internal.h"
 #include "chrome/installer/util/app_registration_data.h"
 #include "chrome/installer/util/channel_info.h"
 #include "chrome/installer/util/google_update_constants.h"
@@ -32,6 +33,8 @@
 #include "chrome/installer/util/updating_app_registration_data.h"
 #include "chrome/installer/util/util_constants.h"
 #include "chrome/installer/util/wmi.h"
+#include "third_party/crashpad/crashpad/client/crash_report_database.h"
+#include "third_party/crashpad/crashpad/client/settings.h"
 
 namespace {
 
@@ -244,6 +247,16 @@
   result.append(L"=");
   result.append(ap_value);
 
+  // Crash client id.
+  base::FilePath crash_dir;
+  if (chrome::GetDefaultCrashDumpLocation(&crash_dir)) {
+    crashpad::UUID client_id;
+    scoped_ptr<crashpad::CrashReportDatabase> database(
+        crashpad::CrashReportDatabase::InitializeWithoutCreating(crash_dir));
+    if (database && database->GetSettings()->GetClientID(&client_id))
+      result.append(L"&crash_client_id=").append(client_id.ToString16());
+  }
+
   return result;
 }