Revert "Refactored IPH demo mode to be run cross-platform."

This reverts commit 31093e7189d7a055b362bc8f325ef96099ee1b20.

Reason for revert: This change adds static initializers to the build, which is not allowed. It broke the `sizes` step as a result:

https://luci-milo.appspot.com/buildbot/chromium/Linux%20x64/41189
https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Fchromium%2FLinux_x64%2F41189%2F%2B%2Frecipes%2Fsteps%2Fsizes%2F0%2Fstdout

Original change's description:
> Refactored IPH demo mode to be run cross-platform.
> 
> Current code only enables IPH demo mode on Android, restricting testing
> on other platforms.
> 
> This feature needs to be cross-platform to be used with deferred onboarding
> (new tab) on Desktop Chrome.
> 
> Things that were changed in this CL:
> * Makes the whole feature engagement tracker available to all platforms
> * Updated documentation to reflect this change
> * Enables demo mode in chrome://flags to be cross-platform
> * Change in feature_engagement_tracker_impl.cc was necessary to make it
>   work for Windows' pathnames.
> 
> Bug: 729138
> Change-Id: I76b382e004ea9b73bd7fb2df26aa83ff7856422e
> Reviewed-on: https://chromium-review.googlesource.com/518933
> Commit-Queue: Catherine Chung <[email protected]>
> Reviewed-by: Tommy Nyquist <[email protected]>
> Reviewed-by: Scott Violet <[email protected]>
> Reviewed-by: Robert Liao <[email protected]>
> Cr-Commit-Position: refs/heads/master@{#477045}

[email protected],[email protected],[email protected],[email protected],[email protected]
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=729138

Change-Id: Ia6b18d2b797eacea75ec16349f9f42d32ea3f0e8
Reviewed-on: https://chromium-review.googlesource.com/524289
Commit-Queue: Dirk Pranke <[email protected]>
Reviewed-by: Dirk Pranke <[email protected]>
Cr-Commit-Position: refs/heads/master@{#477106}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index a0714804..613e668 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -413,8 +413,6 @@
     "favicon/favicon_utils.h",
     "favicon/large_icon_service_factory.cc",
     "favicon/large_icon_service_factory.h",
-    "feature_engagement_tracker/feature_engagement_tracker_factory.cc",
-    "feature_engagement_tracker/feature_engagement_tracker_factory.h",
     "file_select_helper.cc",
     "file_select_helper.h",
     "file_select_helper_mac.mm",
@@ -1528,7 +1526,6 @@
     "//components/favicon/content",
     "//components/favicon/core",
     "//components/favicon_base",
-    "//components/feature_engagement_tracker",
     "//components/flags_ui",
     "//components/gcm_driver",
     "//components/google/core/browser",
@@ -3137,6 +3134,8 @@
       "download/download_request_infobar_delegate_android.h",
       "engagement/site_engagement_service_android.cc",
       "engagement/site_engagement_service_android.h",
+      "feature_engagement_tracker/feature_engagement_tracker_factory.cc",
+      "feature_engagement_tracker/feature_engagement_tracker_factory.h",
       "geolocation/geolocation_infobar_delegate_android.cc",
       "geolocation/geolocation_infobar_delegate_android.h",
       "history/android/android_history_provider_service.cc",
@@ -3260,6 +3259,7 @@
       "//chrome/browser/android/webapk:proto",
       "//components/cdm/browser",
       "//components/data_usage/android",
+      "//components/feature_engagement_tracker",
       "//components/payments/content/android",
       "//components/precache/content",
       "//components/resources:components_resources",
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index d36739be..edfe86d 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -46,8 +46,6 @@
 #include "components/dom_distiller/core/dom_distiller_switches.h"
 #include "components/error_page/common/error_page_switches.h"
 #include "components/favicon/core/features.h"
-#include "components/feature_engagement_tracker/public/feature_constants.h"
-#include "components/feature_engagement_tracker/public/feature_list.h"
 #include "components/flags_ui/feature_entry.h"
 #include "components/flags_ui/feature_entry_macros.h"
 #include "components/flags_ui/flags_storage.h"
@@ -109,6 +107,8 @@
 
 #if defined(OS_ANDROID)
 #include "chrome/browser/android/chrome_feature_list.h"
+#include "components/feature_engagement_tracker/public/feature_constants.h"
+#include "components/feature_engagement_tracker/public/feature_list.h"
 #else  // OS_ANDROID
 #include "ui/message_center/message_center_switches.h"
 #endif  // OS_ANDROID
@@ -1794,12 +1794,14 @@
      flag_descriptions::kChromeHomeSwipeLogicDescription, kOsAndroid,
      MULTI_VALUE_TYPE(kChromeHomeSwipeLogicChoices)},
 #endif  // OS_ANDROID
+#if defined(OS_ANDROID)
     {"iph-demo-mode-choice", flag_descriptions::kIphDemoModeChoiceName,
-     flag_descriptions::kIphDemoModeChoiceDescription, kOsAll,
+     flag_descriptions::kIphDemoModeChoiceDescription, kOsAndroid,
      FEATURE_WITH_PARAMS_VALUE_TYPE(
          feature_engagement_tracker::kIPHDemoMode,
          feature_engagement_tracker::kIPHDemoModeChoiceVariations,
          feature_engagement_tracker::kIPHDemoMode.name)},
+#endif  // OS_ANDROID
     {"num-raster-threads", flag_descriptions::kNumRasterThreadsName,
      flag_descriptions::kNumRasterThreadsDescription, kOsAll,
      MULTI_VALUE_TYPE(kNumRasterThreadsChoices)},
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index 054f5e6b..db5fad8 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -353,11 +353,6 @@
     "Experiment to have all APIs reflect the layout viewport. This will "
     "make window.scroll properties relative to the layout viewport.";
 
-const char kIphDemoModeChoiceName[] = "In-Product Help Demo Mode";
-
-const char kIphDemoModeChoiceDescription[] =
-    "Selects the In-Product Help demo mode.";
-
 const char kColorCorrectRenderingName[] = "Color correct rendering";
 
 const char kColorCorrectRenderingDescription[] =
@@ -1990,6 +1985,17 @@
 
 #endif  // defined(OS_ANDROID)
 
+//  In-Product Help flags
+
+#if defined(OS_ANDROID)
+
+const char kIphDemoModeChoiceName[] = "In-Product Help Demo Mode";
+
+const char kIphDemoModeChoiceDescription[] =
+    "Selects the In-Product Help demo mode.";
+
+#endif  // defined(OS_ANDROID)
+
 //  Settings window flags
 
 const char kSettingsWindowName[] = "Show settings in a window";
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index 4bc25493..5ccc0d6 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -406,9 +406,6 @@
 extern const char kInertVisualViewportName[];
 extern const char kInertVisualViewportDescription[];
 
-extern const char kIphDemoModeChoiceName[];
-extern const char kIphDemoModeChoiceDescription[];
-
 extern const char kJavascriptHarmonyName[];
 extern const char kJavascriptHarmonyDescription[];
 
@@ -988,6 +985,9 @@
 extern const char kHerbPrototypeChoicesDescription[];
 extern const char kHerbPrototypeFlavorElderberry[];
 
+extern const char kIphDemoModeChoiceName[];
+extern const char kIphDemoModeChoiceDescription[];
+
 extern const char kLsdPermissionPromptName[];
 extern const char kLsdPermissionPromptDescription[];
 
diff --git a/components/BUILD.gn b/components/BUILD.gn
index 71bc853..482b3b8 100644
--- a/components/BUILD.gn
+++ b/components/BUILD.gn
@@ -85,7 +85,6 @@
     "//components/download:unit_tests",
     "//components/favicon/core:unit_tests",
     "//components/favicon_base:unit_tests",
-    "//components/feature_engagement_tracker:unit_tests",
     "//components/flags_ui:unit_tests",
     "//components/gcm_driver:unit_tests",
     "//components/gcm_driver/crypto:unit_tests",
@@ -244,6 +243,7 @@
   if (is_android) {
     deps += [
       "//components/cdm/browser:unit_tests",
+      "//components/feature_engagement_tracker:unit_tests",
       "//components/gcm_driver/instance_id:test_support",
       "//components/gcm_driver/instance_id/android:instance_id_driver_java",
       "//components/gcm_driver/instance_id/android:instance_id_driver_test_support_java",
diff --git a/components/feature_engagement_tracker/README.md b/components/feature_engagement_tracker/README.md
index d357494c99..e912703 100644
--- a/components/feature_engagement_tracker/README.md
+++ b/components/feature_engagement_tracker/README.md
@@ -13,6 +13,21 @@
 The backend is feature agnostic and have no special logic for any specific
 features, but instead provides a generic API.
 
+## Compiling for platforms other than Android
+
+For now the code for the Feature Engagement Tracker is only compiled in
+for Android, but only a shim layer is really dependent on Android to provide a
+JNI bridge. The goal is to keep all the business logic in the cross-platform
+part of the code.
+
+For local development, it is therefore possible to compile and run tests for
+the core of the tracker on other platforms. To do this, simply add the
+following line to the `//components:components_unittests` target:
+
+```python
+deps += [ "//components/feature_engagement_tracker:unit_tests" ]
+```
+
 ## Testing
 
 To compile and run tests, assuming the product out directory is `out/Debug`,
diff --git a/components/feature_engagement_tracker/internal/feature_engagement_tracker_impl.cc b/components/feature_engagement_tracker/internal/feature_engagement_tracker_impl.cc
index b2d9374..9d92884 100644
--- a/components/feature_engagement_tracker/internal/feature_engagement_tracker_impl.cc
+++ b/components/feature_engagement_tracker/internal/feature_engagement_tracker_impl.cc
@@ -9,7 +9,6 @@
 
 #include "base/bind.h"
 #include "base/feature_list.h"
-#include "base/files/file_path.h"
 #include "base/memory/ptr_util.h"
 #include "base/metrics/field_trial_params.h"
 #include "base/metrics/user_metrics.h"
@@ -36,10 +35,8 @@
 namespace feature_engagement_tracker {
 
 namespace {
-const base::FilePath::CharType kEventDBStorageDir[] =
-    FILE_PATH_LITERAL("EventDB");
-const base::FilePath::CharType kAvailabilityDBStorageDir[] =
-    FILE_PATH_LITERAL("AvailabilityDB");
+const char kEventDBStorageDir[] = "EventDB";
+const char kAvailabilityDBStorageDir[] = "AvailabilityDB";
 
 // Creates a FeatureEngagementTrackerImpl that is usable for a demo mode.
 std::unique_ptr<FeatureEngagementTracker>
diff --git a/components/feature_engagement_tracker/internal/system_time_provider_unittest.cc b/components/feature_engagement_tracker/internal/system_time_provider_unittest.cc
index e9d08c0..6bcf53c 100644
--- a/components/feature_engagement_tracker/internal/system_time_provider_unittest.cc
+++ b/components/feature_engagement_tracker/internal/system_time_provider_unittest.cc
@@ -17,7 +17,6 @@
   exploded_time.year = year;
   exploded_time.month = month;
   exploded_time.day_of_month = day;
-  exploded_time.day_of_week = 0;
   exploded_time.hour = 0;
   exploded_time.minute = 0;
   exploded_time.second = 0;