summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-22 00:46:59 +0000
committermpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-22 00:46:59 +0000
commit77e9e4d9f3028c80dea47aed96e324b2fe762474 (patch)
tree0ac651772e46a349c3438bc8d6294ac7cf36faf4
parente874ff906edfc43b7aaca2b61441babb4513ebe2 (diff)
downloadchromium_src-77e9e4d9f3028c80dea47aed96e324b2fe762474.zip
chromium_src-77e9e4d9f3028c80dea47aed96e324b2fe762474.tar.gz
chromium_src-77e9e4d9f3028c80dea47aed96e324b2fe762474.tar.bz2
Adds about:user-actions page.
This page listens for all record-user-action events and displays them. It's useful to help verify that the right user actions get sent at the right time. BUG=162309 Review URL: https://chromiumcodereview.appspot.com/11415063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169176 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_about_handler.cc1
-rw-r--r--chrome/browser/browser_resources.grd3
-rw-r--r--chrome/browser/resources/user_actions/user_actions.css15
-rw-r--r--chrome/browser/resources/user_actions/user_actions.html19
-rw-r--r--chrome/browser/resources/user_actions/user_actions.js38
-rw-r--r--chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc3
-rw-r--r--chrome/browser/ui/webui/user_actions/user_actions_ui.cc32
-rw-r--r--chrome/browser/ui/webui/user_actions/user_actions_ui.h20
-rw-r--r--chrome/browser/ui/webui/user_actions/user_actions_ui_handler.cc35
-rw-r--r--chrome/browser/ui/webui/user_actions/user_actions_ui_handler.h38
-rw-r--r--chrome/chrome_browser_ui.gypi4
-rw-r--r--chrome/common/url_constants.cc2
-rw-r--r--chrome/common/url_constants.h2
13 files changed, 212 insertions, 0 deletions
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc
index 4499e70..84bf2c7 100644
--- a/chrome/browser/browser_about_handler.cc
+++ b/chrome/browser/browser_about_handler.cc
@@ -44,6 +44,7 @@ const char* const kPaths[] = {
chrome::kChromeUIStatsHost,
chrome::kChromeUISyncInternalsHost,
chrome::kChromeUITermsHost,
+ chrome::kChromeUIUserActionsHost,
chrome::kChromeUIVersionHost,
#if defined(OS_ANDROID)
chrome::kChromeUIWelcomeHost,
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index 0d2a8c4..82db0d5 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -207,6 +207,9 @@
<include name="IDR_UBER_FRAME_HTML" file="resources\uber\uber_frame.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_UBER_FRAME_JS" file="resources\uber\uber_frame.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_UBER_UTILS_JS" file="resources\uber\uber_utils.js" type="BINDATA" />
+ <include name="IDR_USER_ACTIONS_HTML" file="resources\user_actions\user_actions.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
+ <include name="IDR_USER_ACTIONS_CSS" file="resources\user_actions\user_actions.css" type="BINDATA" />
+ <include name="IDR_USER_ACTIONS_JS" file="resources\user_actions\user_actions.js" type="BINDATA" />
<include name="IDR_WEBSTORE_MANIFEST" file="resources\webstore_app\manifest.json" type="BINDATA" />
<include name="IDR_ENTERPRISE_WEBSTORE_MANIFEST" file="resources\enterprise_webstore_app\manifest.json" type="BINDATA" />
<if expr="pp_ifdef('use_ash')">
diff --git a/chrome/browser/resources/user_actions/user_actions.css b/chrome/browser/resources/user_actions/user_actions.css
new file mode 100644
index 0000000..d6ae04f
--- /dev/null
+++ b/chrome/browser/resources/user_actions/user_actions.css
@@ -0,0 +1,15 @@
+/* Copyright 2012 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file. */
+
+thead {
+ white-space: nowrap;
+}
+
+th {
+ background-color: #C0C0C0;
+}
+
+td {
+ background-color: #F0F0F0;
+}
diff --git a/chrome/browser/resources/user_actions/user_actions.html b/chrome/browser/resources/user_actions/user_actions.html
new file mode 100644
index 0000000..9e1b2501
--- /dev/null
+++ b/chrome/browser/resources/user_actions/user_actions.html
@@ -0,0 +1,19 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>User Actions Debug Page</title>
+ <link rel="stylesheet" href="user_actions.css">
+ <script src="chrome://resources/js/cr.js"></script>
+ <script src="chrome://resources/js/util.js"></script>
+ <script src="user_actions.js"></script>
+</head>
+<body>
+ <p>
+ Listening for user actions...
+ </p>
+ <table id="user-actions-table">
+ <thead><th>User Action</th><th>Timestamp (sec.)</th></thead>
+ </table>
+</body>
+</html>
diff --git a/chrome/browser/resources/user_actions/user_actions.js b/chrome/browser/resources/user_actions/user_actions.js
new file mode 100644
index 0000000..dde9d1e
--- /dev/null
+++ b/chrome/browser/resources/user_actions/user_actions.js
@@ -0,0 +1,38 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * Javascript for user_actions.html, served from chrome://user-actions/
+ * This is used to debug user actions recording. It displays a live
+ * stream of all user action events that occur in chromium while the
+ * chrome://user-actions/ page is open.
+ *
+ * The simple object defined in this javascript file listens for
+ * callbacks from the C++ code saying that a new user action was seen.
+ */
+
+cr.define('userActions', function() {
+ 'user strict';
+
+ /**
+ * Appends a row to the output table listing the user action observed
+ * and the current timestamp.
+ * @param {string} userAction the name of the user action observed.
+ */
+ function observeUserAction(userAction) {
+ var table = $('user-actions-table');
+ var tr = document.createElement('tr');
+ var td = document.createElement('td');
+ td.textContent = userAction;
+ tr.appendChild(td);
+ td = document.createElement('td');
+ td.textContent = Date.now() / 1000; // in seconds since epoch
+ tr.appendChild(td);
+ table.appendChild(tr);
+ }
+
+ return {
+ observeUserAction: observeUserAction
+ };
+});
diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
index 0760005..b6402d2 100644
--- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
@@ -51,6 +51,7 @@
#include "chrome/browser/ui/webui/task_manager/task_manager_ui.h"
#include "chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h"
#include "chrome/browser/ui/webui/tracing_ui.h"
+#include "chrome/browser/ui/webui/user_actions/user_actions_ui.h"
#include "chrome/browser/ui/webui/version_ui.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -229,6 +230,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<SyncInternalsUI>;
if (url.host() == chrome::kChromeUISyncResourcesHost)
return &NewWebUI<WebDialogUI>;
+ if (url.host() == chrome::kChromeUIUserActionsHost)
+ return &NewWebUI<UserActionsUI>;
if (url.host() == chrome::kChromeUIVersionHost)
return &NewWebUI<VersionUI>;
diff --git a/chrome/browser/ui/webui/user_actions/user_actions_ui.cc b/chrome/browser/ui/webui/user_actions/user_actions_ui.cc
new file mode 100644
index 0000000..75f3620
--- /dev/null
+++ b/chrome/browser/ui/webui/user_actions/user_actions_ui.cc
@@ -0,0 +1,32 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/user_actions/user_actions_ui.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
+#include "chrome/browser/ui/webui/user_actions/user_actions_ui_handler.h"
+#include "chrome/common/url_constants.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_controller.h"
+#include "grit/browser_resources.h"
+
+UserActionsUI::UserActionsUI(content::WebUI* web_ui)
+ : content::WebUIController(web_ui) {
+ // Set up the chrome://user-actions/ source.
+ ChromeWebUIDataSource* html_source =
+ new ChromeWebUIDataSource(chrome::kChromeUIUserActionsHost);
+ html_source->set_default_resource(IDR_USER_ACTIONS_HTML);
+ html_source->add_resource_path("user_actions.css", IDR_USER_ACTIONS_CSS);
+ html_source->add_resource_path("user_actions.js", IDR_USER_ACTIONS_JS);
+
+ Profile* profile = Profile::FromWebUI(web_ui);
+ ChromeURLDataManager::AddDataSource(profile, html_source);
+
+ // AddMessageHandler takes ownership of UserActionsUIHandler.
+ web_ui->AddMessageHandler(new UserActionsUIHandler());
+}
+
+UserActionsUI::~UserActionsUI() {}
diff --git a/chrome/browser/ui/webui/user_actions/user_actions_ui.h b/chrome/browser/ui/webui/user_actions/user_actions_ui.h
new file mode 100644
index 0000000..4681175
--- /dev/null
+++ b/chrome/browser/ui/webui/user_actions/user_actions_ui.h
@@ -0,0 +1,20 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_USER_ACTIONS_USER_ACTIONS_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_USER_ACTIONS_USER_ACTIONS_UI_H_
+
+#include "content/public/browser/web_ui_controller.h"
+
+// The UI for chrome://user-actions/
+class UserActionsUI : public content::WebUIController {
+ public:
+ explicit UserActionsUI(content::WebUI* contents);
+ virtual ~UserActionsUI();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(UserActionsUI);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_USER_ACTIONS_USER_ACTIONS_UI_H_
diff --git a/chrome/browser/ui/webui/user_actions/user_actions_ui_handler.cc b/chrome/browser/ui/webui/user_actions/user_actions_ui_handler.cc
new file mode 100644
index 0000000..fa5f956b
--- /dev/null
+++ b/chrome/browser/ui/webui/user_actions/user_actions_ui_handler.cc
@@ -0,0 +1,35 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/user_actions/user_actions_ui_handler.h"
+
+#include "base/logging.h"
+#include "base/values.h"
+#include "content/public/browser/notification_details.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_source.h"
+#include "content/public/browser/notification_types.h"
+#include "content/public/browser/web_ui.h"
+
+UserActionsUIHandler::UserActionsUIHandler() : NotificationObserver() {
+ registrar_.Add(this,
+ content::NOTIFICATION_USER_ACTION,
+ content::NotificationService::AllSources());
+}
+
+UserActionsUIHandler::~UserActionsUIHandler() {
+}
+
+void UserActionsUIHandler::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK_EQ(type, content::NOTIFICATION_USER_ACTION);
+ base::StringValue user_action_name(
+ *content::Details<const char*>(details).ptr());
+ web_ui()->CallJavascriptFunction("userActions.observeUserAction",
+ user_action_name);
+}
+
+void UserActionsUIHandler::RegisterMessages() {}
diff --git a/chrome/browser/ui/webui/user_actions/user_actions_ui_handler.h b/chrome/browser/ui/webui/user_actions/user_actions_ui_handler.h
new file mode 100644
index 0000000..de145ea
--- /dev/null
+++ b/chrome/browser/ui/webui/user_actions/user_actions_ui_handler.h
@@ -0,0 +1,38 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_USER_ACTIONS_USER_ACTIONS_UI_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_USER_ACTIONS_USER_ACTIONS_UI_HANDLER_H_
+
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/web_ui_message_handler.h"
+
+// UI Handler for chrome://user-actions/
+// It listens to user action notifications and passes those notifications
+// into the Javascript to update the page.
+class UserActionsUIHandler : public content::NotificationObserver,
+ public content::WebUIMessageHandler {
+ public:
+ UserActionsUIHandler();
+ virtual ~UserActionsUIHandler();
+
+ // NotificationObserver implementation:
+ // Listens for user action notifications and passes the message to
+ // observeUserAction in user_actions.js.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ // WebUIMessageHandler implementation:
+ // Does nothing for now.
+ virtual void RegisterMessages() OVERRIDE;
+
+ private:
+ content::NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(UserActionsUIHandler);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_USER_ACTIONS_USER_ACTIONS_UI_HANDLER_H_
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index eead1a9..65fab7d 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -2083,6 +2083,10 @@
'browser/ui/webui/tracing_ui.h',
'browser/ui/webui/uber/uber_ui.cc',
'browser/ui/webui/uber/uber_ui.h',
+ 'browser/ui/webui/user_actions/user_actions_ui.cc',
+ 'browser/ui/webui/user_actions/user_actions_ui.h',
+ 'browser/ui/webui/user_actions/user_actions_ui_handler.cc',
+ 'browser/ui/webui/user_actions/user_actions_ui_handler.h',
'browser/ui/webui/version_handler.cc',
'browser/ui/webui/version_handler.h',
'browser/ui/webui/version_handler_chromeos.cc',
diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc
index 86ad5e5..7776094 100644
--- a/chrome/common/url_constants.cc
+++ b/chrome/common/url_constants.cc
@@ -73,6 +73,7 @@ const char kChromeUIThemeURL[] = "chrome://theme/";
const char kChromeUIThumbnailURL[] = "chrome://thumb/";
const char kChromeUIUberURL[] = "chrome://chrome/";
const char kChromeUIUberFrameURL[] = "chrome://uber-frame/";
+const char kChromeUIUserActionsURL[] = "chrome://user-actions/";
const char kChromeUIVersionURL[] = "chrome://version/";
#if defined(OS_ANDROID)
@@ -206,6 +207,7 @@ const char kChromeUITouchIconHost[] = "touch-icon";
const char kChromeUITracingHost[] = "tracing";
const char kChromeUIUberFrameHost[] = "uber-frame";
const char kChromeUIUberHost[] = "chrome";
+const char kChromeUIUserActionsHost[] = "user-actions";
const char kChromeUIVersionHost[] = "version";
const char kChromeUIWorkersHost[] = "workers";
diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h
index a2ff500..d8e3c25 100644
--- a/chrome/common/url_constants.h
+++ b/chrome/common/url_constants.h
@@ -71,6 +71,7 @@ extern const char kChromeUIThemeURL[];
extern const char kChromeUIThumbnailURL[];
extern const char kChromeUIUberURL[];
extern const char kChromeUIUberFrameURL[];
+extern const char kChromeUIUserActionsURL[];
extern const char kChromeUIVersionURL[];
#if defined(OS_ANDROID)
@@ -201,6 +202,7 @@ extern const char kChromeUITouchIconHost[];
extern const char kChromeUITracingHost[];
extern const char kChromeUIUberFrameHost[];
extern const char kChromeUIUberHost[];
+extern const char kChromeUIUserActionsHost[];
extern const char kChromeUIVersionHost[];
extern const char kChromeUIWorkersHost[];