Commit b4da2d05 authored by zork@chromium.org's avatar zork@chromium.org

Add chrome://slow for enabling performance tracing for feedback reports.

BUG=269809

Review URL: https://chromiumcodereview.appspot.com/22336007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216845 0039d316-1c4b-4281-b951-d872f2087c98
parent aa3bef22
...@@ -1618,6 +1618,19 @@ Press any key to continue exploring. ...@@ -1618,6 +1618,19 @@ Press any key to continue exploring.
This SIM card is disabled and cannot be used. Please contact your service provider for a replacement. This SIM card is disabled and cannot be used. Please contact your service provider for a replacement.
</message> </message>
<message name="IDS_SLOW_DISABLE" desc="The text of the button that disables performance collection for feedback reports">
Disable performance data collection
</message>
<message name="IDS_SLOW_ENABLE" desc="The text of the button that enables performance collection for feedback reports">
Enable performance data collection
</message>
<message name="IDS_SLOW_DESCRIPTION" desc="The description of the performance tracing feature for feedback reports.">
Enabling collection of performance data will help Google improve the system over time. No data is sent until you file a feedback report (Alt-Shift-I) and include performance data. You can return to this screen to disable collection at any time.
</message>
<message name="IDS_SLOW_WARNING" desc="The warning that informs users that enabling this can have a negative effect on their performance">
<ph name="BEGIN_BOLD">&lt;strong&gt;</ph>Note:<ph name="END_BOLD">&lt;/strong&gt;</ph> Only enable if you know what you are doing or if you have been asked to do so, as collection of data may reduce performance.
</message>
<message name="IDS_EULA_BACK_BUTTON" desc="Back button shown on EULA screen."> <message name="IDS_EULA_BACK_BUTTON" desc="Back button shown on EULA screen.">
Back Back
</message> </message>
......
...@@ -318,6 +318,8 @@ ...@@ -318,6 +318,8 @@
<include name="IDR_SIM_UNLOCK_HTML" file="resources\chromeos\sim_unlock.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_SIM_UNLOCK_HTML" file="resources\chromeos\sim_unlock.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_WRENCH_MENU_CSS" file="resources\chromeos\wrench_menu.css" flattenhtml="true" type="BINDATA" /> <include name="IDR_WRENCH_MENU_CSS" file="resources\chromeos\wrench_menu.css" flattenhtml="true" type="BINDATA" />
<include name="IDR_WRENCH_MENU_JS" file="resources\chromeos\wrench_menu.js" flattenhtml="true" type="BINDATA" /> <include name="IDR_WRENCH_MENU_JS" file="resources\chromeos\wrench_menu.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_SLOW_HTML" file="resources\chromeos\slow.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_SLOW_JS" file="resources\chromeos\slow.js" type="BINDATA" />
</if> </if>
<if expr="pp_ifdef('file_manager_extension')"> <if expr="pp_ifdef('file_manager_extension')">
<include name="IDR_FILEMANAGER_MANIFEST" file="resources\file_manager\manifest.json" type="BINDATA" /> <include name="IDR_FILEMANAGER_MANIFEST" file="resources\file_manager\manifest.json" type="BINDATA" />
......
/* Copyright 2013 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.
*/
body {
background-color: #E6E6E6;
font-family: Helvetica, Arial, sans-serif;
font-size: 12pt;
margin: 50px 40px 20px 40px;
text-align: center;
}
#container {
background-color: #fbfbfb;
border: 1px solid #AAA;
border-bottom: 1px solid #888;
border-radius: 3px;
box-shadow: 0 2px 2px #AAA;
color: #666;
margin: auto;
max-width: 540px;
min-height: 29px;
min-width: 200px;
padding: 20px 60px;
text-align: start;
}
#container-inner {
background-color: #fbfbfb;
margin-top: 25px;
text-align: center;
}
button {
-webkit-user-select: none;
background-image: -webkit-linear-gradient(#ededed, #ededed 38%, #dedede);
border: 1px solid rgba(0, 0, 0, 0.25);
border-radius: 2px;
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08),
inset 0 1px 2px rgba(255, 255, 255, 0.75);
margin-top: 10px;
min-height: 29px;
min-width: 65px;
padding: 8px 13px;
text-shadow: 0 1px 0 rgb(240, 240, 240);
}
<!DOCTYPE HTML>
<html i18n-values="dir:textdirection">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0,
maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="chrome://resources/css/widgets.css">
<link rel="stylesheet" href="slow.css">
<script src="chrome://resources/js/load_time_data.js"></script>
<script src="chrome://resources/js/cr.js"></script>
<script src="chrome://resources/js/cr/event_target.js"></script>
<script src="chrome://resources/js/util.js"></script>
<script src="chrome://slow/slow.js"></script>
<script src="chrome://slow/strings.js"></script>
</head>
<body i18n-values=".style.fontFamily:fontfamily;">
<div id="container" class="container">
<div i18n-content="slowDescription"></div>
<br>
<div i18n-values=".innerHTML:slowWarning"></div>
<div id="container-inner" width=100% class="container-inner">
<button id="slow-disable" i18n-content="slowDisable" hidden></button>
<button id="slow-enable" i18n-content="slowEnable" hidden></button>
</div>
</div>
<script src="chrome://resources/js/i18n_template2.js"></script>
<script src="chrome://resources/js/jstemplate_compiled.js"></script>
</body>
</html>
// Copyright 2013 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.
cr.define('options', function() {
function Slow() {
}
cr.addSingletonGetter(Slow);
Slow.prototype = {
initialized_: false
};
Slow.initialize = function() {
$('slow-disable').addEventListener('click', function(event) {
Slow.disableTracing();
});
$('slow-enable').addEventListener('click', function(event) {
Slow.enableTracing();
});
this.initialized_ = true;
};
Slow.disableTracing = function() {
chrome.send('disableTracing');
};
Slow.enableTracing = function() {
chrome.send('enableTracing');
};
Slow.tracingPrefChanged = function(enabled) {
$('slow-disable').hidden = !enabled;
$('slow-enable').hidden = enabled;
};
// Export
return {
Slow: Slow
};
});
function load() {
options.Slow.initialize();
chrome.send('loadComplete');
}
document.addEventListener('DOMContentLoaded', load);
...@@ -104,6 +104,7 @@ ...@@ -104,6 +104,7 @@
#include "chrome/browser/ui/webui/chromeos/proxy_settings_ui.h" #include "chrome/browser/ui/webui/chromeos/proxy_settings_ui.h"
#include "chrome/browser/ui/webui/chromeos/salsa_ui.h" #include "chrome/browser/ui/webui/chromeos/salsa_ui.h"
#include "chrome/browser/ui/webui/chromeos/sim_unlock_ui.h" #include "chrome/browser/ui/webui/chromeos/sim_unlock_ui.h"
#include "chrome/browser/ui/webui/chromeos/slow_ui.h"
#include "chrome/browser/ui/webui/chromeos/system_info_ui.h" #include "chrome/browser/ui/webui/chromeos/system_info_ui.h"
#endif #endif
...@@ -361,6 +362,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, ...@@ -361,6 +362,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<SalsaUI>; return &NewWebUI<SalsaUI>;
if (url.host() == chrome::kChromeUISimUnlockHost) if (url.host() == chrome::kChromeUISimUnlockHost)
return &NewWebUI<chromeos::SimUnlockUI>; return &NewWebUI<chromeos::SimUnlockUI>;
if (url.host() == chrome::kChromeUISlowHost)
return &NewWebUI<chromeos::SlowUI>;
if (url.host() == chrome::kChromeUISystemInfoHost) if (url.host() == chrome::kChromeUISystemInfoHost)
return &NewWebUI<chromeos::SystemInfoUI>; return &NewWebUI<chromeos::SystemInfoUI>;
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
......
// Copyright 2013 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/chromeos/slow_ui.h"
#include <string>
#include "base/bind.h"
#include "base/prefs/pref_change_registrar.h"
#include "base/prefs/pref_service.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "grit/browser_resources.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/webui/jstemplate_builder.h"
#include "ui/webui/web_ui_util.h"
using content::WebUIMessageHandler;
namespace {
// JS API callbacks names.
const char kJsApiDisableTracing[] = "disableTracing";
const char kJsApiEnableTracing[] = "enableTracing";
const char kJsApiLoadComplete[] = "loadComplete";
// Page JS API function names.
const char kJsApiTracingPrefChanged[] = "options.Slow.tracingPrefChanged";
} // namespace
namespace chromeos {
content::WebUIDataSource* CreateSlowUIHTMLSource() {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUISlowHost);
source->SetUseJsonJSFormatV2();
source->AddLocalizedString("slowDisable", IDS_SLOW_DISABLE);
source->AddLocalizedString("slowEnable", IDS_SLOW_ENABLE);
source->AddLocalizedString("slowDescription", IDS_SLOW_DESCRIPTION);
source->AddLocalizedString("slowWarning", IDS_SLOW_WARNING);
source->SetJsonPath("strings.js");
source->AddResourcePath("slow.js", IDR_SLOW_JS);
source->SetDefaultResource(IDR_SLOW_HTML);
return source;
}
// The handler for Javascript messages related to the "slow" view.
class SlowHandler : public WebUIMessageHandler {
public:
explicit SlowHandler(Profile* profile);
virtual ~SlowHandler();
// WebUIMessageHandler implementation.
virtual void RegisterMessages() OVERRIDE;
private:
void UpdatePage();
// Handlers for JS WebUI messages.
void HandleDisable(const ListValue* args);
void HandleEnable(const ListValue* args);
void LoadComplete(const ListValue* args);
Profile* profile_;
scoped_ptr<PrefChangeRegistrar> user_pref_registrar_;
DISALLOW_COPY_AND_ASSIGN(SlowHandler);
};
// SlowHandler ------------------------------------------------------------
SlowHandler::SlowHandler(Profile* profile) : profile_(profile) {
}
SlowHandler::~SlowHandler() {
}
void SlowHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(kJsApiDisableTracing,
base::Bind(&SlowHandler::HandleDisable, base::Unretained(this)));
web_ui()->RegisterMessageCallback(kJsApiEnableTracing,
base::Bind(&SlowHandler::HandleEnable, base::Unretained(this)));
web_ui()->RegisterMessageCallback(kJsApiLoadComplete,
base::Bind(&SlowHandler::LoadComplete, base::Unretained(this)));
user_pref_registrar_.reset(new PrefChangeRegistrar);
user_pref_registrar_->Init(profile_->GetPrefs());
user_pref_registrar_->Add(prefs::kPerformanceTracingEnabled,
base::Bind(&SlowHandler::UpdatePage,
base::Unretained(this)));
}
void SlowHandler::HandleDisable(const ListValue* args) {
PrefService* pref_service = profile_->GetPrefs();
pref_service->SetBoolean(prefs::kPerformanceTracingEnabled, false);
}
void SlowHandler::HandleEnable(const ListValue* args) {
PrefService* pref_service = profile_->GetPrefs();
pref_service->SetBoolean(prefs::kPerformanceTracingEnabled, true);
}
void SlowHandler::LoadComplete(const ListValue* args) {
UpdatePage();
}
void SlowHandler::UpdatePage() {
PrefService* pref_service = profile_->GetPrefs();
bool enabled = pref_service->GetBoolean(prefs::kPerformanceTracingEnabled);
base::FundamentalValue pref_value(enabled);
web_ui()->CallJavascriptFunction(kJsApiTracingPrefChanged, pref_value);
}
// SlowUI -----------------------------------------------------------------
SlowUI::SlowUI(content::WebUI* web_ui) : WebUIController(web_ui) {
Profile* profile = Profile::FromWebUI(web_ui);
SlowHandler* handler = new SlowHandler(profile);
web_ui->AddMessageHandler(handler);
// Set up the chrome://slow/ source.
content::WebUIDataSource::Add(profile, CreateSlowUIHTMLSource());
}
} // namespace chromeos
// Copyright 2013 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_CHROMEOS_SLOW_UI_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_SLOW_UI_H_
#include "content/public/browser/web_ui_controller.h"
namespace chromeos {
// A custom WebUI that allows users to enable and disable performance tracing
// for feedback reports.
class SlowUI : public content::WebUIController {
public:
explicit SlowUI(content::WebUI* web_ui);
private:
DISALLOW_COPY_AND_ASSIGN(SlowUI);
};
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_SLOW_UI_H_
...@@ -2059,6 +2059,8 @@ ...@@ -2059,6 +2059,8 @@
'browser/ui/webui/chromeos/proxy_settings_ui.h', 'browser/ui/webui/chromeos/proxy_settings_ui.h',
'browser/ui/webui/chromeos/sim_unlock_ui.cc', 'browser/ui/webui/chromeos/sim_unlock_ui.cc',
'browser/ui/webui/chromeos/sim_unlock_ui.h', 'browser/ui/webui/chromeos/sim_unlock_ui.h',
'browser/ui/webui/chromeos/slow_ui.cc',
'browser/ui/webui/chromeos/slow_ui.h',
'browser/ui/webui/chromeos/system_info_ui.cc', 'browser/ui/webui/chromeos/system_info_ui.cc',
'browser/ui/webui/chromeos/system_info_ui.h', 'browser/ui/webui/chromeos/system_info_ui.h',
'browser/ui/webui/chromeos/ui_account_tweaks.cc', 'browser/ui/webui/chromeos/ui_account_tweaks.cc',
......
...@@ -109,6 +109,7 @@ const char kChromeUIOSCreditsURL[] = "chrome://os-credits/"; ...@@ -109,6 +109,7 @@ const char kChromeUIOSCreditsURL[] = "chrome://os-credits/";
const char kChromeUIProxySettingsURL[] = "chrome://proxy-settings/"; const char kChromeUIProxySettingsURL[] = "chrome://proxy-settings/";
const char kChromeUISimUnlockURL[] = "chrome://sim-unlock/"; const char kChromeUISimUnlockURL[] = "chrome://sim-unlock/";
const char kChromeUISlideshowURL[] = "chrome://slideshow/"; const char kChromeUISlideshowURL[] = "chrome://slideshow/";
const char kChromeUISlowURL[] = "chrome://slow/";
const char kChromeUISystemInfoURL[] = "chrome://system/"; const char kChromeUISystemInfoURL[] = "chrome://system/";
const char kChromeUITermsOemURL[] = "chrome://terms/oem"; const char kChromeUITermsOemURL[] = "chrome://terms/oem";
const char kChromeUIUserImageURL[] = "chrome://userimage/"; const char kChromeUIUserImageURL[] = "chrome://userimage/";
...@@ -262,6 +263,7 @@ const char kChromeUIProxySettingsHost[] = "proxy-settings"; ...@@ -262,6 +263,7 @@ const char kChromeUIProxySettingsHost[] = "proxy-settings";
const char kChromeUIRotateHost[] = "rotate"; const char kChromeUIRotateHost[] = "rotate";
const char kChromeUISimUnlockHost[] = "sim-unlock"; const char kChromeUISimUnlockHost[] = "sim-unlock";
const char kChromeUISlideshowHost[] = "slideshow"; const char kChromeUISlideshowHost[] = "slideshow";
const char kChromeUISlowHost[] = "slow";
const char kChromeUISystemInfoHost[] = "system"; const char kChromeUISystemInfoHost[] = "system";
const char kChromeUIUserImageHost[] = "userimage"; const char kChromeUIUserImageHost[] = "userimage";
......
...@@ -103,6 +103,7 @@ extern const char kChromeUIOSCreditsURL[]; ...@@ -103,6 +103,7 @@ extern const char kChromeUIOSCreditsURL[];
extern const char kChromeUIProxySettingsURL[]; extern const char kChromeUIProxySettingsURL[];
extern const char kChromeUISimUnlockURL[]; extern const char kChromeUISimUnlockURL[];
extern const char kChromeUISlideshowURL[]; extern const char kChromeUISlideshowURL[];
extern const char kChromeUISlowURL[];
extern const char kChromeUISystemInfoURL[]; extern const char kChromeUISystemInfoURL[];
extern const char kChromeUITermsOemURL[]; extern const char kChromeUITermsOemURL[];
extern const char kChromeUIUserImageURL[]; extern const char kChromeUIUserImageURL[];
...@@ -254,6 +255,7 @@ extern const char kChromeUIProxySettingsHost[]; ...@@ -254,6 +255,7 @@ extern const char kChromeUIProxySettingsHost[];
extern const char kChromeUIRotateHost[]; extern const char kChromeUIRotateHost[];
extern const char kChromeUISimUnlockHost[]; extern const char kChromeUISimUnlockHost[];
extern const char kChromeUISlideshowHost[]; extern const char kChromeUISlideshowHost[];
extern const char kChromeUISlowHost[];
extern const char kChromeUISystemInfoHost[]; extern const char kChromeUISystemInfoHost[];
extern const char kChromeUIUserImageHost[]; extern const char kChromeUIUserImageHost[];
......
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