summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-09 14:08:00 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-09 14:08:00 +0000
commit9f39293c0507c538c944de86ca6ce002c6feb2b2 (patch)
tree47755aa650b9d3b859abd0419c6931e28bb1c358 /chrome
parente1af00b15acc4cb11f97cdaf9a166da19c484621 (diff)
downloadchromium_src-9f39293c0507c538c944de86ca6ce002c6feb2b2.zip
chromium_src-9f39293c0507c538c944de86ca6ce002c6feb2b2.tar.gz
chromium_src-9f39293c0507c538c944de86ca6ce002c6feb2b2.tar.bz2
Refresh the history page if history entries get deleted, except for when currently editing entries
BUG=82190 TEST=manual as described in the bug Review URL: http://codereview.chromium.org/7086030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88525 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/resources/history.js20
-rw-r--r--chrome/browser/resources/history2.html20
-rw-r--r--chrome/browser/ui/webui/history2_ui.cc16
-rw-r--r--chrome/browser/ui/webui/history2_ui.h11
-rw-r--r--chrome/browser/ui/webui/history_ui.cc16
-rw-r--r--chrome/browser/ui/webui/history_ui.h11
6 files changed, 90 insertions, 4 deletions
diff --git a/chrome/browser/resources/history.js b/chrome/browser/resources/history.js
index c0a5287d..3fbb300 100644
--- a/chrome/browser/resources/history.js
+++ b/chrome/browser/resources/history.js
@@ -512,6 +512,14 @@ HistoryView.prototype.toggleEditMode = function() {
};
/**
+ * @return {boolean} Whether we are in edit mode where history items can be
+ * deleted
+ */
+HistoryView.prototype.getEditMode = function() {
+ return this.model_.getEditMode();
+};
+
+/**
* Reload the current view.
*/
HistoryView.prototype.reload = function() {
@@ -1022,7 +1030,6 @@ function deleteComplete() {
deleteNextInQueue();
} else {
deleteQueue = [];
- historyView.reload();
}
}
@@ -1037,6 +1044,17 @@ function deleteFailed() {
setTimeout(deleteNextInQueue, 500);
}
+/**
+ * We're called when something is deleted (either by us or by someone
+ * else).
+ */
+function historyDeleted() {
+ window.console.log('History deleted');
+ var anyChecked = document.querySelector('.entry input:checked') != null;
+ if (!(historyView.getEditMode() && anyChecked))
+ historyView.reload();
+}
+
// Add handlers to HTML elements.
document.body.onload = load;
$('history-section').onclick = function () {
diff --git a/chrome/browser/resources/history2.html b/chrome/browser/resources/history2.html
index 5c369b3..eb27f3b 100644
--- a/chrome/browser/resources/history2.html
+++ b/chrome/browser/resources/history2.html
@@ -531,6 +531,14 @@ HistoryView.prototype.toggleEditMode = function() {
};
/**
+ * @return {boolean} Whether we are in edit mode where history items can be
+ * deleted
+ */
+HistoryView.prototype.getEditMode = function() {
+ return this.model_.getEditMode();
+};
+
+/**
* Reload the current view.
*/
HistoryView.prototype.reload = function() {
@@ -1059,7 +1067,6 @@ function deleteComplete() {
deleteNextInQueue();
} else {
deleteQueue = [];
- historyView.reload();
}
}
@@ -1073,6 +1080,17 @@ function deleteFailed() {
deleteInFlight = false;
setTimeout(deleteNextInQueue, 500);
}
+
+/**
+ * We're called when something is deleted (either by us or by someone
+ * else).
+ */
+function historyDeleted() {
+ window.console.log('History deleted');
+ var anyChecked = document.querySelector('.entry input:checked') != null;
+ if (!(historyView.getEditMode() && anyChecked))
+ historyView.reload();
+}
</script>
<link rel="stylesheet" href="webui2.css">
<style>
diff --git a/chrome/browser/ui/webui/history2_ui.cc b/chrome/browser/ui/webui/history2_ui.cc
index 0bb9d1b..c9cab20 100644
--- a/chrome/browser/ui/webui/history2_ui.cc
+++ b/chrome/browser/ui/webui/history2_ui.cc
@@ -31,6 +31,7 @@
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_delegate.h"
#include "content/browser/user_metrics.h"
+#include "content/common/notification_source.h"
#include "grit/browser_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -132,6 +133,9 @@ WebUIMessageHandler* BrowsingHistoryHandler2::Attach(WebUI* web_ui) {
profile->GetChromeURLDataManager()->AddDataSource(
new FaviconSource(profile, FaviconSource::FAVICON));
+ // Get notifications when history is cleared.
+ registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED,
+ Source<Profile>(web_ui->GetProfile()->GetOriginalProfile()));
return WebUIMessageHandler::Attach(web_ui);
}
@@ -369,6 +373,18 @@ history::QueryOptions BrowsingHistoryHandler2::CreateMonthQueryOptions(
return options;
}
+void BrowsingHistoryHandler2::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (type != NotificationType::HISTORY_URLS_DELETED) {
+ NOTREACHED();
+ return;
+ }
+
+ // Some URLs were deleted from history. Reload the list.
+ web_ui_->CallJavascriptFunction("historyDeleted");
+}
+
////////////////////////////////////////////////////////////////////////////////
//
// HistoryUIContents
diff --git a/chrome/browser/ui/webui/history2_ui.h b/chrome/browser/ui/webui/history2_ui.h
index aed4882..26d12b0 100644
--- a/chrome/browser/ui/webui/history2_ui.h
+++ b/chrome/browser/ui/webui/history2_ui.h
@@ -13,6 +13,7 @@
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/browser/ui/webui/chrome_web_ui.h"
#include "content/browser/cancelable_request.h"
+#include "content/common/notification_registrar.h"
class GURL;
@@ -38,7 +39,8 @@ class HistoryUIHTMLSource2 : public ChromeURLDataManager::DataSource {
};
// The handler for Javascript messages related to the "history" view.
-class BrowsingHistoryHandler2 : public WebUIMessageHandler {
+class BrowsingHistoryHandler2 : public WebUIMessageHandler,
+ public NotificationObserver {
public:
BrowsingHistoryHandler2();
virtual ~BrowsingHistoryHandler2();
@@ -59,6 +61,11 @@ class BrowsingHistoryHandler2 : public WebUIMessageHandler {
// Handle for "clearBrowsingData" message.
void HandleClearBrowsingData(const ListValue* args);
+ // NotificationObserver implementation.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
private:
// Callback from the history system when the history list is available.
void QueryComplete(HistoryService::Handle request_handle,
@@ -75,6 +82,8 @@ class BrowsingHistoryHandler2 : public WebUIMessageHandler {
// Figure out the query options for a month-wide query.
history::QueryOptions CreateMonthQueryOptions(int month);
+ NotificationRegistrar registrar_;
+
// Current search text.
string16 search_text_;
diff --git a/chrome/browser/ui/webui/history_ui.cc b/chrome/browser/ui/webui/history_ui.cc
index d5620b7..c4803f8 100644
--- a/chrome/browser/ui/webui/history_ui.cc
+++ b/chrome/browser/ui/webui/history_ui.cc
@@ -32,6 +32,7 @@
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_delegate.h"
#include "content/browser/user_metrics.h"
+#include "content/common/notification_source.h"
#include "grit/browser_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -135,6 +136,9 @@ WebUIMessageHandler* BrowsingHistoryHandler::Attach(WebUI* web_ui) {
profile->GetChromeURLDataManager()->AddDataSource(
new FaviconSource(profile, FaviconSource::FAVICON));
+ // Get notifications when history is cleared.
+ registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED,
+ Source<Profile>(profile->GetOriginalProfile()));
return WebUIMessageHandler::Attach(web_ui);
}
@@ -360,6 +364,18 @@ history::QueryOptions BrowsingHistoryHandler::CreateMonthQueryOptions(
return options;
}
+void BrowsingHistoryHandler::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (type != NotificationType::HISTORY_URLS_DELETED) {
+ NOTREACHED();
+ return;
+ }
+
+ // Some URLs were deleted from history. Reload the list.
+ web_ui_->CallJavascriptFunction("historyDeleted");
+}
+
////////////////////////////////////////////////////////////////////////////////
//
// HistoryUI
diff --git a/chrome/browser/ui/webui/history_ui.h b/chrome/browser/ui/webui/history_ui.h
index 7c490ce..b3523a5 100644
--- a/chrome/browser/ui/webui/history_ui.h
+++ b/chrome/browser/ui/webui/history_ui.h
@@ -13,11 +13,13 @@
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/browser/ui/webui/chrome_web_ui.h"
#include "content/browser/cancelable_request.h"
+#include "content/common/notification_registrar.h"
class GURL;
// The handler for Javascript messages related to the "history" view.
-class BrowsingHistoryHandler : public WebUIMessageHandler {
+class BrowsingHistoryHandler : public WebUIMessageHandler,
+ public NotificationObserver {
public:
BrowsingHistoryHandler();
virtual ~BrowsingHistoryHandler();
@@ -38,6 +40,11 @@ class BrowsingHistoryHandler : public WebUIMessageHandler {
// Handle for "clearBrowsingData" message.
void HandleClearBrowsingData(const ListValue* args);
+ // NotificationObserver implementation.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
private:
// Callback from the history system when the history list is available.
void QueryComplete(HistoryService::Handle request_handle,
@@ -54,6 +61,8 @@ class BrowsingHistoryHandler : public WebUIMessageHandler {
// Figure out the query options for a month-wide query.
history::QueryOptions CreateMonthQueryOptions(int month);
+ NotificationRegistrar registrar_;
+
// Current search text.
string16 search_text_;