summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui
diff options
context:
space:
mode:
authorglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 01:47:22 +0000
committerglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 01:47:22 +0000
commit13dc779186dedb868df4373ba694c9f5d7cdf419 (patch)
treebf33dcecff152df552c29ab696677165baf04a94 /chrome/browser/dom_ui
parent08ca70052ad87e2fe620313585074b7ae453e64b (diff)
downloadchromium_src-13dc779186dedb868df4373ba694c9f5d7cdf419.zip
chromium_src-13dc779186dedb868df4373ba694c9f5d7cdf419.tar.gz
chromium_src-13dc779186dedb868df4373ba694c9f5d7cdf419.tar.bz2
Resolve crash when deleting history by preventing the deleter from being called multiple times. We need to add UI to make what's happening clearer to the user, but this gets us over the hump for now. Also change the history page to queue deletions.Allow history search from the new tab page.Make history title inclusion safer (createTextNode changes).Show starred status on history page.BUG=8214,8163,8271,8284
Review URL: http://codereview.chromium.org/28308 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10773 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r--chrome/browser/dom_ui/history_ui.cc28
-rw-r--r--chrome/browser/dom_ui/history_ui.h3
2 files changed, 20 insertions, 11 deletions
diff --git a/chrome/browser/dom_ui/history_ui.cc b/chrome/browser/dom_ui/history_ui.cc
index 0f735d4..9bc5d61 100644
--- a/chrome/browser/dom_ui/history_ui.cc
+++ b/chrome/browser/dom_ui/history_ui.cc
@@ -10,6 +10,7 @@
#include "base/thread.h"
#include "base/time.h"
#include "base/time_format.h"
+#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/history/history_types.h"
@@ -117,11 +118,13 @@ BrowsingHistoryHandler::BrowsingHistoryHandler(DOMUI* dom_ui)
}
BrowsingHistoryHandler::~BrowsingHistoryHandler() {
+ cancelable_consumer_.CancelAllRequests();
+
NotificationService* service = NotificationService::current();
service->RemoveObserver(this, NotificationType::HISTORY_URLS_DELETED,
Source<Profile>(dom_ui_->get_profile()));
- if (remover_)
+ if (remover_.get())
remover_->RemoveObserver(this);
}
@@ -179,6 +182,11 @@ void BrowsingHistoryHandler::HandleSearchHistory(const Value* value) {
}
void BrowsingHistoryHandler::HandleDeleteDay(const Value* value) {
+ if (BrowsingDataRemover::is_removing()) {
+ dom_ui_->CallJavascriptFunction(L"deleteFailed");
+ return;
+ }
+
// Anything in-flight is invalid.
cancelable_consumer_.CancelAllRequests();
@@ -190,13 +198,10 @@ void BrowsingHistoryHandler::HandleDeleteDay(const Value* value) {
Time begin_time = time.LocalMidnight();
Time end_time = begin_time + TimeDelta::FromDays(1);
- if (!remover_) {
- remover_ = new BrowsingDataRemover(dom_ui_->get_profile(),
- begin_time,
- end_time);
- remover_->AddObserver(this);
- }
-
+ remover_.reset(new BrowsingDataRemover(dom_ui_->get_profile(),
+ begin_time,
+ end_time));
+ remover_->AddObserver(this);
remover_->Remove(BrowsingDataRemover::REMOVE_HISTORY |
BrowsingDataRemover::REMOVE_COOKIES |
BrowsingDataRemover::REMOVE_CACHE);
@@ -204,6 +209,8 @@ void BrowsingHistoryHandler::HandleDeleteDay(const Value* value) {
void BrowsingHistoryHandler::OnBrowsingDataRemoverDone() {
dom_ui_->CallJavascriptFunction(L"deleteComplete");
+ remover_->RemoveObserver(this);
+ remover_.release();
}
void BrowsingHistoryHandler::QueryComplete(
@@ -247,7 +254,8 @@ void BrowsingHistoryHandler::QueryComplete(
base::TimeFormatShortDate(page.visit_time()));
page_value->SetString(L"snippet", page.snippet().text());
}
-
+ page_value->SetBoolean(L"starred",
+ dom_ui_->get_profile()->GetBookmarkModel()->IsBookmarked(page.url()));
results_value.Append(page_value);
}
@@ -370,6 +378,6 @@ GURL HistoryUI::GetBaseURL() {
// static
const GURL HistoryUI::GetHistoryURLWithSearchText(
const std::wstring& text) {
- return GURL(GetBaseURL().spec() + "/?q=" +
+ return GURL(GetBaseURL().spec() + "#q=" +
EscapeQueryParamValue(WideToUTF8(text)));
}
diff --git a/chrome/browser/dom_ui/history_ui.h b/chrome/browser/dom_ui/history_ui.h
index d6bed47..cc643b1 100644
--- a/chrome/browser/dom_ui/history_ui.h
+++ b/chrome/browser/dom_ui/history_ui.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_DOM_UI_HISTORY_UI_H__
#define CHROME_BROWSER_DOM_UI_HISTORY_UI_H__
+#include "base/scoped_ptr.h"
#include "chrome/browser/browsing_data_remover.h"
#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
#include "chrome/browser/dom_ui/dom_ui.h"
@@ -70,7 +71,7 @@ class BrowsingHistoryHandler : public DOMMessageHandler,
std::wstring search_text_;
// Browsing history remover
- BrowsingDataRemover* remover_;
+ scoped_ptr<BrowsingDataRemover> remover_;
// Our consumer for the history service.
CancelableRequestConsumerTSimple<PageUsageData*> cancelable_consumer_;