OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/history2_ui.h" | 5 #include "chrome/browser/dom_ui/history2_ui.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/singleton.h" | 12 #include "base/singleton.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/string_piece.h" | 14 #include "base/string_piece.h" |
15 #include "base/thread.h" | 15 #include "base/thread.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/bookmarks/bookmark_model.h" | 18 #include "chrome/browser/bookmarks/bookmark_model.h" |
19 #include "chrome/browser/browser.h" | 19 #include "chrome/browser/browser.h" |
20 #include "chrome/browser/browser_list.h" | |
21 #include "chrome/browser/chrome_thread.h" | 20 #include "chrome/browser/chrome_thread.h" |
22 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" | 21 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" |
23 #include "chrome/browser/metrics/user_metrics.h" | 22 #include "chrome/browser/metrics/user_metrics.h" |
24 #include "chrome/browser/history/history_types.h" | 23 #include "chrome/browser/history/history_types.h" |
25 #include "chrome/browser/profile.h" | 24 #include "chrome/browser/profile.h" |
26 #include "chrome/browser/tab_contents/tab_contents.h" | 25 #include "chrome/browser/tab_contents/tab_contents.h" |
27 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 26 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
28 #include "chrome/common/jstemplate_builder.h" | 27 #include "chrome/common/jstemplate_builder.h" |
29 #include "chrome/common/notification_service.h" | 28 #include "chrome/common/notification_service.h" |
30 #include "chrome/common/time_format.h" | 29 #include "chrome/common/time_format.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 } | 228 } |
230 | 229 |
231 HistoryService* hs = | 230 HistoryService* hs = |
232 dom_ui_->GetProfile()->GetHistoryService(Profile::EXPLICIT_ACCESS); | 231 dom_ui_->GetProfile()->GetHistoryService(Profile::EXPLICIT_ACCESS); |
233 hs->ExpireHistoryBetween( | 232 hs->ExpireHistoryBetween( |
234 urls, begin_time, end_time, &cancelable_delete_consumer_, | 233 urls, begin_time, end_time, &cancelable_delete_consumer_, |
235 NewCallback(this, &BrowsingHistoryHandler2::RemoveComplete)); | 234 NewCallback(this, &BrowsingHistoryHandler2::RemoveComplete)); |
236 } | 235 } |
237 | 236 |
238 void BrowsingHistoryHandler2::HandleClearBrowsingData(const Value* value) { | 237 void BrowsingHistoryHandler2::HandleClearBrowsingData(const Value* value) { |
239 // TODO(beng): This is an improper direct dependency on Browser. Route this | 238 dom_ui_->tab_contents()->delegate()->GetBrowser()-> |
240 // through some sort of delegate. | 239 OpenClearBrowsingDataDialog(); |
241 Browser* browser = BrowserList::FindBrowserWithProfile(dom_ui_->GetProfile()); | |
242 if (browser) | |
243 browser->OpenClearBrowsingDataDialog(); | |
244 } | 240 } |
245 | 241 |
246 void BrowsingHistoryHandler2::QueryComplete( | 242 void BrowsingHistoryHandler2::QueryComplete( |
247 HistoryService::Handle request_handle, | 243 HistoryService::Handle request_handle, |
248 history::QueryResults* results) { | 244 history::QueryResults* results) { |
249 | 245 |
250 ListValue results_value; | 246 ListValue results_value; |
251 base::Time midnight_today = base::Time::Now().LocalMidnight(); | 247 base::Time midnight_today = base::Time::Now().LocalMidnight(); |
252 | 248 |
253 for (size_t i = 0; i < results->size(); ++i) { | 249 for (size_t i = 0; i < results->size(); ++i) { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 const GURL HistoryUI2::GetHistoryURLWithSearchText(const string16& text) { | 405 const GURL HistoryUI2::GetHistoryURLWithSearchText(const string16& text) { |
410 return GURL(std::string(chrome::kChromeUIHistory2URL) + "#q=" + | 406 return GURL(std::string(chrome::kChromeUIHistory2URL) + "#q=" + |
411 EscapeQueryParamValue(UTF16ToUTF8(text), true)); | 407 EscapeQueryParamValue(UTF16ToUTF8(text), true)); |
412 } | 408 } |
413 | 409 |
414 // static | 410 // static |
415 RefCountedMemory* HistoryUI2::GetFaviconResourceBytes() { | 411 RefCountedMemory* HistoryUI2::GetFaviconResourceBytes() { |
416 return ResourceBundle::GetSharedInstance(). | 412 return ResourceBundle::GetSharedInstance(). |
417 LoadDataResourceBytes(IDR_HISTORY_FAVICON); | 413 LoadDataResourceBytes(IDR_HISTORY_FAVICON); |
418 } | 414 } |
OLD | NEW |