Split captive portal metrics out of SSLErrorClassification

SSLErrorClassification can be shared cross-platform if the Chrome-specific
captive portal logic is moved to its own helper. This also is a nice clean
separation of purposes, since the captive portal logic was fairly disjoint
from the other work being done in SSLErrorClassification. Now the captive
portal logic is handled as a metrics helper.

I also made the ownership of the metrics helper clearer by changing to use a
scoped_ptr.

BUG=488673
[email protected]
[email protected]

Committed: https://crrev.com/5a31c78de2d5a1829910ec09d86ec10ae16e5c4c
Cr-Commit-Position: refs/heads/master@{#351195}

Committed: https://crrev.com/c0a91fac22f1d3ff3f8d052eb5dbffa70ef9835f
Cr-Commit-Position: refs/heads/master@{#351246}

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

Cr-Commit-Position: refs/heads/master@{#351358}
diff --git a/chrome/browser/interstitials/chrome_metrics_helper.h b/chrome/browser/interstitials/chrome_metrics_helper.h
index e56e59a..bba24c2 100644
--- a/chrome/browser/interstitials/chrome_metrics_helper.h
+++ b/chrome/browser/interstitials/chrome_metrics_helper.h
@@ -18,9 +18,13 @@
 class ExperienceSamplingEvent;
 }
 
+class CaptivePortalMetricsRecorder;
+
 // This class adds desktop-Chrome-specific metrics (extension experience
 // sampling) to the security_interstitials::MetricsHelper. Together, they
 // record UMA, Rappor, and experience sampling metrics.
+
+// This class is meant to be used on the UI thread for captive portal metrics.
 class ChromeMetricsHelper : public security_interstitials::MetricsHelper {
  public:
   ChromeMetricsHelper(
@@ -30,12 +34,15 @@
       const std::string& sampling_event_name);
   ~ChromeMetricsHelper() override;
 
+  void StartRecordingCaptivePortalMetrics(bool overridable);
+
  protected:
   // security_interstitials::MetricsHelper methods:
   void RecordExtraUserDecisionMetrics(
       security_interstitials::MetricsHelper::Decision decision) override;
   void RecordExtraUserInteractionMetrics(
       security_interstitials::MetricsHelper::Interaction interaction) override;
+  void RecordExtraShutdownMetrics() override;
 
  private:
   content::WebContents* web_contents_;
@@ -44,6 +51,7 @@
 #if defined(ENABLE_EXTENSIONS)
   scoped_ptr<extensions::ExperienceSamplingEvent> sampling_event_;
 #endif
+  scoped_ptr<CaptivePortalMetricsRecorder> captive_portal_recorder_;
 
   DISALLOW_COPY_AND_ASSIGN(ChromeMetricsHelper);
 };