| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/history_ui.h" | 5 #include "chrome/browser/ui/webui/history_ui.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" |
| 12 #include "base/callback_old.h" |
| 11 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
| 12 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 13 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 14 #include "base/string16.h" | 16 #include "base/string16.h" |
| 15 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
| 16 #include "base/string_piece.h" | 18 #include "base/string_piece.h" |
| 17 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 18 #include "base/time.h" | 20 #include "base/time.h" |
| 19 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 20 #include "base/values.h" | 22 #include "base/values.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 new FaviconSource(profile, FaviconSource::FAVICON)); | 138 new FaviconSource(profile, FaviconSource::FAVICON)); |
| 137 | 139 |
| 138 // Get notifications when history is cleared. | 140 // Get notifications when history is cleared. |
| 139 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, | 141 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, |
| 140 Source<Profile>(profile->GetOriginalProfile())); | 142 Source<Profile>(profile->GetOriginalProfile())); |
| 141 return WebUIMessageHandler::Attach(web_ui); | 143 return WebUIMessageHandler::Attach(web_ui); |
| 142 } | 144 } |
| 143 | 145 |
| 144 void BrowsingHistoryHandler::RegisterMessages() { | 146 void BrowsingHistoryHandler::RegisterMessages() { |
| 145 web_ui_->RegisterMessageCallback("getHistory", | 147 web_ui_->RegisterMessageCallback("getHistory", |
| 146 NewCallback(this, &BrowsingHistoryHandler::HandleGetHistory)); | 148 base::Bind(&BrowsingHistoryHandler::HandleGetHistory, |
| 149 base::Unretained(this))); |
| 147 web_ui_->RegisterMessageCallback("searchHistory", | 150 web_ui_->RegisterMessageCallback("searchHistory", |
| 148 NewCallback(this, &BrowsingHistoryHandler::HandleSearchHistory)); | 151 base::Bind(&BrowsingHistoryHandler::HandleSearchHistory, |
| 152 base::Unretained(this))); |
| 149 web_ui_->RegisterMessageCallback("removeURLsOnOneDay", | 153 web_ui_->RegisterMessageCallback("removeURLsOnOneDay", |
| 150 NewCallback(this, &BrowsingHistoryHandler::HandleRemoveURLsOnOneDay)); | 154 base::Bind(&BrowsingHistoryHandler::HandleRemoveURLsOnOneDay, |
| 155 base::Unretained(this))); |
| 151 web_ui_->RegisterMessageCallback("clearBrowsingData", | 156 web_ui_->RegisterMessageCallback("clearBrowsingData", |
| 152 NewCallback(this, &BrowsingHistoryHandler::HandleClearBrowsingData)); | 157 base::Bind(&BrowsingHistoryHandler::HandleClearBrowsingData, |
| 158 base::Unretained(this))); |
| 153 } | 159 } |
| 154 | 160 |
| 155 void BrowsingHistoryHandler::HandleGetHistory(const ListValue* args) { | 161 void BrowsingHistoryHandler::HandleGetHistory(const ListValue* args) { |
| 156 // Anything in-flight is invalid. | 162 // Anything in-flight is invalid. |
| 157 cancelable_search_consumer_.CancelAllRequests(); | 163 cancelable_search_consumer_.CancelAllRequests(); |
| 158 | 164 |
| 159 // Get arguments (if any). | 165 // Get arguments (if any). |
| 160 int day = 0; | 166 int day = 0; |
| 161 ExtractIntegerValue(args, &day); | 167 ExtractIntegerValue(args, &day); |
| 162 | 168 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 const GURL HistoryUI::GetHistoryURLWithSearchText(const string16& text) { | 403 const GURL HistoryUI::GetHistoryURLWithSearchText(const string16& text) { |
| 398 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + | 404 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + |
| 399 net::EscapeQueryParamValue(UTF16ToUTF8(text), true)); | 405 net::EscapeQueryParamValue(UTF16ToUTF8(text), true)); |
| 400 } | 406 } |
| 401 | 407 |
| 402 // static | 408 // static |
| 403 RefCountedMemory* HistoryUI::GetFaviconResourceBytes() { | 409 RefCountedMemory* HistoryUI::GetFaviconResourceBytes() { |
| 404 return ResourceBundle::GetSharedInstance(). | 410 return ResourceBundle::GetSharedInstance(). |
| 405 LoadDataResourceBytes(IDR_HISTORY_FAVICON); | 411 LoadDataResourceBytes(IDR_HISTORY_FAVICON); |
| 406 } | 412 } |
| OLD | NEW |