Commit 66be5181 authored by samarth@chromium.org's avatar samarth@chromium.org

Add "clear" to about://instant.

Allow users to clear all the log messages in about://instant which makes
debugging a lot easier. Remove the old "Reset" button since it becomes
confusing which one does what (and that button isn't really that useful
anyway).

TESTED=navigate to about://instant, click "Clear"
BUG=none


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186270 0039d316-1c4b-4281-b951-d872f2087c98
parent 563f87f5
...@@ -846,6 +846,10 @@ void InstantController::LogDebugEvent(const std::string& info) const { ...@@ -846,6 +846,10 @@ void InstantController::LogDebugEvent(const std::string& info) const {
debug_events_.pop_back(); debug_events_.pop_back();
} }
void InstantController::ClearDebugEvents() {
debug_events_.clear();
}
void InstantController::DeleteMostVisitedItem(const GURL& url) { void InstantController::DeleteMostVisitedItem(const GURL& url) {
history::TopSites* top_sites = browser_->profile()->GetTopSites(); history::TopSites* top_sites = browser_->profile()->GetTopSites();
if (!top_sites) if (!top_sites)
......
...@@ -174,6 +174,9 @@ class InstantController : public InstantPage::Delegate, ...@@ -174,6 +174,9 @@ class InstantController : public InstantPage::Delegate,
// |debug_events_| doesn't get too large. // |debug_events_| doesn't get too large.
void LogDebugEvent(const std::string& info) const; void LogDebugEvent(const std::string& info) const;
// Resets list of debug events.
void ClearDebugEvents();
// See comments for |debug_events_| below. // See comments for |debug_events_| below.
const std::list<std::pair<int64, std::string> >& debug_events() { const std::list<std::pair<int64, std::string> >& debug_events() {
return debug_events_; return debug_events_;
......
...@@ -16,12 +16,12 @@ found in the LICENSE file. ...@@ -16,12 +16,12 @@ found in the LICENSE file.
<hr> <hr>
<div id="instant-form"></div> <div id="instant-form"></div>
<div class="buttons-pane"> <div class="buttons-pane">
<button id="reset-button">Reset</button>
<button id="save-button">Save</button> <button id="save-button">Save</button>
</div> </div>
<hr/> <hr/>
<div> <div>
<h2>Instant Event Log</h2> <h2>Instant Event Log</h2>
<button id="clear-button">Clear</button><br><br>
<div id="instant-debug-info"></div> <div id="instant-debug-info"></div>
</div> </div>
</body> </body>
......
...@@ -120,22 +120,6 @@ var instantConfig = (function() { ...@@ -120,22 +120,6 @@ var instantConfig = (function() {
chrome.send('setPreferenceValue', [prefName, value]); chrome.send('setPreferenceValue', [prefName, value]);
} }
/**
* Handle processing of "Reset" button.
* Causes off form values to be updated based on current preference values.
*/
function onReset() {
for (var i = 0; i < FIELDS.length; i++) {
var field = FIELDS[i];
if ($(field.key).type == 'checkbox')
$(field.key).checked = field.default;
else
$(field.key).value = field.default;
setPreferenceValue(field.key);
}
return false;
}
/** /**
* Saves data back into Chrome preferences. * Saves data back into Chrome preferences.
*/ */
...@@ -170,6 +154,14 @@ var instantConfig = (function() { ...@@ -170,6 +154,14 @@ var instantConfig = (function() {
} }
} }
/**
* Resets list of debug events.
*/
function clearDebugInfo() {
$('instant-debug-info').innerHTML = '';
chrome.send('clearDebugInfo');
}
function loadForm() { function loadForm() {
for (var i = 0; i < FIELDS.length; i++) for (var i = 0; i < FIELDS.length; i++)
getPreferenceValue(FIELDS[i].key); getPreferenceValue(FIELDS[i].key);
...@@ -184,8 +176,8 @@ var instantConfig = (function() { ...@@ -184,8 +176,8 @@ var instantConfig = (function() {
initForm(); initForm();
getDebugInfo(); getDebugInfo();
$('reset-button').onclick = onReset.bind(this);
$('save-button').onclick = onSave.bind(this); $('save-button').onclick = onSave.bind(this);
$('clear-button').onclick = clearDebugInfo.bind(this);
} }
return { return {
......
...@@ -58,6 +58,7 @@ class InstantUIMessageHandler ...@@ -58,6 +58,7 @@ class InstantUIMessageHandler
void GetPreferenceValue(const base::ListValue* args); void GetPreferenceValue(const base::ListValue* args);
void SetPreferenceValue(const base::ListValue* args); void SetPreferenceValue(const base::ListValue* args);
void GetDebugInfo(const base::ListValue* value); void GetDebugInfo(const base::ListValue* value);
void ClearDebugInfo(const base::ListValue* value);
DISALLOW_COPY_AND_ASSIGN(InstantUIMessageHandler); DISALLOW_COPY_AND_ASSIGN(InstantUIMessageHandler);
}; };
...@@ -79,6 +80,10 @@ void InstantUIMessageHandler::RegisterMessages() { ...@@ -79,6 +80,10 @@ void InstantUIMessageHandler::RegisterMessages() {
"getDebugInfo", "getDebugInfo",
base::Bind(&InstantUIMessageHandler::GetDebugInfo, base::Bind(&InstantUIMessageHandler::GetDebugInfo,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"clearDebugInfo",
base::Bind(&InstantUIMessageHandler::ClearDebugInfo,
base::Unretained(this)));
} }
void InstantUIMessageHandler::GetPreferenceValue(const base::ListValue* args) { void InstantUIMessageHandler::GetPreferenceValue(const base::ListValue* args) {
...@@ -136,6 +141,19 @@ void InstantUIMessageHandler::GetDebugInfo(const base::ListValue* args) { ...@@ -136,6 +141,19 @@ void InstantUIMessageHandler::GetDebugInfo(const base::ListValue* args) {
#endif #endif
} }
void InstantUIMessageHandler::ClearDebugInfo(const base::ListValue* args) {
#if !defined(OS_ANDROID)
if (!web_ui()->GetWebContents())
return;
Browser* browser = chrome::FindBrowserWithWebContents(
web_ui()->GetWebContents());
if (!browser || !browser->instant_controller())
return;
browser->instant_controller()->instant()->ClearDebugEvents();
#endif
}
} // namespace } // namespace
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
......
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