Re-enable rappor for vrshell

There was a dependency cycle and resulting test code build break when
consuming g_browser_process from vr_shell.  This fix provides a way to
report rappor metrics in components that don't depend on chrome/browser.

BUG=667900

Review-Url: https://codereview.chromium.org/2526643002
Cr-Commit-Position: refs/heads/master@{#435119}
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index f56396f..5be550d8 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -98,6 +98,7 @@
 #include "components/prefs/json_pref_store.h"
 #include "components/prefs/pref_registry_simple.h"
 #include "components/prefs/pref_service.h"
+#include "components/rappor/rappor_utils.h"
 #include "components/safe_json/safe_json_parser.h"
 #include "components/signin/core/common/profile_management_switches.h"
 #include "components/subresource_filter/content/browser/content_ruleset_service_delegate.h"
@@ -198,6 +199,12 @@
 using content::PluginService;
 using content::ResourceDispatcherHost;
 
+rappor::RapporService* GetBrowserRapporService() {
+  if (g_browser_process != nullptr)
+    return g_browser_process->rappor_service();
+  return nullptr;
+}
+
 BrowserProcessImpl::BrowserProcessImpl(
     base::SequencedTaskRunner* local_state_task_runner,
     const base::CommandLine& command_line)
@@ -216,6 +223,7 @@
       local_state_task_runner_(local_state_task_runner),
       cached_default_web_client_state_(shell_integration::UNKNOWN_DEFAULT) {
   g_browser_process = this;
+  rappor::SetDefaultServiceAccessor(&GetBrowserRapporService);
   platform_part_.reset(new BrowserProcessPlatformPart());
 
 #if BUILDFLAG(ENABLE_PRINTING)