Commit 8250a63d authored by yfriedman's avatar yfriedman Committed by Commit bot

Add UMA metric for "View Original" link clicks in distilled page viewer.

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

Cr-Commit-Position: refs/heads/master@{#294089}
parent 3458fc00
......@@ -11,6 +11,7 @@
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/user_metrics.h"
#include "base/strings/utf_string_conversions.h"
#include "components/dom_distiller/core/distilled_page_prefs.h"
#include "components/dom_distiller/core/dom_distiller_service.h"
......@@ -21,6 +22,7 @@
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "net/base/url_util.h"
......@@ -284,6 +286,11 @@ void DomDistillerViewerSource::StartDataRequest(
callback.Run(base::RefCountedString::TakeString(&js));
return;
}
if (kViewerViewOriginalPath == path) {
content::RecordAction(base::UserMetricsAction("DomDistiller_ViewOriginal"));
callback.Run(NULL);
return;
}
content::WebContents* web_contents =
content::WebContents::FromRenderFrameHost(
content::RenderFrameHost::FromID(render_process_id,
......
......@@ -11,7 +11,6 @@ found in the LICENSE file.
<title>$1</title>
<link rel="stylesheet" href="/$2">
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<script src="/$3"></script>
</head>
<body class="$4">
<div id="mainContent">
......@@ -79,4 +78,5 @@ found in the LICENSE file.
<a href="$7">$8</a>
</div>
</body>
<script src="/$3"></script>
</html>
......@@ -65,3 +65,12 @@ var updateLoadingIndicator = function() {
}
};
}();
// Add a listener to the "View Original" link to report opt-outs.
document.getElementById('showOriginal').addEventListener('click', function(e) {
var img = document.createElement('img');
img.src = "/vieworiginal";
img.style.display = "none";
document.body.appendChild(img);
}, true);
......@@ -11,5 +11,6 @@ const char kEntryIdKey[] = "entry_id";
const char kUrlKey[] = "url";
const char kViewerCssPath[] = "dom_distiller_viewer.css";
const char kViewerJsPath[] = "dom_distiller_viewer.js";
const char kViewerViewOriginalPath[] = "vieworiginal";
} // namespace dom_distiller
......@@ -12,6 +12,8 @@ extern const char kEntryIdKey[];
extern const char kUrlKey[];
extern const char kViewerCssPath[];
extern const char kViewerJsPath[];
extern const char kViewerViewOriginalPath[];
} // namespace dom_distiller
......
......@@ -2480,6 +2480,14 @@ should be able to be added at any place in this file.
<description>User opens distilled page preferences.</description>
</action>
<action name="DomDistiller_ViewOriginal">
<owner>yfriedman@chromium.org</owner>
<description>
Records clicks on the &quot;View Original&quot; link in the distilled page
viewer.
</description>
</action>
<action name="Duplicate">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment